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

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: Reviewed, rebased 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 c7298670da1a399d868610699b11c5e4afa9815a..b49f5bd16bee31a708374fd37a6721e01c409bb2 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -415,9 +415,14 @@ 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;
+ 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.
}
pending_extension_manager()->AddFromExternalUpdateUrl(
id, update_url, location);
@@ -2163,7 +2168,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);
« no previous file with comments | « chrome/browser/extensions/extension_management_browsertest.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698