| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/crypto/signature_verifier.h" | 9 #include "base/crypto/signature_verifier.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // The ID we expect this extension to have, if any. | 205 // The ID we expect this extension to have, if any. |
| 206 std::string expected_id_; | 206 std::string expected_id_; |
| 207 | 207 |
| 208 // True if we got a response from the utility process and have cleaned up | 208 // True if we got a response from the utility process and have cleaned up |
| 209 // already. | 209 // already. |
| 210 bool got_response_; | 210 bool got_response_; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 ExtensionsService::ExtensionsService(Profile* profile, | 213 ExtensionsService::ExtensionsService(Profile* profile, |
| 214 const CommandLine* command_line, |
| 214 MessageLoop* frontend_loop, | 215 MessageLoop* frontend_loop, |
| 215 MessageLoop* backend_loop) | 216 MessageLoop* backend_loop) |
| 216 : extension_prefs_(new ExtensionPrefs(profile->GetPrefs())), | 217 : extension_prefs_(new ExtensionPrefs(profile->GetPrefs())), |
| 217 backend_loop_(backend_loop), | 218 backend_loop_(backend_loop), |
| 218 install_directory_(profile->GetPath().AppendASCII(kInstallDirectoryName)), | 219 install_directory_(profile->GetPath().AppendASCII(kInstallDirectoryName)), |
| 219 extensions_enabled_(false), | 220 extensions_enabled_(false), |
| 220 show_extensions_prompts_(true), | 221 show_extensions_prompts_(true), |
| 221 ready_(false) { | 222 ready_(false) { |
| 223 // Figure out if extension installation should be enabled. |
| 224 if (command_line->HasSwitch(switches::kEnableExtensions)) |
| 225 extensions_enabled_ = true; |
| 226 else if (profile->GetPrefs()->GetBoolean(prefs::kEnableExtensions)) |
| 227 extensions_enabled_ = true; |
| 228 |
| 222 // We pass ownership of this object to the Backend. | 229 // We pass ownership of this object to the Backend. |
| 223 DictionaryValue* extensions = extension_prefs_->CopyCurrentExtensions(); | 230 DictionaryValue* extensions = extension_prefs_->CopyCurrentExtensions(); |
| 224 backend_ = new ExtensionsServiceBackend( | 231 backend_ = new ExtensionsServiceBackend( |
| 225 install_directory_, g_browser_process->resource_dispatcher_host(), | 232 install_directory_, g_browser_process->resource_dispatcher_host(), |
| 226 frontend_loop, extensions, extensions_enabled()); | 233 frontend_loop, extensions, extensions_enabled()); |
| 227 } | 234 } |
| 228 | 235 |
| 229 ExtensionsService::~ExtensionsService() { | 236 ExtensionsService::~ExtensionsService() { |
| 230 UnloadAllExtensions(); | 237 UnloadAllExtensions(); |
| 231 } | 238 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 463 |
| 457 ExtensionsServiceBackend::ExtensionsServiceBackend( | 464 ExtensionsServiceBackend::ExtensionsServiceBackend( |
| 458 const FilePath& install_directory, ResourceDispatcherHost* rdh, | 465 const FilePath& install_directory, ResourceDispatcherHost* rdh, |
| 459 MessageLoop* frontend_loop, DictionaryValue* extension_prefs, | 466 MessageLoop* frontend_loop, DictionaryValue* extension_prefs, |
| 460 bool extensions_enabled) | 467 bool extensions_enabled) |
| 461 : frontend_(NULL), | 468 : frontend_(NULL), |
| 462 install_directory_(install_directory), | 469 install_directory_(install_directory), |
| 463 resource_dispatcher_host_(rdh), | 470 resource_dispatcher_host_(rdh), |
| 464 alert_on_error_(false), | 471 alert_on_error_(false), |
| 465 frontend_loop_(frontend_loop), | 472 frontend_loop_(frontend_loop), |
| 466 extensions_enabled_(false) { | 473 extensions_enabled_(extensions_enabled) { |
| 467 external_extension_providers_[Extension::EXTERNAL_PREF] = | 474 external_extension_providers_[Extension::EXTERNAL_PREF] = |
| 468 linked_ptr<ExternalExtensionProvider>( | 475 linked_ptr<ExternalExtensionProvider>( |
| 469 new ExternalPrefExtensionProvider(extension_prefs)); | 476 new ExternalPrefExtensionProvider(extension_prefs)); |
| 470 #if defined(OS_WIN) | 477 #if defined(OS_WIN) |
| 471 external_extension_providers_[Extension::EXTERNAL_REGISTRY] = | 478 external_extension_providers_[Extension::EXTERNAL_REGISTRY] = |
| 472 linked_ptr<ExternalExtensionProvider>( | 479 linked_ptr<ExternalExtensionProvider>( |
| 473 new ExternalRegistryExtensionProvider()); | 480 new ExternalRegistryExtensionProvider()); |
| 474 #endif | 481 #endif |
| 475 } | 482 } |
| 476 | 483 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 972 |
| 966 Extension::Location location = Extension::INTERNAL; | 973 Extension::Location location = Extension::INTERNAL; |
| 967 LookupExternalExtension(extension.id(), NULL, &location); | 974 LookupExternalExtension(extension.id(), NULL, &location); |
| 968 | 975 |
| 969 // We currently only allow themes and registry-installed extensions to be | 976 // We currently only allow themes and registry-installed extensions to be |
| 970 // installed. | 977 // installed. |
| 971 if (!extensions_enabled_ && | 978 if (!extensions_enabled_ && |
| 972 !extension.IsTheme() && | 979 !extension.IsTheme() && |
| 973 location != Extension::EXTERNAL_REGISTRY) { | 980 location != Extension::EXTERNAL_REGISTRY) { |
| 974 ReportExtensionInstallError(extension_path, | 981 ReportExtensionInstallError(extension_path, |
| 975 "Extensions are not enabled (yet!)"); | 982 "Extensions are not enabled. Add --enable-extensions to the " |
| 983 "command-line to enable extensions.\n\n" |
| 984 "This is a temporary message and it will be removed when extensions " |
| 985 "UI is finalized."); |
| 976 return; | 986 return; |
| 977 } | 987 } |
| 978 | 988 |
| 979 #if defined(OS_WIN) | 989 #if defined(OS_WIN) |
| 990 // We don't show the install dialog for themes or external extensions. |
| 980 if (!extension.IsTheme() && | 991 if (!extension.IsTheme() && |
| 981 !Extension::IsExternalLocation(location) && | 992 !Extension::IsExternalLocation(location) && |
| 982 frontend_->show_extensions_prompts() && | 993 frontend_->show_extensions_prompts() && |
| 983 win_util::MessageBox(GetForegroundWindow(), | 994 win_util::MessageBox(GetForegroundWindow(), |
| 984 L"Are you sure you want to install this extension?\n\n" | 995 L"Are you sure you want to install this extension?\n\n" |
| 985 L"This is a temporary message and it will be removed when extensions " | 996 L"This is a temporary message and it will be removed when extensions " |
| 986 L"UI is finalized.", | 997 L"UI is finalized.", |
| 987 l10n_util::GetString(IDS_PRODUCT_NAME).c_str(), | 998 l10n_util::GetString(IDS_PRODUCT_NAME).c_str(), |
| 988 MB_OKCANCEL) != IDOK) { | 999 MB_OKCANCEL) != IDOK) { |
| 989 ReportExtensionInstallError(extension_path, | 1000 ReportExtensionInstallError(extension_path, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 Extension::InstallType install_type = | 1285 Extension::InstallType install_type = |
| 1275 CompareToInstalledVersion(id, version->GetString(), ¤t_version); | 1286 CompareToInstalledVersion(id, version->GetString(), ¤t_version); |
| 1276 | 1287 |
| 1277 if (install_type == Extension::DOWNGRADE) | 1288 if (install_type == Extension::DOWNGRADE) |
| 1278 return false; | 1289 return false; |
| 1279 | 1290 |
| 1280 return (install_type == Extension::UPGRADE || | 1291 return (install_type == Extension::UPGRADE || |
| 1281 install_type == Extension::NEW_INSTALL || | 1292 install_type == Extension::NEW_INSTALL || |
| 1282 NeedsReinstall(id, current_version)); | 1293 NeedsReinstall(id, current_version)); |
| 1283 } | 1294 } |
| OLD | NEW |