Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: extensions/browser/mock_extension_system.h

Issue 460203002: Extract a MockExtensionSystem to be used with TestExtensionsBrowserClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: symbol visibility issues Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_
6 #define EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_
7
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"
13
14 namespace extensions {
15
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();
25
26 content::BrowserContext* browser_context() { return browser_context_; }
27
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 UserScriptMaster* 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 ExtensionWarningService* 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
50 private:
51 content::BrowserContext* browser_context_;
52 OneShotEvent ready_;
53
54 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem);
55 };
56
57 // A factory to create a MockExtensionSystem. Sample use:
58 //
59 // MockExtensionSystemFactory<MockExtensionSystemSubclass> factory;
60 // TestExtensionsBrowserClient::set_extension_system_factory(factory);
61 template <typename T>
62 class MockExtensionSystemFactory : public ExtensionSystemProvider {
63 public:
64 MockExtensionSystemFactory()
65 : ExtensionSystemProvider(
66 "MockExtensionSystem",
67 BrowserContextDependencyManager::GetInstance()) {
68 DependsOn(ExtensionRegistryFactory::GetInstance());
69 }
70
71 virtual ~MockExtensionSystemFactory() {}
72
73 // BrowserContextKeyedServiceFactory overrides:
74 virtual KeyedService* BuildServiceInstanceFor(
75 content::BrowserContext* context) const OVERRIDE {
76 return new T(context);
77 }
78
79 // ExtensionSystemProvider overrides:
80 virtual ExtensionSystem* GetForBrowserContext(
81 content::BrowserContext* context) OVERRIDE {
82 return static_cast<ExtensionSystem*>(
83 GetServiceForBrowserContext(context, true));
84 }
85
86 private:
87 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystemFactory);
88 };
89
90 } // namespace extensions
91
92 #endif // EXTENSIONS_BROWSER_MOCK_EXTENSIONS_SYSTEM_H_
OLDNEW
« no previous file with comments | « extensions/browser/lazy_background_task_queue_unittest.cc ('k') | extensions/browser/mock_extension_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698