| 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/wm/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.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/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 return true; | 296 return true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const { | 299 bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const { |
| 300 return controller_->background_layer_.get() && | 300 return controller_->background_layer_.get() && |
| 301 controller_->background_layer_->visible(); | 301 controller_->background_layer_->visible(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 // Simple class that fills |background_layer_| with black. | |
| 305 class PowerButtonController::BackgroundLayerDelegate | |
| 306 : public ui::LayerDelegate { | |
| 307 public: | |
| 308 BackgroundLayerDelegate() {} | |
| 309 virtual ~BackgroundLayerDelegate() {} | |
| 310 | |
| 311 // ui::LayerDelegate implementation: | |
| 312 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | |
| 313 canvas->FillRect(SK_ColorBLACK, aura::RootWindow::GetInstance()->bounds()); | |
| 314 } | |
| 315 | |
| 316 private: | |
| 317 DISALLOW_COPY_AND_ASSIGN(BackgroundLayerDelegate); | |
| 318 }; | |
| 319 | |
| 320 PowerButtonController::PowerButtonController() | 304 PowerButtonController::PowerButtonController() |
| 321 : logged_in_as_non_guest_(false), | 305 : logged_in_as_non_guest_(false), |
| 322 locked_(false), | 306 locked_(false), |
| 323 power_button_down_(false), | 307 power_button_down_(false), |
| 324 lock_button_down_(false), | 308 lock_button_down_(false), |
| 325 shutting_down_(false), | 309 shutting_down_(false), |
| 326 has_legacy_power_button_( | 310 has_legacy_power_button_( |
| 327 CommandLine::ForCurrentProcess()->HasSwitch( | 311 CommandLine::ForCurrentProcess()->HasSwitch( |
| 328 switches::kAuraLegacyPowerButton)) { | 312 switches::kAuraLegacyPowerButton)) { |
| 329 } | 313 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 FROM_HERE, | 498 FROM_HERE, |
| 515 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), | 499 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), |
| 516 this, &PowerButtonController::OnShutdownTimeout); | 500 this, &PowerButtonController::OnShutdownTimeout); |
| 517 } | 501 } |
| 518 | 502 |
| 519 void PowerButtonController::ShowBackgroundLayer() { | 503 void PowerButtonController::ShowBackgroundLayer() { |
| 520 if (hide_background_layer_timer_.IsRunning()) | 504 if (hide_background_layer_timer_.IsRunning()) |
| 521 hide_background_layer_timer_.Stop(); | 505 hide_background_layer_timer_.Stop(); |
| 522 | 506 |
| 523 if (!background_layer_.get()) { | 507 if (!background_layer_.get()) { |
| 524 background_layer_delegate_.reset(new BackgroundLayerDelegate); | 508 background_layer_.reset(new ui::Layer(ui::Layer::LAYER_SOLID_COLOR)); |
| 525 background_layer_.reset(new ui::Layer(ui::Layer::LAYER_HAS_TEXTURE)); | 509 background_layer_->SetColor(SK_ColorBLACK); |
| 526 background_layer_->set_delegate(background_layer_delegate_.get()); | |
| 527 | 510 |
| 528 ui::Layer* root_layer = aura::RootWindow::GetInstance()->layer(); | 511 ui::Layer* root_layer = aura::RootWindow::GetInstance()->layer(); |
| 529 background_layer_->SetBounds(root_layer->bounds()); | 512 background_layer_->SetBounds(root_layer->bounds()); |
| 530 root_layer->Add(background_layer_.get()); | 513 root_layer->Add(background_layer_.get()); |
| 531 root_layer->StackAtBottom(background_layer_.get()); | 514 root_layer->StackAtBottom(background_layer_.get()); |
| 532 } | 515 } |
| 533 background_layer_->SetVisible(true); | 516 background_layer_->SetVisible(true); |
| 534 } | 517 } |
| 535 | 518 |
| 536 void PowerButtonController::HideBackgroundLayer() { | 519 void PowerButtonController::HideBackgroundLayer() { |
| 537 background_layer_.reset(); | 520 background_layer_.reset(); |
| 538 } | 521 } |
| 539 | 522 |
| 540 } // namespace ash | 523 } // namespace ash |
| OLD | NEW |