OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/chrome_feature_list.h" | 5 #include "chrome/browser/android/chrome_feature_list.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/feature_list.h" | |
11 #include "jni/ChromeFeatureList_jni.h" | 10 #include "jni/ChromeFeatureList_jni.h" |
12 | 11 |
13 using base::android::ConvertJavaStringToUTF8; | 12 using base::android::ConvertJavaStringToUTF8; |
14 | 13 |
15 namespace chrome { | 14 namespace chrome { |
16 namespace android { | 15 namespace android { |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 const base::Feature kPhysicalWebFeature { | |
21 "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT | |
22 }; | |
23 | |
24 // Array of features exposed through the Java ChromeFeatureList API. Entries in | 19 // Array of features exposed through the Java ChromeFeatureList API. Entries in |
25 // this array may either refer to features defined in this file (above) or in | 20 // this array may either refer to features defined in this file (above) or in |
26 // other locations in the code base (e.g. chrome/, components/, etc). | 21 // other locations in the code base (e.g. chrome/, components/, etc). |
27 const base::Feature* kFeaturesExposedToJava[] = { | 22 const base::Feature* kFeaturesExposedToJava[] = { |
28 &kPhysicalWebFeature, | 23 &kPhysicalWebFeature, |
29 }; | 24 }; |
30 | 25 |
31 } // namespace | 26 } // namespace |
32 | 27 |
33 static jboolean IsEnabled(JNIEnv* env, | 28 static jboolean IsEnabled(JNIEnv* env, |
34 const JavaParamRef<jclass>& clazz, | 29 const JavaParamRef<jclass>& clazz, |
35 const JavaParamRef<jstring>& jfeature_name) { | 30 const JavaParamRef<jstring>& jfeature_name) { |
36 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); | 31 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); |
37 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { | 32 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
38 if (kFeaturesExposedToJava[i]->name == feature_name) | 33 if (kFeaturesExposedToJava[i]->name == feature_name) |
39 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); | 34 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); |
40 } | 35 } |
41 // Features queried via this API must be present in |kFeaturesExposedToJava|. | 36 // Features queried via this API must be present in |kFeaturesExposedToJava|. |
42 NOTREACHED(); | 37 NOTREACHED(); |
43 return false; | 38 return false; |
44 } | 39 } |
45 | 40 |
46 bool RegisterChromeFeatureListJni(JNIEnv* env) { | 41 bool RegisterChromeFeatureListJni(JNIEnv* env) { |
47 return RegisterNativesImpl(env); | 42 return RegisterNativesImpl(env); |
48 } | 43 } |
49 | 44 |
45 const base::Feature kPhysicalWebFeature { | |
mmocny
2015/12/21 15:45:55
I don't expect its a good idea to use static initi
Alexei Svitkine (slow)
2015/12/21 15:50:50
It's a POD type and this is the correct way to ini
| |
46 "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT | |
47 }; | |
Alexei Svitkine (slow)
2015/12/21 15:48:18
Nit: I'd put this after line 27.
cco3
2015/12/21 18:10:11
Done.
| |
48 | |
50 } // namespace android | 49 } // namespace android |
51 } // namespace chrome | 50 } // namespace chrome |
OLD | NEW |