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

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: Fixed update of webstore_result 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
« no previous file with comments | « chrome/browser/ui/app_list/search/webstore/webstore_result.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3e265593b41ea44d65937af5887ed4b783f6e0c1 100644
--- a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
+++ b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
@@ -82,6 +82,7 @@ WebstoreResult::WebstoreResult(Profile* profile,
set_title(base::UTF8ToUTF16(localized_name_));
SetDefaultDetails();
+ InitAndStartObserving();
UpdateActions();
icon_ = gfx::ImageSkia(
@@ -93,8 +94,6 @@ WebstoreResult::WebstoreResult(Profile* profile,
IDR_WEBSTORE_ICON_32),
gfx::Size(kIconSize, kIconSize));
SetIcon(icon_);
-
- StartObserving();
}
WebstoreResult::~WebstoreResult() {
@@ -124,6 +123,23 @@ scoped_ptr<ChromeSearchResult> WebstoreResult::Duplicate() {
profile_, app_id_, localized_name_, icon_url_, controller_)).Pass();
}
+void WebstoreResult::InitAndStartObserving() {
+ DCHECK(!install_tracker_ && !extension_registry_);
+
+ install_tracker_ = extensions::InstallTrackerFactory::GetForProfile(profile_);
+ extension_registry_ = extensions::ExtensionRegistry::Get(profile_);
+
+ const extensions::ActiveInstallData* install_data =
+ install_tracker_->GetActiveInstall(app_id_);
+ if (install_data) {
+ SetPercentDownloaded(install_data->percent_downloaded);
+ SetIsInstalling(true);
+ }
+
+ install_tracker_->AddObserver(this);
+ extension_registry_->AddObserver(this);
+}
+
void WebstoreResult::UpdateActions() {
Actions actions;
@@ -206,7 +222,7 @@ void WebstoreResult::InstallCallback(bool success, const std::string& error) {
return;
}
- // Success handling is continued in OnExtensionWillBeInstalled.
+ // Success handling is continued in OnExtensionInstalled.
SetPercentDownloaded(100);
}
@@ -218,16 +234,6 @@ void WebstoreResult::LaunchCallback(extensions::webstore_install::Result result,
SetIsInstalling(false);
}
-void WebstoreResult::StartObserving() {
- DCHECK(!install_tracker_ && !extension_registry_);
-
- install_tracker_ = extensions::InstallTrackerFactory::GetForProfile(profile_);
- install_tracker_->AddObserver(this);
-
- extension_registry_ = extensions::ExtensionRegistry::Get(profile_);
- extension_registry_->AddObserver(this);
-}
-
void WebstoreResult::StopObservingInstall() {
if (install_tracker_)
install_tracker_->RemoveObserver(this);
@@ -248,20 +254,18 @@ void WebstoreResult::OnDownloadProgress(const std::string& extension_id,
SetPercentDownloaded(percent_downloaded);
}
-void WebstoreResult::OnExtensionWillBeInstalled(
+void WebstoreResult::OnExtensionInstalled(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
- bool is_update,
- bool from_ephemeral,
- const std::string& old_name) {
+ bool is_update) {
if (extension->id() != app_id_)
return;
SetIsInstalling(false);
+ UpdateActions();
if (extensions::util::IsExtensionInstalledPermanently(extension->id(),
profile_)) {
- UpdateActions();
NotifyItemInstalled();
}
}
« no previous file with comments | « chrome/browser/ui/app_list/search/webstore/webstore_result.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698