OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_VIEWS_ACCESSIBLE_VIEW_HELPER_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBLE_VIEW_HELPER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/scoped_ptr.h" | |
14 #include "base/singleton.h" | |
15 #include "chrome/browser/accessibility_events.h" | |
16 #include "ui/gfx/native_widget_types.h" | |
17 | |
18 #if defined(OS_LINUX) | |
19 #include "chrome/browser/ui/gtk/accessible_widget_helper_gtk.h" | |
20 #endif | |
21 | |
22 class AccessibilityEventRouterViews; | |
23 class Profile; | |
24 namespace views { | |
25 class View; | |
26 } | |
27 | |
28 // NOTE: This class is part of the Accessibility Extension API, which lets | |
29 // extensions receive accessibility events. It's distinct from code that | |
30 // implements platform accessibility APIs like MSAA or ATK. | |
31 // | |
32 // Helper class that helps to manage the accessibility information for a | |
33 // view and all of its descendants. Create an instance of this class for | |
34 // the root of a tree of views (like a dialog) that should send accessibility | |
35 // events for all of its descendants. | |
36 // | |
37 // Most controls have default behavior for accessibility; when this needs | |
38 // to be augmented, call one of the methods below to ignore a particular | |
39 // view or change its details. | |
40 // | |
41 // All of the information managed by this class is registered with the | |
42 // (global) AccessibilityEventRouterViews and unregistered when this object is | |
43 // destroyed. | |
44 class AccessibleViewHelper { | |
45 public: | |
46 // Constructs an AccessibleViewHelper that makes the given view and all | |
47 // of its descendants accessible for the lifetime of this object, | |
48 // sending accessibility notifications to the given profile. | |
49 AccessibleViewHelper(views::View* view_tree, Profile* profile); | |
50 | |
51 virtual ~AccessibleViewHelper(); | |
52 | |
53 // Sends a notification that a new window was opened now, and a | |
54 // corresponding close window notification when this object | |
55 // goes out of scope. | |
56 void SendOpenWindowNotification(const std::string& window_title); | |
57 | |
58 // Uses the following string as the name of this view, instead of | |
59 // view->GetAccessibleName(). | |
60 void SetViewName(views::View* view, std::string name); | |
61 | |
62 // Uses the following string id as the name of this view, instead of | |
63 // view->GetAccessibleName(). | |
64 void SetViewName(views::View* view, int string_id); | |
65 | |
66 private: | |
67 // Returns a native view if the given view has a native view in it. | |
68 gfx::NativeView GetNativeView(views::View* view) const; | |
69 | |
70 AccessibilityEventRouterViews* accessibility_event_router_; | |
71 Profile* profile_; | |
72 views::View* view_tree_; | |
73 std::string window_title_; | |
74 std::vector<views::View*> managed_views_; | |
75 | |
76 #if defined(OS_LINUX) | |
77 scoped_ptr<AccessibleWidgetHelper> widget_helper_; | |
78 #endif | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(AccessibleViewHelper); | |
81 }; | |
82 | |
83 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBLE_VIEW_HELPER_H_ | |
OLD | NEW |