Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / browser / mock_extension_system.h
blob05ca13f41043aa0e94e7a0da806234a7672f5849
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_EXTENSION_SYSTEM_H_
6 #define EXTENSIONS_BROWSER_MOCK_EXTENSION_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 ~MockExtensionSystem() override;
26 content::BrowserContext* browser_context() { return browser_context_; }
28 // ExtensionSystem overrides:
29 void InitForRegularProfile(bool extensions_enabled) override;
30 ExtensionService* extension_service() override;
31 RuntimeData* runtime_data() override;
32 ManagementPolicy* management_policy() override;
33 SharedUserScriptMaster* shared_user_script_master() override;
34 StateStore* state_store() override;
35 StateStore* rules_store() override;
36 InfoMap* info_map() override;
37 QuotaService* quota_service() override;
38 const OneShotEvent& ready() const override;
39 ContentVerifier* content_verifier() override;
40 scoped_ptr<ExtensionSet> GetDependentExtensions(
41 const Extension* extension) override;
43 private:
44 content::BrowserContext* browser_context_;
45 OneShotEvent ready_;
47 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem);
50 // A factory to create a MockExtensionSystem. Sample use:
52 // MockExtensionSystemFactory<MockExtensionSystemSubclass> factory;
53 // TestExtensionsBrowserClient::set_extension_system_factory(factory);
54 template <typename T>
55 class MockExtensionSystemFactory : public ExtensionSystemProvider {
56 public:
57 MockExtensionSystemFactory()
58 : ExtensionSystemProvider(
59 "MockExtensionSystem",
60 BrowserContextDependencyManager::GetInstance()) {
61 DependsOn(ExtensionRegistryFactory::GetInstance());
64 ~MockExtensionSystemFactory() override {}
66 // BrowserContextKeyedServiceFactory overrides:
67 KeyedService* BuildServiceInstanceFor(
68 content::BrowserContext* context) const override {
69 return new T(context);
72 // ExtensionSystemProvider overrides:
73 ExtensionSystem* GetForBrowserContext(
74 content::BrowserContext* context) override {
75 return static_cast<ExtensionSystem*>(
76 GetServiceForBrowserContext(context, true));
79 private:
80 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystemFactory);
83 } // namespace extensions
85 #endif // EXTENSIONS_BROWSER_MOCK_EXTENSION_SYSTEM_H_