diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-19 17:43:37 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-19 17:43:37 +0000 |
commit | 3a7fbc24640bd709fae9fa30ed624ec65487299b (patch) | |
tree | 8fc3a2d407bb79302e18280d03f9720ad7b0d387 | |
parent | c6c02068f3d5c28f5efd0c21cc979c10ae71bddd (diff) | |
download | chromium_src-3a7fbc24640bd709fae9fa30ed624ec65487299b.zip chromium_src-3a7fbc24640bd709fae9fa30ed624ec65487299b.tar.gz chromium_src-3a7fbc24640bd709fae9fa30ed624ec65487299b.tar.bz2 |
Create simplified ExtensionSystem for app_shell
* Only initialize a few core ExtensionSystem services
* Switch to using extension_file_util::LoadExtension instead of AppLoadService,
which allows us to avoid ExtensionService for now.
* Clean up RootWindow creation and handle clicks on the close box.
This allows app_shell to parse a non-app extension and create an Extension
object. The Extension does not yet start running.
BUG=288226
TEST=none
R=derat@chromium.org, yoz@chromium.org
Review URL: https://codereview.chromium.org/116573011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241880 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | apps/apps.gypi | 2 | ||||
-rw-r--r-- | apps/shell/DEPS | 4 | ||||
-rw-r--r-- | apps/shell/shell_browser_context.cc | 18 | ||||
-rw-r--r-- | apps/shell/shell_browser_context.h | 6 | ||||
-rw-r--r-- | apps/shell/shell_browser_main_parts.cc | 116 | ||||
-rw-r--r-- | apps/shell/shell_browser_main_parts.h | 34 | ||||
-rw-r--r-- | apps/shell/shell_content_client.cc | 10 | ||||
-rw-r--r-- | apps/shell/shell_content_client.h | 3 | ||||
-rw-r--r-- | apps/shell/shell_extension_system.cc | 102 | ||||
-rw-r--r-- | apps/shell/shell_extension_system.h | 70 | ||||
-rw-r--r-- | apps/shell/shell_extensions_client.cc | 5 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_system_factory.cc | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_system_factory.h | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/unpacked_installer.cc | 1 | ||||
-rw-r--r-- | extensions/common/url_pattern.cc | 5 |
15 files changed, 337 insertions, 55 deletions
diff --git a/apps/apps.gypi b/apps/apps.gypi index be6a619..5813a3d 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -132,6 +132,8 @@ 'shell/shell_content_browser_client.h', 'shell/shell_content_client.cc', 'shell/shell_content_client.h', + 'shell/shell_extension_system.cc', + 'shell/shell_extension_system.h', 'shell/shell_extensions_browser_client.cc', 'shell/shell_extensions_browser_client.h', 'shell/shell_extensions_client.cc', diff --git a/apps/shell/DEPS b/apps/shell/DEPS index 48d1152..2ac93a1 100644 --- a/apps/shell/DEPS +++ b/apps/shell/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "-chrome", "+chromeos", "+components/user_prefs", "+sync/api", @@ -8,7 +7,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", + "+chrome/common/extensions/extension_file_util.h", + "+chrome/common/extensions/features/base_feature_provider.h", # Pieces of content_shell reused in app_shell. "+content/shell/browser/shell_browser_context.h", diff --git a/apps/shell/shell_browser_context.cc b/apps/shell/shell_browser_context.cc index 32954e7..31a272b 100644 --- a/apps/shell/shell_browser_context.cc +++ b/apps/shell/shell_browser_context.cc @@ -55,5 +55,23 @@ void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext8() { void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext9() { NOTREACHED(); } +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext10() { + NOTREACHED(); +} +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext11() { + NOTREACHED(); +} +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext12() { + NOTREACHED(); +} +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext13() { + NOTREACHED(); +} +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext14() { + NOTREACHED(); +} +void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext15() { + NOTREACHED(); +} } // namespace apps diff --git a/apps/shell/shell_browser_context.h b/apps/shell/shell_browser_context.h index 165f906..120a6b5 100644 --- a/apps/shell/shell_browser_context.h +++ b/apps/shell/shell_browser_context.h @@ -28,6 +28,12 @@ class ShellBrowserContext : public content::ShellBrowserContext { virtual void ProfileFunctionCallOnNonProfileBrowserContext7(); virtual void ProfileFunctionCallOnNonProfileBrowserContext8(); virtual void ProfileFunctionCallOnNonProfileBrowserContext9(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext10(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext11(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext12(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext13(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext14(); + virtual void ProfileFunctionCallOnNonProfileBrowserContext15(); private: DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); diff --git a/apps/shell/shell_browser_main_parts.cc b/apps/shell/shell_browser_main_parts.cc index 846d426..e03fdd2 100644 --- a/apps/shell/shell_browser_main_parts.cc +++ b/apps/shell/shell_browser_main_parts.cc @@ -4,17 +4,18 @@ #include "apps/shell/shell_browser_main_parts.h" -#include "apps/app_load_service.h" #include "apps/shell/shell_browser_context.h" +#include "apps/shell/shell_extension_system.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" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/run_loop.h" +#include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/extensions/extension_file_util.h" #include "chromeos/chromeos_paths.h" #include "content/public/common/result_codes.h" #include "extensions/common/extension_paths.h" @@ -25,44 +26,19 @@ #include "ui/gfx/screen.h" #include "ui/wm/test/wm_test_helper.h" +using content::BrowserContext; +using extensions::Extension; + namespace apps { ShellBrowserMainParts::ShellBrowserMainParts( - const content::MainFunctionParams& parameters) { + const content::MainFunctionParams& parameters) + : extension_system_(NULL) { } ShellBrowserMainParts::~ShellBrowserMainParts() { } -void ShellBrowserMainParts::CreateRootWindow() { - // TODO(jamescook): Replace this with a real Screen implementation. - gfx::Screen::SetScreenInstance( - gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); - // Set up basic pieces of views::corewm. - wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); - // Ensure the X window gets mapped. - wm_test_helper_->root_window()->host()->Show(); -} - -void ShellBrowserMainParts::LoadAndLaunchApp(const base::FilePath& app_dir) { - base::FilePath current_dir; - CHECK(file_util::GetCurrentDirectory(¤t_dir)); - - // HACK: This allows us to see how far we can get without crashing. - Profile* profile = reinterpret_cast<Profile*>(browser_context_.get()); - LOG(WARNING) << "-----------------------------------"; - LOG(WARNING) << "app_shell is expected to crash now."; - LOG(WARNING) << "-----------------------------------"; - - apps::AppLoadService* app_load_service = - apps::AppLoadService::Get(profile); - DCHECK(app_load_service); - if (!app_load_service->LoadAndLaunch( - app_dir, *CommandLine::ForCurrentProcess(), current_dir)) { - LOG(ERROR) << "Unable to launch app at \"" << app_dir.value() << "\""; - } -} - void ShellBrowserMainParts::PreMainMessageLoopStart() { // TODO(jamescook): Initialize touch here? } @@ -106,9 +82,11 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); // TODO(jamescook): Initialize policy::ProfilePolicyConnector. - // TODO(jamescook): Initialize ExtensionSystem and InitForRegularProfile. - // TODO(jamescook): CreateBrowserContextServices using - // BrowserContextDependencyManager. + + CreateExtensionSystem(); + + // TODO(jamescook): Create the rest of the services using + // BrowserContextDependencyManager::CreateBrowserContextServices. CreateRootWindow(); @@ -118,9 +96,8 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); LoadAndLaunchApp(app_dir); } else { - // TODO(jamescook): Create an apps::ShellWindow here. For now, create a - // window with a WebView just to ensure that the content module is properly - // initialized. + // TODO(jamescook): For demo purposes create a window with a WebView just + // to ensure that the content module is properly initialized. ShowWebViewWindow(browser_context_.get(), wm_test_helper_->root_window()->window()); } @@ -134,11 +111,72 @@ bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { } void ShellBrowserMainParts::PostMainMessageLoopRun() { + DestroyRootWindow(); + // TODO(jamescook): Destroy the rest of the services with + // BrowserContextDependencyManager::DestroyBrowserContextServices. extensions::ExtensionsBrowserClient::Set(NULL); extensions_browser_client_.reset(); browser_context_.reset(); - wm_test_helper_.reset(); aura::Env::DeleteInstance(); + + LOG(WARNING) << "-----------------------------------"; + LOG(WARNING) << "app_shell is expected to crash now."; + LOG(WARNING) << "-----------------------------------"; +} + +void ShellBrowserMainParts::OnRootWindowHostCloseRequested( + const aura::RootWindow* root) { + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); +} + +void ShellBrowserMainParts::CreateRootWindow() { + // TODO(jamescook): Replace this with a real Screen implementation. + gfx::Screen::SetScreenInstance( + gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); + // Set up basic pieces of views::corewm. + wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); + // Ensure the X window gets mapped. + wm_test_helper_->root_window()->host()->Show(); + // Watch for the user clicking the close box. + wm_test_helper_->root_window()->AddRootWindowObserver(this); +} + +void ShellBrowserMainParts::DestroyRootWindow() { + wm_test_helper_->root_window()->RemoveRootWindowObserver(this); + wm_test_helper_->root_window()->PrepareForShutdown(); + wm_test_helper_.reset(); +} + +void ShellBrowserMainParts::CreateExtensionSystem() { + DCHECK(browser_context_); + extension_system_ = + new extensions::ShellExtensionSystem(browser_context_.get()); + extensions::ExtensionSystemFactory::GetInstance()->SetCustomInstance( + extension_system_); + // Must occur after setting the instance above, as it will end up calling + // ExtensionSystem::Get(). + extension_system_->InitForRegularProfile(true); +} + +bool ShellBrowserMainParts::LoadAndLaunchApp(const base::FilePath& app_dir) { + DCHECK(extension_system_); + std::string load_error; + scoped_refptr<Extension> extension = + extension_file_util::LoadExtension(app_dir, + extensions::Manifest::COMMAND_LINE, + Extension::NO_FLAGS, + &load_error); + if (!extension) { + LOG(ERROR) << "Loading extension at " << app_dir.value() + << " failed with: " << load_error; + return false; + } + + // TODO(jamescook): Add to ExtensionRegistry. + // TODO(jamescook): Set ExtensionSystem ready. + // TODO(jamescook): Send NOTIFICATION_EXTENSION_LOADED. + return true; } } // namespace apps diff --git a/apps/shell/shell_browser_main_parts.h b/apps/shell/shell_browser_main_parts.h index eb17edd..c246c03 100644 --- a/apps/shell/shell_browser_main_parts.h +++ b/apps/shell/shell_browser_main_parts.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_main_parts.h" +#include "ui/aura/root_window_observer.h" namespace base { class FilePath; @@ -19,8 +20,8 @@ class ShellBrowserContext; struct MainFunctionParams; } -namespace views { -class ViewsDelegate; +namespace extensions { +class ShellExtensionSystem; } namespace wm { @@ -34,7 +35,8 @@ class ShellExtensionsBrowserClient; class ShellExtensionsClient; // Handles initialization of AppShell. -class ShellBrowserMainParts : public content::BrowserMainParts { +class ShellBrowserMainParts : public content::BrowserMainParts, + public aura::RootWindowObserver { public: explicit ShellBrowserMainParts( const content::MainFunctionParams& parameters); @@ -44,12 +46,6 @@ class ShellBrowserMainParts : public content::BrowserMainParts { return browser_context_.get(); } - // Creates the window that hosts the apps. - void CreateRootWindow(); - - // Launches an application from a directory. - void LoadAndLaunchApp(const base::FilePath& app_dir); - // BrowserMainParts overrides. virtual void PreEarlyInitialization() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE; @@ -59,7 +55,24 @@ class ShellBrowserMainParts : public content::BrowserMainParts { virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; + // aura::RootWindowObserver overrides: + virtual void OnRootWindowHostCloseRequested(const aura::RootWindow* root) + OVERRIDE; + private: + // Creates the window that hosts the apps. + void CreateRootWindow(); + + // Closes and destroys the root window hosting the app. + void DestroyRootWindow(); + + // Creates and initializes the ExtensionSystem. + void CreateExtensionSystem(); + + // Loads an unpacked application from a directory and attempts to launch it. + // Returns true on success. + bool LoadAndLaunchApp(const base::FilePath& app_dir); + scoped_ptr<ShellBrowserContext> browser_context_; scoped_ptr<ShellExtensionsClient> extensions_client_; scoped_ptr<ShellExtensionsBrowserClient> extensions_browser_client_; @@ -67,6 +80,9 @@ class ShellBrowserMainParts : public content::BrowserMainParts { // Enable a minimal set of views::corewm to be initialized. scoped_ptr<wm::WMTestHelper> wm_test_helper_; + // Owned by the BrowserContextKeyedService system. + extensions::ShellExtensionSystem* extension_system_; + DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts); }; diff --git a/apps/shell/shell_content_client.cc b/apps/shell/shell_content_client.cc index 9c45cc0..7ec4b0e 100644 --- a/apps/shell/shell_content_client.cc +++ b/apps/shell/shell_content_client.cc @@ -6,6 +6,7 @@ #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversions.h" +#include "extensions/common/constants.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/common/user_agent/user_agent_util.h" @@ -16,6 +17,15 @@ ShellContentClient::ShellContentClient() {} ShellContentClient::~ShellContentClient() {} +void ShellContentClient::AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) { + standard_schemes->push_back(extensions::kExtensionScheme); + savable_schemes->push_back(extensions::kExtensionScheme); + standard_schemes->push_back(extensions::kExtensionResourceScheme); + savable_schemes->push_back(extensions::kExtensionResourceScheme); +} + std::string ShellContentClient::GetUserAgent() const { // TODO(derat): Figure out what this should be for app_shell and determine // whether we need to include a version number to placate browser sniffing. diff --git a/apps/shell/shell_content_client.h b/apps/shell/shell_content_client.h index a2068e0..6010e78 100644 --- a/apps/shell/shell_content_client.h +++ b/apps/shell/shell_content_client.h @@ -15,6 +15,9 @@ class ShellContentClient : public content::ContentClient { ShellContentClient(); virtual ~ShellContentClient(); + virtual void AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* saveable_shemes) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; virtual base::string16 GetLocalizedString(int message_id) const OVERRIDE; virtual base::StringPiece GetDataResource( diff --git a/apps/shell/shell_extension_system.cc b/apps/shell/shell_extension_system.cc new file mode 100644 index 0000000..5d94ef0 --- /dev/null +++ b/apps/shell/shell_extension_system.cc @@ -0,0 +1,102 @@ +// 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_extension_system.h" + +#include "base/command_line.h" +#include "chrome/browser/extensions/extension_prefs.h" +#include "content/public/browser/browser_context.h" +#include "extensions/browser/event_router.h" +#include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" + +using content::BrowserContext; + +namespace extensions { + +ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) + : browser_context_(browser_context) { +} + +ShellExtensionSystem::~ShellExtensionSystem() { +} + +void ShellExtensionSystem::Shutdown() { +} + +void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { + lazy_background_task_queue_.reset( + new LazyBackgroundTaskQueue(browser_context_)); + event_router_.reset( + new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_))); + process_manager_.reset(ProcessManager::Create(browser_context_)); +} + +ExtensionService* ShellExtensionSystem::extension_service() { + // This class only has an ExtensionServiceInterface. + return NULL; +} + +ManagementPolicy* ShellExtensionSystem::management_policy() { + return NULL; +} + +UserScriptMaster* ShellExtensionSystem::user_script_master() { + return NULL; +} + +ProcessManager* ShellExtensionSystem::process_manager() { + return process_manager_.get(); +} + +StateStore* ShellExtensionSystem::state_store() { + return NULL; +} + +StateStore* ShellExtensionSystem::rules_store() { + return NULL; +} + +InfoMap* ShellExtensionSystem::info_map() { + return NULL; +} + +LazyBackgroundTaskQueue* ShellExtensionSystem::lazy_background_task_queue() { + return lazy_background_task_queue_.get(); +} + +EventRouter* ShellExtensionSystem::event_router() { + return event_router_.get(); +} + +ExtensionWarningService* ShellExtensionSystem::warning_service() { + return NULL; +} + +Blacklist* ShellExtensionSystem::blacklist() { + return NULL; +} + +ErrorConsole* ShellExtensionSystem::error_console() { + return NULL; +} + +InstallVerifier* ShellExtensionSystem::install_verifier() { + return NULL; +} + +void ShellExtensionSystem::RegisterExtensionWithRequestContexts( + const Extension* extension) { +} + +void ShellExtensionSystem::UnregisterExtensionWithRequestContexts( + const std::string& extension_id, + const UnloadedExtensionInfo::Reason reason) { +} + +const OneShotEvent& ShellExtensionSystem::ready() const { + return ready_; +} + +} // namespace extensions diff --git a/apps/shell/shell_extension_system.h b/apps/shell/shell_extension_system.h new file mode 100644 index 0000000..ce74d21 --- /dev/null +++ b/apps/shell/shell_extension_system.h @@ -0,0 +1,70 @@ +// 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_EXTENSION_SYSTEM_H_ +#define APPS_SHELL_SHELL_EXTENSION_SYSTEM_H_ + +#include "base/compiler_specific.h" +#include "chrome/browser/extensions/extension_system.h" +#include "extensions/common/one_shot_event.h" + +namespace content { +class BrowserContext; +} + +namespace extensions { + +class EventRouter; +class LazyBackgroundTaskQueue; +class ProcessManager; + +// A simplified version of ExtensionSystem for app_shell. Allows +// app_shell to skip initialization of services it doesn't need. +class ShellExtensionSystem : public ExtensionSystem { + public: + explicit ShellExtensionSystem(content::BrowserContext* browser_context); + virtual ~ShellExtensionSystem(); + + // BrowserContextKeyedService implementation: + virtual void Shutdown() OVERRIDE; + + // ExtensionSystem implementation: + virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE; + virtual ExtensionService* extension_service() OVERRIDE; + virtual ManagementPolicy* management_policy() OVERRIDE; + virtual UserScriptMaster* user_script_master() OVERRIDE; + virtual ProcessManager* process_manager() OVERRIDE; + virtual StateStore* state_store() OVERRIDE; + virtual StateStore* rules_store() OVERRIDE; + virtual InfoMap* info_map() OVERRIDE; + virtual LazyBackgroundTaskQueue* lazy_background_task_queue() + OVERRIDE; + virtual EventRouter* event_router() OVERRIDE; + virtual ExtensionWarningService* warning_service() OVERRIDE; + virtual Blacklist* blacklist() OVERRIDE; + virtual ErrorConsole* error_console() OVERRIDE; + virtual InstallVerifier* install_verifier() OVERRIDE; + virtual void RegisterExtensionWithRequestContexts( + const Extension* extension) OVERRIDE; + virtual void UnregisterExtensionWithRequestContexts( + const std::string& extension_id, + const UnloadedExtensionInfo::Reason reason) OVERRIDE; + virtual const OneShotEvent& ready() const OVERRIDE; + + private: + content::BrowserContext* browser_context_; // Not owned. + + scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; + scoped_ptr<EventRouter> event_router_; + scoped_ptr<ProcessManager> process_manager_; + + // Signaled when the extension system has completed its startup tasks. + OneShotEvent ready_; + + DISALLOW_COPY_AND_ASSIGN(ShellExtensionSystem); +}; + +} // namespace extensions + +#endif // APPS_SHELL_SHELL_EXTENSION_SYSTEM_H_ diff --git a/apps/shell/shell_extensions_client.cc b/apps/shell/shell_extensions_client.cc index a8fa82d..83bd7f6 100644 --- a/apps/shell/shell_extensions_client.cc +++ b/apps/shell/shell_extensions_client.cc @@ -5,6 +5,7 @@ #include "apps/shell/shell_extensions_client.h" #include "base/logging.h" +#include "chrome/common/extensions/features/base_feature_provider.h" #include "extensions/common/permissions/permission_message_provider.h" #include "extensions/common/permissions/permissions_provider.h" #include "extensions/common/url_pattern_set.h" @@ -109,8 +110,8 @@ ShellExtensionsClient::GetPermissionMessageProvider() const { extensions::FeatureProvider* ShellExtensionsClient::GetFeatureProviderByName( const std::string& name) const { - NOTIMPLEMENTED(); - return NULL; + // TODO(jamescook): Factor out an extensions module feature provider. + return extensions::BaseFeatureProvider::GetByName(name); } void ShellExtensionsClient::FilterHostPermissions( diff --git a/chrome/browser/extensions/extension_system_factory.cc b/chrome/browser/extensions/extension_system_factory.cc index 8bb0e0d..228d196 100644 --- a/chrome/browser/extensions/extension_system_factory.cc +++ b/chrome/browser/extensions/extension_system_factory.cc @@ -69,15 +69,23 @@ ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() { ExtensionSystemFactory::ExtensionSystemFactory() : BrowserContextKeyedServiceFactory( "ExtensionSystem", - BrowserContextDependencyManager::GetInstance()) { + BrowserContextDependencyManager::GetInstance()), + custom_instance_(NULL) { DependsOn(ExtensionSystemSharedFactory::GetInstance()); } ExtensionSystemFactory::~ExtensionSystemFactory() { } +void ExtensionSystemFactory::SetCustomInstance( + ExtensionSystem* extension_system) { + custom_instance_ = extension_system; +} + BrowserContextKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor( content::BrowserContext* profile) const { + if (custom_instance_) + return custom_instance_; return new ExtensionSystemImpl(static_cast<Profile*>(profile)); } diff --git a/chrome/browser/extensions/extension_system_factory.h b/chrome/browser/extensions/extension_system_factory.h index 280db7a..1f8a653 100644 --- a/chrome/browser/extensions/extension_system_factory.h +++ b/chrome/browser/extensions/extension_system_factory.h @@ -44,6 +44,10 @@ class ExtensionSystemFactory : public BrowserContextKeyedServiceFactory { static ExtensionSystemFactory* GetInstance(); + // Provides a custom ExtensionSystem to use instead of building a new + // ExtensionSystemImpl. The BrowserContextKeyedService system takes ownership. + void SetCustomInstance(ExtensionSystem* extension_system); + private: friend struct DefaultSingletonTraits<ExtensionSystemFactory>; @@ -55,6 +59,8 @@ class ExtensionSystemFactory : public BrowserContextKeyedServiceFactory { virtual content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* context) const OVERRIDE; virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; + + ExtensionSystem* custom_instance_; // Not owned. }; } // namespace extensions diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc index 9562815..f73f0a3 100644 --- a/chrome/browser/extensions/unpacked_installer.cc +++ b/chrome/browser/extensions/unpacked_installer.cc @@ -88,6 +88,7 @@ namespace extensions { // static scoped_refptr<UnpackedInstaller> UnpackedInstaller::Create( ExtensionService* extension_service) { + DCHECK(extension_service); return scoped_refptr<UnpackedInstaller>( new UnpackedInstaller(extension_service)); } diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc index 5326f43..dc097dc 100644 --- a/extensions/common/url_pattern.cc +++ b/extensions/common/url_pattern.cc @@ -128,8 +128,9 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) match_all_urls_(false), match_subdomains_(false), port_("*") { - if (PARSE_SUCCESS != Parse(pattern)) - NOTREACHED() << "URLPattern is invalid: " << pattern; + ParseResult result = Parse(pattern); + if (PARSE_SUCCESS != result) + NOTREACHED() << "URLPattern invalid: " << pattern << " result " << result; } URLPattern::~URLPattern() { |