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 #include "ui/base/win/accessibility_misc_utils.h" | 4 #include "ui/base/win/accessibility_misc_utils.h" |
5 | 5 |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "ui/base/win/atl_module.h" | 7 #include "ui/base/win/atl_module.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 namespace win { | 10 namespace win { |
11 | 11 |
12 // UIA TextProvider implementation. | 12 // UIA TextProvider implementation. |
13 UIATextProvider::UIATextProvider() | 13 UIATextProvider::UIATextProvider() |
14 : editable_(false) {} | 14 : editable_(false) {} |
15 | 15 |
16 // static | 16 // static |
17 bool UIATextProvider::CreateTextProvider(bool editable, IUnknown** provider) { | 17 bool UIATextProvider::CreateTextProvider(const string16& value, |
| 18 bool editable, |
| 19 IUnknown** provider) { |
18 // Make sure ATL is initialized in this module. | 20 // Make sure ATL is initialized in this module. |
19 ui::win::CreateATLModuleIfNeeded(); | 21 ui::win::CreateATLModuleIfNeeded(); |
20 | 22 |
21 CComObject<UIATextProvider>* text_provider = NULL; | 23 CComObject<UIATextProvider>* text_provider = NULL; |
22 HRESULT hr = CComObject<UIATextProvider>::CreateInstance(&text_provider); | 24 HRESULT hr = CComObject<UIATextProvider>::CreateInstance(&text_provider); |
23 if (SUCCEEDED(hr)) { | 25 if (SUCCEEDED(hr)) { |
24 DCHECK(text_provider); | 26 DCHECK(text_provider); |
25 text_provider->set_editable(editable); | 27 text_provider->set_editable(editable); |
| 28 text_provider->set_value(value); |
26 text_provider->AddRef(); | 29 text_provider->AddRef(); |
27 *provider = static_cast<ITextProvider*>(text_provider); | 30 *provider = static_cast<ITextProvider*>(text_provider); |
28 return true; | 31 return true; |
29 } | 32 } |
30 return false; | 33 return false; |
31 } | 34 } |
32 | 35 |
33 STDMETHODIMP UIATextProvider::get_IsReadOnly(BOOL* read_only) { | 36 STDMETHODIMP UIATextProvider::get_IsReadOnly(BOOL* read_only) { |
34 *read_only = !editable_; | 37 *read_only = !editable_; |
35 return S_OK; | 38 return S_OK; |
36 } | 39 } |
37 | 40 |
| 41 STDMETHODIMP UIATextProvider::get_Value(BSTR* value) { |
| 42 *value = SysAllocString(value_.c_str()); |
| 43 return S_OK; |
| 44 } |
| 45 |
38 } // namespace win | 46 } // namespace win |
39 } // namespace base | 47 } // namespace base |
OLD | NEW |