Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / extensions / browser / mock_extension_system.h
blob7a500dc42a11abf5c25c23dbb7c99d3e08d5eebf
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_
6 #define EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_
8 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "extensions/browser/extension_registry_factory.h"
10 #include "extensions/browser/extension_system.h"
11 #include "extensions/browser/extension_system_provider.h"
12 #include "extensions/common/one_shot_event.h"
14 namespace extensions {
16 // An empty ExtensionSystem for testing. Tests that need only specific
17 // parts of ExtensionSystem should derive from this class and override
18 // functions as needed. To use this, use
19 // TestExtensionsBrowserClient::set_extension_system_factory
20 // with the MockExtensionSystemFactory below.
21 class MockExtensionSystem : public ExtensionSystem {
22 public:
23 explicit MockExtensionSystem(content::BrowserContext* context);
24 virtual ~MockExtensionSystem();
26 content::BrowserContext* browser_context() { return browser_context_; }
28 // ExtensionSystem overrides:
29 virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE;
30 virtual ExtensionService* extension_service() OVERRIDE;
31 virtual RuntimeData* runtime_data() OVERRIDE;
32 virtual ManagementPolicy* management_policy() OVERRIDE;
33 virtual SharedUserScriptMaster* shared_user_script_master() OVERRIDE;
34 virtual ProcessManager* process_manager() OVERRIDE;
35 virtual StateStore* state_store() OVERRIDE;
36 virtual StateStore* rules_store() OVERRIDE;
37 virtual InfoMap* info_map() OVERRIDE;
38 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() OVERRIDE;
39 virtual EventRouter* event_router() OVERRIDE;
40 virtual WarningService* warning_service() OVERRIDE;
41 virtual Blacklist* blacklist() OVERRIDE;
42 virtual ErrorConsole* error_console() OVERRIDE;
43 virtual InstallVerifier* install_verifier() OVERRIDE;
44 virtual QuotaService* quota_service() OVERRIDE;
45 virtual const OneShotEvent& ready() const OVERRIDE;
46 virtual ContentVerifier* content_verifier() OVERRIDE;
47 virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
48 const Extension* extension) OVERRIDE;
49 virtual DeclarativeUserScriptMaster*
50 GetDeclarativeUserScriptMasterByExtension(
51 const ExtensionId& extension_id) OVERRIDE;
53 private:
54 content::BrowserContext* browser_context_;
55 OneShotEvent ready_;
57 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem);
60 // A factory to create a MockExtensionSystem. Sample use:
62 // MockExtensionSystemFactory<MockExtensionSystemSubclass> factory;
63 // TestExtensionsBrowserClient::set_extension_system_factory(factory);
64 template <typename T>
65 class MockExtensionSystemFactory : public ExtensionSystemProvider {
66 public:
67 MockExtensionSystemFactory()
68 : ExtensionSystemProvider(
69 "MockExtensionSystem",
70 BrowserContextDependencyManager::GetInstance()) {
71 DependsOn(ExtensionRegistryFactory::GetInstance());
74 virtual ~MockExtensionSystemFactory() {}
76 // BrowserContextKeyedServiceFactory overrides:
77 virtual KeyedService* BuildServiceInstanceFor(
78 content::BrowserContext* context) const OVERRIDE {
79 return new T(context);
82 // ExtensionSystemProvider overrides:
83 virtual ExtensionSystem* GetForBrowserContext(
84 content::BrowserContext* context) OVERRIDE {
85 return static_cast<ExtensionSystem*>(
86 GetServiceForBrowserContext(context, true));
89 private:
90 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystemFactory);
93 } // namespace extensions
95 #endif // EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_