Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / test_extension_system.h
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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
7
8 #include "chrome/browser/extensions/extension_system.h"
9
10 class CommandLine;
11 class TestingValueStore;
12
13 namespace base {
14 class FilePath;
15 class Time;
16 }
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 namespace extensions {
23 class ExtensionPrefs;
24 class RuntimeData;
25
26 // Test ExtensionSystem, for use with TestingProfile.
27 class TestExtensionSystem : public ExtensionSystem {
28  public:
29   explicit TestExtensionSystem(Profile* profile);
30   virtual ~TestExtensionSystem();
31
32   // BrowserContextKeyedService implementation.
33   virtual void Shutdown() OVERRIDE;
34
35   // Creates an ExtensionPrefs with the testing profile and returns it.
36   // Useful for tests that need to modify prefs before creating the
37   // ExtensionService.
38   ExtensionPrefs* CreateExtensionPrefs(const CommandLine* command_line,
39                                        const base::FilePath& install_directory);
40
41   // Creates an ExtensionService initialized with the testing profile and
42   // returns it, and creates ExtensionPrefs if it hasn't been created yet.
43   ExtensionService* CreateExtensionService(
44       const CommandLine* command_line,
45       const base::FilePath& install_directory,
46       bool autoupdate_enabled);
47
48   // Creates a ProcessManager. If not invoked, the ProcessManager is NULL.
49   void CreateProcessManager();
50
51   // Allows the ProcessManager to be overriden, for example by a stub
52   // implementation. Takes ownership of |manager|.
53   void SetProcessManager(ProcessManager* manager);
54
55   void CreateSocketManager();
56
57   virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE {}
58   void SetExtensionService(ExtensionService* service);
59   virtual ExtensionService* extension_service() OVERRIDE;
60   virtual RuntimeData* runtime_data() OVERRIDE;
61   virtual ManagementPolicy* management_policy() OVERRIDE;
62   virtual UserScriptMaster* user_script_master() OVERRIDE;
63   virtual ProcessManager* process_manager() OVERRIDE;
64   virtual StateStore* state_store() OVERRIDE;
65   virtual StateStore* rules_store() OVERRIDE;
66   TestingValueStore* value_store() { return value_store_; }
67   virtual InfoMap* info_map() OVERRIDE;
68   virtual LazyBackgroundTaskQueue* lazy_background_task_queue() OVERRIDE;
69   virtual EventRouter* event_router() OVERRIDE;
70   virtual ExtensionWarningService* warning_service() OVERRIDE;
71   virtual Blacklist* blacklist() OVERRIDE;
72   virtual const OneShotEvent& ready() const OVERRIDE;
73   virtual ErrorConsole* error_console() OVERRIDE;
74   virtual InstallVerifier* install_verifier() OVERRIDE;
75
76   void SetReady() {
77     LOG(INFO) << "SetReady()";
78     ready_.Signal();
79   }
80
81   // Factory method for tests to use with SetTestingProfile.
82   static BrowserContextKeyedService* Build(content::BrowserContext* profile);
83
84  protected:
85   Profile* profile_;
86
87  private:
88   scoped_ptr<StateStore> state_store_;
89   // A pointer to the TestingValueStore owned by |state_store_|.
90   TestingValueStore* value_store_;
91   scoped_ptr<Blacklist> blacklist_;
92   scoped_ptr<StandardManagementPolicyProvider>
93       standard_management_policy_provider_;
94   scoped_ptr<ManagementPolicy> management_policy_;
95   scoped_ptr<RuntimeData> runtime_data_;
96   scoped_ptr<ExtensionService> extension_service_;
97   scoped_ptr<ProcessManager> process_manager_;
98   scoped_refptr<InfoMap> info_map_;
99   scoped_ptr<ErrorConsole> error_console_;
100   scoped_ptr<InstallVerifier> install_verifier_;
101   OneShotEvent ready_;
102 };
103
104 }  // namespace extensions
105
106 #endif  // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_