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

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

Issue 1014753003: Move low battery notification to Message Center. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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
11 class SkBitmap; 11 class SkBitmap;
12 12
13 namespace gfx { 13 namespace gfx {
14 class Image; 14 class Image;
15 class ImageSkia; 15 class ImageSkia;
16 } 16 }
17 17
18 namespace message_center { 18 namespace message_center {
19 class MessageCenter; 19 class MessageCenter;
20 } 20 }
21 21
22 namespace ash { 22 namespace ash {
23
24 class BatteryNotification;
25
23 namespace tray { 26 namespace tray {
24 class PowerNotificationView;
25 class PowerTrayView; 27 class PowerTrayView;
26 } 28 }
27 29
28 class ASH_EXPORT TrayPower : public SystemTrayItem, 30 class ASH_EXPORT TrayPower : public SystemTrayItem,
29 public PowerStatus::Observer { 31 public PowerStatus::Observer {
30 public: 32 public:
31 // Visible for testing.
32 enum NotificationState { 33 enum NotificationState {
33 NOTIFICATION_NONE, 34 NOTIFICATION_NONE,
34 35
35 // Low battery charge. 36 // Low battery charge.
36 NOTIFICATION_LOW_POWER, 37 NOTIFICATION_LOW_POWER,
37 38
38 // Critically low battery charge. 39 // Critically low battery charge.
39 NOTIFICATION_CRITICAL, 40 NOTIFICATION_CRITICAL,
40 }; 41 };
41 42
(...skipping 21 matching lines...) Expand all
63 MAINS_CHARGER, 64 MAINS_CHARGER,
64 USB_CHARGER, 65 USB_CHARGER,
65 UNCONFIRMED_SPRING_CHARGER, 66 UNCONFIRMED_SPRING_CHARGER,
66 SAFE_SPRING_CHARGER, 67 SAFE_SPRING_CHARGER,
67 CHARGER_TYPE_COUNT, 68 CHARGER_TYPE_COUNT,
68 }; 69 };
69 70
70 // Overridden from SystemTrayItem. 71 // Overridden from SystemTrayItem.
71 views::View* CreateTrayView(user::LoginStatus status) override; 72 views::View* CreateTrayView(user::LoginStatus status) override;
72 views::View* CreateDefaultView(user::LoginStatus status) override; 73 views::View* CreateDefaultView(user::LoginStatus status) override;
73 views::View* CreateNotificationView(user::LoginStatus status) override;
74 void DestroyTrayView() override; 74 void DestroyTrayView() override;
75 void DestroyDefaultView() override; 75 void DestroyDefaultView() override;
76 void DestroyNotificationView() override;
77 void UpdateAfterLoginStatusChange(user::LoginStatus status) override; 76 void UpdateAfterLoginStatusChange(user::LoginStatus status) override;
78 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; 77 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
79 78
80 // Overridden from PowerStatus::Observer. 79 // Overridden from PowerStatus::Observer.
81 void OnPowerStatusChanged() override; 80 void OnPowerStatusChanged() override;
82 81
83 // Show a notification that a low-power USB charger has been connected. 82 // Show a notification that a low-power USB charger has been connected.
84 // Returns true if a notification was shown or explicitly hidden. 83 // Returns true if a notification was shown or explicitly hidden.
85 bool MaybeShowUsbChargerNotification(); 84 bool MaybeShowUsbChargerNotification();
86 85
87 // Sets |notification_state_|. Returns true if a notification should be shown. 86 // Sets |notification_state_|. Returns true if a notification should be shown.
88 bool UpdateNotificationState(); 87 bool UpdateNotificationState();
89 bool UpdateNotificationStateForRemainingTime(); 88 bool UpdateNotificationStateForRemainingTime();
90 bool UpdateNotificationStateForRemainingPercentage(); 89 bool UpdateNotificationStateForRemainingPercentage();
91 90
92 message_center::MessageCenter* message_center_; // Not owned. 91 message_center::MessageCenter* message_center_; // Not owned.
93 tray::PowerTrayView* power_tray_; 92 tray::PowerTrayView* power_tray_;
94 tray::PowerNotificationView* notification_view_; 93 scoped_ptr<BatteryNotification> battery_notification_;
95 NotificationState notification_state_; 94 NotificationState notification_state_;
96 95
97 // Was a USB charger connected the last time OnPowerStatusChanged() was 96 // Was a USB charger connected the last time OnPowerStatusChanged() was
98 // called? 97 // called?
99 bool usb_charger_was_connected_; 98 bool usb_charger_was_connected_;
100 99
101 // Was line power connected the last time onPowerStatusChanged() was called? 100 // Was line power connected the last time onPowerStatusChanged() was called?
102 bool line_power_was_connected_; 101 bool line_power_was_connected_;
103 102
104 DISALLOW_COPY_AND_ASSIGN(TrayPower); 103 DISALLOW_COPY_AND_ASSIGN(TrayPower);
105 }; 104 };
106 105
107 } // namespace ash 106 } // namespace ash
108 107
109 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_ 108 #endif // ASH_SYSTEM_CHROMEOS_POWER_TRAY_POWER_H_
OLDNEW
« no previous file with comments | « ash/system/chromeos/power/power_status_view_unittest.cc ('k') | ash/system/chromeos/power/tray_power.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698