Chromium Code Reviews| 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..d9671a79b29638e03e2e7c31c802e08ab113a0c3 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,8 @@ 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()) { |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| // 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 +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, |
| - content::Source<history::TopSites>(ts)); |
| + content::Source<history::TopSites>(ts.get())); |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| } |
| // We pre-emptively make a fetch for the most visited pages so we have the |
| @@ -138,8 +139,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()) |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| has_blacklisted_urls = ts->HasBlacklistedItems(); |
| base::FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls); |
| @@ -151,8 +153,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()) { |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| ts->GetMostVisitedURLs( |
| base::Bind(&MostVisitedHandler::OnMostVisitedUrlsAvailable, |
| weak_ptr_factory_.GetWeakPtr()), false); |
| @@ -177,8 +180,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()) |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| ts->RemoveBlacklistedURL(GURL(url)); |
| } |
| } |
| @@ -186,8 +190,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()) |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| ts->ClearBlacklistedURLs(); |
| } |
| @@ -253,8 +258,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()) |
|
Bernhard Bauer
2015/01/08 10:22:05
Remove .get().
Jitu( very slow this week)
2015/01/12 11:30:08
Done.
|
| ts->AddBlacklistedURL(url); |
| content::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted")); |
| } |