Chromium Code Reviews| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/date/date_view.h" | 8 #include "ash/system/date/date_view.h" |
| 9 #include "ash/system/power/power_supply_status.h" | 9 #include "ash/system/power/power_supply_status.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 } | 157 } |
| 158 | 158 |
| 159 TrayPower::~TrayPower() { | 159 TrayPower::~TrayPower() { |
| 160 } | 160 } |
| 161 | 161 |
| 162 views::View* TrayPower::CreateTrayView(user::LoginStatus status) { | 162 views::View* TrayPower::CreateTrayView(user::LoginStatus status) { |
| 163 // There may not be enough information when this is created about whether | 163 // There may not be enough information when this is created about whether |
| 164 // there is a battery or not. So always create this, and adjust visibility as | 164 // there is a battery or not. So always create this, and adjust visibility as |
| 165 // necessary. | 165 // necessary. |
| 166 PowerSupplyStatus power_status = | 166 PowerSupplyStatus power_status = |
| 167 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus(); | 167 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus( |
| 168 SystemTrayDelegate::UPDATE_INITIAL); | |
| 168 power_tray_.reset(new tray::PowerTrayView()); | 169 power_tray_.reset(new tray::PowerTrayView()); |
| 169 power_tray_->UpdatePowerStatus(power_status); | 170 power_tray_->UpdatePowerStatus(power_status); |
| 170 return power_tray_.get(); | 171 return power_tray_.get(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { | 174 views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { |
| 174 date_.reset(new tray::DateView(tray::DateView::DATE)); | 175 date_.reset(new tray::DateView(tray::DateView::DATE)); |
| 175 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED) | 176 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED) |
| 176 date_->SetActionable(true); | 177 date_->SetActionable(true); |
| 177 | 178 |
| 178 views::View* container = new views::View; | 179 views::View* container = new views::View; |
| 179 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, | 180 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 180 kTrayPopupPaddingHorizontal, 10, 0); | 181 kTrayPopupPaddingHorizontal, 10, 0); |
| 181 layout->set_spread_blank_space(true); | 182 layout->set_spread_blank_space(true); |
| 182 container->SetLayoutManager(layout); | 183 container->SetLayoutManager(layout); |
| 183 container->set_background(views::Background::CreateSolidBackground( | 184 container->set_background(views::Background::CreateSolidBackground( |
| 184 SkColorSetRGB(0xf1, 0xf1, 0xf1))); | 185 SkColorSetRGB(0xf1, 0xf1, 0xf1))); |
| 185 container->AddChildView(date_.get()); | 186 container->AddChildView(date_.get()); |
| 186 | 187 |
| 187 PowerSupplyStatus power_status = | 188 PowerSupplyStatus power_status = |
| 188 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus(); | 189 ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus( |
| 190 SystemTrayDelegate::UPDATE_USER); | |
|
sadrul
2012/04/10 00:01:34
It probably makes sense to remove the call to Requ
stevenjb
2012/04/10 18:02:03
That makes sense. Done.
| |
| 189 if (power_status.battery_is_present) { | 191 if (power_status.battery_is_present) { |
| 190 power_.reset(new tray::PowerPopupView()); | 192 power_.reset(new tray::PowerPopupView()); |
| 191 power_->UpdatePowerStatus(power_status); | 193 power_->UpdatePowerStatus(power_status); |
| 192 container->AddChildView(power_.get()); | 194 container->AddChildView(power_.get()); |
| 193 } | 195 } |
| 194 return container; | 196 return container; |
| 195 } | 197 } |
| 196 | 198 |
| 197 views::View* TrayPower::CreateDetailedView(user::LoginStatus status) { | 199 views::View* TrayPower::CreateDetailedView(user::LoginStatus status) { |
| 198 return NULL; | 200 return NULL; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 212 | 214 |
| 213 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { | 215 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { |
| 214 if (power_tray_.get()) | 216 if (power_tray_.get()) |
| 215 power_tray_->UpdatePowerStatus(status); | 217 power_tray_->UpdatePowerStatus(status); |
| 216 if (power_.get()) | 218 if (power_.get()) |
| 217 power_->UpdatePowerStatus(status); | 219 power_->UpdatePowerStatus(status); |
| 218 } | 220 } |
| 219 | 221 |
| 220 } // namespace internal | 222 } // namespace internal |
| 221 } // namespace ash | 223 } // namespace ash |
| OLD | NEW |