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 "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/aura/window_property.h" | 9 #include "ui/aura/window_property.h" |
10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( | 32 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( |
33 ui::Layer* layer) : widget_(NULL) { | 33 ui::Layer* layer) : widget_(NULL) { |
34 layer_.reset(layer); | 34 layer_.reset(layer); |
35 } | 35 } |
36 | 36 |
37 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { | 37 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { |
38 if (widget_) { | 38 if (widget_) { |
39 widget_->RemoveObserver(this); | 39 widget_->RemoveObserver(this); |
40 widget_->CloseNow(); | 40 widget_->CloseNow(); |
41 widget_ = NULL; | 41 widget_ = NULL; |
42 } else if (layer_.get()) | 42 } else if (layer_) |
43 layer_.reset(NULL); | 43 layer_.reset(NULL); |
44 } | 44 } |
45 | 45 |
46 void DesktopBackgroundWidgetController::OnWidgetDestroying( | 46 void DesktopBackgroundWidgetController::OnWidgetDestroying( |
47 views::Widget* widget) { | 47 views::Widget* widget) { |
48 widget_->RemoveObserver(this); | 48 widget_->RemoveObserver(this); |
49 widget_ = NULL; | 49 widget_ = NULL; |
50 } | 50 } |
51 | 51 |
52 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { | 52 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { |
53 if (widget_) | 53 if (widget_) |
54 widget_->SetBounds(bounds); | 54 widget_->SetBounds(bounds); |
55 else if (layer_.get()) | 55 else if (layer_) |
56 layer_->SetBounds(bounds); | 56 layer_->SetBounds(bounds); |
57 } | 57 } |
58 | 58 |
59 bool DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, | 59 bool DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, |
60 int src_container, | 60 int src_container, |
61 int dest_container) { | 61 int dest_container) { |
62 if (widget_) { | 62 if (widget_) { |
63 views::Widget::ReparentNativeView(widget_->GetNativeView(), | 63 views::Widget::ReparentNativeView(widget_->GetNativeView(), |
64 root_window->GetChildById(dest_container)); | 64 root_window->GetChildById(dest_container)); |
65 return true; | 65 return true; |
66 } | 66 } |
67 if (layer_.get()) { | 67 if (layer_) { |
68 ui::Layer* layer = layer_.get(); | 68 ui::Layer* layer = layer_.get(); |
69 root_window->GetChildById(src_container)->layer()->Remove(layer); | 69 root_window->GetChildById(src_container)->layer()->Remove(layer); |
70 root_window->GetChildById(dest_container)->layer()->Add(layer); | 70 root_window->GetChildById(dest_container)->layer()->Add(layer); |
71 return true; | 71 return true; |
72 } | 72 } |
73 // Nothing to reparent. | 73 // Nothing to reparent. |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 AnimatingDesktopController::AnimatingDesktopController( | 77 AnimatingDesktopController::AnimatingDesktopController( |
(...skipping 14 matching lines...) Expand all Loading... |
92 | 92 |
93 DesktopBackgroundWidgetController* AnimatingDesktopController::GetController( | 93 DesktopBackgroundWidgetController* AnimatingDesktopController::GetController( |
94 bool pass_ownership) { | 94 bool pass_ownership) { |
95 if (pass_ownership) | 95 if (pass_ownership) |
96 return controller_.release(); | 96 return controller_.release(); |
97 return controller_.get(); | 97 return controller_.get(); |
98 } | 98 } |
99 | 99 |
100 } // namespace internal | 100 } // namespace internal |
101 } // namespace ash | 101 } // namespace ash |
OLD | NEW |