| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/system/power/power_supply_status.h" | 9 #include "ash/system/power/power_supply_status.h" |
| 10 #include "ash/system/tray/tray_background_view.h" | 10 #include "ash/system/tray/tray_background_view.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class SmsObserver; | 34 class SmsObserver; |
| 35 class PowerStatusObserver; | 35 class PowerStatusObserver; |
| 36 class UpdateObserver; | 36 class UpdateObserver; |
| 37 class UserObserver; | 37 class UserObserver; |
| 38 | 38 |
| 39 class SystemTrayItem; | 39 class SystemTrayItem; |
| 40 | 40 |
| 41 namespace internal { | 41 namespace internal { |
| 42 class SystemTrayBubble; | 42 class SystemTrayBubble; |
| 43 class SystemTrayContainer; | 43 class SystemTrayContainer; |
| 44 class SystemTrayLayerAnimationObserver; |
| 44 } | 45 } |
| 45 | 46 |
| 46 // There are different methods for creating bubble views. | 47 // There are different methods for creating bubble views. |
| 47 enum BubbleCreationType { | 48 enum BubbleCreationType { |
| 48 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 49 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. |
| 49 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. | 50 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView { | 53 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView { |
| 53 public: | 54 public: |
| 54 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); | 55 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); |
| 55 virtual ~SystemTray(); | 56 virtual ~SystemTray(); |
| 56 | 57 |
| 58 // Called after the tray has been added to the widget containing it. |
| 59 void Initialize(); |
| 60 |
| 57 // Creates the default set of items for the sytem tray. | 61 // Creates the default set of items for the sytem tray. |
| 58 void CreateItems(); | 62 void CreateItems(); |
| 59 | 63 |
| 60 // Adds a new item in the tray. | 64 // Adds a new item in the tray. |
| 61 void AddTrayItem(SystemTrayItem* item); | 65 void AddTrayItem(SystemTrayItem* item); |
| 62 | 66 |
| 63 // Removes an existing tray item. | 67 // Removes an existing tray item. |
| 64 void RemoveTrayItem(SystemTrayItem* item); | 68 void RemoveTrayItem(SystemTrayItem* item); |
| 65 | 69 |
| 66 // Shows the default view of all items. | 70 // Shows the default view of all items. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 UserObserver* user_observer() const { | 149 UserObserver* user_observer() const { |
| 146 return user_observer_; | 150 return user_observer_; |
| 147 } | 151 } |
| 148 | 152 |
| 149 // Accessors for testing. | 153 // Accessors for testing. |
| 150 | 154 |
| 151 // Returns true if the bubble exists. | 155 // Returns true if the bubble exists. |
| 152 bool CloseBubbleForTest() const; | 156 bool CloseBubbleForTest() const; |
| 153 | 157 |
| 154 // Overridden from TrayBackgroundView. | 158 // Overridden from TrayBackgroundView. |
| 155 virtual void Initialize() OVERRIDE; | |
| 156 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 159 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
| 157 virtual void AnchorUpdated() OVERRIDE; | |
| 158 | 160 |
| 159 private: | 161 private: |
| 162 friend class internal::SystemTrayLayerAnimationObserver; |
| 160 friend class internal::SystemTrayBubble; | 163 friend class internal::SystemTrayBubble; |
| 161 | 164 |
| 162 // Resets |bubble_| and clears any related state. | 165 // Resets |bubble_| and clears any related state. |
| 163 void DestroyBubble(); | 166 void DestroyBubble(); |
| 164 | 167 |
| 165 // Called when the widget associated with |bubble| closes. |bubble| should | 168 // Called when the widget associated with |bubble| closes. |bubble| should |
| 166 // always == |bubble_|. This triggers destroying |bubble_| and hiding the | 169 // always == |bubble_|. This triggers destroying |bubble_| and hiding the |
| 167 // launcher if necessary. | 170 // launcher if necessary. |
| 168 void RemoveBubble(internal::SystemTrayBubble* bubble); | 171 void RemoveBubble(internal::SystemTrayBubble* bubble); |
| 169 | 172 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 181 void ShowItems(const std::vector<SystemTrayItem*>& items, | 184 void ShowItems(const std::vector<SystemTrayItem*>& items, |
| 182 bool details, | 185 bool details, |
| 183 bool activate, | 186 bool activate, |
| 184 BubbleCreationType creation_type, | 187 BubbleCreationType creation_type, |
| 185 int x_offset); | 188 int x_offset); |
| 186 | 189 |
| 187 // Constructs or re-constructs |notification_bubble_| and populates it with | 190 // Constructs or re-constructs |notification_bubble_| and populates it with |
| 188 // |notification_items_|, or destroys it if there are no notification items. | 191 // |notification_items_|, or destroys it if there are no notification items. |
| 189 void UpdateNotificationBubble(); | 192 void UpdateNotificationBubble(); |
| 190 | 193 |
| 194 // Called when the anchor (tray or bubble) may have moved or changed. |
| 195 void UpdateNotificationAnchor(); |
| 196 |
| 191 // Overridden from internal::ActionableView. | 197 // Overridden from internal::ActionableView. |
| 192 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 198 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
| 193 | 199 |
| 194 // Overridden from views::View. | 200 // Overridden from views::View. |
| 195 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 201 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 196 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 202 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 203 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
| 197 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 204 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 205 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
| 198 | 206 |
| 199 // Owned items. | 207 // Owned items. |
| 200 ScopedVector<SystemTrayItem> items_; | 208 ScopedVector<SystemTrayItem> items_; |
| 201 | 209 |
| 202 // Pointers to members of |items_|. | 210 // Pointers to members of |items_|. |
| 203 SystemTrayItem* detailed_item_; | 211 SystemTrayItem* detailed_item_; |
| 204 std::vector<SystemTrayItem*> notification_items_; | 212 std::vector<SystemTrayItem*> notification_items_; |
| 205 | 213 |
| 206 // Mappings of system tray item and it's view in the tray. | 214 // Mappings of system tray item and it's view in the tray. |
| 207 std::map<SystemTrayItem*, views::View*> tray_item_map_; | 215 std::map<SystemTrayItem*, views::View*> tray_item_map_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 224 | 232 |
| 225 // Bubble for default and detailed views. | 233 // Bubble for default and detailed views. |
| 226 scoped_ptr<internal::SystemTrayBubble> bubble_; | 234 scoped_ptr<internal::SystemTrayBubble> bubble_; |
| 227 | 235 |
| 228 // Bubble for notifications. | 236 // Bubble for notifications. |
| 229 scoped_ptr<internal::SystemTrayBubble> notification_bubble_; | 237 scoped_ptr<internal::SystemTrayBubble> notification_bubble_; |
| 230 | 238 |
| 231 // See description agove getter. | 239 // See description agove getter. |
| 232 bool should_show_launcher_; | 240 bool should_show_launcher_; |
| 233 | 241 |
| 242 scoped_ptr<internal::SystemTrayLayerAnimationObserver> |
| 243 layer_animation_observer_; |
| 244 |
| 234 // Keep track of the default view height so that when we create detailed | 245 // Keep track of the default view height so that when we create detailed |
| 235 // views directly (e.g. from a notification) we know what height to use. | 246 // views directly (e.g. from a notification) we know what height to use. |
| 236 int default_bubble_height_; | 247 int default_bubble_height_; |
| 237 | 248 |
| 238 // Set to true when system notifications should be hidden (e.g. web | 249 // Set to true when system notifications should be hidden (e.g. web |
| 239 // notification bubble is visible). | 250 // notification bubble is visible). |
| 240 bool hide_notifications_; | 251 bool hide_notifications_; |
| 241 | 252 |
| 242 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 253 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 243 }; | 254 }; |
| 244 | 255 |
| 245 } // namespace ash | 256 } // namespace ash |
| 246 | 257 |
| 247 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 258 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |