| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 CrxInstaller::Start(extension_path, install_directory_, Extension::INTERNAL, | 162 CrxInstaller::Start(extension_path, install_directory_, Extension::INTERNAL, |
| 163 id, | 163 id, |
| 164 true, // delete crx when complete | 164 true, // delete crx when complete |
| 165 backend_loop_, | 165 backend_loop_, |
| 166 this, | 166 this, |
| 167 NULL); // no client (silent install) | 167 NULL); // no client (silent install) |
| 168 } | 168 } |
| 169 | 169 |
| 170 void ExtensionsService::ReloadExtension(const std::string& extension_id) { | 170 void ExtensionsService::ReloadExtension(const std::string& extension_id) { |
| 171 Extension* extension = GetExtensionById(extension_id); | 171 // Unload the extension if it's loaded. |
| 172 FilePath extension_path = extension->path(); | 172 if (GetExtensionById(extension_id)) |
| 173 UnloadExtension(extension_id); |
| 173 | 174 |
| 174 UnloadExtension(extension_id); | 175 // At this point we have to reconstruct the path from prefs, because |
| 175 LoadExtension(extension_path); | 176 // we have no information about this extension in memory. |
| 177 LoadExtension(extension_prefs_->GetExtensionPath(extension_id)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void ExtensionsService::UninstallExtension(const std::string& extension_id, | 180 void ExtensionsService::UninstallExtension(const std::string& extension_id, |
| 179 bool external_uninstall) { | 181 bool external_uninstall) { |
| 180 Extension* extension = GetExtensionByIdInternal(extension_id, true, true); | 182 Extension* extension = GetExtensionByIdInternal(extension_id, true, true); |
| 181 | 183 |
| 182 // Callers should not send us nonexistant extensions. | 184 // Callers should not send us nonexistant extensions. |
| 183 DCHECK(extension); | 185 DCHECK(extension); |
| 184 | 186 |
| 185 extension_prefs_->OnExtensionUninstalled(extension, external_uninstall); | 187 extension_prefs_->OnExtensionUninstalled(extension, external_uninstall); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 526 } |
| 525 } | 527 } |
| 526 | 528 |
| 527 CrxInstaller::Start(path, install_directory_, location, id, | 529 CrxInstaller::Start(path, install_directory_, location, id, |
| 528 false, // don't delete crx when complete | 530 false, // don't delete crx when complete |
| 529 backend_loop_, | 531 backend_loop_, |
| 530 this, | 532 this, |
| 531 NULL); // no client (silent install) | 533 NULL); // no client (silent install) |
| 532 } | 534 } |
| 533 | 535 |
| 534 | |
| 535 // ExtensionsServicesBackend | 536 // ExtensionsServicesBackend |
| 536 | 537 |
| 537 ExtensionsServiceBackend::ExtensionsServiceBackend( | 538 ExtensionsServiceBackend::ExtensionsServiceBackend( |
| 538 const FilePath& install_directory, MessageLoop* frontend_loop) | 539 const FilePath& install_directory, MessageLoop* frontend_loop) |
| 539 : frontend_(NULL), | 540 : frontend_(NULL), |
| 540 install_directory_(install_directory), | 541 install_directory_(install_directory), |
| 541 alert_on_error_(false), | 542 alert_on_error_(false), |
| 542 frontend_loop_(frontend_loop) { | 543 frontend_loop_(frontend_loop) { |
| 543 // TODO(aa): This ends up doing blocking IO on the UI thread because it reads | 544 // TODO(aa): This ends up doing blocking IO on the UI thread because it reads |
| 544 // pref data in the ctor and that is called on the UI thread. Would be better | 545 // pref data in the ctor and that is called on the UI thread. Would be better |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 linked_ptr<ExternalExtensionProvider>(test_provider); | 672 linked_ptr<ExternalExtensionProvider>(test_provider); |
| 672 } | 673 } |
| 673 | 674 |
| 674 void ExtensionsServiceBackend::OnExternalExtensionFound( | 675 void ExtensionsServiceBackend::OnExternalExtensionFound( |
| 675 const std::string& id, const Version* version, const FilePath& path, | 676 const std::string& id, const Version* version, const FilePath& path, |
| 676 Extension::Location location) { | 677 Extension::Location location) { |
| 677 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, | 678 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, |
| 678 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), | 679 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), |
| 679 path, location)); | 680 path, location)); |
| 680 } | 681 } |
| OLD | NEW |