diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:04:41 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:04:41 +0000 |
commit | 6c0f179fbe911945a500e1f735d61ccbc98f5b51 (patch) | |
tree | 71505e558d252b311c3d4008c75d6044694a2b43 /extensions | |
parent | 0ffdcc38fd049fbbc4225ef2437d4117e9358e7c (diff) | |
download | chromium_src-6c0f179fbe911945a500e1f735d61ccbc98f5b51.zip chromium_src-6c0f179fbe911945a500e1f735d61ccbc98f5b51.tar.gz chromium_src-6c0f179fbe911945a500e1f735d61ccbc98f5b51.tar.bz2 |
Introduce ExtensionHostDelegate, use it for media access requests
As part of the app_shell/extensions refactoring project we're trying to move
ExtensionHost to src/extensions.
* Break ExtensionHost's dependency on chrome/browser/media by delegating out
media access requests. Some extension background pages do make these requests
e.g. the Chromecast extension.
* Also use it for tab creation requests.
* Now that there are 5 methods delegated out of ExtensionHost introduce
ExtensionHostDelegate to implement them and reduce the size of the
ExtensionsBrowserClient interface.
BUG=321341
TEST=browser_tests *Extension* and *Media*
Review URL: https://codereview.chromium.org/203953003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/extension_host_delegate.h | 63 | ||||
-rw-r--r-- | extensions/browser/extensions_browser_client.h | 15 | ||||
-rw-r--r-- | extensions/browser/test_extensions_browser_client.cc | 15 | ||||
-rw-r--r-- | extensions/browser/test_extensions_browser_client.h | 6 | ||||
-rw-r--r-- | extensions/extensions.gyp | 1 |
5 files changed, 73 insertions, 27 deletions
diff --git a/extensions/browser/extension_host_delegate.h b/extensions/browser/extension_host_delegate.h new file mode 100644 index 0000000..0bf52a4 --- /dev/null +++ b/extensions/browser/extension_host_delegate.h @@ -0,0 +1,63 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EXTENSIONS_BROWSER_EXTENSION_HOST_DELEGATE_H_ +#define EXTENSIONS_BROWSER_EXTENSION_HOST_DELEGATE_H_ + +#include <string> + +#include "content/public/common/media_stream_request.h" +#include "ui/base/window_open_disposition.h" + +namespace content { +class JavaScriptDialogManager; +class WebContents; +} + +namespace gfx { +class Rect; +} + +namespace extensions { +class Extension; +class ExtensionHost; + +// A delegate to support functionality that cannot exist in the extensions +// module. This is not an inner class of ExtensionHost to allow it to be forward +// declared. +class ExtensionHostDelegate { + public: + virtual ~ExtensionHostDelegate() {} + + // Called after the hosting |web_contents| for an extension is created. The + // implementation may wish to add preference observers to |web_contents|. + virtual void OnExtensionHostCreated(content::WebContents* web_contents) = 0; + + // Called after |host| creates a RenderView for an extension. + virtual void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host) = 0; + + // Returns the embedder's JavaScriptDialogManager or NULL if the embedder + // does not support JavaScript dialogs. + virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() = 0; + + // Creates a new tab or popup window with |web_contents|. The embedder may + // choose to do nothing if tabs and popups are not supported. + virtual void CreateTab(content::WebContents* web_contents, + const std::string& extension_id, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) = 0; + + // Requests access to an audio or video media stream. Invokes |callback| + // with the response. + virtual void ProcessMediaAccessRequest( + content::WebContents* web_contents, + const content::MediaStreamRequest& request, + const content::MediaResponseCallback& callback, + const Extension* extension) = 0; +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_EXTENSION_HOST_DELEGATE_H_ diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h index b994cca..2e3d26d 100644 --- a/extensions/browser/extensions_browser_client.h +++ b/extensions/browser/extensions_browser_client.h @@ -19,7 +19,6 @@ class CommandLine; namespace content { class BrowserContext; -class JavaScriptDialogManager; class WebContents; } @@ -28,7 +27,7 @@ namespace extensions { class ApiActivityMonitor; class AppSorting; class Extension; -class ExtensionHost; +class ExtensionHostDelegate; class ExtensionSystem; class ExtensionSystemProvider; @@ -98,12 +97,8 @@ class ExtensionsBrowserClient { virtual bool IsBackgroundPageAllowed( content::BrowserContext* context) const = 0; - // Called after the hosting |web_contents| for an extension is created. The - // implementation may wish to add preference observers to |web_contents|. - virtual void OnExtensionHostCreated(content::WebContents* web_contents) = 0; - - // Called after |host| creates a RenderView for an extension. - virtual void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host) = 0; + // Creates a new ExtensionHostDelegate instance. + virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() = 0; // Returns true if the client version has updated since the last run. Called // once each time the extensions system is loaded per browser_context. The @@ -121,10 +116,6 @@ class ExtensionsBrowserClient { // Return true if the system is run in forced app mode. virtual bool IsRunningInForcedAppMode() = 0; - // Returns the embedder's JavaScriptDialogManager or NULL if the embedder - // does not support JavaScript dialogs. - virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() = 0; - // Returns the embedder's ApiActivityMonitor for |context|. Returns NULL if // the embedder does not monitor extension API activity. virtual ApiActivityMonitor* GetApiActivityMonitor( diff --git a/extensions/browser/test_extensions_browser_client.cc b/extensions/browser/test_extensions_browser_client.cc index b9cd561..739450b 100644 --- a/extensions/browser/test_extensions_browser_client.cc +++ b/extensions/browser/test_extensions_browser_client.cc @@ -6,6 +6,7 @@ #include "content/public/browser/browser_context.h" #include "extensions/browser/app_sorting.h" +#include "extensions/browser/extension_host_delegate.h" using content::BrowserContext; @@ -97,11 +98,10 @@ bool TestExtensionsBrowserClient::IsBackgroundPageAllowed( return true; } -void TestExtensionsBrowserClient::OnExtensionHostCreated( - content::WebContents* web_contents) {} - -void TestExtensionsBrowserClient::OnRenderViewCreatedForBackgroundPage( - ExtensionHost* host) {} +scoped_ptr<ExtensionHostDelegate> +TestExtensionsBrowserClient::CreateExtensionHostDelegate() { + return scoped_ptr<ExtensionHostDelegate>(); +} bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) { return false; @@ -115,11 +115,6 @@ scoped_ptr<AppSorting> TestExtensionsBrowserClient::CreateAppSorting() { bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; } -content::JavaScriptDialogManager* -TestExtensionsBrowserClient::GetJavaScriptDialogManager() { - return NULL; -} - ApiActivityMonitor* TestExtensionsBrowserClient::GetApiActivityMonitor( BrowserContext* context) { return NULL; diff --git a/extensions/browser/test_extensions_browser_client.h b/extensions/browser/test_extensions_browser_client.h index 538fc0c..19f33d7 100644 --- a/extensions/browser/test_extensions_browser_client.h +++ b/extensions/browser/test_extensions_browser_client.h @@ -48,16 +48,12 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient { content::BrowserContext* context) const OVERRIDE; virtual bool IsBackgroundPageAllowed(content::BrowserContext* context) const OVERRIDE; - virtual void OnExtensionHostCreated(content::WebContents* web_contents) - OVERRIDE; - virtual void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host) + virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() OVERRIDE; virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE; virtual void PermitExternalProtocolHandler() OVERRIDE; virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE; virtual bool IsRunningInForcedAppMode() OVERRIDE; - virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() - OVERRIDE; virtual ApiActivityMonitor* GetApiActivityMonitor( content::BrowserContext* context) OVERRIDE; virtual ExtensionSystemProvider* GetExtensionSystemFactory() OVERRIDE; diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index b13f128..8debbf4 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -230,6 +230,7 @@ 'browser/event_listener_map.h', 'browser/event_router.cc', 'browser/event_router.h', + 'browser/extension_host_delegate.h', 'browser/extension_error.cc', 'browser/extension_error.h', 'browser/extension_function.cc', |