| 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/declarative_user_script_master.h" | 10 #include "chrome/browser/extensions/declarative_user_script_manager.h" |
| 11 #include "chrome/browser/extensions/error_console/error_console.h" | 11 #include "chrome/browser/extensions/error_console/error_console.h" |
| 12 #include "chrome/browser/extensions/extension_management.h" | 12 #include "chrome/browser/extensions/extension_management.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/install_verifier.h" | 14 #include "chrome/browser/extensions/install_verifier.h" |
| 15 #include "chrome/browser/extensions/shared_module_service.h" | 15 #include "chrome/browser/extensions/shared_module_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_pref_value_map.h" | 20 #include "extensions/browser/extension_pref_value_map.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool autoupdate_enabled) { | 80 bool autoupdate_enabled) { |
| 81 if (!ExtensionPrefs::Get(profile_)) | 81 if (!ExtensionPrefs::Get(profile_)) |
| 82 CreateExtensionPrefs(command_line, install_directory); | 82 CreateExtensionPrefs(command_line, install_directory); |
| 83 install_verifier_.reset( | 83 install_verifier_.reset( |
| 84 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); | 84 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); |
| 85 // The ownership of |value_store_| is immediately transferred to state_store_, | 85 // The ownership of |value_store_| is immediately transferred to state_store_, |
| 86 // but we keep a naked pointer to the TestingValueStore. | 86 // but we keep a naked pointer to the TestingValueStore. |
| 87 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); | 87 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); |
| 88 value_store_ = value_store.get(); | 88 value_store_ = value_store.get(); |
| 89 state_store_.reset(new StateStore(profile_, value_store.Pass())); | 89 state_store_.reset(new StateStore(profile_, value_store.Pass())); |
| 90 declarative_user_script_manager_.reset( |
| 91 new DeclarativeUserScriptManager(profile_)); |
| 90 management_policy_.reset(new ManagementPolicy()); | 92 management_policy_.reset(new ManagementPolicy()); |
| 91 management_policy_->RegisterProviders( | 93 management_policy_->RegisterProviders( |
| 92 ExtensionManagementFactory::GetForBrowserContext(profile_) | 94 ExtensionManagementFactory::GetForBrowserContext(profile_) |
| 93 ->GetProviders()); | 95 ->GetProviders()); |
| 94 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); | 96 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); |
| 95 extension_service_.reset(new ExtensionService(profile_, | 97 extension_service_.reset(new ExtensionService(profile_, |
| 96 command_line, | 98 command_line, |
| 97 install_directory, | 99 install_directory, |
| 98 ExtensionPrefs::Get(profile_), | 100 ExtensionPrefs::Get(profile_), |
| 99 Blacklist::Get(profile_), | 101 Blacklist::Get(profile_), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 } | 119 } |
| 118 | 120 |
| 119 void TestExtensionSystem::SetExtensionService(ExtensionService* service) { | 121 void TestExtensionSystem::SetExtensionService(ExtensionService* service) { |
| 120 extension_service_.reset(service); | 122 extension_service_.reset(service); |
| 121 } | 123 } |
| 122 | 124 |
| 123 SharedUserScriptMaster* TestExtensionSystem::shared_user_script_master() { | 125 SharedUserScriptMaster* TestExtensionSystem::shared_user_script_master() { |
| 124 return NULL; | 126 return NULL; |
| 125 } | 127 } |
| 126 | 128 |
| 129 DeclarativeUserScriptManager* |
| 130 TestExtensionSystem::declarative_user_script_manager() { |
| 131 return declarative_user_script_manager_.get(); |
| 132 } |
| 133 |
| 127 StateStore* TestExtensionSystem::state_store() { | 134 StateStore* TestExtensionSystem::state_store() { |
| 128 return state_store_.get(); | 135 return state_store_.get(); |
| 129 } | 136 } |
| 130 | 137 |
| 131 StateStore* TestExtensionSystem::rules_store() { | 138 StateStore* TestExtensionSystem::rules_store() { |
| 132 return state_store_.get(); | 139 return state_store_.get(); |
| 133 } | 140 } |
| 134 | 141 |
| 135 InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); } | 142 InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); } |
| 136 | 143 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 164 ContentVerifier* TestExtensionSystem::content_verifier() { | 171 ContentVerifier* TestExtensionSystem::content_verifier() { |
| 165 return NULL; | 172 return NULL; |
| 166 } | 173 } |
| 167 | 174 |
| 168 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions( | 175 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions( |
| 169 const Extension* extension) { | 176 const Extension* extension) { |
| 170 return extension_service()->shared_module_service()->GetDependentExtensions( | 177 return extension_service()->shared_module_service()->GetDependentExtensions( |
| 171 extension); | 178 extension); |
| 172 } | 179 } |
| 173 | 180 |
| 174 DeclarativeUserScriptMaster* | |
| 175 TestExtensionSystem::GetDeclarativeUserScriptMasterByExtension( | |
| 176 const ExtensionId& extension_id) { | |
| 177 DCHECK(ready().is_signaled()); | |
| 178 DeclarativeUserScriptMaster* master = NULL; | |
| 179 for (ScopedVector<DeclarativeUserScriptMaster>::iterator it = | |
| 180 declarative_user_script_masters_.begin(); | |
| 181 it != declarative_user_script_masters_.end(); | |
| 182 ++it) { | |
| 183 if ((*it)->extension_id() == extension_id) { | |
| 184 master = *it; | |
| 185 break; | |
| 186 } | |
| 187 } | |
| 188 if (!master) { | |
| 189 master = new DeclarativeUserScriptMaster(profile_, extension_id); | |
| 190 declarative_user_script_masters_.push_back(master); | |
| 191 } | |
| 192 return master; | |
| 193 } | |
| 194 | |
| 195 // static | 181 // static |
| 196 KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) { | 182 KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) { |
| 197 return new TestExtensionSystem(static_cast<Profile*>(profile)); | 183 return new TestExtensionSystem(static_cast<Profile*>(profile)); |
| 198 } | 184 } |
| 199 | 185 |
| 200 } // namespace extensions | 186 } // namespace extensions |
| OLD | NEW |