Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / accessibility / browser_accessibility_manager_win.h
blobf1cb688b659f56993cceaf65650d73ca4da39fff
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.
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
8 #include <oleacc.h>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/win/scoped_comptr.h"
12 #include "content/browser/accessibility/browser_accessibility_manager.h"
14 namespace content {
15 class BrowserAccessibilityWin;
17 // Manages a tree of BrowserAccessibilityWin objects.
18 class CONTENT_EXPORT BrowserAccessibilityManagerWin
19 : public BrowserAccessibilityManager {
20 public:
21 BrowserAccessibilityManagerWin(
22 const SimpleAXTreeUpdate& initial_tree,
23 BrowserAccessibilityDelegate* delegate,
24 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
26 ~BrowserAccessibilityManagerWin() override;
28 static SimpleAXTreeUpdate GetEmptyDocument();
30 // Get the closest containing HWND.
31 HWND GetParentHWND();
33 // The IAccessible for the parent window.
34 IAccessible* GetParentIAccessible();
36 // Calls NotifyWinEvent if the parent window's IAccessible pointer is known.
37 void MaybeCallNotifyWinEvent(DWORD event, BrowserAccessibility* node);
39 // BrowserAccessibilityManager methods
40 void OnWindowFocused() override;
41 void UserIsReloading() override;
42 void NotifyAccessibilityEvent(
43 ui::AXEvent event_type, BrowserAccessibility* node) override;
45 // Track this object and post a VISIBLE_DATA_CHANGED notification when
46 // its container scrolls.
47 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
48 void TrackScrollingObject(BrowserAccessibilityWin* node);
50 // Return a pointer to the object corresponding to the given windows-specific
51 // unique id, does not make a new reference.
52 BrowserAccessibilityWin* GetFromUniqueIdWin(LONG unique_id_win);
54 // Called when |accessible_hwnd_| is deleted by its parent.
55 void OnAccessibleHwndDeleted();
57 protected:
58 // AXTree methods.
59 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override;
60 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override;
61 void OnAtomicUpdateFinished(
62 ui::AXTree* tree,
63 bool root_changed,
64 const std::vector<ui::AXTreeDelegate::Change>& changes) override;
66 private:
67 // Give BrowserAccessibilityManager::Create access to our constructor.
68 friend class BrowserAccessibilityManager;
70 // Track the most recent object that has been asked to scroll and
71 // post a notification directly on it when it reaches its destination.
72 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
73 BrowserAccessibilityWin* tracked_scroll_object_;
75 // A mapping from the Windows-specific unique IDs (unique within the
76 // browser process) to accessibility ids within this page.
77 base::hash_map<long, int32> unique_id_to_ax_id_map_;
79 // A mapping from the Windows-specific unique IDs (unique within the
80 // browser process) to the AXTreeID that contains this unique ID.
81 base::hash_map<long, AXTreeIDRegistry::AXTreeID> unique_id_to_ax_tree_id_map_;
83 // Set to true if we need to fire a focus event on the root as soon as
84 // possible.
85 bool focus_event_on_root_needed_;
87 // A flag to keep track of if we're inside the OnWindowFocused call stack
88 // so we don't keep calling it recursively.
89 bool inside_on_window_focused_;
91 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin);
94 } // namespace content
96 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_