Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / ash / accessibility / automation_manager_views.h
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.
4
5 #ifndef CHROME_BROWSER_UI_ASH_ACCESSIBILITY_AUTOMATION_MANAGER_VIEWS_H_
6 #define CHROME_BROWSER_UI_ASH_ACCESSIBILITY_AUTOMATION_MANAGER_VIEWS_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10
11 #include "chrome/browser/ui/ash/accessibility/ax_tree_source_views.h"
12 #include "ui/accessibility/ax_tree_serializer.h"
13
14 template <typename T> struct DefaultSingletonTraits;
15
16 namespace content {
17 class BrowserContext;
18 }  // namespace content
19
20 namespace views {
21 class AXAuraObjWrapper;
22 class View;
23 }  // namespace views
24
25 // Manages a tree of automation nodes.
26 class AutomationManagerViews {
27  public:
28   // Get the single instance of this class.
29   static AutomationManagerViews* GetInstance();
30
31   // Enable automation support for views.
32   void Enable(content::BrowserContext* context);
33
34   // Disable automation support for views.
35   void Disable();
36
37   // Handle an event fired upon a |View|.
38   void HandleEvent(content::BrowserContext* context,
39                    views::View* view,
40                    ui::AXEvent event_type);
41
42  private:
43   friend struct DefaultSingletonTraits<AutomationManagerViews>;
44
45   AutomationManagerViews();
46   ~AutomationManagerViews();
47
48     // Reset all state in this manager.
49   void Reset();
50
51   void SendEvent(content::BrowserContext* context,
52                  views::AXAuraObjWrapper* aura_obj,
53                  ui::AXEvent event_type);
54
55   // Whether automation support for views is enabled.
56   bool enabled_;
57
58   // Holds the active views-based accessibility tree. A tree currently consists
59   // of all views descendant to a |Widget| (see |AXTreeSourceViews|).
60   // A tree becomes active when an event is fired on a descendant view.
61   scoped_ptr <AXTreeSourceViews> current_tree_;
62
63   // Serializes incremental updates on the currently active tree
64   // |current_tree_|.
65   scoped_ptr<ui::AXTreeSerializer<views::AXAuraObjWrapper*> >
66       current_tree_serializer_;
67
68   DISALLOW_COPY_AND_ASSIGN(AutomationManagerViews);
69 };
70
71 #endif  // CHROME_BROWSER_UI_ASH_ACCESSIBILITY_AUTOMATION_MANAGER_VIEWS_H_