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