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

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

Issue 2819023: Reworked ExtensionsService::AddPendingExtension(). (Closed)
Patch Set: Fixed browsertest test failure Created 10 years, 6 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_updater.cc
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc
index 9c428e34838bf20409910ab3283813ceaede0de3..95177c66107be1daff05a4f5985ae4316c68766f 100644
--- a/chrome/browser/extensions/extension_updater.cc
+++ b/chrome/browser/extensions/extension_updater.cc
@@ -169,7 +169,12 @@ void ManifestFetchesBuilder::AddExtension(const Extension& extension) {
void ManifestFetchesBuilder::AddPendingExtension(
const std::string& id,
const PendingExtensionInfo& info) {
- AddExtensionData(Extension::INTERNAL, id, info.version,
+ // Use a zero version to ensure that a pending extension will always
+ // be updated, and thus installed (assuming all extensions have
+ // non-zero versions).
+ scoped_ptr<Version> version(
+ Version::GetVersionFromString("0.0.0.0"));
+ AddExtensionData(Extension::INTERNAL, id, *version,
false, info.is_theme, info.update_url);
}
@@ -716,12 +721,6 @@ bool ExtensionUpdater::GetExistingVersion(const std::string& id,
WideToASCII(prefs_->GetString(kExtensionBlacklistUpdateVersion));
return true;
}
- PendingExtensionMap::const_iterator it =
- service_->pending_extensions().find(id);
- if (it != service_->pending_extensions().end()) {
- *version = it->second.version.GetString();
- return true;
- }
Extension* extension = service_->GetExtensionById(id, false);
if (!extension) {
return false;
@@ -745,20 +744,24 @@ std::vector<int> ExtensionUpdater::DetermineUpdates(
if (!fetch_data.Includes(update->extension_id))
continue;
- std::string version;
- if (!GetExistingVersion(update->extension_id, &version))
- continue;
+ if (service_->pending_extensions().find(update->extension_id) ==
+ service_->pending_extensions().end()) {
+ // If we're not installing pending extension, and the update
+ // version is the same or older than what's already installed,
+ // we don't want it.
+ std::string version;
+ if (!GetExistingVersion(update->extension_id, &version))
+ continue;
- // If the update version is the same or older than what's already installed,
- // we don't want it.
- scoped_ptr<Version> existing_version(
- Version::GetVersionFromString(version));
- scoped_ptr<Version> update_version(
- Version::GetVersionFromString(update->version));
+ scoped_ptr<Version> existing_version(
+ Version::GetVersionFromString(version));
+ scoped_ptr<Version> update_version(
+ Version::GetVersionFromString(update->version));
- if (!update_version.get() ||
- update_version->CompareTo(*(existing_version.get())) <= 0) {
- continue;
+ if (!update_version.get() ||
+ update_version->CompareTo(*(existing_version.get())) <= 0) {
+ continue;
+ }
}
// If the update specifies a browser minimum version, do we qualify?
« no previous file with comments | « chrome/browser/extensions/extension_prefs_unittest.cc ('k') | chrome/browser/extensions/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698