Commit cae4f3dc authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Updates swipe from shelf state in marketing opt in screen

Disables the swipe when showing accessibility page.

Disables the swipe when screen is not shown fullscreen (i.e. the swipe
is enabled only in OOBE first run).

BUG=1059354,1058896

Change-Id: I400fb1e1321d1123b46cebfcc316cb261ff6e52c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091938
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarMatthew Mourgos <mmourgos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748497}
parent 3fec5f63
...@@ -26,9 +26,11 @@ namespace chromeos { ...@@ -26,9 +26,11 @@ namespace chromeos {
MarketingOptInScreen::MarketingOptInScreen( MarketingOptInScreen::MarketingOptInScreen(
MarketingOptInScreenView* view, MarketingOptInScreenView* view,
bool is_fullscreen,
const base::RepeatingClosure& exit_callback) const base::RepeatingClosure& exit_callback)
: BaseScreen(MarketingOptInScreenView::kScreenId), : BaseScreen(MarketingOptInScreenView::kScreenId),
view_(view), view_(view),
is_fullscreen_(is_fullscreen),
exit_callback_(exit_callback) { exit_callback_(exit_callback) {
DCHECK(view_); DCHECK(view_);
view_->Bind(this); view_->Bind(this);
...@@ -41,7 +43,13 @@ MarketingOptInScreen::~MarketingOptInScreen() { ...@@ -41,7 +43,13 @@ MarketingOptInScreen::~MarketingOptInScreen() {
} }
void MarketingOptInScreen::OnShelfConfigUpdated() { void MarketingOptInScreen::OnShelfConfigUpdated() {
bool allow_shelf_gestures = !ash::ShelfConfig::Get()->shelf_controls_shown(); UpdateShelfGestureHandlingState();
}
void MarketingOptInScreen::UpdateShelfGestureHandlingState() {
const bool allow_shelf_gestures =
is_fullscreen_ && !ash::ShelfConfig::Get()->shelf_controls_shown() &&
!accessibility_page_shown_;
if (allow_shelf_gestures == handling_shelf_gestures_) if (allow_shelf_gestures == handling_shelf_gestures_)
return; return;
...@@ -96,12 +104,13 @@ void MarketingOptInScreen::ShowImpl() { ...@@ -96,12 +104,13 @@ void MarketingOptInScreen::ShowImpl() {
} }
active_ = true; active_ = true;
accessibility_page_shown_ = false;
view_->Show(); view_->Show();
prefs->SetBoolean(prefs::kOobeMarketingOptInScreenFinished, true); prefs->SetBoolean(prefs::kOobeMarketingOptInScreenFinished, true);
shelf_config_observer_.Add(ash::ShelfConfig::Get()); shelf_config_observer_.Add(ash::ShelfConfig::Get());
OnShelfConfigUpdated(); UpdateShelfGestureHandlingState();
// Make sure the screen next button visibility is properly initialized. // Make sure the screen next button visibility is properly initialized.
view_->UpdateAllSetButtonVisibility(!handling_shelf_gestures_ /*visible*/); view_->UpdateAllSetButtonVisibility(!handling_shelf_gestures_ /*visible*/);
...@@ -131,14 +140,11 @@ void MarketingOptInScreen::HideImpl() { ...@@ -131,14 +140,11 @@ void MarketingOptInScreen::HideImpl() {
return; return;
active_ = false; active_ = false;
shelf_config_observer_.RemoveAll(); shelf_config_observer_.RemoveAll();
active_user_pref_change_registrar_.reset();
view_->Hide(); view_->Hide();
ClearLoginShelfGestureHandler(); ClearLoginShelfGestureHandler();
active_user_pref_change_registrar_.reset();
} }
void MarketingOptInScreen::OnAllSet(bool play_communications_opt_in, void MarketingOptInScreen::OnAllSet(bool play_communications_opt_in,
...@@ -147,6 +153,11 @@ void MarketingOptInScreen::OnAllSet(bool play_communications_opt_in, ...@@ -147,6 +153,11 @@ void MarketingOptInScreen::OnAllSet(bool play_communications_opt_in,
ExitScreen(); ExitScreen();
} }
void MarketingOptInScreen::OnAccessibilityPageVisibilityChanged(bool shown) {
accessibility_page_shown_ = shown;
UpdateShelfGestureHandlingState();
}
void MarketingOptInScreen::HandleFlingFromShelf() { void MarketingOptInScreen::HandleFlingFromShelf() {
ExitScreen(); ExitScreen();
} }
......
...@@ -23,6 +23,7 @@ class MarketingOptInScreen : public BaseScreen, ...@@ -23,6 +23,7 @@ class MarketingOptInScreen : public BaseScreen,
public ash::ShelfConfig::Observer { public ash::ShelfConfig::Observer {
public: public:
MarketingOptInScreen(MarketingOptInScreenView* view, MarketingOptInScreen(MarketingOptInScreenView* view,
bool is_fullscreen,
const base::RepeatingClosure& exit_callback); const base::RepeatingClosure& exit_callback);
~MarketingOptInScreen() override; ~MarketingOptInScreen() override;
...@@ -30,6 +31,10 @@ class MarketingOptInScreen : public BaseScreen, ...@@ -30,6 +31,10 @@ class MarketingOptInScreen : public BaseScreen,
void OnAllSet(bool play_communications_opt_in, void OnAllSet(bool play_communications_opt_in,
bool tips_communications_opt_in); bool tips_communications_opt_in);
// Called when the visibility of the accessibility page within the screen
// changes.
void OnAccessibilityPageVisibilityChanged(bool shown);
// ash::ShelfCondif::Observer: // ash::ShelfCondif::Observer:
void OnShelfConfigUpdated() override; void OnShelfConfigUpdated() override;
...@@ -44,6 +49,14 @@ class MarketingOptInScreen : public BaseScreen, ...@@ -44,6 +49,14 @@ class MarketingOptInScreen : public BaseScreen,
void HideImpl() override; void HideImpl() override;
private: private:
// Enables or disables shelf gesture handling depending on the current state.
// Gesture handling should be disabled if shelf navigation buttons should be
// shown in this context, or if the screen is on the accessibility settings
// page.
// Gesture handling is only supported if the screen is shown in fullscreen
// OOBE.
void UpdateShelfGestureHandlingState();
// Called when a fling from the shelf is detected - it exits the screen. // Called when a fling from the shelf is detected - it exits the screen.
// This is the fling callback passed to // This is the fling callback passed to
// LoginScreen::SetLoginShelfGestureHandler(). // LoginScreen::SetLoginShelfGestureHandler().
...@@ -66,12 +79,21 @@ class MarketingOptInScreen : public BaseScreen, ...@@ -66,12 +79,21 @@ class MarketingOptInScreen : public BaseScreen,
MarketingOptInScreenView* const view_; MarketingOptInScreenView* const view_;
// Whether the screen is shown as part the first run with OOBE display type,
// i.e. if the screen UI is shown fullscreen. Note that the shelf swipe
// gesture will only be enabled in fullscreen mode.
const bool is_fullscreen_;
// Whether the screen is shown and exit callback has not been run. // Whether the screen is shown and exit callback has not been run.
bool active_ = false; bool active_ = false;
// Whether the screen has set a login shelf gesture handler. // Whether the screen has set a login shelf gesture handler.
bool handling_shelf_gestures_ = false; bool handling_shelf_gestures_ = false;
// Whether the accessibility page (that contains an option to make the shelf
// navigation buttons show in tablet mode) is currently shown.
bool accessibility_page_shown_ = false;
base::RepeatingClosure exit_callback_; base::RepeatingClosure exit_callback_;
ScopedObserver<ash::ShelfConfig, ash::ShelfConfig::Observer> ScopedObserver<ash::ShelfConfig, ash::ShelfConfig::Observer>
......
...@@ -222,4 +222,125 @@ IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, ...@@ -222,4 +222,125 @@ IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest,
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler()); EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
} }
// Tests that the user can enable shelf navigation buttons in tablet mode from
// the screen.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, EnableShelfNavigationButtons) {
ShowMarketingOptInScreen();
OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
EXPECT_TRUE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tap on accessibility settings link, and wait for the accessibility settings
// UI to show up.
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityLink"})
->Wait();
test::OobeJS().TapLinkOnPath({"marketing-opt-in", "finalAccessibilityLink"});
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityPage"})
->Wait();
// Swipe from shelf should be disabled on this page.
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tap the shelf navigation buttons in tablet mode toggle.
test::OobeJS()
.CreateVisibilityWaiter(true, {"marketing-opt-in", "a11yNavButtonToggle"})
->Wait();
test::OobeJS().ClickOnPath(
{"marketing-opt-in", "a11yNavButtonToggle", "button"});
// Go back to the first screen, and verify the 'all set button' is shown now.
test::OobeJS().TapOnPath(
{"marketing-opt-in", "final-accessibility-back-button"});
test::OobeJS()
.CreateVisibilityWaiter(
true, {"marketing-opt-in", "marketingOptInOverviewDialog"})
->Wait();
// Verify that swipe gesture is still disabled.
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tapping the next button exits the screen.
test::OobeJS().ExpectVisiblePath(
{"marketing-opt-in", "marketing-opt-in-next-button"});
test::OobeJS().TapOnPath(
{"marketing-opt-in", "marketing-opt-in-next-button"});
WaitForScreenExit();
// Verify the accessibility pref for shelf navigation buttons is set.
EXPECT_TRUE(ProfileManager::GetActiveUserProfile()->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilityTabletModeShelfNavigationButtonsEnabled));
}
// Tests that the user can exit the screen from the accessibility page.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, ExitScreenFromA11yPage) {
ShowMarketingOptInScreen();
OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
EXPECT_TRUE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tap on accessibility settings link, and wait for the accessibility settings
// UI to show up.
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityLink"})
->Wait();
test::OobeJS().TapLinkOnPath({"marketing-opt-in", "finalAccessibilityLink"});
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityPage"})
->Wait();
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tapping the next button exits the screen.
test::OobeJS().TapOnPath(
{"marketing-opt-in", "final-accessibility-next-button"});
WaitForScreenExit();
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
}
// Tests that the swipe from shelf gets re-enabled when coming back from
// accessibility settings page (if the shelf navigation toggle was not toggled).
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest,
SwipeFromShelfAfterReturnFromA11yPage) {
ShowMarketingOptInScreen();
OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
EXPECT_TRUE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tap on accessibility settings link, and wait for the accessibility settings
// UI to show up.
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityLink"})
->Wait();
test::OobeJS().TapLinkOnPath({"marketing-opt-in", "finalAccessibilityLink"});
test::OobeJS()
.CreateVisibilityWaiter(true,
{"marketing-opt-in", "finalAccessibilityPage"})
->Wait();
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Tapping back button to go back to the initial page.
test::OobeJS().TapOnPath(
{"marketing-opt-in", "final-accessibility-back-button"});
test::OobeJS()
.CreateVisibilityWaiter(
true, {"marketing-opt-in", "marketingOptInOverviewDialog"})
->Wait();
// Verify that swipe gesture is enabled.
EXPECT_TRUE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
// Swipe from shelf to exit the screen.
SimulateFlingFromShelf();
WaitForScreenExit();
EXPECT_FALSE(ash::ShelfTestApi().HasLoginShelfGestureHandler());
}
} // namespace chromeos } // namespace chromeos
...@@ -583,6 +583,7 @@ std::vector<std::unique_ptr<BaseScreen>> WizardController::CreateScreens() { ...@@ -583,6 +583,7 @@ std::vector<std::unique_ptr<BaseScreen>> WizardController::CreateScreens() {
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
append(std::make_unique<MarketingOptInScreen>( append(std::make_unique<MarketingOptInScreen>(
oobe_ui->GetView<MarketingOptInScreenHandler>(), oobe_ui->GetView<MarketingOptInScreenHandler>(),
oobe_ui->display_type() == OobeUI::kOobeDisplay /*is_fullscreen*/,
base::BindRepeating(&WizardController::OnMarketingOptInScreenExit, base::BindRepeating(&WizardController::OnMarketingOptInScreenExit,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
append(std::make_unique<PackagedLicenseScreen>( append(std::make_unique<PackagedLicenseScreen>(
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<oobe-dialog id="finalAccessibilityPage" role="dialog" has-buttons <oobe-dialog id="finalAccessibilityPage" role="dialog" has-buttons
hidden="[[!isAccessibilitySettingsShown_]]" hidden="[[!isAccessibilitySettingsShown_]]"
title-key="finalA11yPageTitle" title-key="finalA11yPageTitle"
aria-label$="[[i18nDynamic(locale, 'finalA11yPageTitle')]]">> aria-label$="[[i18nDynamic(locale, 'finalA11yPageTitle')]]">
<hd-iron-icon slot="oobe-icon" <hd-iron-icon slot="oobe-icon"
icon1x="marketing-opt-in-32:accessibility" icon1x="marketing-opt-in-32:accessibility"
icon2x="marketing-opt-in-64:accessibility"> icon2x="marketing-opt-in-64:accessibility">
...@@ -118,7 +118,8 @@ ...@@ -118,7 +118,8 @@
<div slot="bottom-buttons" class="layout horizontal justified"> <div slot="bottom-buttons" class="layout horizontal justified">
<oobe-back-button on-tap="onToggleAccessibilityPage_" <oobe-back-button on-tap="onToggleAccessibilityPage_"
id="final-accessibility-back-button"></oobe-back-button> id="final-accessibility-back-button"></oobe-back-button>
<oobe-text-button on-tap="onAllSet_" class="focus-on-show" inverse <oobe-text-button on-tap="onAllSet_" class="focus-on-show"
id="final-accessibility-next-button" inverse
text-key="finalA11yPageDoneButtonTitle"> text-key="finalA11yPageDoneButtonTitle">
</oobe-text-button> </oobe-text-button>
</div> </div>
......
...@@ -58,6 +58,16 @@ Polymer({ ...@@ -58,6 +58,16 @@ Polymer({
.setPlay(true); .setPlay(true);
}, },
/** Called when dialog is shown */
onBeforeShow() {
this.isAccessibilitySettingsShown_ = false;
this.behaviors.forEach((behavior) => {
if (behavior.onBeforeShow)
behavior.onBeforeShow.call(this);
});
},
/** /**
* This is 'on-tap' event handler for 'AcceptAndContinue/Next' buttons. * This is 'on-tap' event handler for 'AcceptAndContinue/Next' buttons.
* @private * @private
...@@ -108,6 +118,11 @@ Polymer({ ...@@ -108,6 +118,11 @@ Polymer({
this.$['marketingOptInOverviewDialog'] this.$['marketingOptInOverviewDialog']
.querySelector('.marketing-animation') .querySelector('.marketing-animation')
.setPlay(!this.isAccessibilitySettingsShown_); .setPlay(!this.isAccessibilitySettingsShown_);
chrome.send(
'login.MarketingOptInScreen.accessibilityPageVisibilityChanged', [
this.isAccessibilitySettingsShown_
]);
}, },
/** /**
......
...@@ -87,6 +87,9 @@ void MarketingOptInScreenHandler::RegisterMessages() { ...@@ -87,6 +87,9 @@ void MarketingOptInScreenHandler::RegisterMessages() {
AddCallback( AddCallback(
"login.MarketingOptInScreen.setA11yNavigationButtonsEnabled", "login.MarketingOptInScreen.setA11yNavigationButtonsEnabled",
&MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled); &MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled);
AddCallback(
"login.MarketingOptInScreen.accessibilityPageVisibilityChanged",
&MarketingOptInScreenHandler::HandleAccessibilityPageVisibilityChanged);
} }
void MarketingOptInScreenHandler::GetAdditionalParameters( void MarketingOptInScreenHandler::GetAdditionalParameters(
...@@ -103,6 +106,11 @@ void MarketingOptInScreenHandler::HandleAllSet( ...@@ -103,6 +106,11 @@ void MarketingOptInScreenHandler::HandleAllSet(
screen_->OnAllSet(play_communications_opt_in, tips_communications_opt_in); screen_->OnAllSet(play_communications_opt_in, tips_communications_opt_in);
} }
void MarketingOptInScreenHandler::HandleAccessibilityPageVisibilityChanged(
bool shown) {
screen_->OnAccessibilityPageVisibilityChanged(shown);
}
void MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled( void MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled(
bool enabled) { bool enabled) {
ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean( ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean(
......
...@@ -67,9 +67,10 @@ class MarketingOptInScreenHandler : public BaseScreenHandler, ...@@ -67,9 +67,10 @@ class MarketingOptInScreenHandler : public BaseScreenHandler,
void RegisterMessages() override; void RegisterMessages() override;
void GetAdditionalParameters(base::DictionaryValue* parameters) override; void GetAdditionalParameters(base::DictionaryValue* parameters) override;
// WebUI event handler. // WebUI event handlers.
void HandleAllSet(bool play_communications_opt_in, void HandleAllSet(bool play_communications_opt_in,
bool tips_communications_opt_in); bool tips_communications_opt_in);
void HandleAccessibilityPageVisibilityChanged(bool shown);
void HandleSetA11yNavigationButtonsEnabled(bool enabled); void HandleSetA11yNavigationButtonsEnabled(bool enabled);
MarketingOptInScreen* screen_ = nullptr; MarketingOptInScreen* screen_ = nullptr;
......
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