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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { | 414 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { |
415 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); | 415 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); |
416 if (!instance_active()) | 416 if (!instance_active()) |
417 return E_FAIL; | 417 return E_FAIL; |
418 | 418 |
419 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 419 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
420 if (!target) | 420 if (!target) |
421 return E_INVALIDARG; | 421 return E_INVALIDARG; |
422 | 422 |
423 // Return an error if it's not clickable. | 423 // Return an error if it's not clickable. |
424 if (!target->HasStringAttribute(ui::AX_ATTR_ACTION)) | 424 if (!target->HasIntAttribute(ui::AX_ATTR_ACTION)) |
425 return DISP_E_MEMBERNOTFOUND; | 425 return DISP_E_MEMBERNOTFOUND; |
426 | 426 |
427 manager()->DoDefaultAction(*target); | 427 manager()->DoDefaultAction(*target); |
428 return S_OK; | 428 return S_OK; |
429 } | 429 } |
430 | 430 |
431 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, | 431 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, |
432 LONG y_top, | 432 LONG y_top, |
433 VARIANT* child) { | 433 VARIANT* child) { |
434 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); | 434 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 if (!instance_active()) | 570 if (!instance_active()) |
571 return E_FAIL; | 571 return E_FAIL; |
572 | 572 |
573 if (!def_action) | 573 if (!def_action) |
574 return E_INVALIDARG; | 574 return E_INVALIDARG; |
575 | 575 |
576 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 576 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
577 if (!target) | 577 if (!target) |
578 return E_INVALIDARG; | 578 return E_INVALIDARG; |
579 | 579 |
580 return target->GetStringAttributeAsBstr( | 580 return target->get_localizedName(0, def_action); |
581 ui::AX_ATTR_ACTION, def_action); | |
582 } | 581 } |
583 | 582 |
584 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, | 583 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, |
585 BSTR* desc) { | 584 BSTR* desc) { |
586 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); | 585 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); |
587 if (!instance_active()) | 586 if (!instance_active()) |
588 return E_FAIL; | 587 return E_FAIL; |
589 | 588 |
590 if (!desc) | 589 if (!desc) |
591 return E_INVALIDARG; | 590 return E_INVALIDARG; |
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2832 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); | 2831 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); |
2833 if (!instance_active()) | 2832 if (!instance_active()) |
2834 return E_FAIL; | 2833 return E_FAIL; |
2835 | 2834 |
2836 if (!n_actions) | 2835 if (!n_actions) |
2837 return E_INVALIDARG; | 2836 return E_INVALIDARG; |
2838 | 2837 |
2839 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| | 2838 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
2840 // to work properly because the |IAccessibleHyperlink| interface inherits from | 2839 // to work properly because the |IAccessibleHyperlink| interface inherits from |
2841 // |IAccessibleAction|. | 2840 // |IAccessibleAction|. |
2842 if (IsHyperlink() || HasStringAttribute(ui::AX_ATTR_ACTION)) { | 2841 if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_ACTION)) { |
2843 *n_actions = 1; | 2842 *n_actions = 1; |
2844 } else { | 2843 } else { |
2845 *n_actions = 0; | 2844 *n_actions = 0; |
2846 } | 2845 } |
2847 | 2846 |
2848 return S_OK; | 2847 return S_OK; |
2849 } | 2848 } |
2850 | 2849 |
2851 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { | 2850 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { |
2852 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); | 2851 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
2853 if (!instance_active()) | 2852 if (!instance_active()) |
2854 return E_FAIL; | 2853 return E_FAIL; |
2855 | 2854 |
2856 if (!HasStringAttribute(ui::AX_ATTR_ACTION) || action_index != 0) | 2855 if (!HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
2857 return E_INVALIDARG; | 2856 return E_INVALIDARG; |
2858 | 2857 |
2859 manager()->DoDefaultAction(*this); | 2858 manager()->DoDefaultAction(*this); |
2860 return S_OK; | 2859 return S_OK; |
2861 } | 2860 } |
2862 | 2861 |
2863 STDMETHODIMP | 2862 STDMETHODIMP |
2864 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { | 2863 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { |
2865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); | 2864 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
2866 return E_NOTIMPL; | 2865 return E_NOTIMPL; |
2867 } | 2866 } |
2868 | 2867 |
2869 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, | 2868 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, |
2870 long n_max_bindings, | 2869 long n_max_bindings, |
2871 BSTR** key_bindings, | 2870 BSTR** key_bindings, |
2872 long* n_bindings) { | 2871 long* n_bindings) { |
2873 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); | 2872 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); |
2874 return E_NOTIMPL; | 2873 return E_NOTIMPL; |
2875 } | 2874 } |
2876 | 2875 |
2877 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { | 2876 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { |
2878 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); | 2877 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
2879 if (!instance_active()) | 2878 if (!instance_active()) |
2880 return E_FAIL; | 2879 return E_FAIL; |
2881 | 2880 |
2882 if (!name) | 2881 if (!name) |
2883 return E_INVALIDARG; | 2882 return E_INVALIDARG; |
2884 | 2883 |
2885 base::string16 action_verb; | 2884 int action; |
2886 if (!GetString16Attribute(ui::AX_ATTR_ACTION, &action_verb) || | 2885 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { |
2887 action_index != 0) { | |
2888 *name = nullptr; | 2886 *name = nullptr; |
2889 return E_INVALIDARG; | 2887 return E_INVALIDARG; |
2890 } | 2888 } |
2891 | 2889 |
2890 base::string16 action_verb = base::UTF8ToUTF16( | |
dmazzoni
2016/11/22 01:01:08
I think I'd prefer if the names of the enum (which
| |
2891 ui::ToString(static_cast<ui::AXSupportedAction>(action))); | |
2892 if (action_verb.empty() || action_verb == L"None") { | |
2893 *name = nullptr; | |
2894 return S_FALSE; | |
2895 } | |
2896 | |
2892 *name = SysAllocString(action_verb.c_str()); | 2897 *name = SysAllocString(action_verb.c_str()); |
2893 DCHECK(name); | 2898 DCHECK(name); |
2894 return S_OK; | 2899 return S_OK; |
2895 } | 2900 } |
2896 | 2901 |
2897 STDMETHODIMP | 2902 STDMETHODIMP |
2898 BrowserAccessibilityWin::get_localizedName(long action_index, | 2903 BrowserAccessibilityWin::get_localizedName(long action_index, |
2899 BSTR* localized_name) { | 2904 BSTR* localized_name) { |
2900 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); | 2905 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
2901 return E_NOTIMPL; | 2906 if (!instance_active()) |
2907 return E_FAIL; | |
2908 | |
2909 if (!localized_name) | |
2910 return E_INVALIDARG; | |
2911 | |
2912 int action; | |
2913 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { | |
2914 *localized_name = nullptr; | |
2915 return E_INVALIDARG; | |
2916 } | |
2917 | |
2918 base::string16 action_verb = | |
2919 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); | |
2920 if (action_verb.empty()) { | |
2921 *localized_name = nullptr; | |
2922 return S_FALSE; | |
2923 } | |
2924 | |
2925 *localized_name = SysAllocString(action_verb.c_str()); | |
2926 DCHECK(localized_name); | |
2927 return S_OK; | |
2902 } | 2928 } |
2903 | 2929 |
2904 // | 2930 // |
2905 // IAccessibleValue methods. | 2931 // IAccessibleValue methods. |
2906 // | 2932 // |
2907 | 2933 |
2908 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { | 2934 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { |
2909 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); | 2935 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); |
2910 if (!instance_active()) | 2936 if (!instance_active()) |
2911 return E_FAIL; | 2937 return E_FAIL; |
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5531 return static_cast<BrowserAccessibilityWin*>(obj); | 5557 return static_cast<BrowserAccessibilityWin*>(obj); |
5532 } | 5558 } |
5533 | 5559 |
5534 const BrowserAccessibilityWin* | 5560 const BrowserAccessibilityWin* |
5535 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5561 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
5536 DCHECK(!obj || obj->IsNative()); | 5562 DCHECK(!obj || obj->IsNative()); |
5537 return static_cast<const BrowserAccessibilityWin*>(obj); | 5563 return static_cast<const BrowserAccessibilityWin*>(obj); |
5538 } | 5564 } |
5539 | 5565 |
5540 } // namespace content | 5566 } // namespace content |
OLD | NEW |