Chromium Code Reviews| Index: chrome/browser/android/most_visited_sites.cc |
| diff --git a/chrome/browser/android/most_visited_sites.cc b/chrome/browser/android/most_visited_sites.cc |
| index ed6a5d7e6c99f021adc36875f7574bf2b4908c3b..15979370a6a2778df5020c6b3b5756b0c4abf448 100644 |
| --- a/chrome/browser/android/most_visited_sites.cc |
| +++ b/chrome/browser/android/most_visited_sites.cc |
| @@ -20,6 +20,7 @@ |
| #include "base/time/time.h" |
| #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/profiles/profile_android.h" |
| #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| @@ -232,8 +233,9 @@ void MostVisitedSites::SetMostVisitedURLsObserver(JNIEnv* env, |
| QueryMostVisitedURLs(); |
| - history::TopSites* top_sites = profile_->GetTopSites(); |
| - if (top_sites) { |
| + scoped_refptr<history::TopSites> top_sites = |
| + TopSitesServiceFactory::GetForProfile(profile_); |
| + if (top_sites.get()) { |
| // TopSites updates itself after a delay. To ensure up-to-date results, |
| // force an update now. |
| top_sites->SyncWithHistory(); |
| @@ -241,7 +243,7 @@ void MostVisitedSites::SetMostVisitedURLsObserver(JNIEnv* env, |
| // Register for notification when TopSites changes so that we can update |
| // ourself. |
| registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| - content::Source<history::TopSites>(top_sites)); |
| + content::Source<history::TopSites>(top_sites.get())); |
| } |
| } |
| @@ -256,7 +258,8 @@ void MostVisitedSites::GetURLThumbnail(JNIEnv* env, |
| j_callback->Reset(env, j_callback_obj); |
| std::string url_string = ConvertJavaStringToUTF8(env, url); |
| - scoped_refptr<TopSites> top_sites(profile_->GetTopSites()); |
| + scoped_refptr<TopSites> top_sites( |
| + TopSitesServiceFactory::GetForProfile(profile_)); |
| // If the Suggestions service is enabled and in use, create a callback to |
| // fetch a server thumbnail from it, in case the local thumbnail is not found. |
| @@ -276,10 +279,9 @@ void MostVisitedSites::GetURLThumbnail(JNIEnv* env, |
| BrowserThread::PostTask( |
| BrowserThread::DB, FROM_HERE, |
| - base::Bind( |
| - &GetUrlThumbnailTask, url_string, top_sites, |
| - base::Owned(j_callback), lookup_success_callback, |
| - lookup_failed_callback)); |
| + base::Bind(&GetUrlThumbnailTask, url_string, top_sites, |
| + base::Owned(j_callback), lookup_success_callback, |
| + lookup_failed_callback)); |
| } |
| void MostVisitedSites::BlacklistUrl(JNIEnv* env, |
| @@ -289,8 +291,9 @@ void MostVisitedSites::BlacklistUrl(JNIEnv* env, |
| switch (mv_source_) { |
| case TOP_SITES: { |
| - TopSites* top_sites = profile_->GetTopSites(); |
| - DCHECK(top_sites); |
| + scoped_refptr<TopSites> top_sites = |
| + TopSitesServiceFactory::GetForProfile(profile_); |
| + DCHECK(top_sites.get()); |
| top_sites->AddBlacklistedURL(GURL(url)); |
| break; |
| } |
| @@ -377,16 +380,16 @@ void MostVisitedSites::QueryMostVisitedURLs() { |
| } |
| void MostVisitedSites::InitiateTopSitesQuery() { |
| - TopSites* top_sites = profile_->GetTopSites(); |
| - if (!top_sites) |
| + scoped_refptr<TopSites> top_sites = |
| + TopSitesServiceFactory::GetForProfile(profile_); |
| + if (top_sites.get() == NULL) |
|
sdefresne
2014/12/29 09:48:14
nit: "if (!top_sites)" should work here and everyw
Jitu( very slow this week)
2014/12/30 10:09:02
Done.
|
| return; |
| top_sites->GetMostVisitedURLs( |
| - base::Bind( |
| - &MostVisitedSites::OnMostVisitedURLsAvailable, |
| - weak_ptr_factory_.GetWeakPtr(), |
| - base::Owned(new ScopedJavaGlobalRef<jobject>(observer_)), |
| - num_sites_), |
| + base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + base::Owned(new ScopedJavaGlobalRef<jobject>(observer_)), |
| + num_sites_), |
| false); |
| } |