forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_feature_list.cc
90 lines (79 loc) · 3.39 KB
/
content_feature_list.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/jni_string.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "content/public/android/content_jni_headers/ContentFeatureListImpl_jni.h"
#include "content/public/common/content_features.h"
#include "third_party/blink/public/common/features.h"
#include "ui/accessibility/accessibility_features.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. content_features.h).
const base::Feature* const kFeaturesExposedToJava[] = {
&blink::features::kPrefetchAndroidFonts,
&features::kAccessibilityPageZoom,
&features::kAutoDisableAccessibility,
&features::kAutoDisableAccessibilityV2,
&features::kBackgroundMediaRendererHasModerateBinding,
&features::kBindingManagerConnectionLimit,
&features::kBindingManagerUseNotPerceptibleBinding,
&features::kComputeAXMode,
&features::kFedCm,
&features::kOnDemandAccessibilityEvents,
&features::kProcessSharingWithStrictSiteInstances,
&features::kReduceGpuPriorityOnBackground,
&features::kRequestDesktopSiteAdditions,
&features::kRequestDesktopSiteExceptions,
&features::kTouchDragAndContextMenu,
&features::kWebAuthConditionalUI,
&features::kWebBluetoothNewPermissionsBackend,
&features::kWebNfc,
};
const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) {
for (const base::Feature* feature : kFeaturesExposedToJava) {
if (feature->name == feature_name)
return feature;
}
NOTREACHED() << "Queried feature cannot be found in ContentFeatureList: "
<< feature_name;
return nullptr;
}
} // namespace
static jboolean JNI_ContentFeatureListImpl_IsEnabled(
JNIEnv* env,
const JavaParamRef<jstring>& jfeature_name) {
const base::Feature* feature =
FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name));
return base::FeatureList::IsEnabled(*feature);
}
static jint JNI_ContentFeatureListImpl_GetFieldTrialParamByFeatureAsInt(
JNIEnv* env,
const JavaParamRef<jstring>& jfeature_name,
const JavaParamRef<jstring>& jparam_name,
const jint jdefault_value) {
const base::Feature* feature =
FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name));
const std::string& param_name = ConvertJavaStringToUTF8(env, jparam_name);
return base::GetFieldTrialParamByFeatureAsInt(*feature, param_name,
jdefault_value);
}
static jboolean JNI_ContentFeatureListImpl_GetFieldTrialParamByFeatureAsBoolean(
JNIEnv* env,
const JavaParamRef<jstring>& jfeature_name,
const JavaParamRef<jstring>& jparam_name,
const jboolean jdefault_value) {
const base::Feature* feature =
FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name));
const std::string& param_name = ConvertJavaStringToUTF8(env, jparam_name);
return base::GetFieldTrialParamByFeatureAsBool(*feature, param_name,
jdefault_value);
}
} // namespace android
} // namespace content