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
3 // found in the LICENSE file.
4 #include "ui/base/win/accessibility_misc_utils.h"
6 #include "base/logging.h"
7 #include "ui/base/win/atl_module.h"
12 // UIA TextProvider implementation.
13 UIATextProvider::UIATextProvider()
17 bool UIATextProvider::CreateTextProvider(const string16
& value
,
19 IUnknown
** provider
) {
20 // Make sure ATL is initialized in this module.
21 ui::win::CreateATLModuleIfNeeded();
23 CComObject
<UIATextProvider
>* text_provider
= NULL
;
24 HRESULT hr
= CComObject
<UIATextProvider
>::CreateInstance(&text_provider
);
26 DCHECK(text_provider
);
27 text_provider
->set_editable(editable
);
28 text_provider
->set_value(value
);
29 text_provider
->AddRef();
30 *provider
= static_cast<ITextProvider
*>(text_provider
);
36 STDMETHODIMP
UIATextProvider::get_IsReadOnly(BOOL
* read_only
) {
37 *read_only
= !editable_
;
41 STDMETHODIMP
UIATextProvider::get_Value(BSTR
* value
) {
42 *value
= SysAllocString(value_
.c_str());