diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 23:46:52 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 23:46:52 +0000 |
commit | c7220f3ce2cd4a1b83f2a43adb3016c7d76aebc8 (patch) | |
tree | 236ec52d1c42c7dd6cfb04d6e1f4702d788725c4 | |
parent | c4374392252dd6f3c833426ca6121292951619fe (diff) | |
download | chromium_src-c7220f3ce2cd4a1b83f2a43adb3016c7d76aebc8.zip chromium_src-c7220f3ce2cd4a1b83f2a43adb3016c7d76aebc8.tar.gz chromium_src-c7220f3ce2cd4a1b83f2a43adb3016c7d76aebc8.tar.bz2 |
Add stub ExtensionsClient to app_shell
Also register ExtensionPrefs. This allows app_shell to run until it tries
tries to bring up ExtensionSystem.
BUG=None
TEST=compiles, app_shell launches
R=yoz@chromium.org
Review URL: https://codereview.chromium.org/110863005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240805 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | apps/DEPS | 4 | ||||
-rw-r--r-- | apps/apps.gypi | 2 | ||||
-rw-r--r-- | apps/shell/DEPS | 2 | ||||
-rw-r--r-- | apps/shell/shell_browser_main_parts.cc | 5 | ||||
-rw-r--r-- | apps/shell/shell_browser_main_parts.h | 2 | ||||
-rw-r--r-- | apps/shell/shell_extensions_browser_client.cc | 3 | ||||
-rw-r--r-- | apps/shell/shell_extensions_client.cc | 147 | ||||
-rw-r--r-- | apps/shell/shell_extensions_client.h | 49 |
8 files changed, 208 insertions, 6 deletions
@@ -29,14 +29,12 @@ include_rules = [ "+chrome/browser/extensions/api/app_runtime/app_runtime_api.h", "+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h", "+chrome/browser/extensions/api/file_system/file_system_api.h", - "+chrome/browser/extensions/event_router.h", "+chrome/browser/extensions/extension_function_dispatcher.h", "+chrome/browser/extensions/extension_icon_image.h", "+chrome/browser/extensions/extension_host.h", "+chrome/browser/extensions/extension_keybinding_registry.h", "+chrome/browser/extensions/extension_prefs.h", "+chrome/browser/extensions/extension_prefs_factory.h", - "+chrome/browser/extensions/extension_process_manager.h", "+chrome/browser/extensions/extension_service.h", "+chrome/browser/extensions/extension_system.h", "+chrome/browser/extensions/extension_system_factory.h", @@ -45,11 +43,9 @@ include_rules = [ "+chrome/browser/extensions/unpacked_installer.h", "+chrome/common/extensions/api/app_runtime.h", "+chrome/common/extensions/api/app_window.h", - "+chrome/common/extensions/extension.h", "+chrome/common/extensions/extension_messages.h", "+chrome/common/extensions/extension_set.h", "+chrome/common/extensions/manifest_handlers/icons_handler.h", - "+chrome/common/extensions/permissions/permission_set.h", ] specific_include_rules = { diff --git a/apps/apps.gypi b/apps/apps.gypi index 381c57c..be6a619 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -134,6 +134,8 @@ 'shell/shell_content_client.h', 'shell/shell_extensions_browser_client.cc', 'shell/shell_extensions_browser_client.h', + 'shell/shell_extensions_client.cc', + 'shell/shell_extensions_client.h', 'shell/shell_main_delegate.cc', 'shell/shell_main_delegate.h', 'shell/shell_main.cc', diff --git a/apps/shell/DEPS b/apps/shell/DEPS index 38fd058..081a2e7 100644 --- a/apps/shell/DEPS +++ b/apps/shell/DEPS @@ -9,6 +9,8 @@ include_rules = [ # TODO(jamescook): Remove these. http://crbug.com/305404 # Chrome pieces for bring-up. "+chrome/common/chrome_paths.h", + "+chrome/browser/extensions/extension_prefs.h", + # Pieces of content_shell reused in app_shell. "+content/shell/browser/shell_browser_context.h", ] diff --git a/apps/shell/shell_browser_main_parts.cc b/apps/shell/shell_browser_main_parts.cc index 262c837..846d426 100644 --- a/apps/shell/shell_browser_main_parts.cc +++ b/apps/shell/shell_browser_main_parts.cc @@ -7,6 +7,7 @@ #include "apps/app_load_service.h" #include "apps/shell/shell_browser_context.h" #include "apps/shell/shell_extensions_browser_client.h" +#include "apps/shell/shell_extensions_client.h" #include "apps/shell/web_view_window.h" #include "base/command_line.h" #include "base/file_util.h" @@ -97,7 +98,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { // Initialize our "profile" equivalent. browser_context_.reset(new ShellBrowserContext); - // TODO(jamescook): Initialize ExtensionsClient. + extensions_client_.reset(new ShellExtensionsClient()); + extensions::ExtensionsClient::Set(extensions_client_.get()); + extensions_browser_client_.reset( new ShellExtensionsBrowserClient(browser_context_.get())); extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); diff --git a/apps/shell/shell_browser_main_parts.h b/apps/shell/shell_browser_main_parts.h index 16f3c7a..eb17edd 100644 --- a/apps/shell/shell_browser_main_parts.h +++ b/apps/shell/shell_browser_main_parts.h @@ -31,6 +31,7 @@ namespace apps { class ShellBrowserContext; class ShellExtensionsBrowserClient; +class ShellExtensionsClient; // Handles initialization of AppShell. class ShellBrowserMainParts : public content::BrowserMainParts { @@ -60,6 +61,7 @@ class ShellBrowserMainParts : public content::BrowserMainParts { private: scoped_ptr<ShellBrowserContext> browser_context_; + scoped_ptr<ShellExtensionsClient> extensions_client_; scoped_ptr<ShellExtensionsBrowserClient> extensions_browser_client_; // Enable a minimal set of views::corewm to be initialized. diff --git a/apps/shell/shell_extensions_browser_client.cc b/apps/shell/shell_extensions_browser_client.cc index c192406..34eb29f 100644 --- a/apps/shell/shell_extensions_browser_client.cc +++ b/apps/shell/shell_extensions_browser_client.cc @@ -8,6 +8,7 @@ #include "base/prefs/pref_service.h" #include "base/prefs/pref_service_factory.h" #include "base/prefs/testing_pref_store.h" +#include "chrome/browser/extensions/extension_prefs.h" #include "components/user_prefs/pref_registry_syncable.h" #include "components/user_prefs/user_prefs.h" #include "extensions/browser/app_sorting.h" @@ -18,7 +19,7 @@ namespace { // See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) { - // TODO(jamescook): ExtensionPrefs::RegisterProfilePrefs(registry) + extensions::ExtensionPrefs::RegisterProfilePrefs(registry); } } // namespace diff --git a/apps/shell/shell_extensions_client.cc b/apps/shell/shell_extensions_client.cc new file mode 100644 index 0000000..a8fa82d --- /dev/null +++ b/apps/shell/shell_extensions_client.cc @@ -0,0 +1,147 @@ +// Copyright 2013 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. + +#include "apps/shell/shell_extensions_client.h" + +#include "base/logging.h" +#include "extensions/common/permissions/permission_message_provider.h" +#include "extensions/common/permissions/permissions_provider.h" +#include "extensions/common/url_pattern_set.h" + +using extensions::APIPermissionInfo; +using extensions::APIPermissionSet; +using extensions::Extension; +using extensions::Manifest; +using extensions::PermissionMessage; +using extensions::PermissionMessages; +using extensions::PermissionSet; +using extensions::URLPatternSet; + +namespace apps { + +namespace { + +// TODO(jamescook): Refactor ChromeAPIPermissions to share some of the +// permissions registration for app_shell. For now, allow no permissions. +class ShellPermissionsProvider : public extensions::PermissionsProvider { + public: + ShellPermissionsProvider() {} + virtual ~ShellPermissionsProvider() {} + + virtual std::vector<APIPermissionInfo*> GetAllPermissions() const OVERRIDE { + return std::vector<APIPermissionInfo*>(); + } + + virtual std::vector<AliasInfo> GetAllAliases() const OVERRIDE { + return std::vector<AliasInfo>(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ShellPermissionsProvider); +}; + +// TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share +// code. +class ShellPermissionMessageProvider + : public extensions::PermissionMessageProvider { + public: + ShellPermissionMessageProvider() {} + virtual ~ShellPermissionMessageProvider() {} + + // PermissionMessageProvider implementation. + virtual PermissionMessages GetPermissionMessages( + const PermissionSet* permissions, + Manifest::Type extension_type) const OVERRIDE { + return PermissionMessages(); + } + + virtual std::vector<base::string16> GetWarningMessages( + const PermissionSet* permissions, + Manifest::Type extension_type) const OVERRIDE { + return std::vector<base::string16>(); + } + + virtual std::vector<base::string16> GetWarningMessagesDetails( + const PermissionSet* permissions, + Manifest::Type extension_type) const OVERRIDE { + return std::vector<base::string16>(); + } + + virtual bool IsPrivilegeIncrease( + const PermissionSet* old_permissions, + const PermissionSet* new_permissions, + Manifest::Type extension_type) const OVERRIDE { + // Ensure we implement this before shipping. + CHECK(false); + return false; + } + + private: + DISALLOW_COPY_AND_ASSIGN(ShellPermissionMessageProvider); +}; + +} // namespace + +ShellExtensionsClient::ShellExtensionsClient() { +} + +ShellExtensionsClient::~ShellExtensionsClient() { +} + +void ShellExtensionsClient::Initialize() { + // TODO(jamescook): Do we need to whitelist any extensions? +} + +const extensions::PermissionsProvider& +ShellExtensionsClient::GetPermissionsProvider() const { + NOTIMPLEMENTED(); + static ShellPermissionsProvider provider; + return provider; +} + +const extensions::PermissionMessageProvider& +ShellExtensionsClient::GetPermissionMessageProvider() const { + NOTIMPLEMENTED(); + static ShellPermissionMessageProvider provider; + return provider; +} + +extensions::FeatureProvider* ShellExtensionsClient::GetFeatureProviderByName( + const std::string& name) const { + NOTIMPLEMENTED(); + return NULL; +} + +void ShellExtensionsClient::FilterHostPermissions( + const URLPatternSet& hosts, + URLPatternSet* new_hosts, + std::set<PermissionMessage>* messages) const { + NOTIMPLEMENTED(); +} + +void ShellExtensionsClient::SetScriptingWhitelist( + const ScriptingWhitelist& whitelist) { + scripting_whitelist_ = whitelist; +} + +const extensions::ExtensionsClient::ScriptingWhitelist& +ShellExtensionsClient::GetScriptingWhitelist() const { + // TODO(jamescook): Real whitelist. + return scripting_whitelist_; +} + +URLPatternSet ShellExtensionsClient::GetPermittedChromeSchemeHosts( + const Extension* extension, + const APIPermissionSet& api_permissions) const { + NOTIMPLEMENTED(); + return URLPatternSet(); +} + +bool ShellExtensionsClient::IsScriptableURL(const GURL& url, + std::string* error) const { + NOTIMPLEMENTED(); + return true; +} + +} // namespace apps diff --git a/apps/shell/shell_extensions_client.h b/apps/shell/shell_extensions_client.h new file mode 100644 index 0000000..1ed3697 --- /dev/null +++ b/apps/shell/shell_extensions_client.h @@ -0,0 +1,49 @@ +// Copyright 2013 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 APPS_SHELL_SHELL_EXTENSIONS_CLIENT_H_ +#define APPS_SHELL_SHELL_EXTENSIONS_CLIENT_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "extensions/common/extensions_client.h" + +namespace apps { + +// The app_shell implementation of ExtensionsClient. +class ShellExtensionsClient : public extensions::ExtensionsClient { + public: + ShellExtensionsClient(); + virtual ~ShellExtensionsClient(); + + // extensions::ExtensionsClient overrides: + virtual void Initialize() OVERRIDE; + virtual const extensions::PermissionsProvider& GetPermissionsProvider() const + OVERRIDE; + virtual const extensions::PermissionMessageProvider& + GetPermissionMessageProvider() const OVERRIDE; + virtual extensions::FeatureProvider* GetFeatureProviderByName( + const std::string& name) const OVERRIDE; + virtual void FilterHostPermissions( + const extensions::URLPatternSet& hosts, + extensions::URLPatternSet* new_hosts, + std::set<extensions::PermissionMessage>* messages) const OVERRIDE; + virtual void SetScriptingWhitelist(const ScriptingWhitelist& whitelist) + OVERRIDE; + virtual const ScriptingWhitelist& GetScriptingWhitelist() const OVERRIDE; + virtual extensions::URLPatternSet GetPermittedChromeSchemeHosts( + const extensions::Extension* extension, + const extensions::APIPermissionSet& api_permissions) const OVERRIDE; + virtual bool IsScriptableURL(const GURL& url, std::string* error) const + OVERRIDE; + + private: + ScriptingWhitelist scripting_whitelist_; + + DISALLOW_COPY_AND_ASSIGN(ShellExtensionsClient); +}; + +} // namespace apps + +#endif // APPS_SHELL_SHELL_EXTENSIONS_CLIENT_H_ |