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> |
| 8 #include <UIAutomationCoreApi.h> |
| 9 |
7 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 11 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/win/accessibility_misc_utils.h" |
10 #include "base/win/enum_variant.h" | 14 #include "base/win/enum_variant.h" |
11 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
| 16 #include "base/win/windows_version.h" |
12 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 17 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
13 #include "content/common/accessibility_messages.h" | 18 #include "content/common/accessibility_messages.h" |
14 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
15 #include "ui/base/accessibility/accessible_text_utils.h" | 20 #include "ui/base/accessibility/accessible_text_utils.h" |
16 | 21 |
17 using webkit_glue::WebAccessibility; | 22 using webkit_glue::WebAccessibility; |
18 | 23 |
19 // The GUID for the ISimpleDOM service is not defined in the IDL files. | 24 // The GUID for the ISimpleDOM service is not defined in the IDL files. |
20 // This is taken directly from the Mozilla sources | 25 // This is taken directly from the Mozilla sources |
21 // (accessible/src/msaa/nsAccessNodeWrap.cpp) and it's also documented at: | 26 // (accessible/src/msaa/nsAccessNodeWrap.cpp) and it's also documented at: |
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 | 2510 |
2506 // | 2511 // |
2507 // IServiceProvider methods. | 2512 // IServiceProvider methods. |
2508 // | 2513 // |
2509 | 2514 |
2510 STDMETHODIMP BrowserAccessibilityWin::QueryService( | 2515 STDMETHODIMP BrowserAccessibilityWin::QueryService( |
2511 REFGUID guidService, REFIID riid, void** object) { | 2516 REFGUID guidService, REFIID riid, void** object) { |
2512 if (!instance_active_) | 2517 if (!instance_active_) |
2513 return E_FAIL; | 2518 return E_FAIL; |
2514 | 2519 |
2515 if (guidService == IID_IAccessible || | 2520 if (riid == IID_IAccessible || |
2516 guidService == IID_IAccessible2 || | 2521 riid == IID_IAccessible2 || |
2517 guidService == IID_IAccessibleAction || | 2522 riid == IID_IAccessibleAction || |
2518 guidService == IID_IAccessibleHyperlink || | 2523 riid == IID_IAccessibleHyperlink || |
2519 guidService == IID_IAccessibleHypertext || | 2524 riid == IID_IAccessibleHypertext || |
2520 guidService == IID_IAccessibleImage || | 2525 riid == IID_IAccessibleImage || |
2521 guidService == IID_IAccessibleTable || | 2526 riid == IID_IAccessibleTable || |
2522 guidService == IID_IAccessibleTable2 || | 2527 riid == IID_IAccessibleTable2 || |
2523 guidService == IID_IAccessibleTableCell || | 2528 riid == IID_IAccessibleTableCell || |
2524 guidService == IID_IAccessibleText || | 2529 riid == IID_IAccessibleText || |
2525 guidService == IID_IAccessibleValue || | 2530 riid == IID_IAccessibleValue || |
2526 guidService == IID_ISimpleDOMDocument || | 2531 riid == IID_ISimpleDOMDocument || |
2527 guidService == IID_ISimpleDOMNode || | 2532 riid == IID_ISimpleDOMNode || |
2528 guidService == IID_ISimpleDOMText || | 2533 riid == IID_ISimpleDOMText || |
2529 guidService == GUID_ISimpleDOM) { | 2534 riid == GUID_ISimpleDOM) { |
| 2535 return QueryInterface(riid, object); |
| 2536 } |
| 2537 |
| 2538 // We only support the IAccessibleEx interface on Windows 8 and above. This |
| 2539 // is needed for the on-screen Keyboard to show up in metro mode, when the |
| 2540 // user taps an editable portion on the page. |
| 2541 // All methods in the IAccessibleEx interface are unimplemented. |
| 2542 if (riid == IID_IAccessibleEx && |
| 2543 base::win::GetVersion() >= base::win::VERSION_WIN8) { |
2530 return QueryInterface(riid, object); | 2544 return QueryInterface(riid, object); |
2531 } | 2545 } |
2532 | 2546 |
2533 *object = NULL; | 2547 *object = NULL; |
2534 return E_FAIL; | 2548 return E_FAIL; |
2535 } | 2549 } |
2536 | 2550 |
| 2551 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider( |
| 2552 PATTERNID id, IUnknown** provider) { |
| 2553 DVLOG(1) << "In Function: " |
| 2554 << __FUNCTION__ |
| 2555 << " for pattern id: " |
| 2556 << id; |
| 2557 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
| 2558 if (IsEditableText()) { |
| 2559 DVLOG(1) << "Returning UIA text provider"; |
| 2560 base::win::UIATextProvider::CreateTextProvider(true, provider); |
| 2561 return S_OK; |
| 2562 } |
| 2563 } |
| 2564 return E_NOTIMPL; |
| 2565 } |
| 2566 |
| 2567 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, |
| 2568 VARIANT* ret) { |
| 2569 DVLOG(1) << "In Function: " |
| 2570 << __FUNCTION__ |
| 2571 << " for property id: " |
| 2572 << id; |
| 2573 V_VT(ret) = VT_EMPTY; |
| 2574 if (id == UIA_ControlTypePropertyId) { |
| 2575 if (IsEditableText()) { |
| 2576 V_VT(ret) = VT_I4; |
| 2577 ret->lVal = UIA_EditControlTypeId; |
| 2578 DVLOG(1) << "Returning Edit control type"; |
| 2579 } else { |
| 2580 DVLOG(1) << "Returning empty control type"; |
| 2581 } |
| 2582 } |
| 2583 return S_OK; |
| 2584 } |
| 2585 |
2537 // | 2586 // |
2538 // CComObjectRootEx methods. | 2587 // CComObjectRootEx methods. |
2539 // | 2588 // |
2540 | 2589 |
2541 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( | 2590 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
2542 void* this_ptr, | 2591 void* this_ptr, |
2543 const _ATL_INTMAP_ENTRY* entries, | 2592 const _ATL_INTMAP_ENTRY* entries, |
2544 REFIID iid, | 2593 REFIID iid, |
2545 void** object) { | 2594 void** object) { |
2546 if (iid == IID_IAccessibleImage) { | 2595 if (iid == IID_IAccessibleImage) { |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3322 } | 3371 } |
3323 | 3372 |
3324 // The role should always be set. | 3373 // The role should always be set. |
3325 DCHECK(!role_name_.empty() || ia_role_); | 3374 DCHECK(!role_name_.empty() || ia_role_); |
3326 | 3375 |
3327 // If we didn't explicitly set the IAccessible2 role, make it the same | 3376 // If we didn't explicitly set the IAccessible2 role, make it the same |
3328 // as the MSAA role. | 3377 // as the MSAA role. |
3329 if (!ia2_role_) | 3378 if (!ia2_role_) |
3330 ia2_role_ = ia_role_; | 3379 ia2_role_ = ia_role_; |
3331 } | 3380 } |
OLD | NEW |