| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/android/content_feature_list.h" | 5 #include "content/browser/android/content_feature_list.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/public/common/content_features.h" | 10 #include "content/public/common/content_features.h" |
| 11 #include "jni/ContentFeatureList_jni.h" | 11 #include "jni/ContentFeatureList_jni.h" |
| 12 | 12 |
| 13 using base::android::ConvertJavaStringToUTF8; | 13 using base::android::ConvertJavaStringToUTF8; |
| 14 using base::android::JavaParamRef; | 14 using base::android::JavaParamRef; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 namespace android { | 17 namespace android { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Array of features exposed through the Java ContentFeatureList API. Entries in | 21 // Array of features exposed through the Java ContentFeatureList API. Entries in |
| 22 // this array may either refer to features defined in the header of this file or | 22 // this array may either refer to features defined in the header of this file or |
| 23 // in other locations in the code base (e.g. content_features.h). | 23 // in other locations in the code base (e.g. content_features.h). |
| 24 const base::Feature* kFeaturesExposedToJava[] = { | 24 const base::Feature* kFeaturesExposedToJava[] = { |
| 25 &kRequestUnbufferedDispatch, &features::kWebNfc, | 25 &kRequestUnbufferedDispatch, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { | 28 const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { |
| 29 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { | 29 for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) { |
| 30 if (kFeaturesExposedToJava[i]->name == feature_name) | 30 if (kFeaturesExposedToJava[i]->name == feature_name) |
| 31 return kFeaturesExposedToJava[i]; | 31 return kFeaturesExposedToJava[i]; |
| 32 } | 32 } |
| 33 NOTREACHED() << "Queried feature cannot be found in ContentFeatureList: " | 33 NOTREACHED() << "Queried feature cannot be found in ContentFeatureList: " |
| 34 << feature_name; | 34 << feature_name; |
| 35 return nullptr; | 35 return nullptr; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 48 FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); | 48 FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); |
| 49 return base::FeatureList::IsEnabled(*feature); | 49 return base::FeatureList::IsEnabled(*feature); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool RegisterContentFeatureListJni(JNIEnv* env) { | 52 bool RegisterContentFeatureListJni(JNIEnv* env) { |
| 53 return RegisterNativesImpl(env); | 53 return RegisterNativesImpl(env); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace android | 56 } // namespace android |
| 57 } // namespace content | 57 } // namespace content |
| OLD | NEW |