1 // Copyright (c) 2012 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 "ash/public/cpp/ash_switches.h"
6 
7 #include "base/command_line.h"
8 #include "base/numerics/ranges.h"
9 #include "base/strings/string_number_conversions.h"
10 
11 namespace {
12 // Max and min number of seconds that must pass between showing user contextual
13 // nudges when override switch is set.
14 constexpr base::TimeDelta kAshContextualNudgesMinInterval =
15     base::TimeDelta::FromSeconds(0);
16 constexpr base::TimeDelta kAshContextualNudgesMaxInterval =
17     base::TimeDelta::FromSeconds(60);
18 }  // namespace
19 
20 namespace ash {
21 namespace switches {
22 
23 // Clear the fast ink buffer upon creation. This is needed on some devices that
24 // do not zero out new buffers.
25 const char kAshClearFastInkBuffer[] = "ash-clear-fast-ink-buffer";
26 
27 // Force the pointer (cursor) position to be kept inside root windows.
28 const char kAshConstrainPointerToRoot[] = "ash-constrain-pointer-to-root";
29 
30 // Overrides the minimum time that must pass between showing user contextual
31 // nudges. Unit of time is in seconds.
32 const char kAshContextualNudgesInterval[] = "ash-contextual-nudges-interval";
33 
34 // Reset contextual nudge shown count on login.
35 const char kAshContextualNudgesResetShownCount[] =
36     "ash-contextual-nudges-reset-shown-count";
37 
38 // Enable keyboard shortcuts useful for debugging.
39 const char kAshDebugShortcuts[] = "ash-debug-shortcuts";
40 
41 // Enable keyboard shortcuts used by developers only.
42 const char kAshDeveloperShortcuts[] = "ash-dev-shortcuts";
43 
44 // Disable the Touch Exploration Mode. Touch Exploration Mode will no longer be
45 // turned on automatically when spoken feedback is enabled when this flag is
46 // set.
47 const char kAshDisableTouchExplorationMode[] =
48     "ash-disable-touch-exploration-mode";
49 
50 // Enable cursor motion blur.
51 const char kAshEnableCursorMotionBlur[] = "ash-enable-cursor-motion-blur";
52 
53 // Enables key bindings to scroll magnified screen.
54 const char kAshEnableMagnifierKeyScroller[] =
55     "ash-enable-magnifier-key-scroller";
56 
57 // Enables the palette on every display, instead of only the internal one.
58 const char kAshEnablePaletteOnAllDisplays[] =
59     "ash-enable-palette-on-all-displays";
60 
61 // If the flag is present, it indicates 1) the device has accelerometer and 2)
62 // the device is a convertible device or a tablet device (thus is capable of
63 // entering tablet mode). If this flag is not set, then the device is not
64 // capable of entering tablet mode. For example, Samus has accelerometer, but
65 // is not a covertible or tablet, thus doesn't have this flag set, thus can't
66 // enter tablet mode.
67 const char kAshEnableTabletMode[] = "enable-touchview";
68 
69 // Enable the wayland server.
70 const char kAshEnableWaylandServer[] = "enable-wayland-server";
71 
72 // Enables the stylus tools next to the status area.
73 const char kAshForceEnableStylusTools[] = "force-enable-stylus-tools";
74 
75 // Forces the status area to allow collapse/expand regardless of the current
76 // state.
77 const char kAshForceStatusAreaCollapsible[] = "force-status-area-collapsible";
78 
79 // Power button position includes the power button's physical display side and
80 // the percentage for power button center position to the display's
81 // width/height in landscape_primary screen orientation. The value is a JSON
82 // object containing a "position" property with the value "left", "right",
83 // "top", or "bottom". For "left" and "right", a "y" property specifies the
84 // button's center position as a fraction of the display's height (in [0.0,
85 // 1.0]) relative to the top of the display. For "top" and "bottom", an "x"
86 // property gives the position as a fraction of the display's width relative to
87 // the left side of the display.
88 const char kAshPowerButtonPosition[] = "ash-power-button-position";
89 
90 // Enables required things for the selected UI mode, regardless of whether the
91 // Chromebook is currently in the selected UI mode.
92 const char kAshUiMode[] = "force-tablet-mode";
93 
94 // Values for the kAshUiMode flag.
95 const char kAshUiModeClamshell[] = "clamshell";
96 const char kAshUiModeTablet[] = "touch_view";
97 
98 // Hides notifications that are irrelevant to Chrome OS device factory testing,
99 // such as battery level updates.
100 const char kAshHideNotificationsForFactory[] =
101     "ash-hide-notifications-for-factory";
102 
103 // Enables the heads-up display for tracking touch points.
104 const char kAshTouchHud[] = "ash-touch-hud";
105 
106 // The physical position info of the side volume button while in landscape
107 // primary screen orientation. The value is a JSON object containing a "region"
108 // property with the value "keyboard", "screen" and a "side" property with the
109 // value "left", "right", "top", "bottom".
110 const char kAshSideVolumeButtonPosition[] = "ash-side-volume-button-position";
111 
112 // (Most) Chrome OS hardware reports ACPI power button releases correctly.
113 // Standard hardware reports releases immediately after presses.  If set, we
114 // lock the screen or shutdown the system immediately in response to a press
115 // instead of displaying an interactive animation.
116 const char kAuraLegacyPowerButton[] = "aura-legacy-power-button";
117 
118 // Enables Shelf Dimming for ChromeOS.
119 const char kEnableDimShelf[] = "enable-dim-shelf";
120 
121 // If set, tablet-like power button behavior (i.e. tapping the button turns the
122 // screen off) is used even if the device is in laptop mode.
123 const char kForceTabletPowerButton[] = "force-tablet-power-button";
124 
125 // Sets the throttle fps for compositor frame submission.
126 const char kFrameThrottleFps[] = "frame-throttle-fps";
127 
128 // Whether this device has an internal stylus.
129 const char kHasInternalStylus[] = "has-internal-stylus";
130 
131 // Draws a circle at each touch point, similar to the Android OS developer
132 // option "Show taps".
133 const char kShowTaps[] = "show-taps";
134 
135 // Chromebases' touchscreens can be used to wake from suspend, unlike the
136 // touchscreens on other Chrome OS devices. If set, the touchscreen is kept
137 // enabled while the screen is off so that it can be used to turn the screen
138 // back on after it has been turned off for inactivity but before the system has
139 // suspended.
140 const char kTouchscreenUsableWhileScreenOff[] =
141     "touchscreen-usable-while-screen-off";
142 
143 // Hides all Message Center notification popups (toasts). Used for testing.
144 const char kSuppressMessageCenterPopups[] = "suppress-message-center-popups";
145 
ContextualNudgesInterval()146 base::Optional<base::TimeDelta> ContextualNudgesInterval() {
147   int numeric_cooldown_time;
148   if (base::CommandLine::ForCurrentProcess()->HasSwitch(
149           kAshContextualNudgesInterval) &&
150       base::StringToInt(
151           base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
152               kAshContextualNudgesInterval),
153           &numeric_cooldown_time)) {
154     base::TimeDelta cooldown_time =
155         base::TimeDelta::FromSeconds(numeric_cooldown_time);
156     cooldown_time =
157         base::ClampToRange(cooldown_time, kAshContextualNudgesMinInterval,
158                            kAshContextualNudgesMaxInterval);
159     return base::Optional<base::TimeDelta>(cooldown_time);
160   }
161   return base::nullopt;
162 }
163 
ContextualNudgesResetShownCount()164 bool ContextualNudgesResetShownCount() {
165   return base::CommandLine::ForCurrentProcess()->HasSwitch(
166       kAshContextualNudgesResetShownCount);
167 }
168 
IsUsingShelfAutoDim()169 bool IsUsingShelfAutoDim() {
170   return base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableDimShelf);
171 }
172 
ShouldClearFastInkBuffer()173 bool ShouldClearFastInkBuffer() {
174   return base::CommandLine::ForCurrentProcess()->HasSwitch(
175       kAshClearFastInkBuffer);
176 }
177 
178 }  // namespace switches
179 }  // namespace ash
180