Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: ash/system/chromeos/power/tray_power.h

Issue 2072013002: mash: Move tray settings and deps to common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo 'git cl format' and nullptr changes. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
6 #define ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
7
8 #include <memory>
9
10 #include "ash/common/system/tray/system_tray_item.h"
11 #include "ash/system/chromeos/power/power_status.h"
12 #include "base/macros.h"
13
14 class SkBitmap;
15
16 namespace gfx {
17 class Image;
18 class ImageSkia;
19 }
20
21 namespace message_center {
22 class MessageCenter;
23 }
24
25 namespace ash {
26
27 class BatteryNotification;
28 class DualRoleNotification;
29
30 namespace tray {
31 class PowerTrayView;
32 }
33
34 class ASH_EXPORT TrayPower : public SystemTrayItem,
35 public PowerStatus::Observer {
36 public:
37 enum NotificationState {
38 NOTIFICATION_NONE,
39
40 // Low battery charge.
41 NOTIFICATION_LOW_POWER,
42
43 // Critically low battery charge.
44 NOTIFICATION_CRITICAL,
45 };
46
47 // Time-based notification thresholds when on battery power.
48 static const int kCriticalMinutes;
49 static const int kLowPowerMinutes;
50 static const int kNoWarningMinutes;
51
52 // Percentage-based notification thresholds when using a low-power charger.
53 static const int kCriticalPercentage;
54 static const int kLowPowerPercentage;
55 static const int kNoWarningPercentage;
56
57 static const char kUsbNotificationId[];
58
59 TrayPower(SystemTray* system_tray,
60 message_center::MessageCenter* message_center);
61 ~TrayPower() override;
62
63 void NotifyUsbNotificationClosedByUser();
64
65 private:
66 friend class TrayPowerTest;
67
68 // This enum is used for histogram. The existing values should not be removed,
69 // and the new values should be added just before CHARGER_TYPE_COUNT.
70 enum ChargerType{
71 UNKNOWN_CHARGER,
72 MAINS_CHARGER,
73 USB_CHARGER,
74 UNCONFIRMED_SPRING_CHARGER,
75 SAFE_SPRING_CHARGER,
76 CHARGER_TYPE_COUNT,
77 };
78
79 // Overridden from SystemTrayItem.
80 views::View* CreateTrayView(LoginStatus status) override;
81 views::View* CreateDefaultView(LoginStatus status) override;
82 void DestroyTrayView() override;
83 void DestroyDefaultView() override;
84 void UpdateAfterLoginStatusChange(LoginStatus status) override;
85 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
86
87 // Overridden from PowerStatus::Observer.
88 void OnPowerStatusChanged() override;
89
90 // Shows a notification that a low-power USB charger has been connected.
91 // Returns true if a notification was shown or explicitly hidden.
92 bool MaybeShowUsbChargerNotification();
93
94 // Shows a notification when dual-role devices are connected.
95 void MaybeShowDualRoleNotification();
96
97 // Sets |notification_state_|. Returns true if a notification should be shown.
98 bool UpdateNotificationState();
99 bool UpdateNotificationStateForRemainingTime();
100 bool UpdateNotificationStateForRemainingPercentage();
101
102 message_center::MessageCenter* message_center_; // Not owned.
103 tray::PowerTrayView* power_tray_;
104 std::unique_ptr<BatteryNotification> battery_notification_;
105 std::unique_ptr<DualRoleNotification> dual_role_notification_;
106 NotificationState notification_state_;
107
108 // Was a USB charger connected the last time OnPowerStatusChanged() was
109 // called?
110 bool usb_charger_was_connected_;
111
112 // Was line power connected the last time onPowerStatusChanged() was called?
113 bool line_power_was_connected_;
114
115 // Has the user already dismissed a low-power notification? Should be set
116 // back to false when all power sources are disconnected.
117 bool usb_notification_dismissed_;
118
119 DISALLOW_COPY_AND_ASSIGN(TrayPower);
120 };
121
122 } // namespace ash
123
124 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698