| 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" |
| 11 #include "ash/system/power/power_supply_status.h" | 11 #include "ash/system/power/power_supply_status.h" |
| 12 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/system/tray/system_tray_delegate.h" | 13 #include "ash/system/tray/system_tray_delegate.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/system/tray/tray_notification_view.h" | 15 #include "ash/system/tray/tray_notification_view.h" |
| 15 #include "ash/system/tray/tray_views.h" | 16 #include "ash/system/tray/tray_views.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
| 18 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
| 21 #include "grit/ui_resources.h" | 22 #include "grit/ui_resources.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 155 } |
| 155 | 156 |
| 156 views::View* TrayPower::CreateTrayView(user::LoginStatus status) { | 157 views::View* TrayPower::CreateTrayView(user::LoginStatus status) { |
| 157 // There may not be enough information when this is created about whether | 158 // There may not be enough information when this is created about whether |
| 158 // there is a battery or not. So always create this, and adjust visibility as | 159 // there is a battery or not. So always create this, and adjust visibility as |
| 159 // necessary. | 160 // necessary. |
| 160 PowerSupplyStatus power_status = | 161 PowerSupplyStatus power_status = |
| 161 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus(); | 162 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus(); |
| 162 CHECK(power_tray_ == NULL); | 163 CHECK(power_tray_ == NULL); |
| 163 power_tray_ = new tray::PowerTrayView(); | 164 power_tray_ = new tray::PowerTrayView(); |
| 165 UpdateAfterShelfAlignmentChange( |
| 166 ash::Shell::GetInstance()->system_tray()->shelf_alignment()); |
| 164 power_tray_->UpdatePowerStatus(power_status); | 167 power_tray_->UpdatePowerStatus(power_status); |
| 165 return power_tray_; | 168 return power_tray_; |
| 166 } | 169 } |
| 167 | 170 |
| 168 views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { | 171 views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { |
| 169 // Make sure icon status is up-to-date. (Also triggers stub activation). | 172 // Make sure icon status is up-to-date. (Also triggers stub activation). |
| 170 ash::Shell::GetInstance()->tray_delegate()->RequestStatusUpdate(); | 173 ash::Shell::GetInstance()->tray_delegate()->RequestStatusUpdate(); |
| 171 return NULL; | 174 return NULL; |
| 172 } | 175 } |
| 173 | 176 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 191 void TrayPower::DestroyDefaultView() { | 194 void TrayPower::DestroyDefaultView() { |
| 192 } | 195 } |
| 193 | 196 |
| 194 void TrayPower::DestroyNotificationView() { | 197 void TrayPower::DestroyNotificationView() { |
| 195 notification_view_ = NULL; | 198 notification_view_ = NULL; |
| 196 } | 199 } |
| 197 | 200 |
| 198 void TrayPower::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 201 void TrayPower::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 199 } | 202 } |
| 200 | 203 |
| 204 void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 205 SetTrayImageItemBorder(power_tray_, alignment); |
| 206 } |
| 207 |
| 201 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { | 208 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { |
| 202 if (power_tray_) | 209 if (power_tray_) |
| 203 power_tray_->UpdatePowerStatus(status); | 210 power_tray_->UpdatePowerStatus(status); |
| 204 if (notification_view_) | 211 if (notification_view_) |
| 205 notification_view_->UpdatePowerStatus(status); | 212 notification_view_->UpdatePowerStatus(status); |
| 206 | 213 |
| 207 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 214 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 208 switches::kAshNotifyDisabled)) { | 215 switches::kAshNotifyDisabled)) { |
| 209 if (UpdateNotificationState(status)) | 216 if (UpdateNotificationState(status)) |
| 210 ShowNotificationView(); | 217 ShowNotificationView(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return false; | 252 return false; |
| 246 case NOTIFICATION_CRITICAL: | 253 case NOTIFICATION_CRITICAL: |
| 247 return false; | 254 return false; |
| 248 } | 255 } |
| 249 NOTREACHED(); | 256 NOTREACHED(); |
| 250 return false; | 257 return false; |
| 251 } | 258 } |
| 252 | 259 |
| 253 } // namespace internal | 260 } // namespace internal |
| 254 } // namespace ash | 261 } // namespace ash |
| OLD | NEW |