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