Added condition that checks if ephemeral user has GAIA account (not a public session...
[chromium-blink-merge.git] / extensions / browser / mock_extension_system.h
blobaf847f5e90041dc7ff4bae9ebd65645a0e0aa86d
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 ServiceWorkerManager* service_worker_manager() override;
34 SharedUserScriptMaster* shared_user_script_master() override;
35 StateStore* state_store() override;
36 StateStore* rules_store() override;
37 InfoMap* info_map() override;
38 QuotaService* quota_service() override;
39 AppSorting* app_sorting() override;
40 const OneShotEvent& ready() const override;
41 ContentVerifier* content_verifier() override;
42 scoped_ptr<ExtensionSet> GetDependentExtensions(
43 const Extension* extension) override;
45 private:
46 content::BrowserContext* browser_context_;
47 OneShotEvent ready_;
49 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem);
52 // A factory to create a MockExtensionSystem. Sample use:
54 // MockExtensionSystemFactory<MockExtensionSystemSubclass> factory;
55 // TestExtensionsBrowserClient::set_extension_system_factory(factory);
56 template <typename T>
57 class MockExtensionSystemFactory : public ExtensionSystemProvider {
58 public:
59 MockExtensionSystemFactory()
60 : ExtensionSystemProvider(
61 "MockExtensionSystem",
62 BrowserContextDependencyManager::GetInstance()) {
63 DependsOn(ExtensionRegistryFactory::GetInstance());
66 ~MockExtensionSystemFactory() override {}
68 // BrowserContextKeyedServiceFactory overrides:
69 KeyedService* BuildServiceInstanceFor(
70 content::BrowserContext* context) const override {
71 return new T(context);
74 // ExtensionSystemProvider overrides:
75 ExtensionSystem* GetForBrowserContext(
76 content::BrowserContext* context) override {
77 return static_cast<ExtensionSystem*>(
78 GetServiceForBrowserContext(context, true));
81 private:
82 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystemFactory);
85 } // namespace extensions
87 #endif // EXTENSIONS_BROWSER_MOCK_EXTENSION_SYSTEM_H_