| 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.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" | 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/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "chrome/browser/android/ntp/popular_sites.h" | 23 #include "chrome/browser/android/ntp/popular_sites.h" |
| 24 #include "chrome/browser/history/top_sites_factory.h" | 24 #include "chrome/browser/history/top_sites_factory.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_android.h" | 26 #include "chrome/browser/profiles/profile_android.h" |
| 27 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 27 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| 28 #include "chrome/browser/search/suggestions/suggestions_source.h" | |
| 29 #include "chrome/browser/supervised_user/supervised_user_service.h" | 28 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 30 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 29 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 31 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 30 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 32 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 31 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 35 #include "components/history/core/browser/top_sites.h" | 34 #include "components/history/core/browser/top_sites.h" |
| 36 #include "components/pref_registry/pref_registry_syncable.h" | 35 #include "components/pref_registry/pref_registry_syncable.h" |
| 37 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
| 38 #include "components/variations/variations_associated_data.h" | 37 #include "components/variations/variations_associated_data.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 : kHistogramServerName; | 181 : kHistogramServerName; |
| 183 } | 182 } |
| 184 NOTREACHED(); | 183 NOTREACHED(); |
| 185 return std::string(); | 184 return std::string(); |
| 186 } | 185 } |
| 187 | 186 |
| 188 MostVisitedSites::MostVisitedSites(Profile* profile) | 187 MostVisitedSites::MostVisitedSites(Profile* profile) |
| 189 : profile_(profile), num_sites_(0), received_most_visited_sites_(false), | 188 : profile_(profile), num_sites_(0), received_most_visited_sites_(false), |
| 190 received_popular_sites_(false), recorded_uma_(false), | 189 received_popular_sites_(false), recorded_uma_(false), |
| 191 scoped_observer_(this), weak_ptr_factory_(this) { | 190 scoped_observer_(this), weak_ptr_factory_(this) { |
| 192 // Register the debugging page for the Suggestions Service and the thumbnails | 191 // Register the thumbnails debugging page. |
| 193 // debugging page. | |
| 194 content::URLDataSource::Add(profile_, | |
| 195 new suggestions::SuggestionsSource(profile_)); | |
| 196 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); | 192 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
| 197 | 193 |
| 198 SupervisedUserService* supervised_user_service = | 194 SupervisedUserService* supervised_user_service = |
| 199 SupervisedUserServiceFactory::GetForProfile(profile_); | 195 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 200 supervised_user_service->AddObserver(this); | 196 supervised_user_service->AddObserver(this); |
| 201 } | 197 } |
| 202 | 198 |
| 203 MostVisitedSites::~MostVisitedSites() { | 199 MostVisitedSites::~MostVisitedSites() { |
| 204 SupervisedUserService* supervised_user_service = | 200 SupervisedUserService* supervised_user_service = |
| 205 SupervisedUserServiceFactory::GetForProfile(profile_); | 201 SupervisedUserServiceFactory::GetForProfile(profile_); |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 867 } |
| 872 } | 868 } |
| 873 | 869 |
| 874 static jlong Init(JNIEnv* env, | 870 static jlong Init(JNIEnv* env, |
| 875 const JavaParamRef<jobject>& obj, | 871 const JavaParamRef<jobject>& obj, |
| 876 const JavaParamRef<jobject>& jprofile) { | 872 const JavaParamRef<jobject>& jprofile) { |
| 877 MostVisitedSites* most_visited_sites = | 873 MostVisitedSites* most_visited_sites = |
| 878 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); | 874 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); |
| 879 return reinterpret_cast<intptr_t>(most_visited_sites); | 875 return reinterpret_cast<intptr_t>(most_visited_sites); |
| 880 } | 876 } |
| OLD | NEW |