summaryrefslogtreecommitdiffstats
path: root/chrome/views/accessibility/accessible_wrapper.h
blob: d9e19ac52afee3048e818c5d70642a88f34fbcd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_
#define CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_

#include <atlcomcli.h>
#include <oleacc.h>

#include "base/basictypes.h"

namespace ChromeViews {
  class View;
}

////////////////////////////////////////////////////////////////////////////////
//
// AccessibleWrapper
//
// Wrapper class for returning a pointer to the appropriate (platform-specific)
// accessibility interface for a given View. Needed to keep platform-specific
// code out of the View class, when answering calls for child/parent IAccessible
// implementations, for instance.
//
////////////////////////////////////////////////////////////////////////////////
class AccessibleWrapper {
 public:
  explicit AccessibleWrapper(ChromeViews::View* view);
  ~AccessibleWrapper() {}

  STDMETHODIMP CreateDefaultInstance(REFIID iid);

  // Returns a pointer to a specified interface on an object to which a client
  // currently holds an interface pointer. If pointer exists, it is reused,
  // otherwise a new pointer is created. Used by accessibility implementation to
  // retrieve MSAA implementation for child or parent, when navigating MSAA
  // hierarchy.
  STDMETHODIMP GetInstance(REFIID iid, void** interface_ptr);

  // Sets the accessibility interface implementation of this wrapper to be
  // anything the user specifies.
  STDMETHODIMP SetInstance(IAccessible* interface_ptr);

 private:
  // Instance of accessibility information and handling for a View.
  CComPtr<IAccessible> accessibility_info_;

  // View needed to initialize IAccessible.
  ChromeViews::View* view_;

  DISALLOW_COPY_AND_ASSIGN(AccessibleWrapper);
};

#endif  // CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_