• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef ASH_SYSTEM_TRAY_ACCESSIBILITY_H_
6 #define ASH_SYSTEM_TRAY_ACCESSIBILITY_H_
7 
8 #include "ash/accessibility_delegate.h"
9 #include "ash/shell_observer.h"
10 #include "ash/system/tray/tray_details_view.h"
11 #include "ash/system/tray/tray_image_item.h"
12 #include "ash/system/tray/tray_notification_view.h"
13 #include "ash/system/tray/view_click_listener.h"
14 #include "base/gtest_prod_util.h"
15 #include "ui/gfx/font.h"
16 #include "ui/views/controls/button/button.h"
17 
18 namespace chromeos {
19 class TrayAccessibilityTest;
20 }
21 
22 namespace views {
23 class Button;
24 class ImageView;
25 class Label;
26 class View;
27 }
28 
29 namespace ash {
30 class HoverHighlightView;
31 class SystemTrayItem;
32 
33 class ASH_EXPORT AccessibilityObserver {
34  public:
~AccessibilityObserver()35   virtual ~AccessibilityObserver() {}
36 
37   // Notifies when accessibilty mode changes.
38   virtual void OnAccessibilityModeChanged(
39       AccessibilityNotificationVisibility notify) = 0;
40 };
41 
42 
43 namespace tray {
44 
45 class AccessibilityPopupView : public TrayNotificationView {
46  public:
47   AccessibilityPopupView(SystemTrayItem* owner, uint32 enabled_state_bits);
48 
label_for_test()49   const views::Label* label_for_test() const { return label_; }
50 
51  private:
52   views::Label* CreateLabel(uint32 enabled_state_bits);
53 
54   views::Label* label_;
55 
56   DISALLOW_COPY_AND_ASSIGN(AccessibilityPopupView);
57 };
58 
59 class AccessibilityDetailedView : public TrayDetailsView,
60                                   public ViewClickListener,
61                                   public views::ButtonListener,
62                                   public ShellObserver {
63  public:
64   explicit AccessibilityDetailedView(SystemTrayItem* owner,
65                                      user::LoginStatus login);
~AccessibilityDetailedView()66   virtual ~AccessibilityDetailedView() {}
67 
68  private:
69   // Add the accessibility feature list.
70   void AppendAccessibilityList();
71 
72   // Add help entries.
73   void AppendHelpEntries();
74 
75   HoverHighlightView* AddScrollListItem(const base::string16& text,
76                                         gfx::Font::FontStyle style,
77                                         bool checked);
78   // Overridden from ViewClickListener.
79   virtual void OnViewClicked(views::View* sender) OVERRIDE;
80   // Overridden from ButtonListener.
81   virtual void ButtonPressed(views::Button* sender,
82                              const ui::Event& event) OVERRIDE;
83 
84   views::View* spoken_feedback_view_;
85   views::View* high_contrast_view_;
86   views::View* screen_magnifier_view_;
87   views::View* large_cursor_view_;
88   views::View* help_view_;
89   views::View* settings_view_;
90   views::View* autoclick_view_;
91   views::View* virtual_keyboard_view_;
92 
93   bool spoken_feedback_enabled_;
94   bool high_contrast_enabled_;
95   bool screen_magnifier_enabled_;
96   bool large_cursor_enabled_;
97   bool autoclick_enabled_;
98   bool virtual_keyboard_enabled_;
99   user::LoginStatus login_;
100 
101   friend class chromeos::TrayAccessibilityTest;
102   DISALLOW_COPY_AND_ASSIGN(AccessibilityDetailedView);
103 };
104 
105 }  // namespace tray
106 
107 class TrayAccessibility : public TrayImageItem,
108                           public AccessibilityObserver {
109  public:
110   explicit TrayAccessibility(SystemTray* system_tray);
111   virtual ~TrayAccessibility();
112 
113  private:
114   void SetTrayIconVisible(bool visible);
115   tray::AccessibilityDetailedView* CreateDetailedMenu();
116 
117   // Overridden from TrayImageItem.
118   virtual bool GetInitialVisibility() OVERRIDE;
119   virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
120   virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
121   virtual void DestroyDefaultView() OVERRIDE;
122   virtual void DestroyDetailedView() OVERRIDE;
123   virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
124 
125   // Overridden from AccessibilityObserver.
126   virtual void OnAccessibilityModeChanged(
127       AccessibilityNotificationVisibility notify) OVERRIDE;
128 
129   views::View* default_;
130   tray::AccessibilityPopupView* detailed_popup_;
131   tray::AccessibilityDetailedView* detailed_menu_;
132 
133   // Bitmap of fvalues from AccessibilityState.  Can contain any or
134   // both of A11Y_SPOKEN_FEEDBACK A11Y_BRAILLE_DISPLAY_CONNECTED.
135   uint32 request_popup_view_state_;
136 
137   bool tray_icon_visible_;
138   user::LoginStatus login_;
139 
140   // Bitmap of values from AccessibilityState enum.
141   uint32 previous_accessibility_state_;
142 
143   // A11y feature status on just entering the lock screen.
144   bool show_a11y_menu_on_lock_screen_;
145 
146   friend class chromeos::TrayAccessibilityTest;
147   DISALLOW_COPY_AND_ASSIGN(TrayAccessibility);
148 };
149 
150 }  // namespace ash
151 
152 #endif  // ASH_SYSTEM_TRAY_ACCESSIBILITY_H_
153