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

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

Issue 1272883004: Popular sites on the NTP: Favicons! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enable_popular_sites
Patch Set: review2 Created 5 years, 4 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
« no previous file with comments | « chrome/browser/android/favicon_helper.cc ('k') | chrome/browser/android/popular_sites.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/most_visited_sites.h" 5 #include "chrome/browser/android/most_visited_sites.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(), 445 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(),
446 ToJavaArrayOfStrings(env, urls).obj()); 446 ToJavaArrayOfStrings(env, urls).obj());
447 } 447 }
448 448
449 void MostVisitedSites::OnPopularSitesAvailable(bool success) { 449 void MostVisitedSites::OnPopularSitesAvailable(bool success) {
450 if (!success) { 450 if (!success) {
451 LOG(WARNING) << "Download of popular sites failed"; 451 LOG(WARNING) << "Download of popular sites failed";
452 return; 452 return;
453 } 453 }
454 454
455 if (!observer_.is_null()) 455 if (observer_.is_null())
456 QueryMostVisitedURLs(); 456 return;
457
458 std::vector<std::string> urls;
459 std::vector<std::string> favicon_urls;
460 for (const PopularSites::Site& popular_site : popular_sites_->sites()) {
461 urls.push_back(popular_site.url.spec());
462 favicon_urls.push_back(popular_site.favicon_url.spec());
463 }
464 JNIEnv* env = AttachCurrentThread();
465 Java_MostVisitedURLsObserver_onPopularURLsAvailable(
466 env, observer_.obj(), ToJavaArrayOfStrings(env, urls).obj(),
467 ToJavaArrayOfStrings(env, favicon_urls).obj());
468
469 QueryMostVisitedURLs();
457 } 470 }
458 471
459 void MostVisitedSites::RecordUMAMetrics() { 472 void MostVisitedSites::RecordUMAMetrics() {
460 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumLocalThumbnailTilesHistogramName, 473 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumLocalThumbnailTilesHistogramName,
461 num_local_thumbs_); 474 num_local_thumbs_);
462 num_local_thumbs_ = 0; 475 num_local_thumbs_ = 0;
463 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumEmptyTilesHistogramName, num_empty_thumbs_); 476 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumEmptyTilesHistogramName, num_empty_thumbs_);
464 num_empty_thumbs_ = 0; 477 num_empty_thumbs_ = 0;
465 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); 478 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_);
466 num_server_thumbs_ = 0; 479 num_server_thumbs_ = 0;
467 } 480 }
468 481
469 void MostVisitedSites::TopSitesLoaded(history::TopSites* top_sites) { 482 void MostVisitedSites::TopSitesLoaded(history::TopSites* top_sites) {
470 } 483 }
471 484
472 void MostVisitedSites::TopSitesChanged(history::TopSites* top_sites, 485 void MostVisitedSites::TopSitesChanged(history::TopSites* top_sites,
473 ChangeReason change_reason) { 486 ChangeReason change_reason) {
474 if (mv_source_ == TOP_SITES) { 487 if (mv_source_ == TOP_SITES) {
475 // The displayed suggestions are invalidated. 488 // The displayed suggestions are invalidated.
476 QueryMostVisitedURLs(); 489 QueryMostVisitedURLs();
477 } 490 }
478 } 491 }
479 492
480 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { 493 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) {
481 MostVisitedSites* most_visited_sites = 494 MostVisitedSites* most_visited_sites =
482 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 495 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
483 return reinterpret_cast<intptr_t>(most_visited_sites); 496 return reinterpret_cast<intptr_t>(most_visited_sites);
484 } 497 }
OLDNEW
« no previous file with comments | « chrome/browser/android/favicon_helper.cc ('k') | chrome/browser/android/popular_sites.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698