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

Unified Diff: chrome/browser/ui/app_list/search/webstore/webstore_result.cc

Issue 389613006: Prevent duplicate concurrent installs of the same extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/ui/app_list/search/webstore/webstore_result.cc
diff --git a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
index 50dea34a92b0e08943f2aa622feaf3130c7ade8b..accad910caba51f40f197a0b906e0a66ca81e368 100644
--- a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
+++ b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
@@ -74,7 +74,8 @@ WebstoreResult::WebstoreResult(Profile* profile,
icon_url_(icon_url),
weak_factory_(this),
controller_(controller),
- install_tracker_(NULL),
+ install_tracker_(
+ extensions::InstallTrackerFactory::GetForProfile(profile)),
extension_registry_(NULL) {
set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
set_relevance(0.0); // What is the right value to use?
@@ -82,6 +83,7 @@ WebstoreResult::WebstoreResult(Profile* profile,
set_title(base::UTF8ToUTF16(localized_name_));
SetDefaultDetails();
+ SetInitialState();
UpdateActions();
icon_ = gfx::ImageSkia(
@@ -124,6 +126,15 @@ scoped_ptr<ChromeSearchResult> WebstoreResult::Duplicate() {
profile_, app_id_, localized_name_, icon_url_, controller_)).Pass();
}
+void WebstoreResult::SetInitialState() {
+ const extensions::InstallTracker::InstallProgressData* install_data =
+ install_tracker_->GetActiveInstall(app_id_);
+ if (install_data) {
+ SetPercentDownloaded(install_data->percent_downloaded);
+ SetIsInstalling(true);
+ }
+}
+
void WebstoreResult::UpdateActions() {
Actions actions;
@@ -219,9 +230,8 @@ void WebstoreResult::LaunchCallback(extensions::webstore_install::Result result,
}
void WebstoreResult::StartObserving() {
- DCHECK(!install_tracker_ && !extension_registry_);
+ DCHECK(!extension_registry_);
- install_tracker_ = extensions::InstallTrackerFactory::GetForProfile(profile_);
install_tracker_->AddObserver(this);
extension_registry_ = extensions::ExtensionRegistry::Get(profile_);
@@ -258,10 +268,10 @@ void WebstoreResult::OnExtensionWillBeInstalled(
return;
SetIsInstalling(false);
+ UpdateActions();
if (extensions::util::IsExtensionInstalledPermanently(extension->id(),
profile_)) {
- UpdateActions();
NotifyItemInstalled();
}
}

Powered by Google App Engine
This is Rietveld 408576698