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 #include "ash/system/power/tray_power.h" | 5 #include "ash/system/power/tray_power.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/system/date/date_view.h" | 9 #include "ash/system/date/date_view.h" |
10 #include "ash/system/power/power_status_view.h" | 10 #include "ash/system/power/power_status_view.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 PowerSupplyStatus supply_status_; | 93 PowerSupplyStatus supply_status_; |
94 | 94 |
95 // Index of the current icon in the icon array image, or -1 if unknown. | 95 // Index of the current icon in the icon array image, or -1 if unknown. |
96 int battery_icon_index_; | 96 int battery_icon_index_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(PowerTrayView); | 98 DISALLOW_COPY_AND_ASSIGN(PowerTrayView); |
99 }; | 99 }; |
100 | 100 |
101 class PowerNotificationView : public TrayNotificationView { | 101 class PowerNotificationView : public TrayNotificationView { |
102 public: | 102 public: |
103 explicit PowerNotificationView(TrayPower* tray) | 103 explicit PowerNotificationView(TrayPower* owner) |
104 : TrayNotificationView(tray, 0), | 104 : TrayNotificationView(owner, 0), |
105 battery_icon_index_(-1) { | 105 battery_icon_index_(-1) { |
106 power_status_view_ = | 106 power_status_view_ = |
107 new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION, true); | 107 new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION, true); |
108 InitView(power_status_view_); | 108 InitView(power_status_view_); |
109 } | 109 } |
110 | 110 |
111 void UpdatePowerStatus(const PowerSupplyStatus& status) { | 111 void UpdatePowerStatus(const PowerSupplyStatus& status) { |
112 int index = TrayPower::GetBatteryImageIndex(status); | 112 int index = TrayPower::GetBatteryImageIndex(status); |
113 if (battery_icon_index_ != index) { | 113 if (battery_icon_index_ != index) { |
114 battery_icon_index_ = index; | 114 battery_icon_index_ = index; |
(...skipping 11 matching lines...) Expand all Loading... |
126 // Index of the current icon in the icon array image, or -1 if unknown. | 126 // Index of the current icon in the icon array image, or -1 if unknown. |
127 int battery_icon_index_; | 127 int battery_icon_index_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(PowerNotificationView); | 129 DISALLOW_COPY_AND_ASSIGN(PowerNotificationView); |
130 }; | 130 }; |
131 | 131 |
132 } // namespace tray | 132 } // namespace tray |
133 | 133 |
134 using tray::PowerNotificationView; | 134 using tray::PowerNotificationView; |
135 | 135 |
136 TrayPower::TrayPower() | 136 TrayPower::TrayPower(SystemTray* system_tray) |
137 : power_tray_(NULL), | 137 : SystemTrayItem(system_tray), |
| 138 power_tray_(NULL), |
138 notification_view_(NULL), | 139 notification_view_(NULL), |
139 notification_state_(NOTIFICATION_NONE) { | 140 notification_state_(NOTIFICATION_NONE) { |
140 } | 141 } |
141 | 142 |
142 TrayPower::~TrayPower() { | 143 TrayPower::~TrayPower() { |
143 } | 144 } |
144 | 145 |
145 // static | 146 // static |
146 int TrayPower::GetBatteryImageIndex(const PowerSupplyStatus& supply_status) { | 147 int TrayPower::GetBatteryImageIndex(const PowerSupplyStatus& supply_status) { |
147 int image_index = 0; | 148 int image_index = 0; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return false; | 266 return false; |
266 case NOTIFICATION_CRITICAL: | 267 case NOTIFICATION_CRITICAL: |
267 return false; | 268 return false; |
268 } | 269 } |
269 NOTREACHED(); | 270 NOTREACHED(); |
270 return false; | 271 return false; |
271 } | 272 } |
272 | 273 |
273 } // namespace internal | 274 } // namespace internal |
274 } // namespace ash | 275 } // namespace ash |
OLD | NEW |