OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 3237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3248 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); | 3248 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); |
3249 break; | 3249 break; |
3250 case ui::AX_INVALID_STATE_GRAMMAR: | 3250 case ui::AX_INVALID_STATE_GRAMMAR: |
3251 win_attributes_->ia2_attributes.push_back(L"invalid:grammar"); | 3251 win_attributes_->ia2_attributes.push_back(L"invalid:grammar"); |
3252 break; | 3252 break; |
3253 case ui::AX_INVALID_STATE_OTHER: | 3253 case ui::AX_INVALID_STATE_OTHER: |
3254 { | 3254 { |
3255 base::string16 aria_invalid_value; | 3255 base::string16 aria_invalid_value; |
3256 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 3256 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
3257 &aria_invalid_value)) { | 3257 &aria_invalid_value)) { |
3258 win_attributes_->ia2_attributes.push_back( | 3258 win_attributes_->ia2_attributes.push_back( |
dmazzoni
2015/10/12 17:15:15
There are other places where we're adding strings
| |
3259 L"invalid:" + aria_invalid_value); | 3259 L"invalid:" + aria_invalid_value); |
3260 } else { | 3260 } else { |
3261 // Set the attribute to L"true", since we cannot be more specific. | 3261 // Set the attribute to L"true", since we cannot be more specific. |
3262 win_attributes_->ia2_attributes.push_back(L"invalid:true"); | 3262 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
3263 } | 3263 } |
3264 } | 3264 } |
3265 break; | 3265 break; |
3266 default: | 3266 default: |
3267 NOTREACHED(); | 3267 NOTREACHED(); |
3268 } | 3268 } |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3624 | 3624 |
3625 if (str.empty()) | 3625 if (str.empty()) |
3626 return S_FALSE; | 3626 return S_FALSE; |
3627 | 3627 |
3628 *value_bstr = SysAllocString(str.c_str()); | 3628 *value_bstr = SysAllocString(str.c_str()); |
3629 DCHECK(*value_bstr); | 3629 DCHECK(*value_bstr); |
3630 | 3630 |
3631 return S_OK; | 3631 return S_OK; |
3632 } | 3632 } |
3633 | 3633 |
3634 // Static | |
3635 void BrowserAccessibilityWin::SanitizeStringAttributeForIA2( | |
3636 const base::string16& input, | |
3637 base::string16* output) { | |
3638 // According to the IA2 Spec, these characters need to be escaped with a | |
3639 // backslash: backslash, colon, comma, equals and semicolon. | |
3640 // Note that backslash must be replaced first. | |
3641 base::ReplaceChars(input, L"\\", L"\\\\", output); | |
3642 base::ReplaceChars(input, L":", L"\\:", output); | |
dmazzoni
2015/10/12 17:15:15
This won't work correctly if input and output are
| |
3643 base::ReplaceChars(input, L",", L"\\,", output); | |
3644 base::ReplaceChars(input, L"=", L"\\=", output); | |
3645 base::ReplaceChars(input, L";", L"\\;", output); | |
3646 } | |
3647 | |
3634 void BrowserAccessibilityWin::StringAttributeToIA2( | 3648 void BrowserAccessibilityWin::StringAttributeToIA2( |
3635 ui::AXStringAttribute attribute, | 3649 ui::AXStringAttribute attribute, |
3636 const char* ia2_attr) { | 3650 const char* ia2_attr) { |
3637 base::string16 value; | 3651 base::string16 value; |
3638 if (GetString16Attribute(attribute, &value)) { | 3652 if (GetString16Attribute(attribute, &value)) { |
3653 SanitizeStringAttributeForIA2(value, &value); | |
3639 win_attributes_->ia2_attributes.push_back( | 3654 win_attributes_->ia2_attributes.push_back( |
3640 base::ASCIIToUTF16(ia2_attr) + L":" + value); | 3655 base::ASCIIToUTF16(ia2_attr) + L":" + value); |
3641 } | 3656 } |
3642 } | 3657 } |
3643 | 3658 |
3644 void BrowserAccessibilityWin::BoolAttributeToIA2( | 3659 void BrowserAccessibilityWin::BoolAttributeToIA2( |
3645 ui::AXBoolAttribute attribute, | 3660 ui::AXBoolAttribute attribute, |
3646 const char* ia2_attr) { | 3661 const char* ia2_attr) { |
3647 bool value; | 3662 bool value; |
3648 if (GetBoolAttribute(attribute, &value)) { | 3663 if (GetBoolAttribute(attribute, &value)) { |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4621 ia2_role = ia_role; | 4636 ia2_role = ia_role; |
4622 | 4637 |
4623 win_attributes_->ia_role = ia_role; | 4638 win_attributes_->ia_role = ia_role; |
4624 win_attributes_->ia_state = ia_state; | 4639 win_attributes_->ia_state = ia_state; |
4625 win_attributes_->role_name = role_name; | 4640 win_attributes_->role_name = role_name; |
4626 win_attributes_->ia2_role = ia2_role; | 4641 win_attributes_->ia2_role = ia2_role; |
4627 win_attributes_->ia2_state = ia2_state; | 4642 win_attributes_->ia2_state = ia2_state; |
4628 } | 4643 } |
4629 | 4644 |
4630 } // namespace content | 4645 } // namespace content |
OLD | NEW |