OLD | NEW |
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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "content/app/strings/grit/content_strings.h" | 12 #include "content/app/strings/grit/content_strings.h" |
13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
14 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
| 20 const base::char16 kSecurePasswordBullet = 0x2022; |
| 21 |
20 // These are enums from android.text.InputType in Java: | 22 // These are enums from android.text.InputType in Java: |
21 enum { | 23 enum { |
22 ANDROID_TEXT_INPUTTYPE_TYPE_NULL = 0, | 24 ANDROID_TEXT_INPUTTYPE_TYPE_NULL = 0, |
23 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME = 0x4, | 25 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME = 0x4, |
24 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE = 0x14, | 26 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE = 0x14, |
25 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME = 0x24, | 27 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME = 0x24, |
26 ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER = 0x2, | 28 ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER = 0x2, |
27 ANDROID_TEXT_INPUTTYPE_TYPE_PHONE = 0x3, | 29 ANDROID_TEXT_INPUTTYPE_TYPE_PHONE = 0x3, |
28 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT = 0x1, | 30 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT = 0x1, |
29 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_URI = 0x11, | 31 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_URI = 0x11, |
(...skipping 29 matching lines...) Expand all Loading... |
59 } | 61 } |
60 | 62 |
61 bool BrowserAccessibilityAndroid::IsNative() const { | 63 bool BrowserAccessibilityAndroid::IsNative() const { |
62 return true; | 64 return true; |
63 } | 65 } |
64 | 66 |
65 void BrowserAccessibilityAndroid::OnLocationChanged() { | 67 void BrowserAccessibilityAndroid::OnLocationChanged() { |
66 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, this); | 68 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, this); |
67 } | 69 } |
68 | 70 |
| 71 base::string16 BrowserAccessibilityAndroid::GetValue() const { |
| 72 base::string16 value = BrowserAccessibility::GetValue(); |
| 73 |
| 74 // Optionally replace entered password text with bullet characters |
| 75 // based on a user preference. |
| 76 if (IsPassword()) { |
| 77 bool should_expose = static_cast<BrowserAccessibilityManagerAndroid*>( |
| 78 manager())->ShouldExposePasswordText(); |
| 79 if (!should_expose) { |
| 80 value = base::string16(value.size(), kSecurePasswordBullet); |
| 81 } |
| 82 } |
| 83 |
| 84 return value; |
| 85 } |
| 86 |
69 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { | 87 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { |
70 if (BrowserAccessibility::PlatformIsLeaf()) | 88 if (BrowserAccessibility::PlatformIsLeaf()) |
71 return true; | 89 return true; |
72 | 90 |
73 // Iframes are always allowed to contain children. | 91 // Iframes are always allowed to contain children. |
74 if (IsIframe() || | 92 if (IsIframe() || |
75 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 93 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
76 GetRole() == ui::AX_ROLE_WEB_AREA) { | 94 GetRole() == ui::AX_ROLE_WEB_AREA) { |
77 return false; | 95 return false; |
78 } | 96 } |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1404 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
1387 int count = 0; | 1405 int count = 0; |
1388 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1406 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
1389 if (PlatformGetChild(i)->GetRole() == role) | 1407 if (PlatformGetChild(i)->GetRole() == role) |
1390 count++; | 1408 count++; |
1391 } | 1409 } |
1392 return count; | 1410 return count; |
1393 } | 1411 } |
1394 | 1412 |
1395 } // namespace content | 1413 } // namespace content |
OLD | NEW |