| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 "content/browser/android/content_feature_list.h" |
| 6 |
| 7 #include "base/android/jni_string.h" |
| 8 #include "base/feature_list.h" |
| 9 #include "base/macros.h" |
| 10 #include "jni/ContentFeatureList_jni.h" |
| 11 |
| 12 using base::android::ConvertJavaStringToUTF8; |
| 13 using base::android::JavaParamRef; |
| 14 |
| 15 namespace content { |
| 16 namespace android { |
| 17 |
| 18 namespace { |
| 19 |
| 20 // Array of features exposed through the Java ContentFeatureList API. Entries in |
| 21 // this array may either refer to features defined in the header of this file or |
| 22 // in other locations in the code base (e.g. content_features.h). |
| 23 const base::Feature* kFeaturesExposedToJava[] = { |
| 24 &kRequestUnbufferedDispatch, |
| 25 }; |
| 26 |
| 27 const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { |
| 28 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
| 29 if (kFeaturesExposedToJava[i]->name == feature_name) |
| 30 return kFeaturesExposedToJava[i]; |
| 31 } |
| 32 NOTREACHED() << "Queried feature cannot be found in ContentFeatureList: " |
| 33 << feature_name; |
| 34 return nullptr; |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
| 39 // Alphabetical: |
| 40 const base::Feature kRequestUnbufferedDispatch{ |
| 41 "RequestUnbufferedDispatch", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 42 |
| 43 static jboolean IsEnabled(JNIEnv* env, |
| 44 const JavaParamRef<jclass>& clazz, |
| 45 const JavaParamRef<jstring>& jfeature_name) { |
| 46 const base::Feature* feature = |
| 47 FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); |
| 48 return base::FeatureList::IsEnabled(*feature); |
| 49 } |
| 50 |
| 51 bool RegisterContentFeatureListJni(JNIEnv* env) { |
| 52 return RegisterNativesImpl(env); |
| 53 } |
| 54 |
| 55 } // namespace android |
| 56 } // namespace content |
| OLD | NEW |