| 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/extension_system.h" | 5 #include "chrome/browser/extensions/extension_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 autoupdate_enabled = !command_line->HasSwitch(switches::kGuestSession); | 124 autoupdate_enabled = !command_line->HasSwitch(switches::kGuestSession); |
| 125 #endif | 125 #endif |
| 126 extension_service_.reset(new ExtensionService( | 126 extension_service_.reset(new ExtensionService( |
| 127 profile_, | 127 profile_, |
| 128 CommandLine::ForCurrentProcess(), | 128 CommandLine::ForCurrentProcess(), |
| 129 profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 129 profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
| 130 extension_prefs_.get(), | 130 extension_prefs_.get(), |
| 131 autoupdate_enabled, | 131 autoupdate_enabled, |
| 132 extensions_enabled)); | 132 extensions_enabled)); |
| 133 | 133 |
| 134 // The ManagementPolicy providers msut be registered before the | 134 // These services must be registered before the ExtensionService tries to |
| 135 // ExtensionService tries to load any extensions. | 135 // load any extensions. |
| 136 management_policy_.reset(new extensions::ManagementPolicy); | 136 { |
| 137 RegisterManagementPolicyProviders(); | 137 rules_registry_service_.reset( |
| 138 new extensions::RulesRegistryService(profile_)); |
| 139 rules_registry_service_->RegisterDefaultRulesRegistries(); |
| 140 |
| 141 management_policy_.reset(new extensions::ManagementPolicy); |
| 142 RegisterManagementPolicyProviders(); |
| 143 } |
| 138 | 144 |
| 139 extension_service_->component_loader()->AddDefaultComponentExtensions(); | 145 extension_service_->component_loader()->AddDefaultComponentExtensions(); |
| 140 if (command_line->HasSwitch(switches::kLoadComponentExtension)) { | 146 if (command_line->HasSwitch(switches::kLoadComponentExtension)) { |
| 141 CommandLine::StringType path_list = command_line->GetSwitchValueNative( | 147 CommandLine::StringType path_list = command_line->GetSwitchValueNative( |
| 142 switches::kLoadComponentExtension); | 148 switches::kLoadComponentExtension); |
| 143 StringTokenizerT<CommandLine::StringType, | 149 StringTokenizerT<CommandLine::StringType, |
| 144 CommandLine::StringType::const_iterator> t(path_list, | 150 CommandLine::StringType::const_iterator> t(path_list, |
| 145 FILE_PATH_LITERAL(",")); | 151 FILE_PATH_LITERAL(",")); |
| 146 while (t.GetNext()) { | 152 while (t.GetNext()) { |
| 147 // Load the component extension manifest synchronously. | 153 // Load the component extension manifest synchronously. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // process (the profile itself is on the main process), wait for import to | 195 // process (the profile itself is on the main process), wait for import to |
| 190 // finish before initializing the routers. | 196 // finish before initializing the routers. |
| 191 if (!command_line->HasSwitch(switches::kImport) && | 197 if (!command_line->HasSwitch(switches::kImport) && |
| 192 !command_line->HasSwitch(switches::kImportFromFile)) { | 198 !command_line->HasSwitch(switches::kImportFromFile)) { |
| 193 if (g_browser_process->profile_manager()->will_import()) { | 199 if (g_browser_process->profile_manager()->will_import()) { |
| 194 extension_service_->InitEventRoutersAfterImport(); | 200 extension_service_->InitEventRoutersAfterImport(); |
| 195 } else { | 201 } else { |
| 196 extension_service_->InitEventRouters(); | 202 extension_service_->InitEventRouters(); |
| 197 } | 203 } |
| 198 } | 204 } |
| 199 | |
| 200 rules_registry_service_.reset(new extensions::RulesRegistryService(profile_)); | |
| 201 rules_registry_service_->RegisterDefaultRulesRegistries(); | |
| 202 } | 205 } |
| 203 | 206 |
| 204 extensions::StateStore* ExtensionSystemImpl::Shared::state_store() { | 207 extensions::StateStore* ExtensionSystemImpl::Shared::state_store() { |
| 205 return state_store_.get(); | 208 return state_store_.get(); |
| 206 } | 209 } |
| 207 | 210 |
| 208 ExtensionService* ExtensionSystemImpl::Shared::extension_service() { | 211 ExtensionService* ExtensionSystemImpl::Shared::extension_service() { |
| 209 return extension_service_.get(); | 212 return extension_service_.get(); |
| 210 } | 213 } |
| 211 | 214 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 354 } |
| 352 | 355 |
| 353 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 356 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
| 354 const std::string& extension_id, | 357 const std::string& extension_id, |
| 355 const extension_misc::UnloadedExtensionReason reason) { | 358 const extension_misc::UnloadedExtensionReason reason) { |
| 356 BrowserThread::PostTask( | 359 BrowserThread::PostTask( |
| 357 BrowserThread::IO, FROM_HERE, | 360 BrowserThread::IO, FROM_HERE, |
| 358 base::Bind(&ExtensionInfoMap::RemoveExtension, info_map(), | 361 base::Bind(&ExtensionInfoMap::RemoveExtension, info_map(), |
| 359 extension_id, reason)); | 362 extension_id, reason)); |
| 360 } | 363 } |
| OLD | NEW |