OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/test_extension_system.h" | 5 #include "chrome/browser/extensions/test_extension_system.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/extensions/blacklist.h" | 9 #include "chrome/browser/extensions/blacklist.h" |
| 10 #include "chrome/browser/extensions/chrome_app_sorting.h" |
10 #include "chrome/browser/extensions/extension_management.h" | 11 #include "chrome/browser/extensions/extension_management.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/shared_module_service.h" | 13 #include "chrome/browser/extensions/shared_module_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "extensions/browser/extension_pref_value_map.h" | |
17 #include "extensions/browser/extension_pref_value_map_factory.h" | |
18 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
21 #include "extensions/browser/extensions_browser_client.h" | 20 #include "extensions/browser/extensions_browser_client.h" |
22 #include "extensions/browser/info_map.h" | 21 #include "extensions/browser/info_map.h" |
23 #include "extensions/browser/management_policy.h" | 22 #include "extensions/browser/management_policy.h" |
24 #include "extensions/browser/quota_service.h" | 23 #include "extensions/browser/quota_service.h" |
25 #include "extensions/browser/runtime_data.h" | 24 #include "extensions/browser/runtime_data.h" |
26 #include "extensions/browser/state_store.h" | 25 #include "extensions/browser/state_store.h" |
27 #include "extensions/browser/value_store/testing_value_store.h" | 26 #include "extensions/browser/value_store/testing_value_store.h" |
28 | 27 |
29 using content::BrowserThread; | 28 using content::BrowserThread; |
30 | 29 |
31 namespace extensions { | 30 namespace extensions { |
32 | 31 |
33 TestExtensionSystem::TestExtensionSystem(Profile* profile) | 32 TestExtensionSystem::TestExtensionSystem(Profile* profile) |
34 : profile_(profile), | 33 : profile_(profile), |
35 value_store_(NULL), | 34 value_store_(NULL), |
36 info_map_(new InfoMap()), | 35 info_map_(new InfoMap()), |
37 quota_service_(new QuotaService()) {} | 36 quota_service_(new QuotaService()), |
| 37 app_sorting_(new ChromeAppSorting(profile_)) { |
| 38 } |
38 | 39 |
39 TestExtensionSystem::~TestExtensionSystem() { | 40 TestExtensionSystem::~TestExtensionSystem() { |
40 } | 41 } |
41 | 42 |
42 void TestExtensionSystem::Shutdown() { | 43 void TestExtensionSystem::Shutdown() { |
43 if (extension_service_) | 44 if (extension_service_) |
44 extension_service_->Shutdown(); | 45 extension_service_->Shutdown(); |
45 } | 46 } |
46 | 47 |
47 scoped_ptr<ExtensionPrefs> TestExtensionSystem::CreateExtensionPrefs( | |
48 const base::CommandLine* command_line, | |
49 const base::FilePath& install_directory) { | |
50 bool extensions_disabled = | |
51 command_line && command_line->HasSwitch(switches::kDisableExtensions); | |
52 | |
53 // Note that the GetPrefs() creates a TestingPrefService, therefore | |
54 // the extension controlled pref values set in ExtensionPrefs | |
55 // are not reflected in the pref service. One would need to | |
56 // inject a new ExtensionPrefStore(extension_pref_value_map, false). | |
57 | |
58 return make_scoped_ptr(ExtensionPrefs::Create( | |
59 profile_->GetPrefs(), install_directory, | |
60 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_), | |
61 ExtensionsBrowserClient::Get()->CreateAppSorting(profile_).Pass(), | |
62 extensions_disabled, std::vector<ExtensionPrefsObserver*>())); | |
63 } | |
64 | |
65 ExtensionService* TestExtensionSystem::CreateExtensionService( | 48 ExtensionService* TestExtensionSystem::CreateExtensionService( |
66 const base::CommandLine* command_line, | 49 const base::CommandLine* command_line, |
67 const base::FilePath& install_directory, | 50 const base::FilePath& install_directory, |
68 bool autoupdate_enabled) { | 51 bool autoupdate_enabled) { |
69 // The ownership of |value_store_| is immediately transferred to state_store_, | 52 // The ownership of |value_store_| is immediately transferred to state_store_, |
70 // but we keep a naked pointer to the TestingValueStore. | 53 // but we keep a naked pointer to the TestingValueStore. |
71 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); | 54 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); |
72 value_store_ = value_store.get(); | 55 value_store_ = value_store.get(); |
73 state_store_.reset(new StateStore(profile_, value_store.Pass())); | 56 state_store_.reset(new StateStore(profile_, value_store.Pass())); |
74 management_policy_.reset(new ManagementPolicy()); | 57 management_policy_.reset(new ManagementPolicy()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 StateStore* TestExtensionSystem::rules_store() { | 98 StateStore* TestExtensionSystem::rules_store() { |
116 return state_store_.get(); | 99 return state_store_.get(); |
117 } | 100 } |
118 | 101 |
119 InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); } | 102 InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); } |
120 | 103 |
121 QuotaService* TestExtensionSystem::quota_service() { | 104 QuotaService* TestExtensionSystem::quota_service() { |
122 return quota_service_.get(); | 105 return quota_service_.get(); |
123 } | 106 } |
124 | 107 |
| 108 AppSorting* TestExtensionSystem::app_sorting() { |
| 109 return app_sorting_.get(); |
| 110 } |
| 111 |
125 const OneShotEvent& TestExtensionSystem::ready() const { | 112 const OneShotEvent& TestExtensionSystem::ready() const { |
126 return ready_; | 113 return ready_; |
127 } | 114 } |
128 | 115 |
129 ContentVerifier* TestExtensionSystem::content_verifier() { | 116 ContentVerifier* TestExtensionSystem::content_verifier() { |
130 return NULL; | 117 return NULL; |
131 } | 118 } |
132 | 119 |
133 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions( | 120 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions( |
134 const Extension* extension) { | 121 const Extension* extension) { |
135 return extension_service()->shared_module_service()->GetDependentExtensions( | 122 return extension_service()->shared_module_service()->GetDependentExtensions( |
136 extension); | 123 extension); |
137 } | 124 } |
138 | 125 |
139 // static | 126 // static |
140 scoped_ptr<KeyedService> TestExtensionSystem::Build( | 127 scoped_ptr<KeyedService> TestExtensionSystem::Build( |
141 content::BrowserContext* profile) { | 128 content::BrowserContext* profile) { |
142 return make_scoped_ptr( | 129 return make_scoped_ptr( |
143 new TestExtensionSystem(static_cast<Profile*>(profile))); | 130 new TestExtensionSystem(static_cast<Profile*>(profile))); |
144 } | 131 } |
145 | 132 |
| 133 void TestExtensionSystem::RecreateAppSorting() { |
| 134 app_sorting_.reset(new ChromeAppSorting(profile_)); |
| 135 } |
| 136 |
146 } // namespace extensions | 137 } // namespace extensions |
OLD | NEW |