| OLD | NEW | 
|---|
|  | (Empty) | 
| 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_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |  | 
| 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |  | 
| 7 |  | 
| 8 #include <memory> |  | 
| 9 |  | 
| 10 #include "ash/ash_export.h" |  | 
| 11 #include "ash/common/login_status.h" |  | 
| 12 #include "ash/public/cpp/shelf_types.h" |  | 
| 13 #include "base/macros.h" |  | 
| 14 #include "base/timer/timer.h" |  | 
| 15 |  | 
| 16 namespace views { |  | 
| 17 class View; |  | 
| 18 } |  | 
| 19 |  | 
| 20 namespace ash { |  | 
| 21 class SystemTray; |  | 
| 22 class SystemTrayBubble; |  | 
| 23 class TrayItemView; |  | 
| 24 |  | 
| 25 // Controller for an item in the system tray. Each item can create these views: |  | 
| 26 // Tray view - The icon in the status area in the shelf. |  | 
| 27 // Default view - The row in the top-level menu. |  | 
| 28 // Detailed view - The submenu shown when the top-level menu row is clicked. |  | 
| 29 class ASH_EXPORT SystemTrayItem { |  | 
| 30  public: |  | 
| 31   // The different types of SystemTrayItems. |  | 
| 32   // |  | 
| 33   // NOTE: These values are used for UMA metrics so do NOT re-order this enum |  | 
| 34   // and only insert items before the COUNT item. |  | 
| 35   enum UmaType { |  | 
| 36     // SystemTrayItem's with this type are not recorded in the histogram. |  | 
| 37     UMA_NOT_RECORDED = 0, |  | 
| 38     // Used for testing purposes only. |  | 
| 39     UMA_TEST = 1, |  | 
| 40     UMA_ACCESSIBILITY = 2, |  | 
| 41     UMA_AUDIO = 3, |  | 
| 42     UMA_BLUETOOTH = 4, |  | 
| 43     UMA_CAPS_LOCK = 5, |  | 
| 44     UMA_CAST = 6, |  | 
| 45     UMA_DATE = 7, |  | 
| 46     UMA_DISPLAY = 8, |  | 
| 47     UMA_DISPLAY_BRIGHTNESS = 9, |  | 
| 48     UMA_ENTERPRISE = 10, |  | 
| 49     UMA_IME = 11, |  | 
| 50     UMA_MULTI_PROFILE_MEDIA = 12, |  | 
| 51     UMA_NETWORK = 13, |  | 
| 52     UMA_SETTINGS = 14, |  | 
| 53     UMA_UPDATE = 15, |  | 
| 54     UMA_POWER = 16, |  | 
| 55     UMA_ROTATION_LOCK = 17, |  | 
| 56     UMA_SCREEN_CAPTURE = 18, |  | 
| 57     UMA_SCREEN_SHARE = 19, |  | 
| 58     UMA_SESSION_LENGTH_LIMIT = 20, |  | 
| 59     UMA_SMS = 21, |  | 
| 60     UMA_SUPERVISED_USER = 22, |  | 
| 61     UMA_TRACING = 23, |  | 
| 62     UMA_USER = 24, |  | 
| 63     UMA_VPN = 25, |  | 
| 64     UMA_COUNT = 26, |  | 
| 65   }; |  | 
| 66 |  | 
| 67   SystemTrayItem(SystemTray* system_tray, UmaType type); |  | 
| 68   virtual ~SystemTrayItem(); |  | 
| 69 |  | 
| 70   // Create* functions may return NULL if nothing should be displayed for the |  | 
| 71   // type of view. The default implementations return NULL. |  | 
| 72 |  | 
| 73   // Returns a view to be displayed in the system tray. If this returns NULL, |  | 
| 74   // then this item is not displayed in the tray. |  | 
| 75   // NOTE: The returned view should almost always be a TrayItemView, which |  | 
| 76   // automatically resizes the widget when the size of the view changes, and |  | 
| 77   // adds animation when the visibility of the view changes. If a view wants to |  | 
| 78   // avoid this behavior, then it should not be a TrayItemView. |  | 
| 79   virtual views::View* CreateTrayView(LoginStatus status); |  | 
| 80 |  | 
| 81   // Returns a view for the item to be displayed in the list. This view can be |  | 
| 82   // displayed with a number of other tray items, so this should not be too |  | 
| 83   // big. |  | 
| 84   virtual views::View* CreateDefaultView(LoginStatus status); |  | 
| 85 |  | 
| 86   // Returns a detailed view for the item. This view is displayed standalone. |  | 
| 87   virtual views::View* CreateDetailedView(LoginStatus status); |  | 
| 88 |  | 
| 89   // These functions are called when the corresponding view item is about to be |  | 
| 90   // removed. An item should do appropriate cleanup in these functions. |  | 
| 91   // The default implementation does nothing. |  | 
| 92   virtual void DestroyTrayView(); |  | 
| 93   virtual void DestroyDefaultView(); |  | 
| 94   virtual void DestroyDetailedView(); |  | 
| 95 |  | 
| 96   // Updates the tray view (if applicable) when the user's login status changes. |  | 
| 97   // It is not necessary the update the default or detailed view, since the |  | 
| 98   // default/detailed popup is closed when login status changes. The default |  | 
| 99   // implementation does nothing. |  | 
| 100   virtual void UpdateAfterLoginStatusChange(LoginStatus status); |  | 
| 101 |  | 
| 102   // Updates the tray view (if applicable) when shelf's alignment changes. |  | 
| 103   // The default implementation does nothing. |  | 
| 104   virtual void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment); |  | 
| 105 |  | 
| 106   // Shows the detailed view for this item. If the main popup for the tray is |  | 
| 107   // currently visible, then making this call would use the existing window to |  | 
| 108   // display the detailed item. The detailed item will inherit the bounds of the |  | 
| 109   // existing window. |  | 
| 110   // |  | 
| 111   // In Material Design the actual transition is intentionally delayed to allow |  | 
| 112   // the user to perceive the ink drop animation on the clicked target. |  | 
| 113   void TransitionDetailedView(); |  | 
| 114 |  | 
| 115   // Pops up the detailed view for this item. An item can request to show its |  | 
| 116   // detailed view using this function (e.g. from an observer callback when |  | 
| 117   // something, e.g. volume, network availability etc. changes). If |  | 
| 118   // |for_seconds| is non-zero, then the popup is closed after the specified |  | 
| 119   // time. |  | 
| 120   void PopupDetailedView(int for_seconds, bool activate); |  | 
| 121 |  | 
| 122   // Continue showing the currently-shown detailed view, if any, for |  | 
| 123   // |for_seconds| seconds.  The caller is responsible for checking that the |  | 
| 124   // currently-shown view is for this item. |  | 
| 125   void SetDetailedViewCloseDelay(int for_seconds); |  | 
| 126 |  | 
| 127   // Hides the detailed view for this item. Disable hiding animation if |  | 
| 128   // |animate| is false. |  | 
| 129   void HideDetailedView(bool animate); |  | 
| 130 |  | 
| 131   // Returns true if this item needs to force the shelf to be visible when |  | 
| 132   // the shelf is in the auto-hide state. Default is true. |  | 
| 133   virtual bool ShouldShowShelf() const; |  | 
| 134 |  | 
| 135   // Returns the system tray that this item belongs to. |  | 
| 136   SystemTray* system_tray() const { return system_tray_; } |  | 
| 137 |  | 
| 138   bool restore_focus() const { return restore_focus_; } |  | 
| 139   void set_restore_focus(bool restore_focus) { restore_focus_ = restore_focus; } |  | 
| 140 |  | 
| 141  private: |  | 
| 142   // Accesses uma_type(). |  | 
| 143   friend class SystemTrayBubble; |  | 
| 144 |  | 
| 145   UmaType uma_type() const { return uma_type_; } |  | 
| 146 |  | 
| 147   SystemTray* system_tray_; |  | 
| 148   UmaType uma_type_; |  | 
| 149   bool restore_focus_; |  | 
| 150 |  | 
| 151   // Used to delay the transition to the detailed view. |  | 
| 152   base::OneShotTimer transition_delay_timer_; |  | 
| 153 |  | 
| 154   DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); |  | 
| 155 }; |  | 
| 156 |  | 
| 157 }  // namespace ash |  | 
| 158 |  | 
| 159 #endif  // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |  | 
| OLD | NEW | 
|---|