summaryrefslogtreecommitdiffstats
path: root/ash/desktop_background
diff options
context:
space:
mode:
authorantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 09:51:26 +0000
committerantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 09:51:26 +0000
commit15089d7fb0cef3bb393f945dee90287ac4c4f17a (patch)
treed98114392d2f609e0844e46e77a54226b93ea710 /ash/desktop_background
parent31874484113209dd1f60b20d6c379bd553352b13 (diff)
downloadchromium_src-15089d7fb0cef3bb393f945dee90287ac4c4f17a.zip
chromium_src-15089d7fb0cef3bb393f945dee90287ac4c4f17a.tar.gz
chromium_src-15089d7fb0cef3bb393f945dee90287ac4c4f17a.tar.bz2
Forget about DesktopBackgroundView if it was deleted
BUG=144047, 145595 Review URL: https://chromiumcodereview.appspot.com/10898007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r--ash/desktop_background/desktop_background_controller.cc10
-rw-r--r--ash/desktop_background/desktop_background_controller.h4
-rw-r--r--ash/desktop_background/desktop_background_view.cc39
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.cc4
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.h3
5 files changed, 60 insertions, 0 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 0bd8b35..bdbad05 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -246,6 +246,16 @@ void DesktopBackgroundController::MoveDesktopToLockedContainer() {
GetBackgroundContainerId(true));
}
+void DesktopBackgroundController::CleanupView(aura::RootWindow* root_window) {
+ internal::ComponentWrapper *wrapper;
+ wrapper = root_window->GetProperty(internal::kComponentWrapper);
+ if (NULL == wrapper)
+ return;
+ if (wrapper->GetComponent(false))
+ wrapper->GetComponent(false)->CleanupWidget();
+}
+
+
void DesktopBackgroundController::MoveDesktopToUnlockedContainer() {
if (!locked_)
return;
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index 0251c1c..71eb8ff 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -125,6 +125,10 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver {
// Move all desktop widgets to unlocked container.
void MoveDesktopToUnlockedContainer();
+ // Drop references to background view for |root_window|, because the view
+ // was deleted.
+ void CleanupView(aura::RootWindow* root_window);
+
// WindowObserver implementation.
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 41345a2..e79bc54 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);
diff --git a/ash/desktop_background/desktop_background_widget_controller.cc b/ash/desktop_background/desktop_background_widget_controller.cc
index cb7a369..8ee45ed 100644
--- a/ash/desktop_background/desktop_background_widget_controller.cc
+++ b/ash/desktop_background/desktop_background_widget_controller.cc
@@ -34,6 +34,10 @@ DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() {
layer_.reset(NULL);
}
+void DesktopBackgroundWidgetController::CleanupWidget() {
+ widget_ = NULL;
+}
+
void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) {
if (widget_)
widget_->SetBounds(bounds);
diff --git a/ash/desktop_background/desktop_background_widget_controller.h b/ash/desktop_background/desktop_background_widget_controller.h
index 6a24716..41288cd 100644
--- a/ash/desktop_background/desktop_background_widget_controller.h
+++ b/ash/desktop_background/desktop_background_widget_controller.h
@@ -28,6 +28,9 @@ class DesktopBackgroundWidgetController {
~DesktopBackgroundWidgetController();
+ // Drop widget reference. widget is not owned.
+ void CleanupWidget();
+
// Set bounds of component that draws background.
void SetBounds(gfx::Rect bounds);