Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / test_extension_system.h
blobcbe45de142a969b9d2aecd9c764db2a55733f1bd
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 "base/memory/scoped_vector.h"
10 #include "extensions/browser/extension_system.h"
11 #include "extensions/common/one_shot_event.h"
13 class Profile;
14 class TestingValueStore;
16 namespace base {
17 class CommandLine;
18 class FilePath;
21 namespace content {
22 class BrowserContext;
25 namespace extensions {
27 // Test ExtensionSystem, for use with TestingProfile.
28 class TestExtensionSystem : public ExtensionSystem {
29 public:
30 explicit TestExtensionSystem(Profile* profile);
31 ~TestExtensionSystem() override;
33 // KeyedService implementation.
34 void Shutdown() override;
36 // Creates an ExtensionService initialized with the testing profile and
37 // returns it, and creates ExtensionPrefs if it hasn't been created yet.
38 ExtensionService* CreateExtensionService(
39 const base::CommandLine* command_line,
40 const base::FilePath& install_directory,
41 bool autoupdate_enabled);
43 void CreateSocketManager();
45 void InitForRegularProfile(bool extensions_enabled) override {}
46 void SetExtensionService(ExtensionService* service);
47 ExtensionService* extension_service() override;
48 RuntimeData* runtime_data() override;
49 ManagementPolicy* management_policy() 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_