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

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..392234c4aeedfd7714d4d6c96cfb3dac85764f91 100644
--- a/chrome/browser/search/instant_service.cc
+++ b/chrome/browser/search/instant_service.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/top_sites.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));
+ scoped_refptr<history::TopSites> top_sites_provider =
sdefresne 2014/12/29 09:48:14 nit: rename top_sites_provider to top_sites
Jitu( very slow this week) 2014/12/30 10:09:03 Done.
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites_provider.get()) {
+ registrar_.Add(
+ this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
+ content::Source<history::TopSites>(top_sites_provider.get()));
}
if (profile_ && profile_->GetResourceContext()) {
@@ -161,24 +163,27 @@ void InstantService::RemoveObserver(InstantServiceObserver* observer) {
}
void InstantService::DeleteMostVisitedItem(const GURL& url) {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites.get() == NULL)
return;
top_sites->AddBlacklistedURL(url);
}
void InstantService::UndoMostVisitedDeletion(const GURL& url) {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites.get() == NULL)
return;
top_sites->RemoveBlacklistedURL(url);
}
void InstantService::UndoAllMostVisitedDeletions() {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (!top_sites)
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites.get() == NULL)
return;
top_sites->ClearBlacklistedURLs();
@@ -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) {
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesServiceFactory::GetForProfile(profile_);
+ if (top_sites.get()) {
top_sites->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