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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 transient_current_extension = NULL; | 630 transient_current_extension = NULL; |
631 | 631 |
632 if (delayed_installs_.Contains(extension_id)) { | 632 if (delayed_installs_.Contains(extension_id)) { |
633 FinishDelayedInstallation(extension_id); | 633 FinishDelayedInstallation(extension_id); |
634 return; | 634 return; |
635 } | 635 } |
636 | 636 |
637 // If we're reloading a component extension, use the component extension | 637 // If we're reloading a component extension, use the component extension |
638 // loader's reloader. | 638 // loader's reloader. |
639 if (component_loader_->Exists(extension_id)) { | 639 if (component_loader_->Exists(extension_id)) { |
640 SetBeingReloaded(extension_id, true); | |
641 component_loader_->Reload(extension_id); | 640 component_loader_->Reload(extension_id); |
642 SetBeingReloaded(extension_id, false); | |
643 return; | 641 return; |
644 } | 642 } |
645 | 643 |
646 // Check the installed extensions to see if what we're reloading was already | 644 // Check the installed extensions to see if what we're reloading was already |
647 // installed. | 645 // installed. |
648 SetBeingReloaded(extension_id, true); | |
649 scoped_ptr<ExtensionInfo> installed_extension( | 646 scoped_ptr<ExtensionInfo> installed_extension( |
650 extension_prefs_->GetInstalledExtensionInfo(extension_id)); | 647 extension_prefs_->GetInstalledExtensionInfo(extension_id)); |
651 if (installed_extension.get() && | 648 if (installed_extension.get() && |
652 installed_extension->extension_manifest.get()) { | 649 installed_extension->extension_manifest.get()) { |
653 extensions::InstalledLoader(this).Load(*installed_extension, false); | 650 extensions::InstalledLoader(this).Load(*installed_extension, false); |
654 } else { | 651 } else { |
655 // Otherwise, the extension is unpacked (location LOAD). | 652 // Otherwise, the extension is unpacked (location LOAD). |
656 // We should always be able to remember the extension's path. If it's not in | 653 // We should always be able to remember the extension's path. If it's not in |
657 // the map, someone failed to update |unloaded_extension_paths_|. | 654 // the map, someone failed to update |unloaded_extension_paths_|. |
658 CHECK(!path.empty()); | 655 CHECK(!path.empty()); |
659 scoped_refptr<extensions::UnpackedInstaller> unpacked_installer = | 656 scoped_refptr<extensions::UnpackedInstaller> unpacked_installer = |
660 extensions::UnpackedInstaller::Create(this); | 657 extensions::UnpackedInstaller::Create(this); |
661 unpacked_installer->set_be_noisy_on_failure(be_noisy); | 658 unpacked_installer->set_be_noisy_on_failure(be_noisy); |
662 unpacked_installer->Load(path); | 659 unpacked_installer->Load(path); |
663 } | 660 } |
664 // When reloading is done, mark this extension as done reloading. | |
665 SetBeingReloaded(extension_id, false); | |
666 #endif // defined(ENABLE_EXTENSIONS) | 661 #endif // defined(ENABLE_EXTENSIONS) |
667 } | 662 } |
668 | 663 |
669 void ExtensionService::ReloadExtension(const std::string& extension_id) { | 664 void ExtensionService::ReloadExtension(const std::string& extension_id) { |
670 ReloadExtensionImpl(extension_id, true); // be_noisy | 665 ReloadExtensionImpl(extension_id, true); // be_noisy |
671 } | 666 } |
672 | 667 |
673 void ExtensionService::ReloadExtensionWithQuietFailure( | 668 void ExtensionService::ReloadExtensionWithQuietFailure( |
674 const std::string& extension_id) { | 669 const std::string& extension_id) { |
675 ReloadExtensionImpl(extension_id, false); // be_noisy | 670 ReloadExtensionImpl(extension_id, false); // be_noisy |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 default: | 2082 default: |
2088 NOTREACHED() << "Unexpected notification type."; | 2083 NOTREACHED() << "Unexpected notification type."; |
2089 } | 2084 } |
2090 } | 2085 } |
2091 | 2086 |
2092 void ExtensionService::OnExtensionInstallPrefChanged() { | 2087 void ExtensionService::OnExtensionInstallPrefChanged() { |
2093 error_controller_->ShowErrorIfNeeded(); | 2088 error_controller_->ShowErrorIfNeeded(); |
2094 CheckManagementPolicy(); | 2089 CheckManagementPolicy(); |
2095 } | 2090 } |
2096 | 2091 |
2097 bool ExtensionService::IsBeingReloaded( | |
2098 const std::string& extension_id) const { | |
2099 return ContainsKey(extensions_being_reloaded_, extension_id); | |
2100 } | |
2101 | |
2102 void ExtensionService::SetBeingReloaded(const std::string& extension_id, | |
2103 bool isBeingReloaded) { | |
2104 if (isBeingReloaded) | |
2105 extensions_being_reloaded_.insert(extension_id); | |
2106 else | |
2107 extensions_being_reloaded_.erase(extension_id); | |
2108 } | |
2109 | |
2110 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { | 2092 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { |
2111 // Extensions installed by policy can't be disabled. So even if a previous | 2093 // Extensions installed by policy can't be disabled. So even if a previous |
2112 // installation disabled the extension, make sure it is now enabled. | 2094 // installation disabled the extension, make sure it is now enabled. |
2113 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) | 2095 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) |
2114 return true; | 2096 return true; |
2115 | 2097 |
2116 if (extension_prefs_->IsExtensionDisabled(extension->id())) | 2098 if (extension_prefs_->IsExtensionDisabled(extension->id())) |
2117 return false; | 2099 return false; |
2118 | 2100 |
2119 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { | 2101 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 } | 2325 } |
2344 | 2326 |
2345 void ExtensionService::OnProfileDestructionStarted() { | 2327 void ExtensionService::OnProfileDestructionStarted() { |
2346 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2328 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2347 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2329 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2348 it != ids_to_unload.end(); | 2330 it != ids_to_unload.end(); |
2349 ++it) { | 2331 ++it) { |
2350 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2332 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2351 } | 2333 } |
2352 } | 2334 } |
OLD | NEW |