Change DtmfSenderHandler to handle events on the signaling thread.
[chromium-blink-merge.git] / athena / system / background_controller.cc
blobacfb2802a6eae1b3e4b462259a0944e6e90b673d
1 // Copyright 2014 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 "athena/system/background_controller.h"
7 #include "athena/system/public/system_ui.h"
8 #include "ui/aura/window.h"
9 #include "ui/compositor/layer.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/views/view.h"
13 #include "ui/views/widget/widget.h"
15 namespace athena {
17 class BackgroundView : public views::View {
18 public:
19 BackgroundView() : system_info_view_(nullptr) {
20 system_info_view_ =
21 SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_LIGHT);
22 AddChildView(system_info_view_);
24 ~BackgroundView() override {}
26 void SetImage(const gfx::ImageSkia& image) {
27 image_ = image;
28 SchedulePaint();
31 // views::View:
32 virtual void Layout() override {
33 system_info_view_->SetBounds(
34 0, 0, width(), system_info_view_->GetPreferredSize().height());
37 virtual void OnPaint(gfx::Canvas* canvas) override {
38 canvas->DrawImageInt(image_,
41 image_.width(),
42 image_.height(),
45 width(),
46 height(),
47 true);
50 private:
51 gfx::ImageSkia image_;
52 views::View* system_info_view_;
54 DISALLOW_COPY_AND_ASSIGN(BackgroundView);
57 BackgroundController::BackgroundController(aura::Window* background_container) {
58 views::Widget* background_widget = new views::Widget;
59 views::Widget::InitParams params(
60 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
61 params.parent = background_container;
62 background_widget->Init(params);
63 background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
64 background_view_ = new BackgroundView;
65 background_widget->SetContentsView(background_view_);
66 background_widget->GetNativeView()->SetName("BackgroundWidget");
67 background_widget->Show();
70 BackgroundController::~BackgroundController() {
71 // background_widget is owned by the container and will be deleted
72 // when the container is deleted.
75 void BackgroundController::SetImage(const gfx::ImageSkia& image) {
76 // TODO(oshima): implement cross fede animation.
77 background_view_->SetImage(image);
80 } // namespace athena