Commit 5b3ecb58 authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

OOBE: Hide accessibility button if gesture screen is not shown

This cl changes the accessibility button on the marketing opt in screen
to only show up when the gesture navigation screen was shown. This cl
adds a function, was_shown(), to the gesture screen. This function can
be called to check whether the the gesture screen was shown or skipped
over.

Bug: 1068686
Change-Id: I2f7808806bd795cc43c62ada40a9e3f830da8e3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142148
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758944}
parent 94cb38fa
......@@ -104,6 +104,7 @@ void GestureNavigationScreen::OnUserAction(const std::string& action_id) {
ash::prefs::kGestureEducationNotificationShown, true);
RecordPageShownTimeMetrics();
was_shown_ = true;
exit_callback_.Run(Result::NEXT);
} else {
BaseScreen::OnUserAction(action_id);
......
......@@ -37,6 +37,9 @@ class GestureNavigationScreen : public BaseScreen {
return exit_callback_;
}
// Returns whether the gesture screen was shown.
bool was_shown() const { return was_shown_; }
// Called when the currently shown page is changed.
void GesturePageChange(const std::string& new_page);
......@@ -65,6 +68,9 @@ class GestureNavigationScreen : public BaseScreen {
// The starting time for the most recently shown page.
base::TimeTicks start_time_;
// Whether the gesture screen was shown.
bool was_shown_ = false;
};
} // namespace chromeos
......
......@@ -22,8 +22,10 @@
#include "chrome/browser/chromeos/login/screen_manager.h"
#include "chrome/browser/chromeos/login/screens/gesture_navigation_screen.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
......@@ -154,6 +156,14 @@ void MarketingOptInScreen::ShowImpl() {
*/
view_->SetEmailToggleState(IsDefaultOptInCountry(country_));
// Only show the link for accessibility settings if the gesture navigation
// screen was shown.
view_->UpdateA11ySettingsButtonVisibility(
static_cast<GestureNavigationScreen*>(
WizardController::default_controller()->screen_manager()->GetScreen(
GestureNavigationScreenView::kScreenId))
->was_shown());
view_->UpdateA11yShelfNavigationButtonToggle(prefs->GetBoolean(
ash::prefs::kAccessibilityTabletModeShelfNavigationButtonsEnabled));
......@@ -196,6 +206,10 @@ void MarketingOptInScreen::OnGetStarted(bool chromebook_email_opt_in) {
ExitScreen();
}
void MarketingOptInScreen::SetA11yButtonVisibilityForTest(bool shown) {
view_->UpdateA11ySettingsButtonVisibility(shown);
}
void MarketingOptInScreen::ExitScreen() {
if (!active_)
return;
......
......@@ -48,6 +48,8 @@ class MarketingOptInScreen : public BaseScreen {
// On "Get Started" button pressed.
void OnGetStarted(bool chromebook_email_opt_in);
void SetA11yButtonVisibilityForTest(bool shown);
void set_exit_callback_for_testing(
const base::RepeatingClosure& exit_callback) {
exit_callback_ = exit_callback;
......
......@@ -54,9 +54,8 @@ class MarketingOptInScreenTest : public OobeBaseTest {
void SetUpOnMainThread() override {
ash::ShellTestApi().SetTabletModeEnabledForTest(true);
MarketingOptInScreen* marketing_screen = static_cast<MarketingOptInScreen*>(
WizardController::default_controller()->screen_manager()->GetScreen(
MarketingOptInScreenView::kScreenId));
MarketingOptInScreen* marketing_screen = MarketingOptInScreen::Get(
WizardController::default_controller()->screen_manager());
marketing_screen->set_exit_callback_for_testing(base::BindRepeating(
&MarketingOptInScreenTest::HandleScreenExit, base::Unretained(this)));
......@@ -80,6 +79,12 @@ class MarketingOptInScreenTest : public OobeBaseTest {
WaitForScreenExit();
}
void ShowAccessibilityButtonForTest() {
MarketingOptInScreen* marketing_screen = MarketingOptInScreen::Get(
WizardController::default_controller()->screen_manager());
marketing_screen->SetA11yButtonVisibilityForTest(true /* shown */);
}
void WaitForScreenExit() {
if (screen_exited_)
return;
......@@ -245,6 +250,7 @@ IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, OptInFlowWhenDefaultIsOptIn) {
// the screen.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, EnableShelfNavigationButtons) {
ShowMarketingOptInScreen();
ShowAccessibilityButtonForTest();
OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
// Tap on accessibility settings link, and wait for the accessibility settings
......@@ -286,6 +292,7 @@ IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, EnableShelfNavigationButtons) {
// Tests that the user can exit the screen from the accessibility page.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, ExitScreenFromA11yPage) {
ShowMarketingOptInScreen();
ShowAccessibilityButtonForTest();
OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
// Tap on accessibility settings link, and wait for the accessibility settings
......
......@@ -65,13 +65,16 @@
</div>
</div>
<div slot="bottom-buttons" class="layout horizontal justified">
<oobe-welcome-secondary-button
id="marketing-opt-in-accessibility-button"
on-tap="onToggleAccessibilityPage_"
icon1x="marketing-opt-in-32:accessibility"
icon2x="marketing-opt-in-64:accessibility"
text-key="marketingOptInA11yButtonLabel">
</oobe-welcome-secondary-button>
<div>
<oobe-welcome-secondary-button
hidden="[[!isA11ySettingsButtonVisible_]]"
id="marketing-opt-in-accessibility-button"
on-tap="onToggleAccessibilityPage_"
icon1x="marketing-opt-in-32:accessibility"
icon2x="marketing-opt-in-64:accessibility"
text-key="marketingOptInA11yButtonLabel">
</oobe-welcome-secondary-button>
</div>
<oobe-text-button on-tap="onGetStarted_" class="focus-on-show"
inverse text-key="marketingOptInScreenAllSet"
id="marketing-opt-in-next-button">
......
......@@ -16,6 +16,15 @@ Polymer({
value: false,
},
/**
* Whether the accessibility button is shown. This button is only shown
* if the gesture EDU screen was shown before the marketing screen.
*/
isA11ySettingsButtonVisible_: {
type: Boolean,
value: false,
},
/**
* Whether the marketing opt in toggles should be shown, which will be the
* case only if marketing opt in feature is enabled AND if the current user
......@@ -33,6 +42,7 @@ Polymer({
/** Overridden from LoginScreenBehavior. */
EXTERNAL_API: [
'updateA11ySettingsButtonVisibility',
'updateA11yNavigationButtonToggle',
'setOptInVisibility',
'setEmailToggleState'
......@@ -69,6 +79,13 @@ Polymer({
[this.$.chromebookUpdatesOption.checked]);
},
/**
* @param {boolean} shown Whether the A11y Settings button should be shown.
*/
updateA11ySettingsButtonVisibility(shown) {
this.isA11ySettingsButtonVisible_ = shown;
},
/**
* @param {boolean} enabled Whether the a11y setting for shownig shelf
* navigation buttons is enabled.
......
......@@ -80,6 +80,12 @@ void MarketingOptInScreenHandler::Hide() {
a11y_nav_buttons_toggle_metrics_reporter_timer_.FireNow();
}
void MarketingOptInScreenHandler::UpdateA11ySettingsButtonVisibility(
bool shown) {
CallJS("login.MarketingOptInScreen.updateA11ySettingsButtonVisibility",
shown);
}
void MarketingOptInScreenHandler::UpdateA11yShelfNavigationButtonToggle(
bool enabled) {
CallJS("login.MarketingOptInScreen.updateA11yNavigationButtonToggle",
......
......@@ -30,6 +30,9 @@ class MarketingOptInScreenView {
// Hides the contents of the screen.
virtual void Hide() = 0;
// Sets whether the a11y Settings button is visible.
virtual void UpdateA11ySettingsButtonVisibility(bool shown) = 0;
// Sets whether the a11y setting for showing shelf navigation buttons is
// toggled on or off.
virtual void UpdateA11yShelfNavigationButtonToggle(bool enabled) = 0;
......@@ -58,6 +61,7 @@ class MarketingOptInScreenHandler : public BaseScreenHandler,
void Bind(MarketingOptInScreen* screen) override;
void Show() override;
void Hide() override;
void UpdateA11ySettingsButtonVisibility(bool shown) override;
void UpdateA11yShelfNavigationButtonToggle(bool enabled) override;
void SetOptInVisibility(bool visible) override;
void SetEmailToggleState(bool checked) override;
......
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