[sessions]: Componentize TabRestore code
[chromium-blink-merge.git] / chrome / browser / extensions / test_extension_system.h
blobd0c11e4a54676637fa1d8a6556557cc069f15ac5
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 "base/memory/scoped_ptr.h"
9 #include "extensions/browser/extension_system.h"
10 #include "extensions/common/one_shot_event.h"
12 class Profile;
13 class TestingValueStore;
15 namespace base {
16 class CommandLine;
17 class FilePath;
20 namespace content {
21 class BrowserContext;
24 namespace extensions {
26 // Test ExtensionSystem, for use with TestingProfile.
27 class TestExtensionSystem : public ExtensionSystem {
28 public:
29 explicit TestExtensionSystem(Profile* profile);
30 ~TestExtensionSystem() override;
32 // KeyedService implementation.
33 void Shutdown() override;
35 // Creates an ExtensionService initialized with the testing profile and
36 // returns it, and creates ExtensionPrefs if it hasn't been created yet.
37 ExtensionService* CreateExtensionService(
38 const base::CommandLine* command_line,
39 const base::FilePath& install_directory,
40 bool autoupdate_enabled);
42 void CreateSocketManager();
44 void InitForRegularProfile(bool extensions_enabled) override {}
45 void SetExtensionService(ExtensionService* service);
46 ExtensionService* extension_service() override;
47 RuntimeData* runtime_data() override;
48 ManagementPolicy* management_policy() override;
49 ServiceWorkerManager* service_worker_manager() override;
50 SharedUserScriptMaster* shared_user_script_master() override;
51 StateStore* state_store() override;
52 StateStore* rules_store() override;
53 TestingValueStore* value_store() { return value_store_; }
54 InfoMap* info_map() override;
55 QuotaService* quota_service() override;
56 AppSorting* app_sorting() override;
57 const OneShotEvent& ready() const override;
58 ContentVerifier* content_verifier() override;
59 scoped_ptr<ExtensionSet> GetDependentExtensions(
60 const Extension* extension) override;
62 // Note that you probably want to use base::RunLoop().RunUntilIdle() right
63 // after this to run all the accumulated tasks.
64 void SetReady() { ready_.Signal(); }
66 // Factory method for tests to use with SetTestingProfile.
67 static scoped_ptr<KeyedService> Build(content::BrowserContext* profile);
69 // Used by ExtensionPrefsTest to re-create the AppSorting after it has
70 // re-created the ExtensionPrefs instance (this can never happen in non-test
71 // code).
72 void RecreateAppSorting();
74 protected:
75 Profile* profile_;
77 private:
78 scoped_ptr<StateStore> state_store_;
79 // A pointer to the TestingValueStore owned by |state_store_|.
80 TestingValueStore* value_store_;
81 scoped_ptr<ManagementPolicy> management_policy_;
82 scoped_ptr<RuntimeData> runtime_data_;
83 scoped_ptr<ExtensionService> extension_service_;
84 scoped_refptr<InfoMap> info_map_;
85 scoped_ptr<QuotaService> quota_service_;
86 scoped_ptr<AppSorting> app_sorting_;
87 OneShotEvent ready_;
90 } // namespace extensions
92 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_