Commit 39d7f83a authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Add a switch that would force gesture navigation mode in clamshell

Currently, we show gesture navigation screen in tablet mode only, though
for touch centric devices, the screen should be shown even if the device
is in clamshell mode.

To achieve this, add support for a command line switch
"oobe-force-tablet-first-run" that would force tablet mode flow for the
first user run, even if the device is in clamshell during setup.

The flag is expected to be passed in by login manager during chrome setup.

BUG=976949

Change-Id: I754eb09c4b3ddbb85af2148f5f062e971e6a1e21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092696Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748279}
parent 1c484b39
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
namespace chromeos { namespace chromeos {
...@@ -36,19 +37,24 @@ GestureNavigationScreen::~GestureNavigationScreen() { ...@@ -36,19 +37,24 @@ GestureNavigationScreen::~GestureNavigationScreen() {
} }
void GestureNavigationScreen::ShowImpl() { void GestureNavigationScreen::ShowImpl() {
// TODO(mmourgos): If clamshell mode is enabled and device is detachable, then
// show the gesture navigation flow.
AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
if (chrome_user_manager_util::IsPublicSessionOrEphemeralLogin() || if (chrome_user_manager_util::IsPublicSessionOrEphemeralLogin() ||
!ash::features::IsHideShelfControlsInTabletModeEnabled() || !ash::features::IsHideShelfControlsInTabletModeEnabled() ||
!ash::TabletMode::Get()->InTabletMode() ||
accessibility_manager->IsSpokenFeedbackEnabled() || accessibility_manager->IsSpokenFeedbackEnabled() ||
accessibility_manager->IsAutoclickEnabled() || accessibility_manager->IsAutoclickEnabled() ||
accessibility_manager->IsSwitchAccessEnabled()) { accessibility_manager->IsSwitchAccessEnabled()) {
exit_callback_.Run(); exit_callback_.Run();
return; return;
} }
// Skip the screen if the device is not in tablet mode, unless tablet mode
// first user run is forced on the device.
if (!ash::TabletMode::Get()->InTabletMode() &&
!chromeos::switches::ShouldOobeUseTabletModeFirstRun()) {
exit_callback_.Run();
return;
}
view_->Show(); view_->Show();
} }
......
...@@ -17,10 +17,19 @@ ...@@ -17,10 +17,19 @@
#include "chrome/browser/chromeos/login/test/oobe_base_test.h" #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chromeos/constants/chromeos_switches.h"
namespace chromeos { namespace chromeos {
class GestureNavigationScreenTest : public OobeBaseTest { namespace {
enum class TestMode { kTablet, kClamshellWithForcedTabletFirstRun };
} // namespace
class GestureNavigationScreenTest
: public OobeBaseTest,
public ::testing::WithParamInterface<TestMode> {
public: public:
GestureNavigationScreenTest() { GestureNavigationScreenTest() {
feature_list_.InitAndEnableFeature( feature_list_.InitAndEnableFeature(
...@@ -29,8 +38,13 @@ class GestureNavigationScreenTest : public OobeBaseTest { ...@@ -29,8 +38,13 @@ class GestureNavigationScreenTest : public OobeBaseTest {
~GestureNavigationScreenTest() override = default; ~GestureNavigationScreenTest() override = default;
// InProcessBrowserTest: // InProcessBrowserTest:
void SetUpCommandLine(base::CommandLine* command_line) override {
if (GetParam() == TestMode::kClamshellWithForcedTabletFirstRun)
command_line->AppendSwitch(switches::kOobeForceTabletFirstRun);
OobeBaseTest::SetUpCommandLine(command_line);
}
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
ash::ShellTestApi().SetTabletModeEnabledForTest(true); ash::ShellTestApi().SetTabletModeEnabledForTest(StartInTabletMode());
GestureNavigationScreen* gesture_screen = GestureNavigationScreen* gesture_screen =
static_cast<GestureNavigationScreen*>( static_cast<GestureNavigationScreen*>(
...@@ -43,6 +57,12 @@ class GestureNavigationScreenTest : public OobeBaseTest { ...@@ -43,6 +57,12 @@ class GestureNavigationScreenTest : public OobeBaseTest {
OobeBaseTest::SetUpOnMainThread(); OobeBaseTest::SetUpOnMainThread();
} }
bool StartInTabletMode() const { return GetParam() == TestMode::kTablet; }
bool ShouldBeSkippedInClamshell() const {
return GetParam() != TestMode::kClamshellWithForcedTabletFirstRun;
}
// Shows the gesture navigation screen. // Shows the gesture navigation screen.
void ShowGestureNavigationScreen() { void ShowGestureNavigationScreen() {
WizardController::default_controller()->AdvanceToScreen( WizardController::default_controller()->AdvanceToScreen(
...@@ -95,8 +115,14 @@ class GestureNavigationScreenTest : public OobeBaseTest { ...@@ -95,8 +115,14 @@ class GestureNavigationScreenTest : public OobeBaseTest {
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
}; };
INSTANTIATE_TEST_SUITE_P(
All,
GestureNavigationScreenTest,
testing::Values(TestMode::kTablet,
TestMode::kClamshellWithForcedTabletFirstRun));
// Ensure a working flow for the gesture navigation screen. // Ensure a working flow for the gesture navigation screen.
IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, FlowTest) { IN_PROC_BROWSER_TEST_P(GestureNavigationScreenTest, FlowTest) {
ShowGestureNavigationScreen(); ShowGestureNavigationScreen();
OobeScreenWaiter(GestureNavigationScreenView::kScreenId).Wait(); OobeScreenWaiter(GestureNavigationScreenView::kScreenId).Wait();
...@@ -139,16 +165,20 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, FlowTest) { ...@@ -139,16 +165,20 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, FlowTest) {
} }
// Ensure the flow is skipped when in clamshell mode. // Ensure the flow is skipped when in clamshell mode.
IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, ScreenSkippedInClamshell) { IN_PROC_BROWSER_TEST_P(GestureNavigationScreenTest, ScreenSkippedInClamshell) {
ash::ShellTestApi().SetTabletModeEnabledForTest(false); ash::ShellTestApi().SetTabletModeEnabledForTest(false);
ShowGestureNavigationScreen(); ShowGestureNavigationScreen();
WaitForScreenExit(); if (ShouldBeSkippedInClamshell()) {
WaitForScreenExit();
} else {
OobeScreenWaiter(GestureNavigationScreenView::kScreenId).Wait();
}
} }
// Ensure the flow is skipped when spoken feedback is enabled. // Ensure the flow is skipped when spoken feedback is enabled.
IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, IN_PROC_BROWSER_TEST_P(GestureNavigationScreenTest,
ScreenSkippedWithSpokenFeedbackEnabled) { ScreenSkippedWithSpokenFeedbackEnabled) {
AccessibilityManager::Get()->EnableSpokenFeedback(true); AccessibilityManager::Get()->EnableSpokenFeedback(true);
...@@ -158,7 +188,7 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, ...@@ -158,7 +188,7 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest,
} }
// Ensure the flow is skipped when autoclick is enabled. // Ensure the flow is skipped when autoclick is enabled.
IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, IN_PROC_BROWSER_TEST_P(GestureNavigationScreenTest,
ScreenSkippedWithAutoclickEnabled) { ScreenSkippedWithAutoclickEnabled) {
AccessibilityManager::Get()->EnableAutoclick(true); AccessibilityManager::Get()->EnableAutoclick(true);
...@@ -168,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, ...@@ -168,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest,
} }
// Ensure the flow is skipped when switch access is enabled. // Ensure the flow is skipped when switch access is enabled.
IN_PROC_BROWSER_TEST_F(GestureNavigationScreenTest, IN_PROC_BROWSER_TEST_P(GestureNavigationScreenTest,
ScreenSkippedWithSwitchAccessEnabled) { ScreenSkippedWithSwitchAccessEnabled) {
AccessibilityManager::Get()->SetSwitchAccessEnabled(true); AccessibilityManager::Get()->SetSwitchAccessEnabled(true);
......
...@@ -76,7 +76,8 @@ void MarketingOptInScreen::ShowImpl() { ...@@ -76,7 +76,8 @@ void MarketingOptInScreen::ShowImpl() {
// user login. Also skip the screen if clamshell mode is active. // user login. Also skip the screen if clamshell mode is active.
// TODO(mmourgos): Enable this screen for clamshell mode. // TODO(mmourgos): Enable this screen for clamshell mode.
if (chrome_user_manager_util::IsPublicSessionOrEphemeralLogin() || if (chrome_user_manager_util::IsPublicSessionOrEphemeralLogin() ||
!ash::TabletMode::Get()->InTabletMode()) { (!ash::TabletMode::Get()->InTabletMode() &&
did_skip_gesture_navigation_screen)) {
exit_callback_.Run(); exit_callback_.Run();
return; return;
} }
......
...@@ -430,6 +430,11 @@ const char kNoteTakingAppIds[] = "note-taking-app-ids"; ...@@ -430,6 +430,11 @@ const char kNoteTakingAppIds[] = "note-taking-app-ids";
// user-image // user-image
const char kOobeForceShowScreen[] = "oobe-force-show-screen"; const char kOobeForceShowScreen[] = "oobe-force-show-screen";
// Indicates that the first user run flow (sequence of OOBE screens after the
// first user login) should show tablet mode centric screens, even if the device
// is not in tablet mode.
const char kOobeForceTabletFirstRun[] = "oobe-force-tablet-first-run";
// Indicates that a guest session has been started before OOBE completion. // Indicates that a guest session has been started before OOBE completion.
const char kOobeGuestSession[] = "oobe-guest-session"; const char kOobeGuestSession[] = "oobe-guest-session";
...@@ -596,5 +601,10 @@ bool IsUnfilteredBluetoothDevicesEnabled() { ...@@ -596,5 +601,10 @@ bool IsUnfilteredBluetoothDevicesEnabled() {
kUnfilteredBluetoothDevices); kUnfilteredBluetoothDevices);
} }
bool ShouldOobeUseTabletModeFirstRun() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
kOobeForceTabletFirstRun);
}
} // namespace switches } // namespace switches
} // namespace chromeos } // namespace chromeos
...@@ -171,6 +171,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) ...@@ -171,6 +171,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kNeedArcMigrationPolicyCheck[]; extern const char kNeedArcMigrationPolicyCheck[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kNoteTakingAppIds[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kNoteTakingAppIds[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeForceShowScreen[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeForceShowScreen[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kOobeForceTabletFirstRun[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeGuestSession[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeGuestSession[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipPostLogin[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipPostLogin[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipToLogin[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipToLogin[];
...@@ -253,6 +255,11 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsArcCpuRestrictionDisabled(); ...@@ -253,6 +255,11 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsArcCpuRestrictionDisabled();
// Returns true if all Bluetooth devices in UI (System Tray/Settings Page.) // Returns true if all Bluetooth devices in UI (System Tray/Settings Page.)
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsUnfilteredBluetoothDevicesEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsUnfilteredBluetoothDevicesEnabled();
// Returns whether the first user run OOBE flow (sequence of screens shown to
// the user on their first login) should show tablet mode screens when the
// device is not in tablet mode.
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldOobeUseTabletModeFirstRun();
} // namespace switches } // namespace switches
} // namespace chromeos } // namespace chromeos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment