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

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

Issue 10409088: Get rid of the RenderViewType concept in content, since it was only used by Chrome. Store the enum… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 7 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/extension_message_handler.h" 5 #include "chrome/browser/extensions/extension_message_handler.h"
6 6
7 #include "chrome/browser/extensions/extension_message_service.h" 7 #include "chrome/browser/extensions/extension_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"
10 #include "chrome/common/extensions/extension_messages.h" 11 #include "chrome/common/extensions/extension_messages.h"
11 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/render_view_host_delegate.h" 14 #include "content/public/browser/web_contents.h"
15
16 using content::WebContents;
14 17
15 ExtensionMessageHandler::ExtensionMessageHandler( 18 ExtensionMessageHandler::ExtensionMessageHandler(
16 content::RenderViewHost* render_view_host) 19 content::RenderViewHost* render_view_host)
17 : content::RenderViewHostObserver(render_view_host) { 20 : content::RenderViewHostObserver(render_view_host) {
18 } 21 }
19 22
20 ExtensionMessageHandler::~ExtensionMessageHandler() { 23 ExtensionMessageHandler::~ExtensionMessageHandler() {
21 } 24 }
22 25
23 bool ExtensionMessageHandler::OnMessageReceived( 26 bool ExtensionMessageHandler::OnMessageReceived(
24 const IPC::Message& message) { 27 const IPC::Message& message) {
25 bool handled = true; 28 bool handled = true;
26 IPC_BEGIN_MESSAGE_MAP(ExtensionMessageHandler, message) 29 IPC_BEGIN_MESSAGE_MAP(ExtensionMessageHandler, message)
27 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage) 30 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage)
28 IPC_MESSAGE_UNHANDLED(handled = false) 31 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP() 32 IPC_END_MESSAGE_MAP()
30 return handled; 33 return handled;
31 } 34 }
32 35
33 void ExtensionMessageHandler::RenderViewHostInitialized() { 36 void ExtensionMessageHandler::RenderViewHostInitialized() {
37 WebContents* web_contents =
38 WebContents::FromRenderViewHost(render_view_host());
34 Send(new ExtensionMsg_NotifyRenderViewType( 39 Send(new ExtensionMsg_NotifyRenderViewType(
35 routing_id(), render_view_host()->GetDelegate()->GetRenderViewType())); 40 routing_id(), chrome::GetViewType(web_contents)));
36 } 41 }
37 42
38 void ExtensionMessageHandler::OnPostMessage(int port_id, 43 void ExtensionMessageHandler::OnPostMessage(int port_id,
39 const std::string& message) { 44 const std::string& message) {
40 Profile* profile = Profile::FromBrowserContext( 45 Profile* profile = Profile::FromBrowserContext(
41 render_view_host()->GetProcess()->GetBrowserContext()); 46 render_view_host()->GetProcess()->GetBrowserContext());
42 ExtensionMessageService* message_service = 47 ExtensionMessageService* message_service =
43 ExtensionSystem::Get(profile)->message_service(); 48 ExtensionSystem::Get(profile)->message_service();
44 if (message_service) { 49 if (message_service) {
45 message_service->PostMessageFromRenderer(port_id, message); 50 message_service->PostMessageFromRenderer(port_id, message);
46 } 51 }
47 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698