1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
8 #include "chrome/browser/extensions/extension_system.h"
11 class TestingValueStore
;
22 namespace extensions
{
25 // Test ExtensionSystem, for use with TestingProfile.
26 class TestExtensionSystem
: public ExtensionSystem
{
28 explicit TestExtensionSystem(Profile
* profile
);
29 virtual ~TestExtensionSystem();
31 // BrowserContextKeyedService implementation.
32 virtual void Shutdown() OVERRIDE
;
34 // Creates an ExtensionPrefs with the testing profile and returns it.
35 // Useful for tests that need to modify prefs before creating the
37 ExtensionPrefs
* CreateExtensionPrefs(const CommandLine
* command_line
,
38 const base::FilePath
& install_directory
);
40 // Creates an ExtensionService initialized with the testing profile and
41 // returns it, and creates ExtensionPrefs if it hasn't been created yet.
42 ExtensionService
* CreateExtensionService(
43 const CommandLine
* command_line
,
44 const base::FilePath
& install_directory
,
45 bool autoupdate_enabled
);
47 // Creates a ProcessManager. If not invoked, the ProcessManager is NULL.
48 void CreateProcessManager();
50 // Allows the ProcessManager to be overriden, for example by a stub
51 // implementation. Takes ownership of |manager|.
52 void SetProcessManager(ProcessManager
* manager
);
54 void CreateSocketManager();
56 virtual void InitForRegularProfile(bool extensions_enabled
) OVERRIDE
{}
57 void SetExtensionService(ExtensionService
* service
);
58 virtual ExtensionService
* extension_service() OVERRIDE
;
59 virtual ManagementPolicy
* management_policy() OVERRIDE
;
60 virtual UserScriptMaster
* user_script_master() OVERRIDE
;
61 virtual ProcessManager
* process_manager() OVERRIDE
;
62 virtual StateStore
* state_store() OVERRIDE
;
63 virtual StateStore
* rules_store() OVERRIDE
;
64 TestingValueStore
* value_store() { return value_store_
; }
65 virtual InfoMap
* info_map() OVERRIDE
;
66 virtual LazyBackgroundTaskQueue
* lazy_background_task_queue() OVERRIDE
;
67 virtual EventRouter
* event_router() OVERRIDE
;
68 virtual ExtensionWarningService
* warning_service() OVERRIDE
;
69 virtual Blacklist
* blacklist() OVERRIDE
;
70 virtual const OneShotEvent
& ready() const OVERRIDE
;
71 virtual ErrorConsole
* error_console() OVERRIDE
;
72 virtual InstallVerifier
* install_verifier() OVERRIDE
;
75 LOG(INFO
) << "SetReady()";
79 // Factory method for tests to use with SetTestingProfile.
80 static BrowserContextKeyedService
* Build(content::BrowserContext
* profile
);
86 scoped_ptr
<StateStore
> state_store_
;
87 // A pointer to the TestingValueStore owned by |state_store_|.
88 TestingValueStore
* value_store_
;
89 scoped_ptr
<Blacklist
> blacklist_
;
90 scoped_ptr
<StandardManagementPolicyProvider
>
91 standard_management_policy_provider_
;
92 scoped_ptr
<ManagementPolicy
> management_policy_
;
93 scoped_ptr
<ExtensionService
> extension_service_
;
94 scoped_ptr
<ProcessManager
> process_manager_
;
95 scoped_refptr
<InfoMap
> info_map_
;
96 scoped_ptr
<ErrorConsole
> error_console_
;
97 scoped_ptr
<InstallVerifier
> install_verifier_
;
101 } // namespace extensions
103 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_