Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/extensions/extension_message_handler.cc

Issue 10787002: Moved ExtensionMessage* into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_message_handler.h"
6
7 #include "chrome/browser/extensions/extension_message_service.h"
8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/view_type_utils.h"
11 #include "chrome/common/extensions/extension_messages.h"
12 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/web_contents.h"
15
16 using content::WebContents;
17
18 ExtensionMessageHandler::ExtensionMessageHandler(
19 content::RenderViewHost* render_view_host)
20 : content::RenderViewHostObserver(render_view_host) {
21 }
22
23 ExtensionMessageHandler::~ExtensionMessageHandler() {
24 }
25
26 bool ExtensionMessageHandler::OnMessageReceived(
27 const IPC::Message& message) {
28 bool handled = true;
29 IPC_BEGIN_MESSAGE_MAP(ExtensionMessageHandler, message)
30 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage)
31 IPC_MESSAGE_UNHANDLED(handled = false)
32 IPC_END_MESSAGE_MAP()
33 return handled;
34 }
35
36 void ExtensionMessageHandler::RenderViewHostInitialized() {
37 WebContents* web_contents =
38 WebContents::FromRenderViewHost(render_view_host());
39 Send(new ExtensionMsg_NotifyRenderViewType(
40 routing_id(), chrome::GetViewType(web_contents)));
41 }
42
43 void ExtensionMessageHandler::OnPostMessage(int port_id,
44 const std::string& message) {
45 Profile* profile = Profile::FromBrowserContext(
46 render_view_host()->GetProcess()->GetBrowserContext());
47 ExtensionMessageService* message_service =
48 extensions::ExtensionSystem::Get(profile)->message_service();
49 if (message_service) {
50 message_service->PostMessageFromRenderer(port_id, message);
51 }
52 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_message_handler.h ('k') | chrome/browser/extensions/extension_message_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698