OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/android/ntp/most_visited_sites_bridge.h" | 5 #include "chrome/browser/android/ntp/most_visited_sites_bridge.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "chrome/browser/android/ntp/popular_sites.h" | 16 #include "chrome/browser/android/ntp/popular_sites.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/history/top_sites_factory.h" | 18 #include "chrome/browser/history/top_sites_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_android.h" | 20 #include "chrome/browser/profiles/profile_android.h" |
20 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 21 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
22 #include "chrome/browser/supervised_user/supervised_user_service.h" | 23 #include "chrome/browser/supervised_user/supervised_user_service.h" |
23 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 24 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
24 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 25 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 large_icon_urls.emplace_back(site.large_icon_url.spec()); | 152 large_icon_urls.emplace_back(site.large_icon_url.spec()); |
152 } | 153 } |
153 Java_MostVisitedURLsObserver_onPopularURLsAvailable( | 154 Java_MostVisitedURLsObserver_onPopularURLsAvailable( |
154 env, observer_, ToJavaArrayOfStrings(env, urls), | 155 env, observer_, ToJavaArrayOfStrings(env, urls), |
155 ToJavaArrayOfStrings(env, favicon_urls), | 156 ToJavaArrayOfStrings(env, favicon_urls), |
156 ToJavaArrayOfStrings(env, large_icon_urls)); | 157 ToJavaArrayOfStrings(env, large_icon_urls)); |
157 } | 158 } |
158 | 159 |
159 MostVisitedSitesBridge::MostVisitedSitesBridge(Profile* profile) | 160 MostVisitedSitesBridge::MostVisitedSitesBridge(Profile* profile) |
160 : supervisor_(profile), | 161 : supervisor_(profile), |
161 popular_sites_(BrowserThread::GetBlockingPool(), | |
162 profile->GetPrefs(), | |
163 TemplateURLServiceFactory::GetForProfile(profile), | |
164 g_browser_process->variations_service(), | |
165 profile->GetRequestContext(), | |
166 ChromePopularSites::GetDirectory(), | |
167 base::Bind(safe_json::SafeJsonParser::Parse)), | |
168 most_visited_(profile->GetPrefs(), | 162 most_visited_(profile->GetPrefs(), |
169 TopSitesFactory::GetForProfile(profile), | 163 TopSitesFactory::GetForProfile(profile), |
170 SuggestionsServiceFactory::GetForProfile(profile), | 164 SuggestionsServiceFactory::GetForProfile(profile), |
171 &popular_sites_, | 165 base::MakeUnique<ntp_tiles::PopularSites>( |
| 166 BrowserThread::GetBlockingPool(), |
| 167 profile->GetPrefs(), |
| 168 TemplateURLServiceFactory::GetForProfile(profile), |
| 169 g_browser_process->variations_service(), |
| 170 profile->GetRequestContext(), |
| 171 ChromePopularSites::GetDirectory(), |
| 172 base::Bind(safe_json::SafeJsonParser::Parse)), |
172 &supervisor_) { | 173 &supervisor_) { |
173 // Register the thumbnails debugging page. | 174 // Register the thumbnails debugging page. |
174 // TODO(sfiera): find thumbnails a home. They don't belong here. | 175 // TODO(sfiera): find thumbnails a home. They don't belong here. |
175 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); | 176 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); |
176 } | 177 } |
177 | 178 |
178 MostVisitedSitesBridge::~MostVisitedSitesBridge() {} | 179 MostVisitedSitesBridge::~MostVisitedSitesBridge() {} |
179 | 180 |
180 void MostVisitedSitesBridge::Destroy( | 181 void MostVisitedSitesBridge::Destroy( |
181 JNIEnv* env, const JavaParamRef<jobject>& obj) { | 182 JNIEnv* env, const JavaParamRef<jobject>& obj) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 230 } |
230 | 231 |
231 static jlong Init(JNIEnv* env, | 232 static jlong Init(JNIEnv* env, |
232 const JavaParamRef<jobject>& obj, | 233 const JavaParamRef<jobject>& obj, |
233 const JavaParamRef<jobject>& jprofile) { | 234 const JavaParamRef<jobject>& jprofile) { |
234 MostVisitedSitesBridge* most_visited_sites = | 235 MostVisitedSitesBridge* most_visited_sites = |
235 new MostVisitedSitesBridge( | 236 new MostVisitedSitesBridge( |
236 ProfileAndroid::FromProfileAndroid(jprofile)); | 237 ProfileAndroid::FromProfileAndroid(jprofile)); |
237 return reinterpret_cast<intptr_t>(most_visited_sites); | 238 return reinterpret_cast<intptr_t>(most_visited_sites); |
238 } | 239 } |
OLD | NEW |