Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / extensions / browser / mock_extension_system.h
blobc06b7bc204b69505ba92c98d94cea0902ff782f8
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 void set_event_router(EventRouter* router) { event_router_ = router; }
30 // ExtensionSystem overrides:
31 void InitForRegularProfile(bool extensions_enabled) override;
32 ExtensionService* extension_service() override;
33 RuntimeData* runtime_data() override;
34 ManagementPolicy* management_policy() override;
35 SharedUserScriptMaster* shared_user_script_master() override;
36 StateStore* state_store() override;
37 StateStore* rules_store() override;
38 InfoMap* info_map() override;
39 EventRouter* event_router() override;
40 QuotaService* quota_service() override;
41 const OneShotEvent& ready() const override;
42 ContentVerifier* content_verifier() override;
43 scoped_ptr<ExtensionSet> GetDependentExtensions(
44 const Extension* extension) override;
46 private:
47 content::BrowserContext* browser_context_;
48 OneShotEvent ready_;
50 // Not owned, defaults to null.
51 EventRouter* event_router_;
53 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem);
56 // A factory to create a MockExtensionSystem. Sample use:
58 // MockExtensionSystemFactory<MockExtensionSystemSubclass> factory;
59 // TestExtensionsBrowserClient::set_extension_system_factory(factory);
60 template <typename T>
61 class MockExtensionSystemFactory : public ExtensionSystemProvider {
62 public:
63 MockExtensionSystemFactory()
64 : ExtensionSystemProvider(
65 "MockExtensionSystem",
66 BrowserContextDependencyManager::GetInstance()) {
67 DependsOn(ExtensionRegistryFactory::GetInstance());
70 ~MockExtensionSystemFactory() override {}
72 // BrowserContextKeyedServiceFactory overrides:
73 KeyedService* BuildServiceInstanceFor(
74 content::BrowserContext* context) const override {
75 return new T(context);
78 // ExtensionSystemProvider overrides:
79 ExtensionSystem* GetForBrowserContext(
80 content::BrowserContext* context) override {
81 return static_cast<ExtensionSystem*>(
82 GetServiceForBrowserContext(context, true));
85 private:
86 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystemFactory);
89 } // namespace extensions
91 #endif // EXTENSIONS_BROWSER_MOCK_EXTENSION_SYSTEM_H_