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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_host.cc
===================================================================
--- chrome/browser/extensions/extension_host.cc (revision 80315)
+++ chrome/browser/extensions/extension_host.cc (working copy)
@@ -16,7 +16,7 @@
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/debugger/devtools_handler.h"
#include "chrome/browser/desktop_notification_handler.h"
-#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_message_handler.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/file_select_helper.h"
@@ -32,7 +32,6 @@
#include "chrome/common/bindings_policy.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/view_types.h"
@@ -160,6 +159,8 @@
desktop_notification_handler_.reset(
new DesktopNotificationHandler(NULL, render_process_host()));
dev_tools_handler_.reset(new DevToolsHandler(NULL, render_view_host_));
+ extension_message_handler_.reset(new ExtensionMessageHandler(
+ render_process_host()->id(), render_view_host_, profile_));
}
ExtensionHost::~ExtensionHost() {
@@ -336,7 +337,7 @@
return;
if (!params.url.SchemeIs(chrome::kExtensionScheme)) {
- extension_function_dispatcher_.reset(NULL);
+ SetExtensionFunctionDispatcher(NULL);
url_ = params.url;
return;
}
@@ -351,12 +352,12 @@
// it's better than the alternative.
// TODO(erikkay) Perhaps we should display errors in developer mode.
if (params.url.host() != extension_->id()) {
- extension_function_dispatcher_.reset(NULL);
+ SetExtensionFunctionDispatcher(NULL);
return;
}
url_ = params.url;
- extension_function_dispatcher_.reset(
+ SetExtensionFunctionDispatcher(
ExtensionFunctionDispatcher::Create(render_view_host_, this, url_));
}
@@ -556,13 +557,6 @@
return webkit_prefs;
}
-void ExtensionHost::ProcessWebUIMessage(
- const ExtensionHostMsg_DomMessage_Params& params) {
- if (extension_function_dispatcher_.get()) {
- extension_function_dispatcher_->HandleRequest(params);
- }
-}
-
RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() {
return this;
}
@@ -794,7 +788,6 @@
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
- IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -802,6 +795,8 @@
handled = desktop_notification_handler_->OnMessageReceived(message);
if (!handled)
handled = dev_tools_handler_->OnMessageReceived(message);
+ if (!handled)
+ handled = extension_message_handler_->OnMessageReceived(message);
return handled;
}
@@ -817,7 +812,7 @@
// we'll create 2 EFDs for the first navigation. We should try to find a
// better way to unify them.
// See http://code.google.com/p/chromium/issues/detail?id=18240
- extension_function_dispatcher_.reset(
+ SetExtensionFunctionDispatcher(
ExtensionFunctionDispatcher::Create(render_view_host, this, url_));
if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
@@ -852,9 +847,8 @@
file_select_helper_->RunFileChooser(render_view_host_, params);
}
-void ExtensionHost::OnPostMessage(int port_id, const std::string& message) {
- if (profile()->GetExtensionMessageService()) {
- profile()->GetExtensionMessageService()->PostMessageFromRenderer(
- port_id, message);
- }
+void ExtensionHost::SetExtensionFunctionDispatcher(
+ ExtensionFunctionDispatcher* efd) {
+ extension_function_dispatcher_.reset(efd);
+ extension_message_handler_->set_extension_function_dispatcher(efd);
}

Powered by Google App Engine
This is Rietveld 408576698