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

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: For trybot 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
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..662e7b3bc7fd19852f50b83bf9afe792312bbf1b 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
@@ -22,6 +22,7 @@
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/top_sites_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,7 @@ void MostVisitedHandler::RegisterMessages() {
content::URLDataSource::Add(
profile, new FaviconSource(profile, FaviconSource::FAVICON));
- history::TopSites* ts = profile->GetTopSites();
+ scoped_refptr<history::TopSites> ts = TopSitesFactory::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 +94,7 @@ void MostVisitedHandler::RegisterMessages() {
// Register for notification when TopSites changes so that we can update
// ourself.
registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
sdefresne 2015/01/21 17:57:23 Same here, you have a conflict with upstream that
sdefresne 2015/01/21 17:57:24 Same here, you have a conflict with upstream that
- content::Source<history::TopSites>(ts));
+ content::Source<history::TopSites>(ts.get()));
}
// We pre-emptively make a fetch for the most visited pages so we have the
@@ -138,7 +139,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();
+ scoped_refptr<history::TopSites> ts =
+ TopSitesFactory::GetForProfile(profile);
if (ts)
has_blacklisted_urls = ts->HasBlacklistedItems();
@@ -151,7 +153,8 @@ void MostVisitedHandler::SendPagesValue() {
}
void MostVisitedHandler::StartQueryForMostVisited() {
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ scoped_refptr<history::TopSites> ts =
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts) {
ts->GetMostVisitedURLs(
base::Bind(&MostVisitedHandler::OnMostVisitedUrlsAvailable,
@@ -177,7 +180,8 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist(
return;
}
content::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"));
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ scoped_refptr<history::TopSites> ts =
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->RemoveBlacklistedURL(GURL(url));
}
@@ -186,7 +190,8 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist(
void MostVisitedHandler::HandleClearBlacklist(const base::ListValue* args) {
content::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"));
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ scoped_refptr<history::TopSites> ts =
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->ClearBlacklistedURLs();
}
@@ -253,7 +258,8 @@ void MostVisitedHandler::Observe(int type,
}
void MostVisitedHandler::BlacklistUrl(const GURL& url) {
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
+ scoped_refptr<history::TopSites> ts =
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (ts)
ts->AddBlacklistedURL(url);
content::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted"));

Powered by Google App Engine
This is Rietveld 408576698