| 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/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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "chrome/browser/android/popular_sites.h" | 20 #include "chrome/browser/android/popular_sites.h" |
| 20 #include "chrome/browser/history/top_sites_factory.h" | 21 #include "chrome/browser/history/top_sites_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_android.h" | 23 #include "chrome/browser/profiles/profile_android.h" |
| 23 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 24 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| 24 #include "chrome/browser/search/suggestions/suggestions_source.h" | 25 #include "chrome/browser/search/suggestions/suggestions_source.h" |
| 25 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bool ShouldShowPopularSites() { | 115 bool ShouldShowPopularSites() { |
| 115 // Note: It's important to query the field trial state first, to ensure that | 116 // Note: It's important to query the field trial state first, to ensure that |
| 116 // UMA reports the correct group. | 117 // UMA reports the correct group. |
| 117 const std::string group_name = | 118 const std::string group_name = |
| 118 base::FieldTrialList::FindFullName(kPopularSitesFieldTrialName); | 119 base::FieldTrialList::FindFullName(kPopularSitesFieldTrialName); |
| 119 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 120 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 120 if (cmd_line->HasSwitch(switches::kDisableNTPPopularSites)) | 121 if (cmd_line->HasSwitch(switches::kDisableNTPPopularSites)) |
| 121 return false; | 122 return false; |
| 122 if (cmd_line->HasSwitch(switches::kEnableNTPPopularSites)) | 123 if (cmd_line->HasSwitch(switches::kEnableNTPPopularSites)) |
| 123 return true; | 124 return true; |
| 124 return group_name == "Enabled"; | 125 return base::StartsWith(group_name, "Enabled", |
| 126 base::CompareCase::INSENSITIVE_ASCII); |
| 125 } | 127 } |
| 126 | 128 |
| 127 std::string GetPopularSitesFilename() { | 129 std::string GetPopularSitesFilename() { |
| 128 return variations::GetVariationParamValue(kPopularSitesFieldTrialName, | 130 return variations::GetVariationParamValue(kPopularSitesFieldTrialName, |
| 129 "filename"); | 131 "filename"); |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace | 134 } // namespace |
| 133 | 135 |
| 134 MostVisitedSites::MostVisitedSites(Profile* profile) | 136 MostVisitedSites::MostVisitedSites(Profile* profile) |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 590 } |
| 589 } | 591 } |
| 590 | 592 |
| 591 static jlong Init(JNIEnv* env, | 593 static jlong Init(JNIEnv* env, |
| 592 const JavaParamRef<jobject>& obj, | 594 const JavaParamRef<jobject>& obj, |
| 593 const JavaParamRef<jobject>& jprofile) { | 595 const JavaParamRef<jobject>& jprofile) { |
| 594 MostVisitedSites* most_visited_sites = | 596 MostVisitedSites* most_visited_sites = |
| 595 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); | 597 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); |
| 596 return reinterpret_cast<intptr_t>(most_visited_sites); | 598 return reinterpret_cast<intptr_t>(most_visited_sites); |
| 597 } | 599 } |
| OLD | NEW |