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

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

Issue 13375017: Move the ViewType enum to extensions\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/message_handler.h" 5 #include "chrome/browser/extensions/message_handler.h"
6 6
7 #include "chrome/browser/extensions/api/messaging/message_service.h" 7 #include "chrome/browser/extensions/api/messaging/message_service.h"
8 #include "chrome/browser/extensions/extension_system.h" 8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/view_type_utils.h"
11 #include "chrome/common/extensions/extension_messages.h" 10 #include "chrome/common/extensions/extension_messages.h"
12 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "extensions/browser/view_type_utils.h"
15 15
16 using content::WebContents; 16 using content::WebContents;
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 MessageHandler::MessageHandler( 20 MessageHandler::MessageHandler(
21 content::RenderViewHost* render_view_host) 21 content::RenderViewHost* render_view_host)
22 : content::RenderViewHostObserver(render_view_host) { 22 : content::RenderViewHostObserver(render_view_host) {
23 } 23 }
24 24
25 MessageHandler::~MessageHandler() { 25 MessageHandler::~MessageHandler() {
26 } 26 }
27 27
28 bool MessageHandler::OnMessageReceived( 28 bool MessageHandler::OnMessageReceived(
29 const IPC::Message& message) { 29 const IPC::Message& message) {
30 bool handled = true; 30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP(MessageHandler, message) 31 IPC_BEGIN_MESSAGE_MAP(MessageHandler, message)
32 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage) 32 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage)
33 IPC_MESSAGE_UNHANDLED(handled = false) 33 IPC_MESSAGE_UNHANDLED(handled = false)
34 IPC_END_MESSAGE_MAP() 34 IPC_END_MESSAGE_MAP()
35 return handled; 35 return handled;
36 } 36 }
37 37
38 void MessageHandler::RenderViewHostInitialized() { 38 void MessageHandler::RenderViewHostInitialized() {
39 WebContents* web_contents = 39 WebContents* web_contents =
40 WebContents::FromRenderViewHost(render_view_host()); 40 WebContents::FromRenderViewHost(render_view_host());
41 Send(new ExtensionMsg_NotifyRenderViewType( 41 Send(new ExtensionMsg_NotifyRenderViewType(
42 routing_id(), chrome::GetViewType(web_contents))); 42 routing_id(), extensions::GetViewType(web_contents)));
43 } 43 }
44 44
45 void MessageHandler::OnPostMessage(int port_id, 45 void MessageHandler::OnPostMessage(int port_id,
46 const std::string& message) { 46 const std::string& message) {
47 Profile* profile = Profile::FromBrowserContext( 47 Profile* profile = Profile::FromBrowserContext(
48 render_view_host()->GetProcess()->GetBrowserContext()); 48 render_view_host()->GetProcess()->GetBrowserContext());
49 MessageService* message_service = 49 MessageService* message_service =
50 ExtensionSystem::Get(profile)->message_service(); 50 ExtensionSystem::Get(profile)->message_service();
51 if (message_service) { 51 if (message_service) {
52 message_service->PostMessage(port_id, message); 52 message_service->PostMessage(port_id, message);
53 } 53 }
54 } 54 }
55 55
56 } // namespace extensions 56 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698