ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / ui / aura / accessibility / automation_manager_aura.h
blob7d11622eec682dba82a24bdf307d9847174ea5c3
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 template <typename T>
15 struct DefaultSingletonTraits;
17 namespace content {
18 class BrowserContext;
19 } // namespace content
21 namespace views {
22 class AXAuraObjWrapper;
23 class View;
24 } // namespace views
26 using AuraAXTreeSerializer =
27 ui::AXTreeSerializer<views::AXAuraObjWrapper*, ui::AXNodeData>;
29 // Manages a tree of automation nodes.
30 class AutomationManagerAura : public extensions::AutomationActionAdapter {
31 public:
32 // Get the single instance of this class.
33 static AutomationManagerAura* GetInstance();
35 // Enable automation support for views.
36 void Enable(content::BrowserContext* context);
38 // Disable automation support for views.
39 void Disable();
41 // Handle an event fired upon a |View|.
42 void HandleEvent(content::BrowserContext* context,
43 views::View* view,
44 ui::AXEvent event_type);
46 void HandleAlert(content::BrowserContext* context, const std::string& text);
48 // AutomationActionAdapter implementation.
49 void DoDefault(int32 id) override;
50 void Focus(int32 id) override;
51 void MakeVisible(int32 id) override;
52 void SetSelection(int32 id, int32 start, int32 end) override;
53 void ShowContextMenu(int32 id) override;
55 private:
56 friend struct DefaultSingletonTraits<AutomationManagerAura>;
58 AutomationManagerAura();
59 virtual ~AutomationManagerAura();
61 // Reset all state in this manager.
62 void ResetSerializer();
64 void SendEvent(content::BrowserContext* context,
65 views::AXAuraObjWrapper* aura_obj,
66 ui::AXEvent event_type);
68 // Whether automation support for views is enabled.
69 bool enabled_;
71 // Holds the active views-based accessibility tree. A tree currently consists
72 // of all views descendant to a |Widget| (see |AXTreeSourceViews|).
73 // A tree becomes active when an event is fired on a descendant view.
74 scoped_ptr<AXTreeSourceAura> current_tree_;
76 // Serializes incremental updates on the currently active tree
77 // |current_tree_|.
78 scoped_ptr<AuraAXTreeSerializer> current_tree_serializer_;
80 bool processing_events_;
82 std::vector<std::pair<views::AXAuraObjWrapper*, ui::AXEvent>> pending_events_;
84 DISALLOW_COPY_AND_ASSIGN(AutomationManagerAura);
87 #endif // CHROME_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_