| 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 aff9226b57c4905164c7fceedf1440f6704f96af..cc5e8dee9b9bb9057b065ed6ae8856a9f31f8ef1 100644
|
| --- a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
|
| +++ b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc
|
| @@ -21,6 +21,7 @@
|
| #include "chrome/browser/ui/browser_navigator.h"
|
| #include "chrome/browser/ui/extensions/application_launch.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| #include "extensions/browser/extension_system.h"
|
| #include "extensions/browser/extension_util.h"
|
| #include "extensions/common/extension.h"
|
| @@ -75,7 +76,8 @@ WebstoreResult::WebstoreResult(Profile* profile,
|
| icon_url_(icon_url),
|
| weak_factory_(this),
|
| controller_(controller),
|
| - install_tracker_(NULL) {
|
| + install_tracker_(NULL),
|
| + extension_registry_(NULL) {
|
| set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
|
| set_relevance(0.0); // What is the right value to use?
|
|
|
| @@ -94,11 +96,12 @@ WebstoreResult::WebstoreResult(Profile* profile,
|
| gfx::Size(kIconSize, kIconSize));
|
| SetIcon(icon_);
|
|
|
| - StartObservingInstall();
|
| + StartObserving();
|
| }
|
|
|
| WebstoreResult::~WebstoreResult() {
|
| StopObservingInstall();
|
| + StopObservingRegistry();
|
| }
|
|
|
| void WebstoreResult::Open(int event_flags) {
|
| @@ -210,20 +213,28 @@ void WebstoreResult::InstallCallback(bool success, const std::string& error) {
|
| SetPercentDownloaded(100);
|
| }
|
|
|
| -void WebstoreResult::StartObservingInstall() {
|
| - DCHECK(!install_tracker_);
|
| +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);
|
| -
|
| install_tracker_ = NULL;
|
| }
|
|
|
| +void WebstoreResult::StopObservingRegistry() {
|
| + if (extension_registry_)
|
| + extension_registry_->RemoveObserver(this);
|
| + extension_registry_ = NULL;
|
| +}
|
| +
|
| void WebstoreResult::OnDownloadProgress(const std::string& extension_id,
|
| int percent_downloaded) {
|
| if (extension_id != app_id_ || percent_downloaded < 0)
|
| @@ -232,8 +243,12 @@ void WebstoreResult::OnDownloadProgress(const std::string& extension_id,
|
| SetPercentDownloaded(percent_downloaded);
|
| }
|
|
|
| -void WebstoreResult::OnExtensionInstalled(
|
| - const extensions::Extension* extension) {
|
| +void WebstoreResult::OnExtensionWillBeInstalled(
|
| + content::BrowserContext* browser_context,
|
| + const extensions::Extension* extension,
|
| + bool is_update,
|
| + bool from_ephemeral,
|
| + const std::string& old_name) {
|
| if (extension->id() != app_id_)
|
| return;
|
|
|
| @@ -246,6 +261,10 @@ void WebstoreResult::OnShutdown() {
|
| StopObservingInstall();
|
| }
|
|
|
| +void WebstoreResult::OnShutdown(extensions::ExtensionRegistry* registry) {
|
| + StopObservingRegistry();
|
| +}
|
| +
|
| ChromeSearchResultType WebstoreResult::GetType() {
|
| return SEARCH_WEBSTORE_SEARCH_RESULT;
|
| }
|
|
|