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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/chrome_feature_list.h"
6
7 #include <string>
8
9 #include "base/android/jni_string.h"
10 #include "base/feature_list.h"
11 #include "jni/ChromeFeatureList_jni.h"
12
13 using base::android::ConvertJavaStringToUTF8;
14
15 namespace {
16
17 const base::Feature kPhysicalWebFeature {
18 "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT
19 };
20
21 // Array of features exposed through the Java ChromeFeatureList API. Entries in
22 // this array may either refer to features defined in this file (above) or in
23 // other locations in the code base (e.g. chrome/, components/, etc).
24 const base::Feature* kFeaturesExposedToJava[] = {
25 &kPhysicalWebFeature,
26 };
27
28 } // namespace
29
30 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
31 const JavaParamRef<jclass>& clazz,
32 const JavaParamRef<jstring>& jfeature_name) {
33 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name);
34 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) {
35 if (kFeaturesExposedToJava[i]->name == feature_name)
36 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]);
37 }
38 // Features queried via this API must be present in |kFeaturesExposedToJava|.
39 NOTREACHED();
40 return false;
41 }
42
43 namespace chrome {
44 namespace android {
45
46 bool RegisterChromeFeatureListJni(JNIEnv* env) {
47 return RegisterNativesImpl(env);
48 }
49
50 } // namespace android
51 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698