Commit 61cd5fb8 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Disable tablet mode if screen reader is enabled.

This is a temporary fix while we hash out the attached a11y bugs.

Bug: 1136185, 1136236
Change-Id: I8a5ab6584fb708112c4b27ecae643be5a09f6564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459056Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815331}
parent c0cf6f4e
......@@ -172,7 +172,9 @@
#include "content/public/common/content_switches.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_mode_observer.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/hit_test.h"
......@@ -511,6 +513,32 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
BrowserView* browser_view_;
};
///////////////////////////////////////////////////////////////////////////////
// BrowserView::AccessibilityModeObserver:
class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
public:
explicit AccessibilityModeObserver(BrowserView* browser_view)
: browser_view_(browser_view) {
ui::AXPlatformNode::AddAXModeObserver(this);
}
~AccessibilityModeObserver() override {
ui::AXPlatformNode::RemoveAXModeObserver(this);
}
private:
// ui::AXModeObserver:
void OnAXModeAdded(ui::AXMode mode) override {
// This will have the effect of turning tablet mode off if a screen reader
// is enabled while Chrome is already open. It will not return the browser
// to tablet mode if the user kills their screen reader.
if (mode.has_mode(ui::AXMode::kScreenReader))
browser_view_->MaybeInitializeWebUITabStrip();
}
BrowserView* const browser_view_;
};
///////////////////////////////////////////////////////////////////////////////
// BrowserView, public:
......@@ -518,7 +546,10 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
const char BrowserView::kViewClassName[] = "BrowserView";
BrowserView::BrowserView(std::unique_ptr<Browser> browser)
: views::ClientView(nullptr, nullptr), browser_(std::move(browser)) {
: views::ClientView(nullptr, nullptr),
browser_(std::move(browser)),
accessibility_mode_observer_(
std::make_unique<AccessibilityModeObserver>(this)) {
SetShowIcon(::ShouldShowWindowIcon(browser_.get()));
SetHasWindowSizeControls(!chrome::IsRunningInForcedAppMode());
SetCanResize(browser_->can_resize());
......
......@@ -617,6 +617,7 @@ class BrowserView : public BrowserWindow,
friend class TopControlsSlideControllerTest;
FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView);
FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, AccessibleWindowTitle);
class AccessibilityModeObserver;
// If the browser is in immersive full screen mode, it will reveal the
// tabstrip for a short duration. This is useful for shortcuts that perform
......@@ -803,6 +804,13 @@ class BrowserView : public BrowserWindow,
// the webui based tabstrip, when applicable. see https://crbug.com/989131.
WebUITabStripContainerView* webui_tab_strip_ = nullptr;
// Allows us to react to changes in accessibility mode.
// TODO(dfried): this is only used to disable WebUI tabstrip (see above) while
// that mode has accessibile mode issues (e.g. crbug.com/1136185,
// crbug.com/1136236). Having an observer object allows for the browser to
// change mode if it enters or leaves accessibility mode.
std::unique_ptr<AccessibilityModeObserver> accessibility_mode_observer_;
// The Toolbar containing the navigation buttons, menus and the address bar.
ToolbarView* toolbar_ = nullptr;
......
......@@ -55,6 +55,8 @@
#include "components/feature_engagement/public/tracker.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/drop_data.h"
#include "ui/accessibility/ax_mode.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/aura/window.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/custom_data_helper.h"
......@@ -515,6 +517,14 @@ bool WebUITabStripContainerView::SupportsTouchableTabStrip(
// static
bool WebUITabStripContainerView::UseTouchableTabStrip(const Browser* browser) {
// TODO(crbug.com/1136185, crbug.com/1136236): We currently do not switch to
// touchable tabstrip in Screen Reader mode due to the touchable tabstrip
// being less accessible than the traditional tabstrip.
if (ui::AXPlatformNode::GetAccessibilityMode().has_mode(
ui::AXMode::kScreenReader)) {
return false;
}
// This is called at Browser start to check which mode to use. It is a
// good place to check the feature state and set up a synthetic field
// trial.
......
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