1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/342213636): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
#include <windows.h> // Must be in front of other Windows header files.
#include <stddef.h>
#include <memory>
#include "base/check_deref.h"
#include "base/containers/heap_array.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/thread_pool.h"
#include "base/win/registry.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/scoped_accessibility_mode.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/platform/ax_platform.h"
#include "ui/accessibility/platform/ax_platform_node_win.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/win/singleton_hwnd_observer.h"
namespace content {
namespace {
// Killswitch to turn off this feature remotely in case it affects ATs in a way
// we didn't expect. This is temporary.
// TODO(crbug.com/407891291): Remove this feature flag in Chrome 139.
BASE_FEATURE(kDisableUiaProviderWhenJawsIsRunning,
"DisableUiaProviderWhenJawsIsRunning",
base::FEATURE_ENABLED_BY_DEFAULT);
const wchar_t kNarratorRegistryKey[] = L"Software\\Microsoft\\Narrator\\NoRoam";
const wchar_t kWinMagnifierRegistryKey[] =
L"Software\\Microsoft\\ScreenMagnifier";
const wchar_t kWinATRunningStateValueName[] = L"RunningState";
enum class AccessibilityTarget {
kStickyKeys,
kUia,
kJaws,
kNarrator,
kNvda,
kWinMagnifier,
kSupernova,
kZoomText,
kZdsr,
};
struct ModuleVersion {
uint16_t major = 0, minor = 0, build = 0, revision = 0;
bool IsLowerThan(const ModuleVersion& other) const {
if (major != other.major) {
return major < other.major;
}
if (minor != other.minor) {
return minor < other.minor;
}
if (build != other.build) {
return build < other.build;
}
return revision < other.revision;
}
std::string ToString() const {
return base::StringPrintf("%u.%u.%u.%u", major, minor, build, revision);
}
};
struct AssistiveTechInfo {
AccessibilityTarget tech;
std::optional<ModuleVersion> version;
};
std::optional<ModuleVersion> GetModuleVersion(const std::wstring& filename) {
DWORD dummy = 0;
DWORD size = ::GetFileVersionInfoSizeW(filename.c_str(), &dummy);
if (size == 0) {
return std::nullopt;
}
std::vector<BYTE> buffer(size);
if (!::GetFileVersionInfoW(filename.c_str(), dummy, size, buffer.data())) {
return std::nullopt;
}
VS_FIXEDFILEINFO* ffi = nullptr;
UINT len = 0;
if (::VerQueryValueW(buffer.data(), L"\\", reinterpret_cast<void**>(&ffi),
&len) &&
len != 0 && ffi->dwSignature == VS_FFI_SIGNATURE) {
uint16_t major = HIWORD(ffi->dwProductVersionMS);
uint16_t minor = LOWORD(ffi->dwProductVersionMS);
uint16_t build = HIWORD(ffi->dwProductVersionLS);
uint16_t revision = LOWORD(ffi->dwProductVersionLS);
return ModuleVersion{major, minor, build, revision};
}
return std::nullopt;
}
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(JawsMajorVersion)
enum class JawsMajorVersion {
kLegacy = 0,
k2020 = 1,
k2021 = 2,
k2022 = 3,
k2023 = 4,
k2024 = 5,
k2025 = 6,
k2026 = 7,
k2027 = 8,
k2028 = 9,
k2029 = 10,
k2030 = 11,
k2031 = 12,
k2032 = 13,
k2033 = 14,
k2034 = 15,
k2035 = 16,
k2036 = 17,
k2037 = 18,
k2038 = 19,
k2039 = 20,
k2040 = 21,
kPost2040 = 22,
kMaxValue = kPost2040,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/accessibility/enums.xml:JAWSMajorVersion)
JawsMajorVersion MapModuleVersionToJaws(const ModuleVersion& version) {
constexpr uint16_t kFirstKnownVersion = 2020;
constexpr uint16_t kLastKnownVersion = 2040;
if (version.major > kLastKnownVersion) {
return JawsMajorVersion::kPost2040;
}
if (version.major >= kFirstKnownVersion &&
version.major <= kLastKnownVersion) {
return static_cast<JawsMajorVersion>(version.major -
(kFirstKnownVersion - 1));
}
return JawsMajorVersion::kLegacy;
}
// Older versions of JAWS are known to not work well with text fields when we
// expose the native UIA provider. Disable it when we detect an older version
// version of JAWS. JAWS fixed the issue in versions:
// * 2022.2402.1+
// * 2023.2402.1+
// * 2024.2312.99+
// * 2025+
bool IsJawsCompatibleWithUIA(const ModuleVersion& version) {
return !(version.IsLowerThan(ModuleVersion{2022, 0, 0, 0}) ||
(version.major == 2022 &&
version.IsLowerThan(ModuleVersion{2022, 2402, 1, 0})) ||
(version.major == 2023 &&
version.IsLowerThan(ModuleVersion{2023, 2402, 1, 0})) ||
(version.major == 2024 &&
version.IsLowerThan(ModuleVersion{2024, 2312, 99, 0})));
}
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(NvdaMajorVersion)
enum class NvdaMajorVersion {
kLegacy = 0,
k2020 = 1,
k2021 = 2,
k2022 = 3,
k2023 = 4,
k2024 = 5,
k2025 = 6,
k2026 = 7,
k2027 = 8,
k2028 = 9,
k2029 = 10,
k2030 = 11,
k2031 = 12,
k2032 = 13,
k2033 = 14,
k2034 = 15,
k2035 = 16,
k2036 = 17,
k2037 = 18,
k2038 = 19,
k2039 = 20,
k2040 = 21,
kPost2040 = 22,
kMaxValue = kPost2040,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/accessibility/enums.xml:NVDAMajorVersion)
NvdaMajorVersion MapModuleVersionToNvda(const ModuleVersion& version) {
constexpr uint16_t kFirstKnownVersion = 2020;
constexpr uint16_t kLastKnownVersion = 2040;
if (version.major > kLastKnownVersion) {
return NvdaMajorVersion::kPost2040;
}
if (version.major >= kFirstKnownVersion &&
version.major <= kLastKnownVersion) {
return static_cast<NvdaMajorVersion>(version.major -
(kFirstKnownVersion - 1));
}
return NvdaMajorVersion::kLegacy;
}
// Returns a vector of all Assistive Technologies that are currently running,
// and their versions if available. We return a vector instead of a map
// because it's technically possible to have multiple versions of the same
// AT running at the same time.
std::vector<AssistiveTechInfo> DiscoverAssistiveTech() {
std::vector<AssistiveTechInfo> discovered_ats;
// NOTE: this method is run from another thread to reduce jank, since
// there's no guarantee these system calls will return quickly.
STICKYKEYS sticky_keys = {.cbSize = sizeof(STICKYKEYS)};
SystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sticky_keys, 0);
if (sticky_keys.dwFlags & SKF_STICKYKEYSON) {
discovered_ats.push_back({AccessibilityTarget::kStickyKeys, std::nullopt});
}
// Narrator detection. Narrator is not injected in process so it needs to be
// detected in a different way.
DWORD narrator_value = 0;
if (base::win::RegKey(HKEY_CURRENT_USER, kNarratorRegistryKey,
KEY_QUERY_VALUE)
.ReadValueDW(kWinATRunningStateValueName, &narrator_value) ==
ERROR_SUCCESS &&
narrator_value) {
discovered_ats.push_back({AccessibilityTarget::kNarrator, std::nullopt});
}
// Windows magnifier detection.
DWORD windows_magnifier_value = 0;
if (base::win::RegKey(HKEY_CURRENT_USER, kWinMagnifierRegistryKey,
KEY_QUERY_VALUE)
.ReadValueDW(kWinATRunningStateValueName,
&windows_magnifier_value) == ERROR_SUCCESS &&
windows_magnifier_value) {
discovered_ats.push_back(
{AccessibilityTarget::kWinMagnifier, std::nullopt});
}
std::vector<HMODULE> snapshot;
if (!base::win::GetLoadedModulesSnapshot(::GetCurrentProcess(), &snapshot)) {
return discovered_ats;
}
TCHAR filename[MAX_PATH];
for (HMODULE module : snapshot) {
auto name_length =
::GetModuleFileName(module, filename, std::size(filename));
if (name_length == 0 || name_length >= std::size(filename)) {
continue;
}
std::string module_name(base::FilePath(filename).BaseName().AsUTF8Unsafe());
if (base::EqualsCaseInsensitiveASCII(module_name, "fsdomsrv.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kJaws, GetModuleVersion(filename)});
}
if (base::EqualsCaseInsensitiveASCII(module_name,
"vbufbackend_gecko_ia2.dll") ||
base::EqualsCaseInsensitiveASCII(module_name, "nvdahelperremote.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kNvda, GetModuleVersion(filename)});
}
if (base::EqualsCaseInsensitiveASCII(module_name, "dolwinhk.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kSupernova, GetModuleVersion(filename)});
}
if (base::EqualsCaseInsensitiveASCII(module_name, "outhelper.dll") ||
base::EqualsCaseInsensitiveASCII(module_name, "outhelper_x64.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kZdsr, GetModuleVersion(filename)});
}
if (base::EqualsCaseInsensitiveASCII(module_name, "zslhook.dll") ||
base::EqualsCaseInsensitiveASCII(module_name, "zslhook64.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kZoomText, GetModuleVersion(filename)});
}
if (base::EqualsCaseInsensitiveASCII(module_name, "uiautomation.dll") ||
base::EqualsCaseInsensitiveASCII(module_name, "uiautomationcore.dll")) {
discovered_ats.push_back(
{AccessibilityTarget::kUia, GetModuleVersion(filename)});
}
}
return discovered_ats;
}
void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (message == WM_SETTINGCHANGE && wparam == SPI_SETCLIENTAREAANIMATION) {
gfx::Animation::UpdatePrefersReducedMotion();
BrowserAccessibilityStateImpl::GetInstance()
->NotifyWebContentsPreferencesChanged();
}
}
} // namespace
class BrowserAccessibilityStateImplWin : public BrowserAccessibilityStateImpl {
public:
BrowserAccessibilityStateImplWin();
protected:
void RefreshAssistiveTech() override;
void RefreshAssistiveTechIfNecessary(ui::AXMode new_mode) override;
ui::AXPlatform::ProductStrings GetProductStrings() override;
void OnUiaProviderRequested(bool uia_provider_enabled) override;
void OnUiaProviderDisabled() override;
private:
void OnDiscoveredAssistiveTech(
const std::vector<AssistiveTechInfo>& discovered_ats);
std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
// A ScopedAccessibilityMode that holds AXMode::kScreenReader when
// an active screen reader has been detected.
std::unique_ptr<ScopedAccessibilityMode> screen_reader_mode_;
// The presence of an AssistiveTech is currently being recomputed.
// Will be updated via DiscoverAssistiveTech().
bool awaiting_known_assistive_tech_computation_ = false;
};
BrowserAccessibilityStateImplWin::BrowserAccessibilityStateImplWin() {
if (base::SingleThreadTaskRunner::HasCurrentDefault()) {
singleton_hwnd_observer_ = std::make_unique<gfx::SingletonHwndObserver>(
base::BindRepeating(&OnWndProc));
}
}
void BrowserAccessibilityStateImplWin::RefreshAssistiveTech() {
if (!awaiting_known_assistive_tech_computation_) {
awaiting_known_assistive_tech_computation_ = true;
// Using base::Unretained() instead of a weak pointer as the lifetime of
// this is tied to BrowserMainLoop.
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&DiscoverAssistiveTech),
base::BindOnce(
&BrowserAccessibilityStateImplWin::OnDiscoveredAssistiveTech,
base::Unretained(this)));
}
}
void BrowserAccessibilityStateImplWin::RefreshAssistiveTechIfNecessary(
ui::AXMode new_mode) {
bool was_screen_reader_active = ax_platform().IsScreenReaderActive();
bool has_screen_reader_mode = new_mode.has_mode(ui::AXMode::kScreenReader);
if (was_screen_reader_active != has_screen_reader_mode) {
OnAssistiveTechFound(has_screen_reader_mode
? ui::AssistiveTech::kGenericScreenReader
: ui::AssistiveTech::kNone);
return;
}
// An expensive check is required to determine which type of assistive tech is
// in use. Make this check only when `kExtendedProperties` is added or removed
// from the process-wide mode flags and no previous assistive tech has been
// discovered (in the former case) or one had been discovered (in the latter
// case). `kScreenReader` will be added/removed from the process-wide mode
// flags on completion and `OnAssistiveTechFound()` will be called with the
// results of the check.
bool has_extended_properties =
new_mode.has_mode(ui::AXMode::kExtendedProperties);
if (was_screen_reader_active != has_extended_properties) {
// Perform expensive assistive tech detection.
RefreshAssistiveTech();
}
}
void BrowserAccessibilityStateImplWin::OnDiscoveredAssistiveTech(
const std::vector<AssistiveTechInfo>& at_infos) {
awaiting_known_assistive_tech_computation_ = false;
if (ActiveAssistiveTech() == ui::AssistiveTech::kGenericScreenReader) {
// A test has overridden the screen reader state manually.
// In such cases, we don't want to alter it.
return;
}
// Older versions of JAWS are known to not work well with text fields when we
// expose the native UIA provider. Disable it when we detect an older version
// version of JAWS. JAWS fixed the issue in versions:
// * 2022.2402.1+
// * 2023.2402.1+
// * 2024.2312.99+
// * 2025+
if (base::FeatureList::IsEnabled(kDisableUiaProviderWhenJawsIsRunning) &&
ui::AXPlatform::GetInstance().IsUiaProviderEnabled()) {
for (const auto& info : at_infos) {
if (info.tech == AccessibilityTarget::kJaws && info.version.has_value()) {
if (!IsJawsCompatibleWithUIA(*info.version)) {
ui::AXPlatform::GetInstance().DisableActiveUiaProvider();
break;
}
}
}
}
// Helper lambda to check for a specific AT.
auto HasTarget = [&at_infos](AccessibilityTarget target) -> bool {
for (const auto& info : at_infos) {
if (info.tech == target) {
return true;
}
}
return false;
};
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinJAWS",
HasTarget(AccessibilityTarget::kJaws));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinNarrator",
HasTarget(AccessibilityTarget::kNarrator));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinNVDA",
HasTarget(AccessibilityTarget::kNvda));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinSupernova",
HasTarget(AccessibilityTarget::kSupernova));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinMagnifier",
HasTarget(AccessibilityTarget::kWinMagnifier));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinZoomText",
HasTarget(AccessibilityTarget::kZoomText));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinAPIs.UIAutomation",
HasTarget(AccessibilityTarget::kUia));
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinStickyKeys",
HasTarget(AccessibilityTarget::kStickyKeys));
static auto* ax_jaws_crash_key = base::debug::AllocateCrashKeyString(
"ax_jaws", base::debug::CrashKeySize::Size32);
static auto* ax_narrator_crash_key = base::debug::AllocateCrashKeyString(
"ax_narrator", base::debug::CrashKeySize::Size32);
static auto* ax_win_magnifier_crash_key = base::debug::AllocateCrashKeyString(
"ax_win_magnifier", base::debug::CrashKeySize::Size32);
static auto* ax_nvda_crash_key = base::debug::AllocateCrashKeyString(
"ax_nvda", base::debug::CrashKeySize::Size32);
static auto* ax_supernova_crash_key = base::debug::AllocateCrashKeyString(
"ax_supernova", base::debug::CrashKeySize::Size32);
static auto* ax_zdsr_crash_key = base::debug::AllocateCrashKeyString(
"ax_zdsr", base::debug::CrashKeySize::Size32);
static auto* ax_zoomtext_crash_key = base::debug::AllocateCrashKeyString(
"ax_zoomtext", base::debug::CrashKeySize::Size32);
static auto* ax_uia_crash_key = base::debug::AllocateCrashKeyString(
"ax_ui_automation", base::debug::CrashKeySize::Size32);
// API support library, not an actual AT.
if (HasTarget(AccessibilityTarget::kUia)) {
base::debug::SetCrashKeyString(ax_uia_crash_key, "true");
} else {
base::debug::ClearCrashKeyString(ax_uia_crash_key);
}
// More than one type of assistive tech can be running at the same time.
// Will prefer to report screen reader over other types of assistive tech,
// because screen readers have the strongest effect on the user experience.
ui::AssistiveTech most_important_assistive_tech = ui::AssistiveTech::kNone;
if (HasTarget(AccessibilityTarget::kWinMagnifier)) {
base::debug::SetCrashKeyString(ax_narrator_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kWinMagnifier;
} else {
base::debug::ClearCrashKeyString(ax_win_magnifier_crash_key);
}
if (HasTarget(AccessibilityTarget::kZoomText)) {
base::debug::SetCrashKeyString(ax_zoomtext_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kZoomText;
} else {
base::debug::ClearCrashKeyString(ax_zoomtext_crash_key);
}
if (HasTarget(AccessibilityTarget::kJaws)) {
base::debug::SetCrashKeyString(ax_jaws_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kJaws;
} else {
base::debug::ClearCrashKeyString(ax_jaws_crash_key);
}
if (HasTarget(AccessibilityTarget::kNarrator)) {
base::debug::SetCrashKeyString(ax_narrator_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kNarrator;
} else {
base::debug::ClearCrashKeyString(ax_narrator_crash_key);
}
if (HasTarget(AccessibilityTarget::kNvda)) {
base::debug::SetCrashKeyString(ax_nvda_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kNvda;
} else {
base::debug::ClearCrashKeyString(ax_nvda_crash_key);
}
if (HasTarget(AccessibilityTarget::kSupernova)) {
base::debug::SetCrashKeyString(ax_supernova_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kSupernova;
} else {
base::debug::ClearCrashKeyString(ax_supernova_crash_key);
}
if (HasTarget(AccessibilityTarget::kZdsr)) {
base::debug::SetCrashKeyString(ax_zdsr_crash_key, "true");
most_important_assistive_tech = ui::AssistiveTech::kZdsr;
} else {
base::debug::ClearCrashKeyString(ax_zdsr_crash_key);
}
// Histograms for the JAWS and NVDA versions.
for (const auto& info : at_infos) {
if (info.tech == AccessibilityTarget::kJaws && info.version) {
UMA_HISTOGRAM_BOOLEAN("Accessibility.WinJAWSCompatibleWithUIA",
IsJawsCompatibleWithUIA(*info.version));
JawsMajorVersion jaws_version = MapModuleVersionToJaws(*info.version);
base::UmaHistogramEnumeration("Accessibility.WinJAWSVersion",
jaws_version);
continue;
}
if (info.tech == AccessibilityTarget::kNvda && info.version) {
NvdaMajorVersion nvda_version = MapModuleVersionToNvda(*info.version);
base::UmaHistogramEnumeration("Accessibility.WinNVDAVersion",
nvda_version);
continue;
}
}
// Save the current assistive tech before toggling AXModes, so
// that RefreshAssistiveTechIfNecessary() is a noop.
OnAssistiveTechFound(most_important_assistive_tech);
// Add kScreenReader mode flag for products with screen reader features, which
// includes some magnifiers with light screen reader features (e.g. heading
// navigation).
if (ui::IsScreenReader(most_important_assistive_tech)) {
if (!screen_reader_mode_) {
screen_reader_mode_ = CreateScopedModeForProcess(
ui::kAXModeComplete | ui::AXMode::kScreenReader);
}
} else {
screen_reader_mode_.reset();
}
}
ui::AXPlatform::ProductStrings
BrowserAccessibilityStateImplWin::GetProductStrings() {
ContentClient& content_client = CHECK_DEREF(content::GetContentClient());
// GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
// the part before and after the "/".
std::vector<std::string> product_components = base::SplitString(
CHECK_DEREF(CHECK_DEREF(content::GetContentClient()).browser())
.GetProduct(),
"/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (product_components.size() != 2) {
return {{}, {}, CHECK_DEREF(content_client.browser()).GetUserAgent()};
}
return {product_components[0], product_components[1],
CHECK_DEREF(content_client.browser()).GetUserAgent()};
}
void BrowserAccessibilityStateImplWin::OnUiaProviderRequested(
bool uia_provider_enabled) {
CHECK_DEREF(CHECK_DEREF(GetContentClient()).browser())
.OnUiaProviderRequested(uia_provider_enabled);
}
void BrowserAccessibilityStateImplWin::OnUiaProviderDisabled() {
CHECK_DEREF(CHECK_DEREF(GetContentClient()).browser())
.OnUiaProviderDisabled();
}
// static
std::unique_ptr<BrowserAccessibilityStateImpl>
BrowserAccessibilityStateImpl::Create() {
return std::make_unique<BrowserAccessibilityStateImplWin>();
}
} // namespace content
|