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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if (extension_sync_service_) | 1061 if (extension_sync_service_) |
1062 extension_sync_service_->SyncDisableExtension(*extension); | 1062 extension_sync_service_->SyncDisableExtension(*extension); |
1063 } | 1063 } |
1064 | 1064 |
1065 void ExtensionService::DisableUserExtensions( | 1065 void ExtensionService::DisableUserExtensions( |
1066 const std::vector<std::string>& except_ids) { | 1066 const std::vector<std::string>& except_ids) { |
1067 extensions::ManagementPolicy* management_policy = | 1067 extensions::ManagementPolicy* management_policy = |
1068 system_->management_policy(); | 1068 system_->management_policy(); |
1069 extensions::ExtensionList to_disable; | 1069 extensions::ExtensionList to_disable; |
1070 | 1070 |
| 1071 // TODO(rlp): Clean up this code. crbug.com/353266. |
1071 const ExtensionSet& enabled_set = registry_->enabled_extensions(); | 1072 const ExtensionSet& enabled_set = registry_->enabled_extensions(); |
1072 for (ExtensionSet::const_iterator extension = enabled_set.begin(); | 1073 for (ExtensionSet::const_iterator extension = enabled_set.begin(); |
1073 extension != enabled_set.end(); ++extension) { | 1074 extension != enabled_set.end(); ++extension) { |
1074 if (management_policy->UserMayModifySettings(extension->get(), NULL)) | 1075 if (management_policy->UserMayModifySettings(extension->get(), NULL) && |
| 1076 extension->get()->location() != Manifest::EXTERNAL_COMPONENT) |
1075 to_disable.push_back(*extension); | 1077 to_disable.push_back(*extension); |
1076 } | 1078 } |
1077 const ExtensionSet& terminated_set = registry_->terminated_extensions(); | 1079 const ExtensionSet& terminated_set = registry_->terminated_extensions(); |
1078 for (ExtensionSet::const_iterator extension = terminated_set.begin(); | 1080 for (ExtensionSet::const_iterator extension = terminated_set.begin(); |
1079 extension != terminated_set.end(); ++extension) { | 1081 extension != terminated_set.end(); ++extension) { |
1080 if (management_policy->UserMayModifySettings(extension->get(), NULL)) | 1082 if (management_policy->UserMayModifySettings(extension->get(), NULL) && |
| 1083 extension->get()->location() != Manifest::EXTERNAL_COMPONENT) |
1081 to_disable.push_back(*extension); | 1084 to_disable.push_back(*extension); |
1082 } | 1085 } |
1083 | 1086 |
1084 for (extensions::ExtensionList::const_iterator extension = to_disable.begin(); | 1087 for (extensions::ExtensionList::const_iterator extension = to_disable.begin(); |
1085 extension != to_disable.end(); ++extension) { | 1088 extension != to_disable.end(); ++extension) { |
1086 if ((*extension)->was_installed_by_default() && | 1089 if ((*extension)->was_installed_by_default() && |
1087 extension_urls::IsWebstoreUpdateUrl( | 1090 extension_urls::IsWebstoreUpdateUrl( |
1088 extensions::ManifestURL::GetUpdateURL(*extension))) | 1091 extensions::ManifestURL::GetUpdateURL(*extension))) |
1089 continue; | 1092 continue; |
1090 const std::string& id = (*extension)->id(); | 1093 const std::string& id = (*extension)->id(); |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 bool isBeingReloaded) { | 2659 bool isBeingReloaded) { |
2657 if (isBeingReloaded) | 2660 if (isBeingReloaded) |
2658 extensions_being_reloaded_.insert(extension_id); | 2661 extensions_being_reloaded_.insert(extension_id); |
2659 else | 2662 else |
2660 extensions_being_reloaded_.erase(extension_id); | 2663 extensions_being_reloaded_.erase(extension_id); |
2661 } | 2664 } |
2662 | 2665 |
2663 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { | 2666 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { |
2664 // Extensions installed by policy can't be disabled. So even if a previous | 2667 // Extensions installed by policy can't be disabled. So even if a previous |
2665 // installation disabled the extension, make sure it is now enabled. | 2668 // installation disabled the extension, make sure it is now enabled. |
2666 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) | 2669 // TODO(rlp): Clean up the special case for external components as noted |
| 2670 // in crbug.com/353266. For now, EXTERNAL_COMPONENT apps should be |
| 2671 // default enabled on install as before. |
| 2672 if (system_->management_policy()->MustRemainEnabled(extension, NULL) || |
| 2673 extension->location() == Manifest::EXTERNAL_COMPONENT) { |
2667 return true; | 2674 return true; |
| 2675 } |
2668 | 2676 |
2669 if (extension_prefs_->IsExtensionDisabled(extension->id())) | 2677 if (extension_prefs_->IsExtensionDisabled(extension->id())) |
2670 return false; | 2678 return false; |
2671 | 2679 |
2672 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { | 2680 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { |
2673 // External extensions are initially disabled. We prompt the user before | 2681 // External extensions are initially disabled. We prompt the user before |
2674 // enabling them. Hosted apps are excepted because they are not dangerous | 2682 // enabling them. Hosted apps are excepted because they are not dangerous |
2675 // (they need to be launched by the user anyway). | 2683 // (they need to be launched by the user anyway). |
2676 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && | 2684 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && |
2677 Manifest::IsExternalLocation(extension->location()) && | 2685 Manifest::IsExternalLocation(extension->location()) && |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 void ExtensionService::UnloadAllExtensionsInternal() { | 2909 void ExtensionService::UnloadAllExtensionsInternal() { |
2902 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2910 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2903 | 2911 |
2904 registry_->ClearAll(); | 2912 registry_->ClearAll(); |
2905 system_->runtime_data()->ClearAll(); | 2913 system_->runtime_data()->ClearAll(); |
2906 | 2914 |
2907 // TODO(erikkay) should there be a notification for this? We can't use | 2915 // TODO(erikkay) should there be a notification for this? We can't use |
2908 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2916 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2909 // or uninstalled. | 2917 // or uninstalled. |
2910 } | 2918 } |
OLD | NEW |