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

Unified Diff: chrome/browser/ui/webui/ntp/most_visited_handler.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/ui/webui/ntp/most_visited_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.cc b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
index 704380e324a05f29910a7d72b3a5f9705e57b7c2..dd7d4cdeeb7740dd2731191db26413cbaaeb3d9a 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
@@ -21,7 +21,8 @@
#include "base/threading/thread.h"
#include "base/values.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/thumbnails/thumbnail_list_source.h"
#include "chrome/browser/ui/browser.h"
@@ -83,7 +84,8 @@ void MostVisitedHandler::RegisterMessages() {
content::URLDataSource::Add(
profile, new FaviconSource(profile, FaviconSource::FAVICON));
- history::TopSites* ts = profile->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(profile);
if (ts) {
// TopSites updates itself after a delay. This is especially noticable when
// your profile is empty. Ask TopSites to update itself when we're about to
@@ -93,7 +95,7 @@ void MostVisitedHandler::RegisterMessages() {
// Register for notification when TopSites changes so that we can update
// ourself.
registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
- content::Source<history::TopSites>(ts));
+ content::Source<history::TopSitesProvider>(ts));
}
// We pre-emptively make a fetch for the most visited pages so we have the
@@ -138,7 +140,8 @@ void MostVisitedHandler::SendPagesValue() {
const base::DictionaryValue* url_blacklist =
profile->GetPrefs()->GetDictionary(prefs::kNtpMostVisitedURLsBlacklist);
bool has_blacklisted_urls = !url_blacklist->empty();
- history::TopSites* ts = profile->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(profile);
if (ts)
has_blacklisted_urls = ts->HasBlacklistedItems();
@@ -151,7 +154,8 @@ void MostVisitedHandler::SendPagesValue() {
}
void MostVisitedHandler::StartQueryForMostVisited() {
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts) {
ts->GetMostVisitedURLs(
base::Bind(&MostVisitedHandler::OnMostVisitedUrlsAvailable,
@@ -177,7 +181,8 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist(
return;
}
content::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"));
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->RemoveBlacklistedURL(GURL(url));
}
@@ -186,7 +191,8 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist(
void MostVisitedHandler::HandleClearBlacklist(const base::ListValue* args) {
content::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"));
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->ClearBlacklistedURLs();
}
@@ -253,7 +259,8 @@ void MostVisitedHandler::Observe(int type,
}
void MostVisitedHandler::BlacklistUrl(const GURL& url) {
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ history::TopSitesProvider* ts =
+ TopSitesServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->AddBlacklistedURL(url);
content::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted"));

Powered by Google App Engine
This is Rietveld 408576698