| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 224 void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 225 SetTrayImageItemBorder(power_tray_, alignment); | 225 SetTrayImageItemBorder(power_tray_, alignment); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { | 228 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { |
| 229 if (power_tray_) | 229 if (power_tray_) |
| 230 power_tray_->UpdatePowerStatus(status); | 230 power_tray_->UpdatePowerStatus(status); |
| 231 if (notification_view_) | 231 if (notification_view_) |
| 232 notification_view_->UpdatePowerStatus(status); | 232 notification_view_->UpdatePowerStatus(status); |
| 233 | 233 |
| 234 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 234 if (UpdateNotificationState(status)) |
| 235 switches::kAshNotifyDisabled)) { | 235 ShowNotificationView(); |
| 236 if (UpdateNotificationState(status)) | 236 else if (notification_state_ == NOTIFICATION_NONE) |
| 237 ShowNotificationView(); | 237 HideNotificationView(); |
| 238 else if (notification_state_ == NOTIFICATION_NONE) | |
| 239 HideNotificationView(); | |
| 240 } | |
| 241 } | 238 } |
| 242 | 239 |
| 243 bool TrayPower::UpdateNotificationState(const PowerSupplyStatus& status) { | 240 bool TrayPower::UpdateNotificationState(const PowerSupplyStatus& status) { |
| 244 if (!status.battery_is_present || | 241 if (!status.battery_is_present || |
| 245 status.is_calculating_battery_time || | 242 status.is_calculating_battery_time || |
| 246 status.line_power_on) { | 243 status.line_power_on) { |
| 247 notification_state_ = NOTIFICATION_NONE; | 244 notification_state_ = NOTIFICATION_NONE; |
| 248 return false; | 245 return false; |
| 249 } | 246 } |
| 250 | 247 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 272 return false; | 269 return false; |
| 273 case NOTIFICATION_CRITICAL: | 270 case NOTIFICATION_CRITICAL: |
| 274 return false; | 271 return false; |
| 275 } | 272 } |
| 276 NOTREACHED(); | 273 NOTREACHED(); |
| 277 return false; | 274 return false; |
| 278 } | 275 } |
| 279 | 276 |
| 280 } // namespace internal | 277 } // namespace internal |
| 281 } // namespace ash | 278 } // namespace ash |
| OLD | NEW |