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