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_CHROMEOS_TRAY_DISPLAY_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_ |
6 #define ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_ | 6 #define ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_ |
7 | 7 |
| 8 #include <map> |
| 9 |
| 10 #include "ash/ash_export.h" |
8 #include "ash/display/display_controller.h" | 11 #include "ash/display/display_controller.h" |
| 12 #include "ash/display/display_info.h" |
| 13 #include "ash/system/tray/actionable_view.h" |
9 #include "ash/system/tray/system_tray_item.h" | 14 #include "ash/system/tray/system_tray_item.h" |
| 15 #include "base/strings/string16.h" |
| 16 |
| 17 namespace gfx { |
| 18 class Point; |
| 19 } |
10 | 20 |
11 namespace views { | 21 namespace views { |
| 22 class ImageView; |
| 23 class Label; |
12 class View; | 24 class View; |
13 } | 25 } |
14 | 26 |
15 namespace ash { | 27 namespace ash { |
| 28 namespace test { |
| 29 class AshTestBase; |
| 30 } |
| 31 |
16 namespace internal { | 32 namespace internal { |
17 | 33 |
18 enum TrayDisplayMode { | 34 class DisplayNotificationView; |
19 TRAY_DISPLAY_SINGLE, | 35 |
20 TRAY_DISPLAY_EXTENDED, | 36 class DisplayView : public ash::internal::ActionableView { |
21 TRAY_DISPLAY_MIRRORED, | 37 public: |
22 TRAY_DISPLAY_DOCKED, | 38 explicit DisplayView(user::LoginStatus login_status); |
| 39 virtual ~DisplayView(); |
| 40 |
| 41 void Update(); |
| 42 |
| 43 views::Label* label() { return label_; } |
| 44 |
| 45 // Overridden from views::View. |
| 46 virtual bool GetTooltipText(const gfx::Point& p, |
| 47 string16* tooltip) const OVERRIDE; |
| 48 |
| 49 private: |
| 50 base::string16 GetInternalDisplayInfo() const; |
| 51 |
| 52 // Overridden from ActionableView. |
| 53 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
| 54 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 55 |
| 56 user::LoginStatus login_status_; |
| 57 views::ImageView* image_; |
| 58 views::Label* label_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(DisplayView); |
23 }; | 61 }; |
24 | 62 |
25 class DisplayView; | 63 class ASH_EXPORT TrayDisplay : public SystemTrayItem, |
26 class DisplayNotificationView; | 64 public DisplayController::Observer { |
27 | |
28 class TrayDisplay : public SystemTrayItem, | |
29 public DisplayController::Observer { | |
30 public: | 65 public: |
31 explicit TrayDisplay(SystemTray* system_tray); | 66 explicit TrayDisplay(SystemTray* system_tray); |
32 virtual ~TrayDisplay(); | 67 virtual ~TrayDisplay(); |
33 | 68 |
34 private: | 69 private: |
| 70 friend class test::AshTestBase; |
| 71 friend class TrayDisplayTest; |
| 72 |
| 73 // Checks the current display settings and determine what message should be |
| 74 // shown for notification. |
| 75 base::string16 GetDisplayMessageForNotification(); |
| 76 |
35 // Overridden from SystemTrayItem. | 77 // Overridden from SystemTrayItem. |
36 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; | 78 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; |
37 virtual views::View* CreateNotificationView( | 79 virtual views::View* CreateNotificationView( |
38 user::LoginStatus status) OVERRIDE; | 80 user::LoginStatus status) OVERRIDE; |
39 virtual void DestroyDefaultView() OVERRIDE; | 81 virtual void DestroyDefaultView() OVERRIDE; |
40 virtual void DestroyNotificationView() OVERRIDE; | 82 virtual void DestroyNotificationView() OVERRIDE; |
41 virtual bool ShouldShowLauncher() const OVERRIDE; | 83 virtual bool ShouldShowLauncher() const OVERRIDE; |
42 | 84 |
43 // Overridden from DisplayControllerObserver: | 85 // Overridden from DisplayControllerObserver: |
44 virtual void OnDisplayConfigurationChanged() OVERRIDE; | 86 virtual void OnDisplayConfigurationChanged() OVERRIDE; |
45 | 87 |
| 88 // Call this to true when the test case wants to see the display notification. |
| 89 // Default is false on test. |
| 90 static void SetDisplayNotificationsEnabledForTest(bool enabled); |
| 91 |
| 92 // Test utilities. |
| 93 DisplayView* default_view() { return default_; } |
| 94 const string16& current_message() const { return current_message_; } |
| 95 |
46 DisplayView* default_; | 96 DisplayView* default_; |
47 DisplayNotificationView* notification_; | 97 DisplayNotificationView* notification_; |
48 TrayDisplayMode current_mode_; | 98 string16 current_message_; |
| 99 std::map<int64, DisplayInfo> display_info_; |
49 | 100 |
50 DISALLOW_COPY_AND_ASSIGN(TrayDisplay); | 101 DISALLOW_COPY_AND_ASSIGN(TrayDisplay); |
51 }; | 102 }; |
52 | 103 |
53 } // namespace internal | 104 } // namespace internal |
54 } // namespace ash | 105 } // namespace ash |
55 | 106 |
56 #endif // ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_ | 107 #endif // ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_ |
OLD | NEW |