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_POWER_TRAY_POWER_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ |
6 #define ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ | 6 #define ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ |
7 | 7 |
8 #include "ash/system/chromeos/power/power_status.h" | 8 #include "ash/system/chromeos/power/power_status.h" |
9 #include "ash/system/tray/system_tray_item.h" | 9 #include "ash/system/tray/system_tray_item.h" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 NOTIFICATION_CRITICAL, | 41 NOTIFICATION_CRITICAL, |
42 }; | 42 }; |
43 | 43 |
44 TrayPower(SystemTray* system_tray, | 44 TrayPower(SystemTray* system_tray, |
45 message_center::MessageCenter* message_center); | 45 message_center::MessageCenter* message_center); |
46 virtual ~TrayPower(); | 46 virtual ~TrayPower(); |
47 | 47 |
48 private: | 48 private: |
49 friend class TrayPowerTest; | 49 friend class TrayPowerTest; |
50 | 50 |
| 51 // This enum is used for histogram. The existing values should not be removed, |
| 52 // and the new values should be added just before CHARGER_TYPE_COUNT. |
| 53 enum ChargerType{ |
| 54 UNKNOWN_CHARGER, |
| 55 MAINS_CHARGER, |
| 56 USB_CHARGER, |
| 57 UNCONFIRMED_SPRING_CHARGER, |
| 58 SAFE_SPRING_CHARGER, |
| 59 CHARGER_TYPE_COUNT, |
| 60 }; |
| 61 |
51 // Overridden from SystemTrayItem. | 62 // Overridden from SystemTrayItem. |
52 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; | 63 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; |
53 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; | 64 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; |
54 virtual views::View* CreateNotificationView( | 65 virtual views::View* CreateNotificationView( |
55 user::LoginStatus status) OVERRIDE; | 66 user::LoginStatus status) OVERRIDE; |
56 virtual void DestroyTrayView() OVERRIDE; | 67 virtual void DestroyTrayView() OVERRIDE; |
57 virtual void DestroyDefaultView() OVERRIDE; | 68 virtual void DestroyDefaultView() OVERRIDE; |
58 virtual void DestroyNotificationView() OVERRIDE; | 69 virtual void DestroyNotificationView() OVERRIDE; |
59 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; | 70 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; |
60 virtual void UpdateAfterShelfAlignmentChange( | 71 virtual void UpdateAfterShelfAlignmentChange( |
61 ShelfAlignment alignment) OVERRIDE; | 72 ShelfAlignment alignment) OVERRIDE; |
62 | 73 |
63 // Overridden from PowerStatus::Observer. | 74 // Overridden from PowerStatus::Observer. |
64 virtual void OnPowerStatusChanged() OVERRIDE; | 75 virtual void OnPowerStatusChanged() OVERRIDE; |
65 | 76 |
66 // Show a notification that a low-power USB charger has been connected. | 77 // Show a notification that a low-power USB charger has been connected. |
67 // Returns true if a notification was shown or explicitly hidden. | 78 // Returns true if a notification was shown or explicitly hidden. |
68 bool MaybeShowUsbChargerNotification(); | 79 bool MaybeShowUsbChargerNotification(); |
69 | 80 |
70 // Sets |notification_state_|. Returns true if a notification should be shown. | 81 // Sets |notification_state_|. Returns true if a notification should be shown. |
71 bool UpdateNotificationState(); | 82 bool UpdateNotificationState(); |
72 bool UpdateNotificationStateForRemainingTime(); | 83 bool UpdateNotificationStateForRemainingTime(); |
73 bool UpdateNotificationStateForRemainingPercentage(); | 84 bool UpdateNotificationStateForRemainingPercentage(); |
74 | 85 |
| 86 // Records the charger type in UMA. |
| 87 void RecordChargerType(); |
| 88 |
75 message_center::MessageCenter* message_center_; // Not owned. | 89 message_center::MessageCenter* message_center_; // Not owned. |
76 tray::PowerTrayView* power_tray_; | 90 tray::PowerTrayView* power_tray_; |
77 tray::PowerNotificationView* notification_view_; | 91 tray::PowerNotificationView* notification_view_; |
78 NotificationState notification_state_; | 92 NotificationState notification_state_; |
79 | 93 |
80 // Was a USB charger connected the last time OnPowerStatusChanged() was | 94 // Was a USB charger connected the last time OnPowerStatusChanged() was |
81 // called? | 95 // called? |
82 bool usb_charger_was_connected_; | 96 bool usb_charger_was_connected_; |
83 | 97 |
| 98 // Was line power connected the last time onPowerStatusChanged() was called? |
| 99 bool line_power_was_connected_; |
| 100 |
84 DISALLOW_COPY_AND_ASSIGN(TrayPower); | 101 DISALLOW_COPY_AND_ASSIGN(TrayPower); |
85 }; | 102 }; |
86 | 103 |
87 } // namespace internal | 104 } // namespace internal |
88 } // namespace ash | 105 } // namespace ash |
89 | 106 |
90 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ | 107 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ |
OLD | NEW |