| 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 "base/metrics/field_trial_params.h" |
| 14 #include "chrome/common/chrome_features.h" | 15 #include "chrome/common/chrome_features.h" |
| 15 #include "components/autofill/core/browser/autofill_experiments.h" | 16 #include "components/autofill/core/browser/autofill_experiments.h" |
| 16 #include "components/ntp_snippets/features.h" | 17 #include "components/ntp_snippets/features.h" |
| 17 #include "components/offline_pages/core/offline_page_feature.h" | 18 #include "components/offline_pages/core/offline_page_feature.h" |
| 18 #include "components/password_manager/core/common/password_manager_features.h" | 19 #include "components/password_manager/core/common/password_manager_features.h" |
| 19 #include "content/public/common/content_features.h" | 20 #include "content/public/common/content_features.h" |
| 20 #include "jni/ChromeFeatureList_jni.h" | 21 #include "jni/ChromeFeatureList_jni.h" |
| 21 | 22 |
| 22 using base::android::ConvertJavaStringToUTF8; | 23 using base::android::ConvertJavaStringToUTF8; |
| 23 using base::android::JavaParamRef; | 24 using base::android::JavaParamRef; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 53 &kNTPOfflinePagesFeature, | 54 &kNTPOfflinePagesFeature, |
| 54 &kNTPSuggestionsStandaloneUIFeature, | 55 &kNTPSuggestionsStandaloneUIFeature, |
| 55 &kPhysicalWebFeature, | 56 &kPhysicalWebFeature, |
| 56 &kPhysicalWebIgnoreOtherClientsFeature, | 57 &kPhysicalWebIgnoreOtherClientsFeature, |
| 57 &kSpecialLocaleFeature, | 58 &kSpecialLocaleFeature, |
| 58 &kSpecialLocaleWrapper, | 59 &kSpecialLocaleWrapper, |
| 59 &kTabsInCBD, | 60 &kTabsInCBD, |
| 60 &kTabReparenting, | 61 &kTabReparenting, |
| 61 &kWebPaymentsModifiers, | 62 &kWebPaymentsModifiers, |
| 62 &kWebPaymentsSingleAppUiSkip, | 63 &kWebPaymentsSingleAppUiSkip, |
| 64 &kWebVRCardboardSupport, |
| 63 &ntp_snippets::kIncreasedVisibility, | 65 &ntp_snippets::kIncreasedVisibility, |
| 64 &ntp_snippets::kForeignSessionsSuggestionsFeature, | 66 &ntp_snippets::kForeignSessionsSuggestionsFeature, |
| 65 &ntp_snippets::kOfflineBadgeFeature, | 67 &ntp_snippets::kOfflineBadgeFeature, |
| 66 &ntp_snippets::kSaveToOfflineFeature, | 68 &ntp_snippets::kSaveToOfflineFeature, |
| 67 &ntp_snippets::kSectionDismissalFeature, | 69 &ntp_snippets::kSectionDismissalFeature, |
| 68 &offline_pages::kBackgroundLoaderForDownloadsFeature, | 70 &offline_pages::kBackgroundLoaderForDownloadsFeature, |
| 69 &offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421. | 71 &offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421. |
| 70 &offline_pages::kOfflinePagesSharingFeature, | 72 &offline_pages::kOfflinePagesSharingFeature, |
| 71 &password_manager::features::kViewPasswords, | 73 &password_manager::features::kViewPasswords, |
| 72 }; | 74 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 139 |
| 138 const base::Feature kUserMediaScreenCapturing{ | 140 const base::Feature kUserMediaScreenCapturing{ |
| 139 "UserMediaScreenCapturing", base::FEATURE_DISABLED_BY_DEFAULT}; | 141 "UserMediaScreenCapturing", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 140 | 142 |
| 141 const base::Feature kWebPaymentsModifiers{"WebPaymentsModifiers", | 143 const base::Feature kWebPaymentsModifiers{"WebPaymentsModifiers", |
| 142 base::FEATURE_DISABLED_BY_DEFAULT}; | 144 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 143 | 145 |
| 144 const base::Feature kWebPaymentsSingleAppUiSkip{ | 146 const base::Feature kWebPaymentsSingleAppUiSkip{ |
| 145 "WebPaymentsSingleAppUiSkip", base::FEATURE_ENABLED_BY_DEFAULT}; | 147 "WebPaymentsSingleAppUiSkip", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 146 | 148 |
| 149 const base::Feature kWebVRCardboardSupport{ |
| 150 "WebVRCardboardSupport", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 151 |
| 147 static jboolean IsEnabled(JNIEnv* env, | 152 static jboolean IsEnabled(JNIEnv* env, |
| 148 const JavaParamRef<jclass>& clazz, | 153 const JavaParamRef<jclass>& clazz, |
| 149 const JavaParamRef<jstring>& jfeature_name) { | 154 const JavaParamRef<jstring>& jfeature_name) { |
| 150 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); | 155 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); |
| 151 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { | 156 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
| 152 if (kFeaturesExposedToJava[i]->name == feature_name) | 157 if (kFeaturesExposedToJava[i]->name == feature_name) |
| 153 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); | 158 return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]); |
| 154 } | 159 } |
| 155 // Features queried via this API must be present in |kFeaturesExposedToJava|. | 160 // Features queried via this API must be present in |kFeaturesExposedToJava|. |
| 156 NOTREACHED(); | 161 NOTREACHED(); |
| 157 return false; | 162 return false; |
| 158 } | 163 } |
| 159 | 164 |
| 165 static jint GetFieldTrialParamByFeatureAsInt( |
| 166 JNIEnv* env, |
| 167 const JavaParamRef<jclass>& clazz, |
| 168 const JavaParamRef<jstring>& jfeature_name, |
| 169 const JavaParamRef<jstring>& jparam_name, |
| 170 const jint jdefault_value) { |
| 171 const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name); |
| 172 const std::string param_name = ConvertJavaStringToUTF8(env, jparam_name); |
| 173 int default_value = static_cast<int>(jdefault_value); |
| 174 |
| 175 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
| 176 if (kFeaturesExposedToJava[i]->name == feature_name) |
| 177 return base::GetFieldTrialParamByFeatureAsInt( |
| 178 *kFeaturesExposedToJava[i], param_name, default_value); |
| 179 } |
| 180 // Features queried via this API must be present in |kFeaturesExposedToJava|. |
| 181 NOTREACHED(); |
| 182 return jdefault_value; |
| 183 } |
| 184 |
| 160 bool RegisterChromeFeatureListJni(JNIEnv* env) { | 185 bool RegisterChromeFeatureListJni(JNIEnv* env) { |
| 161 return RegisterNativesImpl(env); | 186 return RegisterNativesImpl(env); |
| 162 } | 187 } |
| 163 | 188 |
| 164 } // namespace android | 189 } // namespace android |
| 165 } // namespace chrome | 190 } // namespace chrome |
| OLD | NEW |