| 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/common/wallpaper/wallpaper_widget_controller.h" | 5 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 8 #include "ash/common/wallpaper/wallpaper_delegate.h" | 8 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 9 #include "ash/common/wm_lookup.h" | |
| 10 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 11 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| 12 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 13 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
| 14 #include "ui/compositor/scoped_layer_animation_settings.h" | 13 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 15 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 16 | 15 |
| 17 namespace ash { | 16 namespace ash { |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Is this object observing the initial brightness/grayscale animation? | 56 // Is this object observing the initial brightness/grayscale animation? |
| 58 const bool is_initial_animation_; | 57 const bool is_initial_animation_; |
| 59 | 58 |
| 60 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); | 59 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 } // namespace | 62 } // namespace |
| 64 | 63 |
| 65 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget) | 64 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget) |
| 66 : widget_(widget), | 65 : widget_(widget), |
| 67 widget_parent_(WmLookup::Get()->GetWindowForWidget(widget)->GetParent()) { | 66 widget_parent_(WmWindow::Get(widget->GetNativeWindow())->GetParent()) { |
| 68 DCHECK(widget_); | 67 DCHECK(widget_); |
| 69 widget_->AddObserver(this); | 68 widget_->AddObserver(this); |
| 70 widget_parent_->aura_window()->AddObserver(this); | 69 widget_parent_->aura_window()->AddObserver(this); |
| 71 } | 70 } |
| 72 | 71 |
| 73 WallpaperWidgetController::~WallpaperWidgetController() { | 72 WallpaperWidgetController::~WallpaperWidgetController() { |
| 74 if (widget_) { | 73 if (widget_) { |
| 75 views::Widget* widget = widget_; | 74 views::Widget* widget = widget_; |
| 76 RemoveObservers(); | 75 RemoveObservers(); |
| 77 widget->CloseNow(); | 76 widget->CloseNow(); |
| 78 } | 77 } |
| 79 } | 78 } |
| 80 | 79 |
| 81 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) { | 80 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) { |
| 82 RemoveObservers(); | 81 RemoveObservers(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) { | 84 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) { |
| 86 if (widget_) | 85 if (widget_) |
| 87 widget_->SetBounds(bounds); | 86 widget_->SetBounds(bounds); |
| 88 } | 87 } |
| 89 | 88 |
| 90 bool WallpaperWidgetController::Reparent(WmWindow* root_window, int container) { | 89 bool WallpaperWidgetController::Reparent(WmWindow* root_window, int container) { |
| 91 if (widget_) { | 90 if (widget_) { |
| 92 widget_parent_->aura_window()->RemoveObserver(this); | 91 widget_parent_->aura_window()->RemoveObserver(this); |
| 93 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_); | 92 WmWindow* window = WmWindow::Get(widget_->GetNativeWindow()); |
| 94 root_window->GetChildByShellWindowId(container)->AddChild(window); | 93 root_window->GetChildByShellWindowId(container)->AddChild(window); |
| 95 widget_parent_ = WmLookup::Get()->GetWindowForWidget(widget_)->GetParent(); | 94 widget_parent_ = WmWindow::Get(widget_->GetNativeWindow())->GetParent(); |
| 96 widget_parent_->aura_window()->AddObserver(this); | 95 widget_parent_->aura_window()->AddObserver(this); |
| 97 return true; | 96 return true; |
| 98 } | 97 } |
| 99 // Nothing to reparent. | 98 // Nothing to reparent. |
| 100 return false; | 99 return false; |
| 101 } | 100 } |
| 102 | 101 |
| 103 void WallpaperWidgetController::RemoveObservers() { | 102 void WallpaperWidgetController::RemoveObservers() { |
| 104 widget_parent_->aura_window()->RemoveObserver(this); | 103 widget_parent_->aura_window()->RemoveObserver(this); |
| 105 widget_->RemoveObserver(this); | 104 widget_->RemoveObserver(this); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 140 } |
| 142 | 141 |
| 143 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( | 142 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( |
| 144 bool pass_ownership) { | 143 bool pass_ownership) { |
| 145 if (pass_ownership) | 144 if (pass_ownership) |
| 146 return controller_.release(); | 145 return controller_.release(); |
| 147 return controller_.get(); | 146 return controller_.get(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |