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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "jni/ChromeFeatureList_jni.h" | 14 #include "jni/ChromeFeatureList_jni.h" |
15 | 15 |
16 using base::android::ConvertJavaStringToUTF8; | 16 using base::android::ConvertJavaStringToUTF8; |
17 | 17 |
18 namespace chrome { | 18 namespace chrome { |
19 namespace android { | 19 namespace android { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Array of features exposed through the Java ChromeFeatureList API. Entries in | 23 // Array of features exposed through the Java ChromeFeatureList API. Entries in |
24 // this array may either refer to features defined in this file (above) or in | 24 // this array may either refer to features defined in this file (above) or in |
25 // other locations in the code base (e.g. chrome/, components/, etc). | 25 // other locations in the code base (e.g. chrome/, components/, etc). |
26 const base::Feature* kFeaturesExposedToJava[] = { | 26 const base::Feature* kFeaturesExposedToJava[] = { |
27 &kNTPOfflinePagesFeature, | 27 &kNTPOfflinePagesFeature, |
| 28 &kNTPSnippetsFeature, |
28 &kPhysicalWebFeature, | 29 &kPhysicalWebFeature, |
29 }; | 30 }; |
30 | 31 |
31 } // namespace | 32 } // namespace |
32 | 33 |
33 const base::Feature kNTPOfflinePagesFeature { | 34 const base::Feature kNTPOfflinePagesFeature { |
34 "NTPOfflinePages", base::FEATURE_DISABLED_BY_DEFAULT | 35 "NTPOfflinePages", base::FEATURE_DISABLED_BY_DEFAULT |
35 }; | 36 }; |
36 | 37 |
| 38 const base::Feature kNTPSnippetsFeature { |
| 39 "NTPSnippets", base::FEATURE_DISABLED_BY_DEFAULT |
| 40 }; |
| 41 |
37 const base::Feature kPhysicalWebFeature { | 42 const base::Feature kPhysicalWebFeature { |
38 "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT | 43 "PhysicalWeb", base::FEATURE_DISABLED_BY_DEFAULT |
39 }; | 44 }; |
40 | 45 |
41 static jboolean IsEnabled(JNIEnv* env, | 46 static jboolean IsEnabled(JNIEnv* env, |
42 const JavaParamRef<jclass>& clazz, | 47 const JavaParamRef<jclass>& clazz, |
43 const JavaParamRef<jstring>& jfeature_name) { | 48 const JavaParamRef<jstring>& jfeature_name) { |
44 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); | 49 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); |
45 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { | 50 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
46 if (kFeaturesExposedToJava[i]->name == feature_name) | 51 if (kFeaturesExposedToJava[i]->name == feature_name) |
47 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); | 52 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); |
48 } | 53 } |
49 // Features queried via this API must be present in |kFeaturesExposedToJava|. | 54 // Features queried via this API must be present in |kFeaturesExposedToJava|. |
50 NOTREACHED(); | 55 NOTREACHED(); |
51 return false; | 56 return false; |
52 } | 57 } |
53 | 58 |
54 bool RegisterChromeFeatureListJni(JNIEnv* env) { | 59 bool RegisterChromeFeatureListJni(JNIEnv* env) { |
55 return RegisterNativesImpl(env); | 60 return RegisterNativesImpl(env); |
56 } | 61 } |
57 | 62 |
58 } // namespace android | 63 } // namespace android |
59 } // namespace chrome | 64 } // namespace chrome |
OLD | NEW |