Chromium Code Reviews| Index: content/browser/android/content_feature_list.cc |
| diff --git a/content/browser/android/content_feature_list.cc b/content/browser/android/content_feature_list.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d694f550b5eeca2c0b4795ec84448c455915c777 |
| --- /dev/null |
| +++ b/content/browser/android/content_feature_list.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/android/content_feature_list.h" |
| + |
| +#include "base/android/jni_string.h" |
| +#include "base/feature_list.h" |
| +#include "base/macros.h" |
| +#include "jni/ContentFeatureList_jni.h" |
| + |
| +using base::android::ConvertJavaStringToUTF8; |
| +using base::android::JavaParamRef; |
| + |
| +namespace content { |
| +namespace android { |
| + |
| +namespace { |
| + |
| +// Array of features exposed through the Java ContentFeatureList API. Entries in |
| +// this array may either refer to features defined in the header of this file or |
| +// in other locations in the code base (e.g. chrome/, components/, etc). |
|
Ilya Sherman
2017/03/16 03:39:49
nit: Probably not in chrome/ nor components/ ;-)
chongz
2017/03/16 16:12:21
Done.
|
| +const base::Feature* kFeaturesExposedToJava[] = { |
| + &kRequestUnbufferedDispatch, |
| +}; |
| + |
| +const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { |
| + for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
| + if (kFeaturesExposedToJava[i]->name == feature_name) |
| + return kFeaturesExposedToJava[i]; |
| + } |
| + NOTREACHED() << "Features queried via ContentFeatureList must be present in " |
| + "|kFeaturesExposedToJava|."; |
|
Ilya Sherman
2017/03/16 03:39:49
nit: Could you please move this string into a comm
chongz
2017/03/16 16:12:21
Done.
|
| + return nullptr; |
| +} |
| + |
| +} // namespace |
| + |
| +// Alphabetical: |
| +const base::Feature kRequestUnbufferedDispatch{ |
| + "RequestUnbufferedDispatch", base::FEATURE_DISABLED_BY_DEFAULT}; |
| + |
| +static jboolean IsEnabled(JNIEnv* env, |
| + const JavaParamRef<jclass>& clazz, |
| + const JavaParamRef<jstring>& jfeature_name) { |
| + const base::Feature* feature = |
| + FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); |
| + return base::FeatureList::IsEnabled(*feature); |
| +} |
| + |
| +bool RegisterContentFeatureListJni(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace android |
| +} // namespace content |