Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / aura / accessibility / automation_manager_aura.h
blob98cfe7f538ebca47b08d0ae66086ef875fbe9095
1 // Copyright 2014 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 CHROME_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_
6 #define CHROME_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/api/automation_internal/automation_action_adapter.h"
11 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h"
12 #include "ui/accessibility/ax_tree_serializer.h"
14 namespace base {
15 template <typename T>
16 struct DefaultSingletonTraits;
17 } // namespace base
19 namespace content {
20 class BrowserContext;
21 } // namespace content
23 namespace views {
24 class AXAuraObjWrapper;
25 class View;
26 } // namespace views
28 using AuraAXTreeSerializer =
29 ui::AXTreeSerializer<views::AXAuraObjWrapper*, ui::AXNodeData>;
31 // Manages a tree of automation nodes.
32 class AutomationManagerAura : public extensions::AutomationActionAdapter {
33 public:
34 // Get the single instance of this class.
35 static AutomationManagerAura* GetInstance();
37 // Enable automation support for views.
38 void Enable(content::BrowserContext* context);
40 // Disable automation support for views.
41 void Disable();
43 // Handle an event fired upon a |View|.
44 void HandleEvent(content::BrowserContext* context,
45 views::View* view,
46 ui::AXEvent event_type);
48 void HandleAlert(content::BrowserContext* context, const std::string& text);
50 // AutomationActionAdapter implementation.
51 void DoDefault(int32 id) override;
52 void Focus(int32 id) override;
53 void MakeVisible(int32 id) override;
54 void SetSelection(int32 id, int32 start, int32 end) override;
55 void ShowContextMenu(int32 id) override;
57 private:
58 friend struct base::DefaultSingletonTraits<AutomationManagerAura>;
60 AutomationManagerAura();
61 virtual ~AutomationManagerAura();
63 // Reset all state in this manager.
64 void ResetSerializer();
66 void SendEvent(content::BrowserContext* context,
67 views::AXAuraObjWrapper* aura_obj,
68 ui::AXEvent event_type);
70 // Whether automation support for views is enabled.
71 bool enabled_;
73 // Holds the active views-based accessibility tree. A tree currently consists
74 // of all views descendant to a |Widget| (see |AXTreeSourceViews|).
75 // A tree becomes active when an event is fired on a descendant view.
76 scoped_ptr<AXTreeSourceAura> current_tree_;
78 // Serializes incremental updates on the currently active tree
79 // |current_tree_|.
80 scoped_ptr<AuraAXTreeSerializer> current_tree_serializer_;
82 bool processing_events_;
84 std::vector<std::pair<views::AXAuraObjWrapper*, ui::AXEvent>> pending_events_;
86 DISALLOW_COPY_AND_ASSIGN(AutomationManagerAura);
89 #endif // CHROME_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_