Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / wm / system_background_controller.cc
blob86ec63df2d9b519ec8bad1cbfa2a355c830d5324
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
3 // found in the LICENSE file.
5 #include "ash/wm/system_background_controller.h"
7 #include "ui/aura/window.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_type.h"
11 namespace ash {
13 SystemBackgroundController::SystemBackgroundController(
14 aura::Window* root_window,
15 SkColor color)
16 : root_window_(root_window),
17 layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)) {
18 root_window_->AddObserver(this);
19 layer_->SetColor(color);
21 ui::Layer* root_layer = root_window_->layer();
22 layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
23 root_layer->Add(layer_.get());
24 root_layer->StackAtBottom(layer_.get());
27 SystemBackgroundController::~SystemBackgroundController() {
28 root_window_->RemoveObserver(this);
31 void SystemBackgroundController::SetColor(SkColor color) {
32 layer_->SetColor(color);
35 void SystemBackgroundController::OnWindowBoundsChanged(
36 aura::Window* root,
37 const gfx::Rect& old_bounds,
38 const gfx::Rect& new_bounds) {
39 DCHECK_EQ(root_window_, root);
40 layer_->SetBounds(gfx::Rect(root_window_->layer()->bounds().size()));
43 } // namespace ash