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 "ui/base/ui_base_features.h"
6
7 #include "build/chromeos_buildflags.h"
8
9 #if defined(OS_WIN)
10 #include "base/win/windows_version.h"
11 #endif
12
13 #if defined(OS_ANDROID)
14 #include "base/android/build_info.h"
15 #endif
16
17 namespace features {
18
19 #if defined(OS_WIN)
20 // If enabled, calculate native window occlusion - Windows-only.
21 const base::Feature kCalculateNativeWinOcclusion{
22 "CalculateNativeWinOcclusion", base::FEATURE_ENABLED_BY_DEFAULT};
23
24 const base::Feature kCalculateNativeWinOcclusionCheckVirtualDesktopUsed{
25 "CalculateNativeWinOcclusionCheckVirtualDesktopUsed",
26 base::FEATURE_DISABLED_BY_DEFAULT};
27 #endif // OW_WIN
28
29 // Whether or not to delegate color queries to the color provider.
30 const base::Feature kColorProviderRedirection = {
31 "ColorProviderRedirection", base::FEATURE_DISABLED_BY_DEFAULT};
32
33 #if defined(OS_CHROMEOS)
34 // Integrate input method specific settings to Chrome OS settings page.
35 // https://crbug.com/895886.
36 const base::Feature kSettingsShowsPerKeyboardSettings = {
37 "InputMethodIntegratedSettings", base::FEATURE_DISABLED_BY_DEFAULT};
38
39 // Experimental shortcut handling and mapping to address i18n issues.
40 // https://crbug.com/1067269
41 const base::Feature kNewShortcutMapping = {"NewShortcutMapping",
42 base::FEATURE_DISABLED_BY_DEFAULT};
43
IsNewShortcutMappingEnabled()44 bool IsNewShortcutMappingEnabled() {
45 return base::FeatureList::IsEnabled(kNewShortcutMapping);
46 }
47 #endif // defined(OS_CHROMEOS)
48
49 // Update of the virtual keyboard settings UI as described in
50 // https://crbug.com/876901.
51 const base::Feature kInputMethodSettingsUiUpdate = {
52 "InputMethodSettingsUiUpdate", base::FEATURE_DISABLED_BY_DEFAULT};
53
54 // Enables percent-based scrolling for mousewheel and keyboard initiated
55 // scrolls.
56 const base::Feature kPercentBasedScrolling = {
57 "PercentBasedScrolling", base::FEATURE_DISABLED_BY_DEFAULT};
58
59 // Allows requesting unadjusted movement when entering pointerlock.
60 const base::Feature kPointerLockOptions = {"PointerLockOptions",
61 base::FEATURE_ENABLED_BY_DEFAULT};
62
63 // Allows system caption style for WebVTT Captions.
64 const base::Feature kSystemCaptionStyle{"SystemCaptionStyle",
65 base::FEATURE_ENABLED_BY_DEFAULT};
66
67 // Allows system keyboard event capture via the keyboard lock API.
68 const base::Feature kSystemKeyboardLock{"SystemKeyboardLock",
69 base::FEATURE_ENABLED_BY_DEFAULT};
70
71 const base::Feature kNotificationIndicator = {
72 "EnableNotificationIndicator", base::FEATURE_DISABLED_BY_DEFAULT};
73
IsNotificationIndicatorEnabled()74 bool IsNotificationIndicatorEnabled() {
75 return base::FeatureList::IsEnabled(kNotificationIndicator);
76 }
77
78 // Enables GPU rasterization for all UI drawing (where not blocklisted).
79 const base::Feature kUiGpuRasterization = {"UiGpuRasterization",
80 #if defined(OS_APPLE) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA)
81 base::FEATURE_ENABLED_BY_DEFAULT
82 #else
83 base::FEATURE_DISABLED_BY_DEFAULT
84 #endif
85 };
86
IsUiGpuRasterizationEnabled()87 bool IsUiGpuRasterizationEnabled() {
88 return base::FeatureList::IsEnabled(kUiGpuRasterization);
89 }
90
91 // Enables scrolling with layers under ui using the ui::Compositor.
92 const base::Feature kUiCompositorScrollWithLayers = {
93 "UiCompositorScrollWithLayers",
94 // TODO(https://crbug.com/615948): Use composited scrolling on all platforms.
95 #if defined(OS_APPLE)
96 base::FEATURE_ENABLED_BY_DEFAULT
97 #else
98 base::FEATURE_DISABLED_BY_DEFAULT
99 #endif
100 };
101
102 // Enables compositor threaded scrollbar scrolling by mapping pointer events to
103 // gesture events.
104 const base::Feature kCompositorThreadedScrollbarScrolling = {
105 "CompositorThreadedScrollbarScrolling", base::FEATURE_ENABLED_BY_DEFAULT};
106
107 // Enables the use of a touch fling curve that is based on the behavior of
108 // native apps on Windows.
109 const base::Feature kExperimentalFlingAnimation {
110 "ExperimentalFlingAnimation",
111 #if defined(OS_WIN) || \
112 (defined(OS_LINUX) && !defined(OS_CHROMEOS) && !BUILDFLAG(IS_LACROS)) || defined(OS_BSD)
113 base::FEATURE_ENABLED_BY_DEFAULT
114 #else
115 base::FEATURE_DISABLED_BY_DEFAULT
116 #endif
117 };
118
119 #if defined(OS_WIN)
120 const base::Feature kElasticOverscrollWin = {"ElasticOverscrollWin",
121 base::FEATURE_DISABLED_BY_DEFAULT};
122
123 // Enables InputPane API for controlling on screen keyboard.
124 const base::Feature kInputPaneOnScreenKeyboard = {
125 "InputPaneOnScreenKeyboard", base::FEATURE_ENABLED_BY_DEFAULT};
126
127 // Enables using WM_POINTER instead of WM_TOUCH for touch events.
128 const base::Feature kPointerEventsForTouch = {"PointerEventsForTouch",
129 base::FEATURE_ENABLED_BY_DEFAULT};
130 // Enables using TSF (over IMM32) for IME.
131 const base::Feature kTSFImeSupport = {"TSFImeSupport",
132 base::FEATURE_ENABLED_BY_DEFAULT};
133
IsUsingWMPointerForTouch()134 bool IsUsingWMPointerForTouch() {
135 return base::win::GetVersion() >= base::win::Version::WIN8 &&
136 base::FeatureList::IsEnabled(kPointerEventsForTouch);
137 }
138
139 // Enables Logging for DirectManipulation.
140 const base::Feature kPrecisionTouchpadLogging{
141 "PrecisionTouchpadLogging", base::FEATURE_DISABLED_BY_DEFAULT};
142 #endif // defined(OS_WIN)
143
144 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_BSD) || \
145 defined(OS_CHROMEOS)
146 // Enables stylus appearing as touch when in contact with digitizer.
147 const base::Feature kDirectManipulationStylus = {
148 "DirectManipulationStylus",
149 #if defined(OS_WIN)
150 base::FEATURE_ENABLED_BY_DEFAULT
151 #else
152 base::FEATURE_DISABLED_BY_DEFAULT
153 #endif
154 };
155 #endif // defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_BSD) ||
156 // defined(OS_CHROMEOS)
157
158 // Enables forced colors mode for web content.
159 const base::Feature kForcedColors{"ForcedColors",
160 base::FEATURE_DISABLED_BY_DEFAULT};
161
IsForcedColorsEnabled()162 bool IsForcedColorsEnabled() {
163 static const bool forced_colors_enabled =
164 base::FeatureList::IsEnabled(features::kForcedColors);
165 return forced_colors_enabled;
166 }
167
168 // Enables the eye-dropper in the refresh color-picker for Windows and Mac.
169 // This feature will be released for other platforms in later milestones.
170 const base::Feature kEyeDropper {
171 "EyeDropper",
172 #if defined(OS_WIN) || defined(OS_MAC)
173 base::FEATURE_ENABLED_BY_DEFAULT
174 #else
175 base::FEATURE_DISABLED_BY_DEFAULT
176 #endif
177 };
178
IsEyeDropperEnabled()179 bool IsEyeDropperEnabled() {
180 return IsFormControlsRefreshEnabled() &&
181 base::FeatureList::IsEnabled(features::kEyeDropper);
182 }
183
184 // Enable the CSSColorSchemeUARendering feature for Windows, ChromeOS, Linux,
185 // and Mac. This feature will be released for Android in later milestones. See
186 // crbug.com/1086530 for the Desktop launch bug.
187 const base::Feature kCSSColorSchemeUARendering = {
188 "CSSColorSchemeUARendering", base::FEATURE_DISABLED_BY_DEFAULT};
189
IsCSSColorSchemeUARenderingEnabled()190 bool IsCSSColorSchemeUARenderingEnabled() {
191 static const bool css_color_scheme_ua_rendering_enabled =
192 base::FeatureList::IsEnabled(features::kCSSColorSchemeUARendering);
193 return css_color_scheme_ua_rendering_enabled;
194 }
195
196 // Enable the FormControlsRefresh feature for Windows, ChromeOS, Linux, and Mac.
197 // This feature will be released for Android in later milestones. See
198 // crbug.com/1012106 for the Windows launch bug, and crbug.com/1012108 for the
199 // Mac launch bug.
200 const base::Feature kFormControlsRefresh = {"FormControlsRefresh",
201 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_BSD) || \
202 defined(OS_APPLE)
203 base::FEATURE_ENABLED_BY_DEFAULT
204 #else
205 base::FEATURE_DISABLED_BY_DEFAULT
206 #endif
207 };
208
IsFormControlsRefreshEnabled()209 bool IsFormControlsRefreshEnabled() {
210 static const bool form_controls_refresh_enabled =
211 base::FeatureList::IsEnabled(features::kFormControlsRefresh);
212 return form_controls_refresh_enabled;
213 }
214
215 // Enable the common select popup.
216 const base::Feature kUseCommonSelectPopup = {"UseCommonSelectPopup",
217 base::FEATURE_DISABLED_BY_DEFAULT};
218
IsUseCommonSelectPopupEnabled()219 bool IsUseCommonSelectPopupEnabled() {
220 return base::FeatureList::IsEnabled(features::kUseCommonSelectPopup);
221 }
222
223 #if defined(OS_CHROMEOS)
224 const base::Feature kHandwritingGesture = {"HandwritingGesture",
225 base::FEATURE_ENABLED_BY_DEFAULT};
226 #endif
227
228 const base::Feature kSynchronousPageFlipTesting{
229 "SynchronousPageFlipTesting", base::FEATURE_DISABLED_BY_DEFAULT};
230
IsSynchronousPageFlipTestingEnabled()231 bool IsSynchronousPageFlipTestingEnabled() {
232 return base::FeatureList::IsEnabled(kSynchronousPageFlipTesting);
233 }
234
235 #if defined(USE_X11) || defined(USE_OZONE)
236 const base::Feature kUseOzonePlatform {
237 "UseOzonePlatform",
238 #if defined(USE_X11)
239 base::FEATURE_DISABLED_BY_DEFAULT
240 };
241 #else
242 base::FEATURE_ENABLED_BY_DEFAULT
243 };
244 #endif
245
IsUsingOzonePlatform()246 bool IsUsingOzonePlatform() {
247 // Only allow enabling and disabling the OzonePlatform on USE_X11 && USE_OZONE
248 // builds.
249 static const bool using_ozone_platform =
250 #if defined(USE_X11) && defined(USE_OZONE) && !BUILDFLAG(IS_LACROS)
251 base::FeatureList::IsEnabled(kUseOzonePlatform);
252 #elif defined(USE_X11) && !defined(USE_OZONE)
253 // This shouldn't be switchable for pure X11 builds.
254 false;
255 #else
256 // All the other platforms must use Ozone by default and can't disable
257 // that.
258 true;
259 #endif
260 return using_ozone_platform;
261 }
262 #endif // defined(USE_X11) || defined(USE_OZONE)
263
264 const char kPredictorNameLsq[] = "lsq";
265 const char kPredictorNameKalman[] = "kalman";
266 const char kPredictorNameLinearFirst[] = "linear_first";
267 const char kPredictorNameLinearSecond[] = "linear_second";
268 const char kPredictorNameLinearResampling[] = "linear_resampling";
269 const char kPredictorNameEmpty[] = "empty";
270
271 const char kFilterNameEmpty[] = "empty_filter";
272 const char kFilterNameOneEuro[] = "one_euro_filter";
273
274 const base::Feature kSwipeToMoveCursor{"SwipeToMoveCursor",
275 base::FEATURE_DISABLED_BY_DEFAULT};
276
IsSwipeToMoveCursorEnabled()277 bool IsSwipeToMoveCursorEnabled() {
278 static const bool enabled =
279 base::FeatureList::IsEnabled(kSwipeToMoveCursor)
280 #if defined(OS_ANDROID)
281 && base::android::BuildInfo::GetInstance()->sdk_int() >=
282 base::android::SDK_VERSION_R;
283 #else
284 ;
285 #endif
286 return enabled;
287 }
288
289 } // namespace features
290