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

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

Issue 323763002: Remove InstallTracker's extension installed, uninstalled observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix clang error Created 6 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
« no previous file with comments | « chrome/browser/ui/app_list/search/webstore/webstore_result.h ('k') | no next file » | 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 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;
}
« no previous file with comments | « chrome/browser/ui/app_list/search/webstore/webstore_result.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698