| Index: components/ntp_tiles/most_visited_sites.cc
|
| diff --git a/components/ntp_tiles/most_visited_sites.cc b/components/ntp_tiles/most_visited_sites.cc
|
| index e78b0e01b380ebd801ca8e02cffa04a62c688b9a..42fa3f41994892ef83def7ca9fc164d5b430d7bf 100644
|
| --- a/components/ntp_tiles/most_visited_sites.cc
|
| +++ b/components/ntp_tiles/most_visited_sites.cc
|
| @@ -9,18 +9,12 @@
|
| #include <string>
|
| #include <utility>
|
|
|
| -#if defined(OS_ANDROID)
|
| -#include <jni.h>
|
| -#endif
|
| -
|
| #include "base/callback.h"
|
| -#include "base/command_line.h"
|
| #include "base/feature_list.h"
|
| -#include "base/metrics/field_trial.h"
|
| -#include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "components/history/core/browser/top_sites.h"
|
| #include "components/ntp_tiles/constants.h"
|
| +#include "components/ntp_tiles/field_trial.h"
|
| #include "components/ntp_tiles/icon_cacher.h"
|
| #include "components/ntp_tiles/metrics.h"
|
| #include "components/ntp_tiles/pref_names.h"
|
| @@ -28,11 +22,6 @@
|
| #include "components/pref_registry/pref_registry_syncable.h"
|
| #include "components/prefs/pref_service.h"
|
|
|
| -#if defined(OS_ANDROID)
|
| -#include "base/android/jni_android.h"
|
| -#include "jni/MostVisitedSites_jni.h"
|
| -#endif
|
| -
|
| using history::TopSites;
|
| using suggestions::ChromeSuggestion;
|
| using suggestions::SuggestionsProfile;
|
| @@ -45,30 +34,6 @@ namespace {
|
| const base::Feature kDisplaySuggestionsServiceTiles{
|
| "DisplaySuggestionsServiceTiles", base::FEATURE_ENABLED_BY_DEFAULT};
|
|
|
| -bool ShouldShowPopularSites() {
|
| - // Note: It's important to query the field trial state first, to ensure that
|
| - // UMA reports the correct group.
|
| - const std::string group_name =
|
| - base::FieldTrialList::FindFullName(kPopularSitesFieldTrialName);
|
| -
|
| - base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
|
| - if (cmd_line->HasSwitch(switches::kDisableNTPPopularSites))
|
| - return false;
|
| -
|
| - if (cmd_line->HasSwitch(switches::kEnableNTPPopularSites))
|
| - return true;
|
| -
|
| -#if defined(OS_ANDROID)
|
| - if (Java_MostVisitedSites_isPopularSitesForceEnabled(
|
| - base::android::AttachCurrentThread())) {
|
| - return true;
|
| - }
|
| -#endif
|
| -
|
| - return base::StartsWith(group_name, "Enabled",
|
| - base::CompareCase::INSENSITIVE_ASCII);
|
| -}
|
| -
|
| // Determine whether we need any tiles from PopularSites to fill up a grid of
|
| // |num_tiles| tiles.
|
| bool NeedPopularSites(const PrefService* prefs, int num_tiles) {
|
| @@ -121,8 +86,10 @@ void MostVisitedSites::SetMostVisitedURLsObserver(Observer* observer,
|
| observer_ = observer;
|
| num_sites_ = num_sites;
|
|
|
| - if (popular_sites_ && ShouldShowPopularSites() &&
|
| - NeedPopularSites(prefs_, num_sites_)) {
|
| + // The order for this condition is important, ShouldShowPopularSite() should
|
| + // always be called last to keep metrics as relevant as possible.
|
| + if (popular_sites_ && NeedPopularSites(prefs_, num_sites_) &&
|
| + ShouldShowPopularSites()) {
|
| popular_sites_->StartFetch(
|
| false, base::Bind(&MostVisitedSites::OnPopularSitesAvailable,
|
| base::Unretained(this)));
|
|
|