| 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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 if (extension_sync_service_) | 1058 if (extension_sync_service_) |
| 1059 extension_sync_service_->SyncDisableExtension(*extension); | 1059 extension_sync_service_->SyncDisableExtension(*extension); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 void ExtensionService::DisableUserExtensions( | 1062 void ExtensionService::DisableUserExtensions( |
| 1063 const std::vector<std::string>& except_ids) { | 1063 const std::vector<std::string>& except_ids) { |
| 1064 extensions::ManagementPolicy* management_policy = | 1064 extensions::ManagementPolicy* management_policy = |
| 1065 system_->management_policy(); | 1065 system_->management_policy(); |
| 1066 extensions::ExtensionList to_disable; | 1066 extensions::ExtensionList to_disable; |
| 1067 | 1067 |
| 1068 // TODO(rlp): Clean up this code. crbug.com/353266. |
| 1068 const ExtensionSet& enabled_set = registry_->enabled_extensions(); | 1069 const ExtensionSet& enabled_set = registry_->enabled_extensions(); |
| 1069 for (ExtensionSet::const_iterator extension = enabled_set.begin(); | 1070 for (ExtensionSet::const_iterator extension = enabled_set.begin(); |
| 1070 extension != enabled_set.end(); ++extension) { | 1071 extension != enabled_set.end(); ++extension) { |
| 1071 if (management_policy->UserMayModifySettings(extension->get(), NULL)) | 1072 if (management_policy->UserMayModifySettings(extension->get(), NULL) && |
| 1073 extension->get()->location() != Manifest::EXTERNAL_COMPONENT) |
| 1072 to_disable.push_back(*extension); | 1074 to_disable.push_back(*extension); |
| 1073 } | 1075 } |
| 1074 const ExtensionSet& terminated_set = registry_->terminated_extensions(); | 1076 const ExtensionSet& terminated_set = registry_->terminated_extensions(); |
| 1075 for (ExtensionSet::const_iterator extension = terminated_set.begin(); | 1077 for (ExtensionSet::const_iterator extension = terminated_set.begin(); |
| 1076 extension != terminated_set.end(); ++extension) { | 1078 extension != terminated_set.end(); ++extension) { |
| 1077 if (management_policy->UserMayModifySettings(extension->get(), NULL)) | 1079 if (management_policy->UserMayModifySettings(extension->get(), NULL) && |
| 1080 extension->get()->location() != Manifest::EXTERNAL_COMPONENT) |
| 1078 to_disable.push_back(*extension); | 1081 to_disable.push_back(*extension); |
| 1079 } | 1082 } |
| 1080 | 1083 |
| 1081 for (extensions::ExtensionList::const_iterator extension = to_disable.begin(); | 1084 for (extensions::ExtensionList::const_iterator extension = to_disable.begin(); |
| 1082 extension != to_disable.end(); ++extension) { | 1085 extension != to_disable.end(); ++extension) { |
| 1083 if ((*extension)->was_installed_by_default() && | 1086 if ((*extension)->was_installed_by_default() && |
| 1084 extension_urls::IsWebstoreUpdateUrl( | 1087 extension_urls::IsWebstoreUpdateUrl( |
| 1085 extensions::ManifestURL::GetUpdateURL(*extension))) | 1088 extensions::ManifestURL::GetUpdateURL(*extension))) |
| 1086 continue; | 1089 continue; |
| 1087 const std::string& id = (*extension)->id(); | 1090 const std::string& id = (*extension)->id(); |
| (...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 bool isBeingReloaded) { | 2639 bool isBeingReloaded) { |
| 2637 if (isBeingReloaded) | 2640 if (isBeingReloaded) |
| 2638 extensions_being_reloaded_.insert(extension_id); | 2641 extensions_being_reloaded_.insert(extension_id); |
| 2639 else | 2642 else |
| 2640 extensions_being_reloaded_.erase(extension_id); | 2643 extensions_being_reloaded_.erase(extension_id); |
| 2641 } | 2644 } |
| 2642 | 2645 |
| 2643 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { | 2646 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { |
| 2644 // Extensions installed by policy can't be disabled. So even if a previous | 2647 // Extensions installed by policy can't be disabled. So even if a previous |
| 2645 // installation disabled the extension, make sure it is now enabled. | 2648 // installation disabled the extension, make sure it is now enabled. |
| 2646 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) | 2649 // TODO(rlp): Clean up the special case for external components as noted |
| 2650 // in crbug.com/353266. For now, EXTERNAL_COMPONENT apps should be |
| 2651 // default enabled on install as before. |
| 2652 if (system_->management_policy()->MustRemainEnabled(extension, NULL) || |
| 2653 extension->location() == Manifest::EXTERNAL_COMPONENT) { |
| 2647 return true; | 2654 return true; |
| 2655 } |
| 2648 | 2656 |
| 2649 if (extension_prefs_->IsExtensionDisabled(extension->id())) | 2657 if (extension_prefs_->IsExtensionDisabled(extension->id())) |
| 2650 return false; | 2658 return false; |
| 2651 | 2659 |
| 2652 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { | 2660 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { |
| 2653 // External extensions are initially disabled. We prompt the user before | 2661 // External extensions are initially disabled. We prompt the user before |
| 2654 // enabling them. Hosted apps are excepted because they are not dangerous | 2662 // enabling them. Hosted apps are excepted because they are not dangerous |
| 2655 // (they need to be launched by the user anyway). | 2663 // (they need to be launched by the user anyway). |
| 2656 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && | 2664 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && |
| 2657 Manifest::IsExternalLocation(extension->location()) && | 2665 Manifest::IsExternalLocation(extension->location()) && |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2881 void ExtensionService::UnloadAllExtensionsInternal() { | 2889 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2882 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2890 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2883 | 2891 |
| 2884 registry_->ClearAll(); | 2892 registry_->ClearAll(); |
| 2885 system_->runtime_data()->ClearAll(); | 2893 system_->runtime_data()->ClearAll(); |
| 2886 | 2894 |
| 2887 // TODO(erikkay) should there be a notification for this? We can't use | 2895 // TODO(erikkay) should there be a notification for this? We can't use |
| 2888 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2896 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2889 // or uninstalled. | 2897 // or uninstalled. |
| 2890 } | 2898 } |
| OLD | NEW |