summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_service.cc
diff options
context:
space:
mode:
authorpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 10:07:33 +0000
committerpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 10:07:33 +0000
commit95da88c4dc2f8890aa76ce8ef17148f806baac48 (patch)
tree021141b25ce4f84f96a76d93a228adb30168447f /chrome/browser/extensions/extension_service.cc
parent4b7296e0f086b5184b20e5b218827a634214e1ce (diff)
downloadchromium_src-95da88c4dc2f8890aa76ce8ef17148f806baac48.zip
chromium_src-95da88c4dc2f8890aa76ce8ef17148f806baac48.tar.gz
chromium_src-95da88c4dc2f8890aa76ce8ef17148f806baac48.tar.bz2
Disable uninstalling and editing permissions for policy controlled extensions.
Continuation of the work on Jochen's CL 4115004. BUG=63599 TEST=unit_tests: ExtensionServiceTest suite. Review URL: http://codereview.chromium.org/6680001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_service.cc')
-rw-r--r--chrome/browser/extensions/extension_service.cc32
1 files changed, 25 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index cb99385..e77eb34 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -355,17 +355,25 @@ bool ExtensionService::UninstallExtensionHelper(
ExtensionService* extensions_service,
const std::string& extension_id) {
- // We can't call UninstallExtension with an invalid extension ID, so check it
- // first.
- if (extensions_service->GetExtensionById(extension_id, true) ||
- extensions_service->GetTerminatedExtension(extension_id)) {
- extensions_service->UninstallExtension(extension_id, false);
- } else {
+ const Extension* extension =
+ extensions_service->GetExtensionById(extension_id, true);
+ if (!extension)
+ extension = extensions_service->GetTerminatedExtension(extension_id);
+
+ // We can't call UninstallExtension with an invalid extension ID. We should
+ // not allow an uninstall of a policy-controlled extension.
+ if (!extension) {
LOG(WARNING) << "Attempted uninstallation of non-existent extension with "
- << "id: " << extension_id;
+ << "id: " << extension_id;
+ return false;
+ } else if (!Extension::UserMayDisable(extension->location())) {
+ LOG(WARNING) << "Attempted uninstallation of an extension that is non-"
+ << "usermanagable with id: " << extension_id;
return false;
}
+ extensions_service->UninstallExtension(extension_id, false);
+
return true;
}
@@ -602,6 +610,13 @@ void ExtensionService::UninstallExtension(const std::string& extension_id,
// pointer will be invalid then.
GURL extension_url(extension->url());
Extension::Location location(extension->location());
+
+ // Policy change which triggers an uninstall will always set
+ // |external_uninstall| to true so this is the only way to uninstall
+ // managed extensions.
+ if (!Extension::UserMayDisable(location) && !external_uninstall)
+ return;
+
UninstalledExtensionInfo uninstalled_extension_info(*extension);
UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType",
@@ -683,6 +698,9 @@ void ExtensionService::DisableExtension(const std::string& extension_id) {
if (!extension)
return;
+ if (!Extension::UserMayDisable(extension->location()))
+ return;
+
extension_prefs_->SetExtensionState(extension, Extension::DISABLED);
// Move it over to the disabled list.