| 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 | 654 |
| 655 return target->GetStringAttributeAsBstr( | 655 return target->GetStringAttributeAsBstr( |
| 656 ui::AX_ATTR_SHORTCUT, acc_key); | 656 ui::AX_ATTR_SHORTCUT, acc_key); |
| 657 } | 657 } |
| 658 | 658 |
| 659 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { | 659 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { |
| 660 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); | 660 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); |
| 661 if (!instance_active()) | 661 if (!instance_active()) |
| 662 return E_FAIL; | 662 return E_FAIL; |
| 663 | 663 |
| 664 if (!name) | 664 return GetPlatformNodeWin()->get_accName(var_id, name); |
| 665 return E_INVALIDARG; | |
| 666 | |
| 667 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | |
| 668 if (!target) | |
| 669 return E_INVALIDARG; | |
| 670 | |
| 671 base::string16 name_str = target->name(); | |
| 672 if (name_str.empty()) { | |
| 673 if (target->ia2_role() == ROLE_SYSTEM_DOCUMENT && PlatformGetParent()) { | |
| 674 // Hack: Some versions of JAWS crash if they get an empty name on | |
| 675 // a document that's the child of an iframe, so always return a | |
| 676 // nonempty string for this role. https://crbug.com/583057 | |
| 677 name_str = L" "; | |
| 678 } else { | |
| 679 return S_FALSE; | |
| 680 } | |
| 681 } | |
| 682 | |
| 683 *name = SysAllocString(name_str.c_str()); | |
| 684 | |
| 685 DCHECK(*name); | |
| 686 return S_OK; | |
| 687 } | 665 } |
| 688 | 666 |
| 689 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { | 667 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
| 690 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); | 668 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); |
| 691 if (!instance_active()) | 669 if (!instance_active()) |
| 692 return E_FAIL; | 670 return E_FAIL; |
| 693 | 671 |
| 694 if (!disp_parent) | 672 if (!disp_parent) |
| 695 return E_INVALIDARG; | 673 return E_INVALIDARG; |
| 696 | 674 |
| (...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5672 return static_cast<BrowserAccessibilityWin*>(obj); | 5650 return static_cast<BrowserAccessibilityWin*>(obj); |
| 5673 } | 5651 } |
| 5674 | 5652 |
| 5675 const BrowserAccessibilityWin* | 5653 const BrowserAccessibilityWin* |
| 5676 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5654 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
| 5677 DCHECK(!obj || obj->IsNative()); | 5655 DCHECK(!obj || obj->IsNative()); |
| 5678 return static_cast<const BrowserAccessibilityWin*>(obj); | 5656 return static_cast<const BrowserAccessibilityWin*>(obj); |
| 5679 } | 5657 } |
| 5680 | 5658 |
| 5681 } // namespace content | 5659 } // namespace content |
| OLD | NEW |