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