Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4716)

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 7605001: Extensions installed by policy overrun previously installed extensions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More tests. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index b72df86857ff5978d3583103cd47d3c6d169c86f..14e0350c185ed2df6639a853328068db9c7f3e61 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -415,12 +415,19 @@ void ExtensionService::OnExternalExtensionUpdateUrlFound(
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CHECK(Extension::IdIsValid(id));
- if (GetExtensionById(id, true)) {
- // Already installed. Do not change the update URL that the extension set.
- return;
+ bool overwrite = false;
+ const Extension* extension = GetExtensionById(id, true);
+ if (extension) {
+ // Already installed. Skip this install if the current location has
+ // higher priority than |location|.
+ Extension::Location current = extension->location();
+ if (current == Extension::GetHigherPriorityLocation(current, location))
+ return;
+ // Otherwise, overwrite the current installation.
+ overwrite = true;
}
pending_extension_manager()->AddFromExternalUpdateUrl(
- id, update_url, location);
+ id, update_url, location, overwrite);
external_extension_url_added_ |= true;
}
@@ -2163,7 +2170,11 @@ void ExtensionService::OnExtensionInstalled(
// Ensure extension is deleted unless we transfer ownership.
scoped_refptr<const Extension> scoped_extension(extension);
const std::string& id = extension->id();
- bool initial_enable = !extension_prefs_->IsExtensionDisabled(id);
+ // Extensions installed by policy can't be disabled. So even if a previous
+ // installation disabled the extension, make sure it is now enabled.
+ bool initial_enable =
+ !extension_prefs_->IsExtensionDisabled(id) ||
+ !Extension::UserMayDisable(extension->location());
PendingExtensionInfo pending_extension_info;
if (pending_extension_manager()->GetById(id, &pending_extension_info)) {
pending_extension_manager()->Remove(id);

Powered by Google App Engine
This is Rietveld 408576698