OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "ash/desktop_background/desktop_background_widget_controller.h" | |
6 | |
7 #include "ui/aura/root_window.h" | |
8 #include "ui/views/widget/widget.h" | |
9 | |
10 DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::DesktopBackgroundWidgetController*); | |
11 | |
12 namespace ash { | |
13 namespace internal { | |
14 | |
15 DEFINE_OWNED_WINDOW_PROPERTY_KEY(DesktopBackgroundWidgetController, | |
16 kWindowDesktopComponent, NULL); | |
17 | |
18 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( | |
19 views::Widget* widget) : widget_(widget) { | |
20 } | |
21 | |
22 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( | |
23 ui::Layer* layer) : widget_(NULL) { | |
24 layer_.reset(layer); | |
25 } | |
26 | |
bshe
2012/07/30 21:38:20
nit: remove the extra line here.
| |
27 | |
28 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { | |
29 if (widget_) { | |
30 widget_->CloseNow(); | |
31 widget_ = NULL; | |
32 } else if (layer_.get()) | |
33 layer_.reset(NULL); | |
34 } | |
35 | |
36 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { | |
37 if (widget_) | |
38 widget_->SetBounds(bounds); | |
39 else if (layer_.get()) | |
40 layer_->SetBounds(bounds); | |
41 } | |
42 | |
43 | |
44 void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, | |
45 int src_container, | |
46 int dest_container) { | |
47 if (widget_) { | |
48 views::Widget::ReparentNativeView(widget_->GetNativeView(), | |
49 root_window->GetChildById(dest_container)); | |
50 } else if (layer_.get()) { | |
51 ui::Layer* layer = layer_.get(); | |
52 root_window->GetChildById(src_container)->layer()->Remove(layer); | |
53 root_window->GetChildById(dest_container)->layer()->Add(layer); | |
54 } | |
55 } | |
56 | |
57 } // namespace internal | |
58 } // namespace ash | |
OLD | NEW |