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

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

Issue 20909002: Correct the flag: is_extension_upgrade, which denote whether the extension is being upgrading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Shouldn't break CheckPermissionsIncrease. Created 7 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 42cb3fa69ea9ea451229871e5df976d830fb9cd7..e27b2389849751e5be933a6c1a38d50441d3ff2a 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2006,13 +2006,17 @@ void ExtensionService::AddExtension(const Extension* extension) {
}
bool is_extension_upgrade = false;
- if (const Extension* old = GetInstalledExtension(extension->id())) {
- is_extension_upgrade = true;
- DCHECK_NE(extension, old);
+ bool is_extension_installed = false;
+ const Extension* old = GetInstalledExtension(extension->id());
+ if (old) {
+ is_extension_installed = true;
+ int version_compare_result =
+ extension->version()->CompareTo(*(old->version()));
+ is_extension_upgrade = version_compare_result > 0;
// Other than for unpacked extensions, CrxInstaller should have guaranteed
// that we aren't downgrading.
if (!Manifest::IsUnpackedLocation(extension->location()))
- CHECK_GE(extension->version()->CompareTo(*(old->version())), 0);
+ CHECK_GE(version_compare_result, 0);
}
SetBeingUpgraded(extension, is_extension_upgrade);
@@ -2027,9 +2031,9 @@ void ExtensionService::AddExtension(const Extension* extension) {
// Check if the extension's privileges have changed and mark the
// extension disabled if necessary.
- CheckPermissionsIncrease(extension, is_extension_upgrade);
+ CheckPermissionsIncrease(extension, is_extension_installed);
- if (is_extension_upgrade && !reloading) {
+ if (is_extension_installed && !reloading) {
// To upgrade an extension in place, unload the old one and then load the
// new one. ReloadExtension disables the extension, which is sufficient.
UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_UPDATE);
@@ -2132,7 +2136,7 @@ void ExtensionService::UpdateActivePermissions(const Extension* extension) {
}
void ExtensionService::CheckPermissionsIncrease(const Extension* extension,
- bool is_extension_upgrade) {
+ bool is_extension_installed) {
UpdateActivePermissions(extension);
// We keep track of all permissions the user has granted each extension.
@@ -2159,7 +2163,7 @@ void ExtensionService::CheckPermissionsIncrease(const Extension* extension,
int disable_reasons = extension_prefs_->GetDisableReasons(extension->id());
bool auto_grant_permission =
- (!is_extension_upgrade && extension->was_installed_by_default()) ||
+ (!is_extension_installed && extension->was_installed_by_default()) ||
chrome::IsRunningInForcedAppMode();
// Silently grant all active permissions to default apps only on install.
// After install they should behave like other apps.
@@ -2187,7 +2191,7 @@ void ExtensionService::CheckPermissionsIncrease(const Extension* extension,
extension->GetActivePermissions().get(), extension->GetType());
}
- if (is_extension_upgrade) {
+ if (is_extension_installed) {
// If the extension was already disabled, suppress any alerts for becoming
// disabled on permissions increase.
bool previously_disabled =
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698