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(); |
} |
} |