diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2015-06-10 16:32:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-10 23:33:30 +0000 |
commit | cb2ec659ab8741962f3391970a5fff512ebb6509 (patch) | |
tree | 84c87ca2540a0f0e7dc66bb0b82a5abc79ad012b /extensions/shell | |
parent | 1bcab9592f6213b9f44379bb66ce7b613b371e0b (diff) | |
download | chromium_src-cb2ec659ab8741962f3391970a5fff512ebb6509.zip chromium_src-cb2ec659ab8741962f3391970a5fff512ebb6509.tar.gz chromium_src-cb2ec659ab8741962f3391970a5fff512ebb6509.tar.bz2 |
[Extensions] Clean up the handling of ExtensionHostMsg_Request
ExtensionHostMsg_Request is sent when an extension calls an API function. Before
this patch, this IPC would be sent to one of 11 different call sites, all of
which then routed it to the ExtensionFunctionDispatcher - and all of which
have to implement ExtensionFunctionDispatcher::Delegate.
Instead, have ExtensionWebContentsObserver handle the IPC, since it is created
(or should be) for all extension web contents. This also lets us eliminate many
(though not all) of the ExtensionFunctionDispatcher::Delegate implementations
(I will try to clean more up in a later patch).
The size of this patch is due to a number of yaks that needed shaving along the
way - in particular, around GuestView.
BUG=498017
BUG=405246
Review URL: https://codereview.chromium.org/1169223002
Cr-Commit-Position: refs/heads/master@{#333843}
Diffstat (limited to 'extensions/shell')
5 files changed, 19 insertions, 0 deletions
diff --git a/extensions/shell/browser/shell_app_delegate.cc b/extensions/shell/browser/shell_app_delegate.cc index 3871027..6404964 100644 --- a/extensions/shell/browser/shell_app_delegate.cc +++ b/extensions/shell/browser/shell_app_delegate.cc @@ -7,6 +7,7 @@ #include "content/public/browser/web_contents.h" #include "extensions/common/constants.h" #include "extensions/shell/browser/media_capture_util.h" +#include "extensions/shell/browser/shell_extension_web_contents_observer.h" namespace extensions { @@ -17,6 +18,7 @@ ShellAppDelegate::~ShellAppDelegate() { } void ShellAppDelegate::InitWebContents(content::WebContents* web_contents) { + ShellExtensionWebContentsObserver::CreateForWebContents(web_contents); } void ShellAppDelegate::RenderViewCreated( diff --git a/extensions/shell/browser/shell_extensions_api_client.cc b/extensions/shell/browser/shell_extensions_api_client.cc index 43d9fdd3..527b883 100644 --- a/extensions/shell/browser/shell_extensions_api_client.cc +++ b/extensions/shell/browser/shell_extensions_api_client.cc @@ -5,12 +5,18 @@ #include "extensions/shell/browser/shell_extensions_api_client.h" #include "extensions/shell/browser/shell_app_view_guest_delegate.h" +#include "extensions/shell/browser/shell_extension_web_contents_observer.h" namespace extensions { ShellExtensionsAPIClient::ShellExtensionsAPIClient() { } +void ShellExtensionsAPIClient::AttachWebContentsHelpers( + content::WebContents* web_contents) const { + ShellExtensionWebContentsObserver::CreateForWebContents(web_contents); +} + AppViewGuestDelegate* ShellExtensionsAPIClient::CreateAppViewGuestDelegate() const { return new ShellAppViewGuestDelegate(); diff --git a/extensions/shell/browser/shell_extensions_api_client.h b/extensions/shell/browser/shell_extensions_api_client.h index 6c40889..17a26fc 100644 --- a/extensions/shell/browser/shell_extensions_api_client.h +++ b/extensions/shell/browser/shell_extensions_api_client.h @@ -14,6 +14,8 @@ class ShellExtensionsAPIClient : public ExtensionsAPIClient { ShellExtensionsAPIClient(); // ExtensionsAPIClient implementation. + void AttachWebContentsHelpers(content::WebContents* web_contents) const + override; AppViewGuestDelegate* CreateAppViewGuestDelegate() const override; }; diff --git a/extensions/shell/browser/shell_extensions_browser_client.cc b/extensions/shell/browser/shell_extensions_browser_client.cc index 01a7e75..a79d866 100644 --- a/extensions/shell/browser/shell_extensions_browser_client.cc +++ b/extensions/shell/browser/shell_extensions_browser_client.cc @@ -19,6 +19,7 @@ #include "extensions/shell/browser/api/generated_api_registration.h" #include "extensions/shell/browser/shell_extension_host_delegate.h" #include "extensions/shell/browser/shell_extension_system_factory.h" +#include "extensions/shell/browser/shell_extension_web_contents_observer.h" #include "extensions/shell/browser/shell_extensions_api_client.h" #include "extensions/shell/browser/shell_runtime_api_delegate.h" @@ -240,4 +241,10 @@ void ShellExtensionsBrowserClient::SetAPIClientForTest( api_client_.reset(api_client); } +ExtensionWebContentsObserver* +ShellExtensionsBrowserClient::GetExtensionWebContentsObserver( + content::WebContents* web_contents) { + return ShellExtensionWebContentsObserver::FromWebContents(web_contents); +} + } // namespace extensions diff --git a/extensions/shell/browser/shell_extensions_browser_client.h b/extensions/shell/browser/shell_extensions_browser_client.h index 4d868b7..24ca6d9 100644 --- a/extensions/shell/browser/shell_extensions_browser_client.h +++ b/extensions/shell/browser/shell_extensions_browser_client.h @@ -85,6 +85,8 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { ExtensionCache* GetExtensionCache() override; bool IsBackgroundUpdateAllowed() override; bool IsMinBrowserVersionSupported(const std::string& min_version) override; + ExtensionWebContentsObserver* GetExtensionWebContentsObserver( + content::WebContents* web_contents) override; // Sets the API client. void SetAPIClientForTest(ExtensionsAPIClient* api_client); |