| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 if (out_crx_installer) | 590 if (out_crx_installer) |
| 591 *out_crx_installer = installer.get(); | 591 *out_crx_installer = installer.get(); |
| 592 | 592 |
| 593 return true; | 593 return true; |
| 594 #else | 594 #else |
| 595 return false; | 595 return false; |
| 596 #endif | 596 #endif |
| 597 } | 597 } |
| 598 | 598 |
| 599 void ExtensionService::ReloadExtension( | 599 void ExtensionService::ReloadExtensionImpl( |
| 600 // "transient" because the process of reloading may cause the reference | 600 // "transient" because the process of reloading may cause the reference |
| 601 // to become invalid. Instead, use |extension_id|, a copy. | 601 // to become invalid. Instead, use |extension_id|, a copy. |
| 602 const std::string& transient_extension_id) { | 602 const std::string& transient_extension_id, |
| 603 bool be_noisy) { |
| 603 #if defined(ENABLE_EXTENSIONS) | 604 #if defined(ENABLE_EXTENSIONS) |
| 604 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 605 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 605 | 606 |
| 606 // If the extension is already reloading, don't reload again. | 607 // If the extension is already reloading, don't reload again. |
| 607 if (extension_prefs_->GetDisableReasons(transient_extension_id) & | 608 if (extension_prefs_->GetDisableReasons(transient_extension_id) & |
| 608 Extension::DISABLE_RELOAD) { | 609 Extension::DISABLE_RELOAD) { |
| 609 return; | 610 return; |
| 610 } | 611 } |
| 611 | 612 |
| 612 // Ignore attempts to reload a blacklisted extension. Sometimes this can | 613 // Ignore attempts to reload a blacklisted extension. Sometimes this can |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 scoped_ptr<ExtensionInfo> installed_extension( | 677 scoped_ptr<ExtensionInfo> installed_extension( |
| 677 extension_prefs_->GetInstalledExtensionInfo(extension_id)); | 678 extension_prefs_->GetInstalledExtensionInfo(extension_id)); |
| 678 if (installed_extension.get() && | 679 if (installed_extension.get() && |
| 679 installed_extension->extension_manifest.get()) { | 680 installed_extension->extension_manifest.get()) { |
| 680 extensions::InstalledLoader(this).Load(*installed_extension, false); | 681 extensions::InstalledLoader(this).Load(*installed_extension, false); |
| 681 } else { | 682 } else { |
| 682 // Otherwise, the extension is unpacked (location LOAD). | 683 // Otherwise, the extension is unpacked (location LOAD). |
| 683 // We should always be able to remember the extension's path. If it's not in | 684 // We should always be able to remember the extension's path. If it's not in |
| 684 // the map, someone failed to update |unloaded_extension_paths_|. | 685 // the map, someone failed to update |unloaded_extension_paths_|. |
| 685 CHECK(!path.empty()); | 686 CHECK(!path.empty()); |
| 686 extensions::UnpackedInstaller::Create(this)->Load(path); | 687 scoped_refptr<extensions::UnpackedInstaller> unpacked_installer = |
| 688 extensions::UnpackedInstaller::Create(this); |
| 689 unpacked_installer->set_be_noisy_on_failure(be_noisy); |
| 690 unpacked_installer->Load(path); |
| 687 } | 691 } |
| 688 // When reloading is done, mark this extension as done reloading. | 692 // When reloading is done, mark this extension as done reloading. |
| 689 SetBeingReloaded(extension_id, false); | 693 SetBeingReloaded(extension_id, false); |
| 690 #endif // defined(ENABLE_EXTENSIONS) | 694 #endif // defined(ENABLE_EXTENSIONS) |
| 691 } | 695 } |
| 692 | 696 |
| 697 void ExtensionService::ReloadExtension(const std::string& extension_id) { |
| 698 ReloadExtensionImpl(extension_id, true); // be_noisy |
| 699 } |
| 700 |
| 701 void ExtensionService::ReloadExtensionWithQuietFailure( |
| 702 const std::string& extension_id) { |
| 703 ReloadExtensionImpl(extension_id, false); // be_noisy |
| 704 } |
| 705 |
| 693 bool ExtensionService::UninstallExtension( | 706 bool ExtensionService::UninstallExtension( |
| 694 // "transient" because the process of uninstalling may cause the reference | 707 // "transient" because the process of uninstalling may cause the reference |
| 695 // to become invalid. Instead, use |extenson->id()|. | 708 // to become invalid. Instead, use |extenson->id()|. |
| 696 const std::string& transient_extension_id, | 709 const std::string& transient_extension_id, |
| 697 UninstallReason reason, | 710 UninstallReason reason, |
| 698 base::string16* error) { | 711 base::string16* error) { |
| 699 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 712 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 700 | 713 |
| 701 scoped_refptr<const Extension> extension = | 714 scoped_refptr<const Extension> extension = |
| 702 GetInstalledExtension(transient_extension_id); | 715 GetInstalledExtension(transient_extension_id); |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 } | 2359 } |
| 2347 | 2360 |
| 2348 void ExtensionService::OnProfileDestructionStarted() { | 2361 void ExtensionService::OnProfileDestructionStarted() { |
| 2349 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2362 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2350 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2363 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2351 it != ids_to_unload.end(); | 2364 it != ids_to_unload.end(); |
| 2352 ++it) { | 2365 ++it) { |
| 2353 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2366 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2354 } | 2367 } |
| 2355 } | 2368 } |
| OLD | NEW |