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

Unified Diff: chrome/browser/android/chrome_feature_list.cc

Issue 1538573004: Expose a Java API for base/feature_list.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: chrome/browser/android/chrome_feature_list.cc
diff --git a/chrome/browser/android/chrome_feature_list.cc b/chrome/browser/android/chrome_feature_list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a76be513adad756e961359d4017aa2ca19623e4
--- /dev/null
+++ b/chrome/browser/android/chrome_feature_list.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/chrome_feature_list.h"
+
+#include <string>
+
+#include "base/android/jni_string.h"
+#include "base/feature_list.h"
+#include "jni/ChromeFeatureList_jni.h"
+
+using base::android::ConvertJavaStringToUTF8;
+
+namespace {
+
+const base::Feature kPhysicalWebFeature {
+ "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT
+};
+
+// Array of features exposed through the Java ChromeFeatureList API. Entries in
+// this array may either refer to features defined in this file (above) or in
+// other locations in the code base (e.g. chrome/, components/, etc).
+const base::Feature* kFeaturesExposedToJava[] = {
+ &kPhysicalWebFeature,
+};
+
+} // namespace
+
+static jboolean IsEnabled(JNIEnv* env,
nyquist 2015/12/18 22:47:39 Why is this not namespaces to chrome::android?
Alexei Svitkine (slow) 2015/12/18 22:54:45 I tried this originally, but seems the header defi
Alexei Svitkine (slow) 2015/12/18 23:06:59 Looks like I was missing the @JNINamespace annotat
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jstring>& jfeature_name) {
+ const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name);
+ for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) {
+ if (kFeaturesExposedToJava[i]->name == feature_name)
+ return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]);
+ }
+ // Features queried via this API must be present in |kFeaturesExposedToJava|.
+ NOTREACHED();
+ return false;
+}
+
+namespace chrome {
+namespace android {
+
+bool RegisterChromeFeatureListJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace android
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698