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

Unified Diff: ash/desktop_background/desktop_background_view.cc

Issue 10898007: Forget about DesktopBackgroundWidget if it was deleted (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Additional check 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 side-by-side diff with in-line comments
Download patch
Index: ash/desktop_background/desktop_background_view.cc
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 41345a2f0487467bd89b99feb44db11113bd1c2a..e79bc54b379997572f0a8a7b5a0501e02d3d4960 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -23,11 +23,47 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
namespace ash {
namespace internal {
namespace {
+class DesktopBackgroundViewCleanup : public views::WidgetDelegate {
+ public:
+ DesktopBackgroundViewCleanup(views::Widget* widget,
+ aura::RootWindow* root_window)
+ : widget_(widget_),
+ root_window_(root_window) {
+ }
+
+ // Called when the window closes. The delegate MUST NOT delete itself during
+ // this call, since it can be called afterwards. See DeleteDelegate().
+ virtual void WindowClosing() OVERRIDE {
+ DesktopBackgroundController* controller = ash::Shell::GetInstance()->
+ desktop_background_controller();
+ controller->CleanupView(root_window_);
+ }
+
+ virtual const views::Widget* GetWidget() OVERRIDE const {
+ return widget_;
+ }
+
+ virtual views::Widget* GetWidget() OVERRIDE {
+ return widget_;
+ }
+
+ virtual void DeleteDelegate() OVERRIDE {
+ delete this;
+ }
+
+ private:
+ views::Widget* widget_;
+ aura::RootWindow* root_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundViewCleanup);
+};
+
class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
public:
ShowWallpaperAnimationObserver(aura::RootWindow* root_window,
@@ -149,12 +185,15 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
DesktopBackgroundController* controller = ash::Shell::GetInstance()->
desktop_background_controller();
views::Widget* desktop_widget = new views::Widget;
+ DesktopBackgroundViewCleanup* cleanup;
+ cleanup = new DesktopBackgroundViewCleanup(desktop_widget, root_window);
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
DesktopBackgroundView* view = new DesktopBackgroundView();
params.delegate = view;
if (controller->GetWallpaper().isNull())
params.transparent = true;
+ params.delegate = cleanup;
params.parent = root_window->GetChildById(container_id);
desktop_widget->Init(params);
desktop_widget->SetContentsView(view);
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/desktop_background/desktop_background_widget_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698