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

Unified Diff: chrome/browser/search/instant_service.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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
Index: chrome/browser/search/instant_service.cc
diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc
index 1144e405f7885dd2572749e7fd40575caf337fa9..8ffabe7dce81cb4652360bed88e9a4d614e2f87f 100644
--- a/chrome/browser/search/instant_service.cc
+++ b/chrome/browser/search/instant_service.cc
@@ -5,7 +5,8 @@
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/top_sites_provider.h"
+#include "chrome/browser/history/top_sites_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/instant_io_context.h"
#include "chrome/browser/search/instant_service_observer.h"
@@ -92,11 +93,12 @@ InstantService::InstantService(Profile* profile)
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
- history::TopSites* top_sites = profile_->GetTopSites();
- if (top_sites) {
- registrar_.Add(this,
- chrome::NOTIFICATION_TOP_SITES_CHANGED,
- content::Source<history::TopSites>(top_sites));
+ history::TopSitesProvider* top_sites_provider =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites_provider) {
+ registrar_.Add(
+ this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
+ content::Source<history::TopSitesProvider>(top_sites_provider));
}
if (profile_ && profile_->GetResourceContext()) {
@@ -161,27 +163,30 @@ void InstantService::RemoveObserver(InstantServiceObserver* observer) {
}
void InstantService::DeleteMostVisitedItem(const GURL& url) {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ history::TopSitesProvider* top_sites_provider =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (!top_sites_provider)
return;
- top_sites->AddBlacklistedURL(url);
+ top_sites_provider->AddBlacklistedURL(url);
}
void InstantService::UndoMostVisitedDeletion(const GURL& url) {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ history::TopSitesProvider* top_sites_provider =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (!top_sites_provider)
return;
- top_sites->RemoveBlacklistedURL(url);
+ top_sites_provider->RemoveBlacklistedURL(url);
}
void InstantService::UndoAllMostVisitedDeletions() {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ history::TopSitesProvider* top_sites_provider =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (!top_sites_provider)
return;
- top_sites->ClearBlacklistedURLs();
+ top_sites_provider->ClearBlacklistedURLs();
}
void InstantService::UpdateThemeInfo() {
@@ -222,11 +227,13 @@ void InstantService::Observe(int type,
content::Source<content::RenderProcessHost>(source)->GetID());
break;
case chrome::NOTIFICATION_TOP_SITES_CHANGED: {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (top_sites) {
- top_sites->GetMostVisitedURLs(
+ history::TopSitesProvider* top_sites_provider =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites_provider) {
+ top_sites_provider->GetMostVisitedURLs(
base::Bind(&InstantService::OnMostVisitedItemsReceived,
- weak_ptr_factory_.GetWeakPtr()), false);
+ weak_ptr_factory_.GetWeakPtr()),
+ false);
}
break;
}

Powered by Google App Engine
This is Rietveld 408576698