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..92dc75eee13ee9028b752b6d3cacddf926498626 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,8 +84,9 @@ void MostVisitedHandler::RegisterMessages() { |
content::URLDataSource::Add( |
profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
- history::TopSites* ts = profile->GetTopSites(); |
- if (ts) { |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(profile); |
+ if (ts.get()) { |
// 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 |
// show the new tab page. |
@@ -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::TopSites>(ts.get())); |
} |
// We pre-emptively make a fetch for the most visited pages so we have the |
@@ -138,8 +140,9 @@ 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(); |
- if (ts) |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(profile); |
+ if (ts.get()) |
has_blacklisted_urls = ts->HasBlacklistedItems(); |
base::FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls); |
@@ -151,8 +154,9 @@ void MostVisitedHandler::SendPagesValue() { |
} |
void MostVisitedHandler::StartQueryForMostVisited() { |
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites(); |
- if (ts) { |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
+ if (ts.get()) { |
ts->GetMostVisitedURLs( |
base::Bind(&MostVisitedHandler::OnMostVisitedUrlsAvailable, |
weak_ptr_factory_.GetWeakPtr()), false); |
@@ -177,8 +181,9 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist( |
return; |
} |
content::RecordAction(UserMetricsAction("MostVisited_UrlRemoved")); |
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites(); |
- if (ts) |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
+ if (ts.get()) |
ts->RemoveBlacklistedURL(GURL(url)); |
} |
} |
@@ -186,8 +191,9 @@ void MostVisitedHandler::HandleRemoveUrlsFromBlacklist( |
void MostVisitedHandler::HandleClearBlacklist(const base::ListValue* args) { |
content::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared")); |
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites(); |
- if (ts) |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
+ if (ts.get()) |
ts->ClearBlacklistedURLs(); |
} |
@@ -253,8 +259,9 @@ void MostVisitedHandler::Observe(int type, |
} |
void MostVisitedHandler::BlacklistUrl(const GURL& url) { |
- history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites(); |
- if (ts) |
+ scoped_refptr<history::TopSites> ts = |
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
+ if (ts.get()) |
ts->AddBlacklistedURL(url); |
content::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted")); |
} |