Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / system / chromeos / power / tray_power.h
blob3bd0b201453d973a6e1067dad89b20aec82eabf9
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.
5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
6 #define ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
8 #include "ash/system/chromeos/power/power_status.h"
9 #include "ash/system/tray/system_tray_item.h"
11 class SkBitmap;
13 namespace gfx {
14 class Image;
15 class ImageSkia;
18 namespace message_center {
19 class MessageCenter;
22 namespace ash {
23 namespace tray {
24 class PowerNotificationView;
25 class PowerTrayView;
28 class ASH_EXPORT TrayPower : public SystemTrayItem,
29 public PowerStatus::Observer {
30 public:
31 // Visible for testing.
32 enum NotificationState {
33 NOTIFICATION_NONE,
35 // Low battery charge.
36 NOTIFICATION_LOW_POWER,
38 // Critically low battery charge.
39 NOTIFICATION_CRITICAL,
42 // Time-based notification thresholds when on battery power.
43 static const int kCriticalMinutes;
44 static const int kLowPowerMinutes;
45 static const int kNoWarningMinutes;
47 // Percentage-based notification thresholds when using a low-power charger.
48 static const int kCriticalPercentage;
49 static const int kLowPowerPercentage;
50 static const int kNoWarningPercentage;
52 TrayPower(SystemTray* system_tray,
53 message_center::MessageCenter* message_center);
54 virtual ~TrayPower();
56 private:
57 friend class TrayPowerTest;
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.
61 enum ChargerType{
62 UNKNOWN_CHARGER,
63 MAINS_CHARGER,
64 USB_CHARGER,
65 UNCONFIRMED_SPRING_CHARGER,
66 SAFE_SPRING_CHARGER,
67 CHARGER_TYPE_COUNT,
70 // Overridden from SystemTrayItem.
71 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
72 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
73 virtual views::View* CreateNotificationView(
74 user::LoginStatus status) OVERRIDE;
75 virtual void DestroyTrayView() OVERRIDE;
76 virtual void DestroyDefaultView() OVERRIDE;
77 virtual void DestroyNotificationView() OVERRIDE;
78 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
79 virtual void UpdateAfterShelfAlignmentChange(
80 ShelfAlignment alignment) OVERRIDE;
82 // Overridden from PowerStatus::Observer.
83 virtual void OnPowerStatusChanged() OVERRIDE;
85 // Show a notification that a low-power USB charger has been connected.
86 // Returns true if a notification was shown or explicitly hidden.
87 bool MaybeShowUsbChargerNotification();
89 // Sets |notification_state_|. Returns true if a notification should be shown.
90 bool UpdateNotificationState();
91 bool UpdateNotificationStateForRemainingTime();
92 bool UpdateNotificationStateForRemainingPercentage();
94 // Records the charger type in UMA.
95 void RecordChargerType();
97 message_center::MessageCenter* message_center_; // Not owned.
98 tray::PowerTrayView* power_tray_;
99 tray::PowerNotificationView* notification_view_;
100 NotificationState notification_state_;
102 // Was a USB charger connected the last time OnPowerStatusChanged() was
103 // called?
104 bool usb_charger_was_connected_;
106 // Was line power connected the last time onPowerStatusChanged() was called?
107 bool line_power_was_connected_;
109 DISALLOW_COPY_AND_ASSIGN(TrayPower);
112 } // namespace ash
114 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_