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

Unified Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2172203002: Enable Popular Sites in Android demo mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: x Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | tools/android/eclipse/.classpath » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 236ad773be75d2115c55005df7537931612c60dc..ee951a3322c47d90916834030913710b0b197ef5 100644
--- a/components/ntp_tiles/most_visited_sites.cc
+++ b/components/ntp_tiles/most_visited_sites.cc
@@ -9,6 +9,10 @@
#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"
@@ -27,6 +31,11 @@
#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;
@@ -66,11 +75,21 @@ bool ShouldShowPopularSites() {
// 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);
}
@@ -166,6 +185,13 @@ MostVisitedSites::~MostVisitedSites() {
supervisor_->SetObserver(nullptr);
}
+#if defined(OS_ANDROID)
+// static
+bool MostVisitedSites::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+#endif
+
void MostVisitedSites::SetMostVisitedURLsObserver(Observer* observer,
int num_sites) {
DCHECK(observer);
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | tools/android/eclipse/.classpath » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698