diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 05:06:09 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 05:06:09 +0000 |
commit | c5dbef0ce4b8279cb14ce5516a1f67f6543f5283 (patch) | |
tree | 036a5d68df14f300c6549286daceccb0a3ad4159 /chrome/browser/notifications | |
parent | 42aec6de361b66396e60725353adc477948d6a43 (diff) | |
download | chromium_src-c5dbef0ce4b8279cb14ce5516a1f67f6543f5283.zip chromium_src-c5dbef0ce4b8279cb14ce5516a1f67f6543f5283.tar.gz chromium_src-c5dbef0ce4b8279cb14ce5516a1f67f6543f5283.tar.bz2 |
Re-land r84928: Move EFD to ExtensionTabHelper.
BUG=80308
TBR=mpcomplete@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r-- | chrome/browser/notifications/balloon_host.cc | 57 | ||||
-rw-r--r-- | chrome/browser/notifications/balloon_host.h | 11 |
2 files changed, 26 insertions, 42 deletions
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index 3d600a0..7219be0 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -3,14 +3,13 @@ // found in the LICENSE file. #include "chrome/browser/notifications/balloon_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" -#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" +#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/browser_render_process_host.h" @@ -30,20 +29,12 @@ BalloonHost::BalloonHost(Balloon* balloon) balloon_(balloon), initialized_(false), should_notify_on_disconnect_(false), - enable_web_ui_(false) { - DCHECK(balloon_); - - // If the notification is for an extension URL, make sure to use the extension - // process to render it, so that it can communicate with other views in the - // extension. - const GURL& balloon_url = balloon_->notification().content_url(); - if (balloon_url.SchemeIs(chrome::kExtensionScheme)) { - site_instance_ = - balloon_->profile()->GetExtensionProcessManager()->GetSiteInstanceForURL( - balloon_url); - } else { - site_instance_ = SiteInstance::CreateSiteInstance(balloon_->profile()); - } + enable_web_ui_(false), + ALLOW_THIS_IN_INITIALIZER_LIST( + extension_function_dispatcher_(GetProfile(), this)) { + CHECK(balloon_); + site_instance_ = SiteInstance::CreateSiteInstanceForURL(balloon_->profile(), + GetURL()); } void BalloonHost::Shutdown() { @@ -64,7 +55,9 @@ gfx::NativeView BalloonHost::GetNativeViewOfHost() { return NULL; } -TabContents* BalloonHost::associated_tab_contents() const { return NULL; } +TabContents* BalloonHost::GetAssociatedTabContents() const { + return NULL; +} const string16& BalloonHost::GetSource() const { return balloon_->notification().display_source(); @@ -133,10 +126,16 @@ RenderViewHostDelegate::View* BalloonHost::GetViewDelegate() { } bool BalloonHost::OnMessageReceived(const IPC::Message& message) { - if (extension_function_dispatcher_.get()) - return extension_function_dispatcher_->OnMessageReceived(message); + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(BalloonHost, message) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} - return false; +void BalloonHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { + extension_function_dispatcher_.Dispatch(params, render_view_host_); } // RenderViewHostDelegate::View methods implemented to allow links to @@ -196,24 +195,8 @@ void BalloonHost::Init() { DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; RenderViewHost* rvh = new RenderViewHost( site_instance_.get(), this, MSG_ROUTING_NONE, NULL); - if (GetProfile()->GetExtensionService()) { - extension_function_dispatcher_.reset( - ExtensionFunctionDispatcher::Create( - rvh, this, balloon_->notification().content_url())); - } - if (extension_function_dispatcher_.get()) { - rvh->AllowBindings(BindingsPolicy::EXTENSION); - rvh->set_is_extension_process(true); - const Extension* installed_app = - GetProfile()->GetExtensionService()->GetInstalledApp( - balloon_->notification().content_url()); - if (installed_app) { - GetProfile()->GetExtensionService()->SetInstalledAppForRenderer( - rvh->process()->id(), installed_app); - } - } else if (enable_web_ui_) { + if (enable_web_ui_) rvh->AllowBindings(BindingsPolicy::WEB_UI); - } // Do platform-specific initialization. render_view_host_ = rvh; diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 9a70e61..2a03506 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -44,7 +44,7 @@ class BalloonHost : public RenderViewHostDelegate, // ExtensionFunctionDispatcher::Delegate overrides. virtual Browser* GetBrowser(); virtual gfx::NativeView GetNativeViewOfHost(); - virtual TabContents* associated_tab_contents() const; + virtual TabContents* GetAssociatedTabContents() const; RenderViewHost* render_view_host() const { return render_view_host_; } @@ -137,6 +137,9 @@ class BalloonHost : public RenderViewHostDelegate, // RenderViewHostDelegate virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + // Message handlers + void OnRequest(const ExtensionHostMsg_Request_Params& params); + // Called to send an event that the balloon has been disconnected from // a renderer (if should_notify_on_disconnect_ is true). void NotifyDisconnect(); @@ -158,14 +161,12 @@ class BalloonHost : public RenderViewHostDelegate, // Common implementations of some RenderViewHostDelegate::View methods. RenderViewHostDelegateViewHelper delegate_view_helper_; - // Handles requests to extension APIs. Will only be non-NULL if we are - // rendering a page from an extension. - scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; - // A flag to enable Web UI. bool enable_web_ui_; NotificationRegistrar registrar_; + + ExtensionFunctionDispatcher extension_function_dispatcher_; }; #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ |