| 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*); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 widget_ = NULL; | 42 widget_ = NULL; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { | 45 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { |
| 46 if (widget_) | 46 if (widget_) |
| 47 widget_->SetBounds(bounds); | 47 widget_->SetBounds(bounds); |
| 48 else if (layer_.get()) | 48 else if (layer_.get()) |
| 49 layer_->SetBounds(bounds); | 49 layer_->SetBounds(bounds); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, | 52 bool DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, |
| 53 int src_container, | 53 int src_container, |
| 54 int dest_container) { | 54 int dest_container) { |
| 55 if (widget_) { | 55 if (widget_) { |
| 56 views::Widget::ReparentNativeView(widget_->GetNativeView(), | 56 views::Widget::ReparentNativeView(widget_->GetNativeView(), |
| 57 root_window->GetChildById(dest_container)); | 57 root_window->GetChildById(dest_container)); |
| 58 } else if (layer_.get()) { | 58 return true; |
| 59 } |
| 60 if (layer_.get()) { |
| 59 ui::Layer* layer = layer_.get(); | 61 ui::Layer* layer = layer_.get(); |
| 60 root_window->GetChildById(src_container)->layer()->Remove(layer); | 62 root_window->GetChildById(src_container)->layer()->Remove(layer); |
| 61 root_window->GetChildById(dest_container)->layer()->Add(layer); | 63 root_window->GetChildById(dest_container)->layer()->Add(layer); |
| 64 return true; |
| 62 } | 65 } |
| 66 // Nothing to reparent. |
| 67 return false; |
| 63 } | 68 } |
| 64 | 69 |
| 65 ComponentWrapper::ComponentWrapper( | 70 ComponentWrapper::ComponentWrapper( |
| 66 DesktopBackgroundWidgetController* component) { | 71 DesktopBackgroundWidgetController* component) { |
| 67 component_.reset(component); | 72 component_.reset(component); |
| 68 } | 73 } |
| 69 | 74 |
| 70 ComponentWrapper::~ComponentWrapper() { | 75 ComponentWrapper::~ComponentWrapper() { |
| 71 } | 76 } |
| 72 | 77 |
| 73 DesktopBackgroundWidgetController* ComponentWrapper::GetComponent( | 78 DesktopBackgroundWidgetController* ComponentWrapper::GetComponent( |
| 74 bool pass_ownership) { | 79 bool pass_ownership) { |
| 75 if (pass_ownership) | 80 if (pass_ownership) |
| 76 return component_.release(); | 81 return component_.release(); |
| 77 return component_.get(); | 82 return component_.get(); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace internal | 85 } // namespace internal |
| 81 } // namespace ash | 86 } // namespace ash |
| OLD | NEW |