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

Side by Side Diff: chrome/browser/android/ntp/most_visited_sites.cc

Issue 1899683003: NTP tiles: Split C++ and Java MostVisitedSites classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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.h" 5 #include "chrome/browser/android/ntp/most_visited_sites.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h"
12 #include "base/android/scoped_java_ref.h"
13 #include "base/callback.h" 9 #include "base/callback.h"
14 #include "base/command_line.h" 10 #include "base/command_line.h"
15 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
17 #include "base/metrics/sparse_histogram.h" 13 #include "base/metrics/sparse_histogram.h"
18 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 18 #include "base/time/time.h"
23 #include "chrome/browser/android/ntp/popular_sites.h" 19 #include "chrome/browser/android/ntp/popular_sites.h"
24 #include "chrome/browser/history/top_sites_factory.h" 20 #include "chrome/browser/history/top_sites_factory.h"
25 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_android.h"
27 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 22 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
28 #include "chrome/browser/supervised_user/supervised_user_service.h" 23 #include "chrome/browser/supervised_user/supervised_user_service.h"
29 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 24 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
30 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 25 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
31 #include "chrome/browser/thumbnails/thumbnail_list_source.h" 26 #include "chrome/browser/thumbnails/thumbnail_list_source.h"
32 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
34 #include "components/history/core/browser/top_sites.h" 29 #include "components/history/core/browser/top_sites.h"
35 #include "components/pref_registry/pref_registry_syncable.h" 30 #include "components/pref_registry/pref_registry_syncable.h"
36 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
37 #include "components/variations/variations_associated_data.h" 32 #include "components/variations/variations_associated_data.h"
38 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/url_data_source.h" 34 #include "content/public/browser/url_data_source.h"
40 #include "jni/MostVisitedSites_jni.h"
41 #include "third_party/skia/include/core/SkBitmap.h" 35 #include "third_party/skia/include/core/SkBitmap.h"
42 #include "ui/gfx/android/java_bitmap.h"
43 #include "ui/gfx/codec/jpeg_codec.h" 36 #include "ui/gfx/codec/jpeg_codec.h"
44 #include "url/gurl.h" 37 #include "url/gurl.h"
45 38
46 using base::android::AttachCurrentThread;
47 using base::android::ConvertJavaStringToUTF8;
48 using base::android::ScopedJavaGlobalRef;
49 using base::android::ScopedJavaLocalRef;
50 using base::android::ToJavaArrayOfStrings;
51 using content::BrowserThread; 39 using content::BrowserThread;
52 using history::TopSites; 40 using history::TopSites;
53 using suggestions::ChromeSuggestion; 41 using suggestions::ChromeSuggestion;
54 using suggestions::SuggestionsProfile; 42 using suggestions::SuggestionsProfile;
55 using suggestions::SuggestionsService; 43 using suggestions::SuggestionsService;
56 using suggestions::SuggestionsServiceFactory; 44 using suggestions::SuggestionsServiceFactory;
57 45
58 namespace { 46 namespace {
59 47
60 // Identifiers for the various tile sources. 48 // Identifiers for the various tile sources.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 142 }
155 // The whole grid is already filled with personal suggestions, no point in 143 // The whole grid is already filled with personal suggestions, no point in
156 // bothering with popular ones. 144 // bothering with popular ones.
157 return false; 145 return false;
158 } 146 }
159 147
160 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) { 148 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) {
161 return url1.host() == url2.host() && url1.path() == url2.path(); 149 return url1.host() == url2.host() && url1.path() == url2.path();
162 } 150 }
163 151
164 class JavaObserverBridge : public MostVisitedSitesObserver {
165 public:
166 JavaObserverBridge(JNIEnv* env, const JavaParamRef<jobject>& obj)
167 : observer_(env, obj) {}
168
169 void OnMostVisitedURLsAvailable(
170 const std::vector<base::string16>& titles,
171 const std::vector<std::string>& urls,
172 const std::vector<std::string>& whitelist_icon_paths) override {
173 JNIEnv* env = AttachCurrentThread();
174 DCHECK_EQ(titles.size(), urls.size());
175 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
176 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(),
177 ToJavaArrayOfStrings(env, urls).obj(),
178 ToJavaArrayOfStrings(env, whitelist_icon_paths).obj());
179 }
180
181 void OnPopularURLsAvailable(
182 const std::vector<std::string>& urls,
183 const std::vector<std::string>& favicon_urls,
184 const std::vector<std::string>& large_icon_urls) override {
185 JNIEnv* env = AttachCurrentThread();
186 Java_MostVisitedURLsObserver_onPopularURLsAvailable(
187 env, observer_.obj(), ToJavaArrayOfStrings(env, urls).obj(),
188 ToJavaArrayOfStrings(env, favicon_urls).obj(),
189 ToJavaArrayOfStrings(env, large_icon_urls).obj());
190 }
191
192 private:
193 ScopedJavaGlobalRef<jobject> observer_;
194
195 DISALLOW_COPY_AND_ASSIGN(JavaObserverBridge);
196 };
197
198 } // namespace 152 } // namespace
199 153
200 MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {} 154 MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {}
201 155
202 MostVisitedSites::Suggestion::~Suggestion() {} 156 MostVisitedSites::Suggestion::~Suggestion() {}
203 157
204 std::string MostVisitedSites::Suggestion::GetSourceHistogramName() const { 158 std::string MostVisitedSites::Suggestion::GetSourceHistogramName() const {
205 switch (source) { 159 switch (source) {
206 case MostVisitedSites::TOP_SITES: 160 case MostVisitedSites::TOP_SITES:
207 return kHistogramClientName; 161 return kHistogramClientName;
208 case MostVisitedSites::POPULAR: 162 case MostVisitedSites::POPULAR:
209 return kHistogramPopularName; 163 return kHistogramPopularName;
210 case MostVisitedSites::WHITELIST: 164 case MostVisitedSites::WHITELIST:
211 return kHistogramWhitelistName; 165 return kHistogramWhitelistName;
212 case MostVisitedSites::SUGGESTIONS_SERVICE: 166 case MostVisitedSites::SUGGESTIONS_SERVICE:
213 return provider_index >= 0 167 return provider_index >= 0
214 ? base::StringPrintf(kHistogramServerFormat, provider_index) 168 ? base::StringPrintf(kHistogramServerFormat, provider_index)
215 : kHistogramServerName; 169 : kHistogramServerName;
216 } 170 }
217 NOTREACHED(); 171 NOTREACHED();
218 return std::string(); 172 return std::string();
219 } 173 }
220 174
221 MostVisitedSites::MostVisitedSites(Profile* profile) 175 MostVisitedSites::MostVisitedSites(Profile* profile)
222 : profile_(profile), num_sites_(0), received_most_visited_sites_(false), 176 : profile_(profile), observer_(nullptr), num_sites_(0),
223 received_popular_sites_(false), recorded_uma_(false), 177 received_most_visited_sites_(false), received_popular_sites_(false),
224 scoped_observer_(this), weak_ptr_factory_(this) { 178 recorded_uma_(false), scoped_observer_(this), weak_ptr_factory_(this) {
225 // Register the thumbnails debugging page. 179 // Register the thumbnails debugging page.
226 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); 180 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_));
227 181
228 SupervisedUserService* supervised_user_service = 182 SupervisedUserService* supervised_user_service =
229 SupervisedUserServiceFactory::GetForProfile(profile_); 183 SupervisedUserServiceFactory::GetForProfile(profile_);
230 supervised_user_service->AddObserver(this); 184 supervised_user_service->AddObserver(this);
231 } 185 }
232 186
233 MostVisitedSites::~MostVisitedSites() { 187 MostVisitedSites::~MostVisitedSites() {
234 SupervisedUserService* supervised_user_service = 188 SupervisedUserService* supervised_user_service =
235 SupervisedUserServiceFactory::GetForProfile(profile_); 189 SupervisedUserServiceFactory::GetForProfile(profile_);
236 supervised_user_service->RemoveObserver(this); 190 supervised_user_service->RemoveObserver(this);
237 } 191 }
238 192
239 void MostVisitedSites::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
240 delete this;
241 }
242
243 void MostVisitedSites::SetMostVisitedURLsObserver( 193 void MostVisitedSites::SetMostVisitedURLsObserver(
244 JNIEnv* env, 194 MostVisitedSitesObserver* observer, int num_sites) {
245 const JavaParamRef<jobject>& obj, 195 observer_ = observer;
246 const JavaParamRef<jobject>& j_observer,
247 jint num_sites) {
248 SetMostVisitedURLsObserver(
249 std::unique_ptr<MostVisitedSitesObserver>(
250 new JavaObserverBridge(env, j_observer)),
251 num_sites);
252 }
253
254 void MostVisitedSites::SetMostVisitedURLsObserver(
255 std::unique_ptr<MostVisitedSitesObserver> observer, int num_sites) {
256 observer_ = std::move(observer);
257 num_sites_ = num_sites; 196 num_sites_ = num_sites;
258 197
259 if (ShouldShowPopularSites() && 198 if (ShouldShowPopularSites() &&
260 NeedPopularSites(profile_->GetPrefs(), num_sites_)) { 199 NeedPopularSites(profile_->GetPrefs(), num_sites_)) {
261 popular_sites_.reset(new PopularSites( 200 popular_sites_.reset(new PopularSites(
262 profile_, 201 profile_,
263 GetPopularSitesCountry(), 202 GetPopularSitesCountry(),
264 GetPopularSitesVersion(), 203 GetPopularSitesVersion(),
265 false, 204 false,
266 base::Bind(&MostVisitedSites::OnPopularSitesAvailable, 205 base::Bind(&MostVisitedSites::OnPopularSitesAvailable,
(...skipping 20 matching lines...) Expand all
287 base::Unretained(this))); 226 base::Unretained(this)));
288 227
289 // Immediately get the current suggestions from the cache. If the cache is 228 // Immediately get the current suggestions from the cache. If the cache is
290 // empty, this will fall back to TopSites. 229 // empty, this will fall back to TopSites.
291 OnSuggestionsProfileAvailable( 230 OnSuggestionsProfileAvailable(
292 suggestions_service->GetSuggestionsDataFromCache()); 231 suggestions_service->GetSuggestionsDataFromCache());
293 // Also start a request for fresh suggestions. 232 // Also start a request for fresh suggestions.
294 suggestions_service->FetchSuggestionsData(); 233 suggestions_service->FetchSuggestionsData();
295 } 234 }
296 235
297 static void CallJavaWithBitmap(
298 std::unique_ptr<ScopedJavaGlobalRef<jobject>> j_callback,
299 bool is_local_thumbnail,
300 const SkBitmap* bitmap);
301
302 void MostVisitedSites::GetURLThumbnail(
303 JNIEnv* env,
304 const JavaParamRef<jobject>& obj,
305 const JavaParamRef<jstring>& j_url,
306 const JavaParamRef<jobject>& j_callback_obj) {
307 std::unique_ptr<ScopedJavaGlobalRef<jobject>> j_callback(
308 new ScopedJavaGlobalRef<jobject>(env, j_callback_obj));
309 auto callback = base::Bind(&CallJavaWithBitmap, base::Passed(&j_callback));
310 GURL url(ConvertJavaStringToUTF8(env, j_url));
311 GetURLThumbnail(url, callback);
312 }
313
314 void MostVisitedSites::GetURLThumbnail( 236 void MostVisitedSites::GetURLThumbnail(
315 const GURL& url, 237 const GURL& url,
316 const ThumbnailCallback& callback) { 238 const ThumbnailCallback& callback) {
317 DCHECK_CURRENTLY_ON(BrowserThread::UI); 239 DCHECK_CURRENTLY_ON(BrowserThread::UI);
318 scoped_refptr<TopSites> top_sites(TopSitesFactory::GetForProfile(profile_)); 240 scoped_refptr<TopSites> top_sites(TopSitesFactory::GetForProfile(profile_));
319 241
320 BrowserThread::PostTaskAndReplyWithResult( 242 BrowserThread::PostTaskAndReplyWithResult(
321 BrowserThread::DB, FROM_HERE, 243 BrowserThread::DB, FROM_HERE,
322 base::Bind(&MaybeFetchLocalThumbnail, url, top_sites), 244 base::Bind(&MaybeFetchLocalThumbnail, url, top_sites),
323 base::Bind(&MostVisitedSites::OnLocalThumbnailFetched, 245 base::Bind(&MostVisitedSites::OnLocalThumbnailFetched,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 284
363 void MostVisitedSites::OnObtainedThumbnail( 285 void MostVisitedSites::OnObtainedThumbnail(
364 bool is_local_thumbnail, 286 bool is_local_thumbnail,
365 const ThumbnailCallback& callback, 287 const ThumbnailCallback& callback,
366 const GURL& url, 288 const GURL& url,
367 const SkBitmap* bitmap) { 289 const SkBitmap* bitmap) {
368 DCHECK_CURRENTLY_ON(BrowserThread::UI); 290 DCHECK_CURRENTLY_ON(BrowserThread::UI);
369 callback.Run(is_local_thumbnail, bitmap); 291 callback.Run(is_local_thumbnail, bitmap);
370 } 292 }
371 293
372 static void CallJavaWithBitmap(
373 std::unique_ptr<ScopedJavaGlobalRef<jobject>> j_callback,
374 bool is_local_thumbnail,
375 const SkBitmap* bitmap) {
376 JNIEnv* env = AttachCurrentThread();
377 ScopedJavaLocalRef<jobject> j_bitmap;
378 if (bitmap)
379 j_bitmap = gfx::ConvertToJavaBitmap(bitmap);
380 Java_ThumbnailCallback_onMostVisitedURLsThumbnailAvailable(
381 env, j_callback->obj(), j_bitmap.obj(), is_local_thumbnail);
382 }
383
384 void MostVisitedSites::AddOrRemoveBlacklistedUrl(
385 JNIEnv* env,
386 const JavaParamRef<jobject>& obj,
387 const JavaParamRef<jstring>& j_url,
388 jboolean add_url) {
389 GURL url(ConvertJavaStringToUTF8(env, j_url));
390 AddOrRemoveBlacklistedUrl(url, add_url);
391 }
392
393 void MostVisitedSites::AddOrRemoveBlacklistedUrl( 294 void MostVisitedSites::AddOrRemoveBlacklistedUrl(
394 const GURL& url, bool add_url) { 295 const GURL& url, bool add_url) {
395 // Always blacklist in the local TopSites. 296 // Always blacklist in the local TopSites.
396 scoped_refptr<TopSites> top_sites = TopSitesFactory::GetForProfile(profile_); 297 scoped_refptr<TopSites> top_sites = TopSitesFactory::GetForProfile(profile_);
397 if (top_sites) { 298 if (top_sites) {
398 if (add_url) 299 if (add_url)
399 top_sites->AddBlacklistedURL(url); 300 top_sites->AddBlacklistedURL(url);
400 else 301 else
401 top_sites->RemoveBlacklistedURL(url); 302 top_sites->RemoveBlacklistedURL(url);
402 } 303 }
403 304
404 // Only blacklist in the server-side suggestions service if it's active. 305 // Only blacklist in the server-side suggestions service if it's active.
405 if (mv_source_ == SUGGESTIONS_SERVICE) { 306 if (mv_source_ == SUGGESTIONS_SERVICE) {
406 SuggestionsService* suggestions_service = 307 SuggestionsService* suggestions_service =
407 SuggestionsServiceFactory::GetForProfile(profile_); 308 SuggestionsServiceFactory::GetForProfile(profile_);
408 if (add_url) 309 if (add_url)
409 suggestions_service->BlacklistURL(url); 310 suggestions_service->BlacklistURL(url);
410 else 311 else
411 suggestions_service->UndoBlacklistURL(url); 312 suggestions_service->UndoBlacklistURL(url);
412 } 313 }
413 } 314 }
414 315
415 void MostVisitedSites::RecordTileTypeMetrics( 316 void MostVisitedSites::RecordTileTypeMetrics(
416 JNIEnv* env,
417 const JavaParamRef<jobject>& obj,
418 const JavaParamRef<jintArray>& jtile_types) {
419 std::vector<int> tile_types;
420 base::android::JavaIntArrayToIntVector(env, jtile_types, &tile_types);
421 DCHECK_EQ(current_suggestions_.size(), tile_types.size());
422 RecordTileTypeMetrics(tile_types);
423 }
424
425 void MostVisitedSites::RecordTileTypeMetrics(
426 const std::vector<int>& tile_types) { 317 const std::vector<int>& tile_types) {
318 DCHECK_EQ(current_suggestions_.size(), tile_types.size());
427 int counts_per_type[NUM_TILE_TYPES] = {0}; 319 int counts_per_type[NUM_TILE_TYPES] = {0};
428 for (size_t i = 0; i < tile_types.size(); ++i) { 320 for (size_t i = 0; i < tile_types.size(); ++i) {
429 int tile_type = tile_types[i]; 321 int tile_type = tile_types[i];
430 ++counts_per_type[tile_type]; 322 ++counts_per_type[tile_type];
431 std::string histogram = base::StringPrintf( 323 std::string histogram = base::StringPrintf(
432 "NewTabPage.TileType.%s", 324 "NewTabPage.TileType.%s",
433 current_suggestions_[i]->GetSourceHistogramName().c_str()); 325 current_suggestions_[i]->GetSourceHistogramName().c_str());
434 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); 326 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES);
435 } 327 }
436 328
437 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", 329 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal",
438 counts_per_type[ICON_REAL]); 330 counts_per_type[ICON_REAL]);
439 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", 331 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor",
440 counts_per_type[ICON_COLOR]); 332 counts_per_type[ICON_COLOR]);
441 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", 333 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray",
442 counts_per_type[ICON_DEFAULT]); 334 counts_per_type[ICON_DEFAULT]);
443 } 335 }
444 336
445 void MostVisitedSites::RecordOpenedMostVisitedItem(
446 JNIEnv* env,
447 const JavaParamRef<jobject>& obj,
448 jint index,
449 jint tile_type) {
450 RecordOpenedMostVisitedItem(index, tile_type);
451 }
452
453 void MostVisitedSites::RecordOpenedMostVisitedItem(int index, int tile_type) { 337 void MostVisitedSites::RecordOpenedMostVisitedItem(int index, int tile_type) {
454 DCHECK_GE(index, 0); 338 DCHECK_GE(index, 0);
455 DCHECK_LT(index, static_cast<int>(current_suggestions_.size())); 339 DCHECK_LT(index, static_cast<int>(current_suggestions_.size()));
456 std::string histogram = base::StringPrintf( 340 std::string histogram = base::StringPrintf(
457 "NewTabPage.MostVisited.%s", 341 "NewTabPage.MostVisited.%s",
458 current_suggestions_[index]->GetSourceHistogramName().c_str()); 342 current_suggestions_[index]->GetSourceHistogramName().c_str());
459 LogHistogramEvent(histogram, index, num_sites_); 343 LogHistogramEvent(histogram, index, num_sites_);
460 344
461 histogram = base::StringPrintf( 345 histogram = base::StringPrintf(
462 "NewTabPage.TileTypeClicked.%s", 346 "NewTabPage.TileTypeClicked.%s",
463 current_suggestions_[index]->GetSourceHistogramName().c_str()); 347 current_suggestions_[index]->GetSourceHistogramName().c_str());
464 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); 348 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES);
465 } 349 }
466 350
467 void MostVisitedSites::OnURLFilterChanged() { 351 void MostVisitedSites::OnURLFilterChanged() {
468 QueryMostVisitedURLs(); 352 QueryMostVisitedURLs();
469 } 353 }
470 354
471 // static 355 // static
472 bool MostVisitedSites::Register(JNIEnv* env) {
473 return RegisterNativesImpl(env);
474 }
475
476 // static
477 void MostVisitedSites::RegisterProfilePrefs( 356 void MostVisitedSites::RegisterProfilePrefs(
478 user_prefs::PrefRegistrySyncable* registry) { 357 user_prefs::PrefRegistrySyncable* registry) {
479 registry->RegisterListPref(prefs::kNTPSuggestionsURL); 358 registry->RegisterListPref(prefs::kNTPSuggestionsURL);
480 registry->RegisterListPref(prefs::kNTPSuggestionsIsPersonal); 359 registry->RegisterListPref(prefs::kNTPSuggestionsIsPersonal);
481 } 360 }
482 361
483 void MostVisitedSites::QueryMostVisitedURLs() { 362 void MostVisitedSites::QueryMostVisitedURLs() {
484 SuggestionsService* suggestions_service = 363 SuggestionsService* suggestions_service =
485 SuggestionsServiceFactory::GetForProfile(profile_); 364 SuggestionsServiceFactory::GetForProfile(profile_);
486 if (suggestions_service->FetchSuggestionsData()) { 365 if (suggestions_service->FetchSuggestionsData()) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 798
920 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} 799 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
921 800
922 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 801 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
923 ChangeReason change_reason) { 802 ChangeReason change_reason) {
924 if (mv_source_ == TOP_SITES) { 803 if (mv_source_ == TOP_SITES) {
925 // The displayed suggestions are invalidated. 804 // The displayed suggestions are invalidated.
926 InitiateTopSitesQuery(); 805 InitiateTopSitesQuery();
927 } 806 }
928 } 807 }
929
930 static jlong Init(JNIEnv* env,
931 const JavaParamRef<jobject>& obj,
932 const JavaParamRef<jobject>& jprofile) {
933 MostVisitedSites* most_visited_sites =
934 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
935 return reinterpret_cast<intptr_t>(most_visited_sites);
936 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites.h ('k') | chrome/browser/android/ntp/most_visited_sites_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698