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

Side by Side Diff: ash/desktop_background/desktop_background_controller.cc

Issue 10854153: Fix memory leak on Chromium OS Heapcheck and Chromium OS (valgrind) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use scoped ptr to manage ownership Created 8 years, 4 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 | Annotate | Revision Log
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/desktop_background/desktop_background_controller.h" 5 #include "ash/desktop_background/desktop_background_controller.h"
6 6
7 #include "ash/desktop_background/desktop_background_view.h" 7 #include "ash/desktop_background/desktop_background_view.h"
8 #include "ash/desktop_background/desktop_background_widget_controller.h" 8 #include "ash/desktop_background/desktop_background_widget_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_factory.h" 10 #include "ash/shell_factory.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 void DesktopBackgroundController::MoveDesktopToUnlockedContainer() { 233 void DesktopBackgroundController::MoveDesktopToUnlockedContainer() {
234 if (!locked_) 234 if (!locked_)
235 return; 235 return;
236 locked_ = false; 236 locked_ = false;
237 ReparentBackgroundWidgets(GetBackgroundContainerId(true), 237 ReparentBackgroundWidgets(GetBackgroundContainerId(true),
238 GetBackgroundContainerId(false)); 238 GetBackgroundContainerId(false));
239 } 239 }
240 240
241 void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) { 241 void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) {
242 window->SetProperty(internal::kWindowDesktopComponent, 242 window->SetProperty(internal::kWindowDesktopComponent,
243 static_cast<internal::DesktopBackgroundWidgetController*>(NULL)); 243 static_cast<internal::DesktopBackgroundWidgetController*>(NULL));
244 window->SetProperty(internal::kComponentWrapper, 244 window->SetProperty(internal::kComponentWrapper,
245 static_cast<internal::ComponentWrapper*>(NULL)); 245 static_cast<internal::ComponentWrapper*>(NULL));
246 } 246 }
247 247
248 void DesktopBackgroundController::SetDesktopBackgroundImageMode() { 248 void DesktopBackgroundController::SetDesktopBackgroundImageMode() {
249 desktop_background_mode_ = BACKGROUND_IMAGE; 249 desktop_background_mode_ = BACKGROUND_IMAGE;
250 InstallComponentForAllWindows(); 250 InstallComponentForAllWindows();
251 } 251 }
252 252
253 void DesktopBackgroundController::OnWallpaperLoadCompleted( 253 void DesktopBackgroundController::OnWallpaperLoadCompleted(
254 scoped_refptr<WallpaperOperation> wo) { 254 scoped_refptr<WallpaperOperation> wo) {
255 current_wallpaper_.reset(wo->ReleaseWallpaperData()); 255 current_wallpaper_.reset(wo->ReleaseWallpaperData());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 313
314 void DesktopBackgroundController::ReparentBackgroundWidgets(int src_container, 314 void DesktopBackgroundController::ReparentBackgroundWidgets(int src_container,
315 int dst_container) { 315 int dst_container) {
316 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 316 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
317 for (Shell::RootWindowList::iterator iter = root_windows.begin(); 317 for (Shell::RootWindowList::iterator iter = root_windows.begin();
318 iter != root_windows.end(); ++iter) { 318 iter != root_windows.end(); ++iter) {
319 aura::RootWindow* root_window = *iter; 319 aura::RootWindow* root_window = *iter;
320 if (root_window->GetProperty(internal::kComponentWrapper)) { 320 if (root_window->GetProperty(internal::kComponentWrapper)) {
321 internal::DesktopBackgroundWidgetController* component = root_window-> 321 internal::DesktopBackgroundWidgetController* component = root_window->
322 GetProperty(internal::kComponentWrapper)->component(); 322 GetProperty(internal::kWindowDesktopComponent);
323 // Wallpaper animation may not finish at this point. Try to get component
324 // from kComponentWrapper instead.
325 if (!component) {
326 component = root_window->GetProperty(internal::kComponentWrapper)->
327 GetComponent(false);
328 }
323 DCHECK(component); 329 DCHECK(component);
324 component->Reparent(root_window, 330 component->Reparent(root_window,
325 src_container, 331 src_container,
326 dst_container); 332 dst_container);
327 } 333 }
328 } 334 }
329 } 335 }
330 336
331 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { 337 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) {
332 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : 338 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer :
333 internal::kShellWindowId_DesktopBackgroundContainer; 339 internal::kShellWindowId_DesktopBackgroundContainer;
334 } 340 }
335 341
336 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { 342 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() {
337 WallpaperResolution resolution = SMALL; 343 WallpaperResolution resolution = SMALL;
338 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 344 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
339 for (Shell::RootWindowList::iterator iter = root_windows.begin(); 345 for (Shell::RootWindowList::iterator iter = root_windows.begin();
340 iter != root_windows.end(); ++iter) { 346 iter != root_windows.end(); ++iter) {
341 gfx::Size root_window_size = (*iter)->GetHostSize(); 347 gfx::Size root_window_size = (*iter)->GetHostSize();
342 if (root_window_size.width() > kSmallWallpaperMaximalWidth || 348 if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
343 root_window_size.height() > kSmallWallpaperMaximalHeight) 349 root_window_size.height() > kSmallWallpaperMaximalHeight)
344 resolution = LARGE; 350 resolution = LARGE;
345 } 351 }
346 return resolution; 352 return resolution;
347 } 353 }
348 354
349 } // namespace ash 355 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/desktop_background/desktop_background_view.cc » ('j') | ash/desktop_background/desktop_background_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698