Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: ash/common/wallpaper/wallpaper_widget_controller.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 9 #include "ash/common/wm_lookup.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); 60 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
61 }; 61 };
62 62
63 } // namespace 63 } // namespace
64 64
65 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget) 65 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget)
66 : widget_(widget), 66 : widget_(widget),
67 widget_parent_(WmLookup::Get()->GetWindowForWidget(widget)->GetParent()) { 67 widget_parent_(WmLookup::Get()->GetWindowForWidget(widget)->GetParent()) {
68 DCHECK(widget_); 68 DCHECK(widget_);
69 widget_->AddObserver(this); 69 widget_->AddObserver(this);
70 widget_parent_->AddObserver(this); 70 widget_parent_->aura_window()->AddObserver(this);
71 } 71 }
72 72
73 WallpaperWidgetController::~WallpaperWidgetController() { 73 WallpaperWidgetController::~WallpaperWidgetController() {
74 if (widget_) { 74 if (widget_) {
75 views::Widget* widget = widget_; 75 views::Widget* widget = widget_;
76 RemoveObservers(); 76 RemoveObservers();
77 widget->CloseNow(); 77 widget->CloseNow();
78 } 78 }
79 } 79 }
80 80
81 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) { 81 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) {
82 RemoveObservers(); 82 RemoveObservers();
83 } 83 }
84 84
85 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) { 85 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) {
86 if (widget_) 86 if (widget_)
87 widget_->SetBounds(bounds); 87 widget_->SetBounds(bounds);
88 } 88 }
89 89
90 bool WallpaperWidgetController::Reparent(WmWindow* root_window, int container) { 90 bool WallpaperWidgetController::Reparent(WmWindow* root_window, int container) {
91 if (widget_) { 91 if (widget_) {
92 widget_parent_->RemoveObserver(this); 92 widget_parent_->aura_window()->RemoveObserver(this);
93 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_); 93 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_);
94 root_window->GetChildByShellWindowId(container)->AddChild(window); 94 root_window->GetChildByShellWindowId(container)->AddChild(window);
95 widget_parent_ = WmLookup::Get()->GetWindowForWidget(widget_)->GetParent(); 95 widget_parent_ = WmLookup::Get()->GetWindowForWidget(widget_)->GetParent();
96 widget_parent_->AddObserver(this); 96 widget_parent_->aura_window()->AddObserver(this);
97 return true; 97 return true;
98 } 98 }
99 // Nothing to reparent. 99 // Nothing to reparent.
100 return false; 100 return false;
101 } 101 }
102 102
103 void WallpaperWidgetController::RemoveObservers() { 103 void WallpaperWidgetController::RemoveObservers() {
104 widget_parent_->RemoveObserver(this); 104 widget_parent_->aura_window()->RemoveObserver(this);
105 widget_->RemoveObserver(this); 105 widget_->RemoveObserver(this);
106 widget_ = nullptr; 106 widget_ = nullptr;
107 } 107 }
108 108
109 void WallpaperWidgetController::OnWindowBoundsChanged( 109 void WallpaperWidgetController::OnWindowBoundsChanged(
110 WmWindow* window, 110 aura::Window* window,
111 const gfx::Rect& old_bounds, 111 const gfx::Rect& old_bounds,
112 const gfx::Rect& new_bounds) { 112 const gfx::Rect& new_bounds) {
113 SetBounds(new_bounds); 113 SetBounds(new_bounds);
114 } 114 }
115 115
116 void WallpaperWidgetController::StartAnimating( 116 void WallpaperWidgetController::StartAnimating(
117 RootWindowController* root_window_controller) { 117 RootWindowController* root_window_controller) {
118 if (widget_) { 118 if (widget_) {
119 ui::ScopedLayerAnimationSettings settings( 119 ui::ScopedLayerAnimationSettings settings(
120 widget_->GetLayer()->GetAnimator()); 120 widget_->GetLayer()->GetAnimator());
(...skipping 20 matching lines...) Expand all
141 } 141 }
142 142
143 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( 143 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController(
144 bool pass_ownership) { 144 bool pass_ownership) {
145 if (pass_ownership) 145 if (pass_ownership)
146 return controller_.release(); 146 return controller_.release();
147 return controller_.get(); 147 return controller_.get();
148 } 148 }
149 149
150 } // namespace ash 150 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wallpaper/wallpaper_widget_controller.h ('k') | ash/common/wm/always_on_top_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698