Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 2881723002: Fix TalkBack feedback for password fields in Android O (Closed)
Patch Set: Address feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/accessibility/browser_accessibility_android.h" 5 #include "content/browser/accessibility/browser_accessibility_android.h"
6 6
7 #include "base/i18n/break_iterator.h" 7 #include "base/i18n/break_iterator.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ui::AX_EVENT_LOCATION_CHANGED, 70 ui::AX_EVENT_LOCATION_CHANGED,
71 this); 71 this);
72 } 72 }
73 73
74 base::string16 BrowserAccessibilityAndroid::GetValue() const { 74 base::string16 BrowserAccessibilityAndroid::GetValue() const {
75 base::string16 value = BrowserAccessibility::GetValue(); 75 base::string16 value = BrowserAccessibility::GetValue();
76 76
77 // Optionally replace entered password text with bullet characters 77 // Optionally replace entered password text with bullet characters
78 // based on a user preference. 78 // based on a user preference.
79 if (IsPassword()) { 79 if (IsPassword()) {
80 bool should_expose = static_cast<BrowserAccessibilityManagerAndroid*>( 80 auto* manager =
81 manager())->ShouldExposePasswordText(); 81 static_cast<BrowserAccessibilityManagerAndroid*>(this->manager());
82 if (!should_expose) { 82 if (manager->ShouldRespectDisplayedPasswordText()) {
83 // In the Chrome accessibility tree, the value of a password node is
84 // unobscured. However, if ShouldRespectDisplayedPasswordText() returns
85 // true we should try to expose whatever's actually visually displayed,
86 // whether that's the actual password or dots or whatever. To do this
87 // we rely on the password field's shadow dom.
88 value = base::UTF8ToUTF16(ComputeAccessibleNameFromDescendants());
89 } else if (!manager->ShouldExposePasswordText()) {
83 value = base::string16(value.size(), ui::kSecurePasswordBullet); 90 value = base::string16(value.size(), ui::kSecurePasswordBullet);
84 } 91 }
85 } 92 }
86 93
87 return value; 94 return value;
88 } 95 }
89 96
90 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { 97 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const {
91 if (BrowserAccessibility::PlatformIsLeaf()) 98 if (BrowserAccessibility::PlatformIsLeaf())
92 return true; 99 return true;
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1423 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1417 int count = 0; 1424 int count = 0;
1418 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1425 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1419 if (PlatformGetChild(i)->GetRole() == role) 1426 if (PlatformGetChild(i)->GetRole() == role)
1420 count++; 1427 count++;
1421 } 1428 }
1422 return count; 1429 return count;
1423 } 1430 }
1424 1431
1425 } // namespace content 1432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698