Home | History | Annotate | Download | only in win
      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 #ifndef UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
      5 #define UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
      6 
      7 #include <atlbase.h>
      8 #include <atlcom.h>
      9 #include <UIAutomationCore.h>
     10 
     11 #include "base/compiler_specific.h"
     12 #include "base/strings/string16.h"
     13 #include "ui/base/ui_base_export.h"
     14 
     15 namespace base {
     16 namespace win {
     17 
     18   // UIA Text provider implementation for edit controls.
     19 class UI_BASE_EXPORT UIATextProvider
     20     : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>),
     21       public IValueProvider,
     22       public ITextProvider {
     23  public:
     24   BEGIN_COM_MAP(UIATextProvider)
     25     COM_INTERFACE_ENTRY2(IUnknown, ITextProvider)
     26     COM_INTERFACE_ENTRY(IValueProvider)
     27     COM_INTERFACE_ENTRY(ITextProvider)
     28   END_COM_MAP()
     29 
     30   UIATextProvider();
     31 
     32   // Creates an instance of the UIATextProvider class.
     33   // Returns true on success
     34   static bool CreateTextProvider(const string16& value,
     35                                  bool editable,
     36                                  IUnknown** provider);
     37 
     38   void set_editable(bool editable) {
     39     editable_ = editable;
     40   }
     41 
     42   void set_value(const string16& value) { value_ = value; }
     43 
     44   //
     45   // IValueProvider methods.
     46   //
     47   STDMETHOD(get_IsReadOnly)(BOOL* read_only);
     48 
     49   //
     50   // IValueProvider methods not implemented.
     51   //
     52   STDMETHOD(SetValue)(const wchar_t* val) {
     53     return E_NOTIMPL;
     54   }
     55 
     56   STDMETHOD(get_Value)(BSTR* value);
     57 
     58   //
     59   // ITextProvider methods.
     60   //
     61   STDMETHOD(GetSelection)(SAFEARRAY** ret) {
     62     return E_NOTIMPL;
     63   }
     64 
     65   STDMETHOD(GetVisibleRanges)(SAFEARRAY** ret) {
     66     return E_NOTIMPL;
     67   }
     68 
     69   STDMETHOD(RangeFromChild)(IRawElementProviderSimple* child,
     70                             ITextRangeProvider** ret) {
     71     return E_NOTIMPL;
     72   }
     73 
     74   STDMETHOD(RangeFromPoint)(struct UiaPoint point,
     75                             ITextRangeProvider** ret) {
     76     return E_NOTIMPL;
     77   }
     78 
     79   STDMETHOD(get_DocumentRange)(ITextRangeProvider** ret) {
     80     return E_NOTIMPL;
     81   }
     82 
     83   STDMETHOD(get_SupportedTextSelection)(enum SupportedTextSelection* ret) {
     84     return E_NOTIMPL;
     85   }
     86 
     87  private:
     88   bool editable_;
     89   string16 value_;
     90 };
     91 
     92 }  // win
     93 }  // base
     94 
     95 #endif  // UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
     96