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

Unified Diff: chrome/browser/jumplist_win.cc

Issue 845013002: Remove TopSites notification in favor of Observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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/jumplist_win.h ('k') | chrome/browser/search/instant_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/jumplist_win.cc
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc
index 10eb183eee5f251895aaf4147ad2b839afce32ac..0c866b521e63573fd54edd6e6a85432a25acdf52 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -256,10 +256,9 @@ JumpList::JumpList(Profile* profile)
// initialized.
top_sites->SyncWithHistory();
registrar_.reset(new content::NotificationRegistrar);
- // Register for notification when TopSites changes so that we can update
- // ourself.
- registrar_->Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
- content::Source<history::TopSites>(top_sites));
+ // Register as TopSitesObserver so that we can update ourselves when the
+ // TopSites changes.
+ top_sites->AddObserver(this);
// Register for notification when profile is destroyed to ensure that all
// observers are detatched at that time.
registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
@@ -293,25 +292,9 @@ bool JumpList::Enabled() {
void JumpList::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_TOP_SITES_CHANGED: {
- // Most visited urls changed, query again.
- history::TopSites* top_sites = profile_->GetTopSites();
- if (top_sites) {
- top_sites->GetMostVisitedURLs(
- base::Bind(&JumpList::OnMostVisitedURLsAvailable,
- weak_ptr_factory_.GetWeakPtr()), false);
- }
- break;
- }
- case chrome::NOTIFICATION_PROFILE_DESTROYED: {
- // Profile was destroyed, do clean-up.
- Terminate();
- break;
- }
- default:
- NOTREACHED() << "Unexpected notification type.";
- }
+ DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED);
+ // Profile was destroyed, do clean-up.
+ Terminate();
}
void JumpList::CancelPendingUpdate() {
@@ -328,6 +311,9 @@ void JumpList::Terminate() {
TabRestoreServiceFactory::GetForProfile(profile_);
if (tab_restore_service)
tab_restore_service->RemoveObserver(this);
+ history::TopSites* top_sites = profile_->GetTopSites();
+ if (top_sites)
+ top_sites->RemoveObserver(this);
registrar_.reset();
pref_change_registrar_.reset();
}
@@ -615,3 +601,13 @@ void JumpList::UpdateProfileSwitcher() {
new_profile_switcher.swap(profile_switcher_);
}
}
+
+void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
+}
+
+void JumpList::TopSitesChanged(history::TopSites* top_sites) {
+ top_sites->GetMostVisitedURLs(
+ base::Bind(&JumpList::OnMostVisitedURLsAvailable,
+ weak_ptr_factory_.GetWeakPtr()),
+ false);
+}
« no previous file with comments | « chrome/browser/jumplist_win.h ('k') | chrome/browser/search/instant_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698