diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 00:54:59 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 00:54:59 +0000 |
commit | 191351811c42f24ddc0f73d60d0909c33f1d1bd6 (patch) | |
tree | 3b3c911563bb9935bdea2ef1d9a5f80c792f365e | |
parent | bd11fab96cc0e4ba2fe0bc5199b43ad3b10358a5 (diff) | |
download | chromium_src-191351811c42f24ddc0f73d60d0909c33f1d1bd6.zip chromium_src-191351811c42f24ddc0f73d60d0909c33f1d1bd6.tar.gz chromium_src-191351811c42f24ddc0f73d60d0909c33f1d1bd6.tar.bz2 |
Fix a bug where ExtensionHost and ExtensionView weren't getting closed properly when a browser window was closed.
BUG=13975
TEST=see bug for repro steps
Review URL: http://codereview.chromium.org/125164
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18470 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_view.h | 12 |
2 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc index a375c04..7a9a6b5 100644 --- a/chrome/browser/extensions/extension_view.cc +++ b/chrome/browser/extensions/extension_view.cc @@ -10,12 +10,16 @@ #if defined(OS_WIN) #include "chrome/browser/renderer_host/render_widget_host_view_win.h" #endif +#include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" #include "views/widget/widget.h" ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser) : host_(host), browser_(browser), initialized_(false), pending_preferred_width_(0), container_(NULL) { host_->set_view(this); + registrar_.Add(this, NotificationType::BROWSER_CLOSED, + Source<Browser>(browser_)); } ExtensionView::~ExtensionView() { @@ -120,6 +124,16 @@ void ExtensionView::ViewHierarchyChanged(bool is_add, } } +void ExtensionView::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::BROWSER_CLOSED) { + delete host_; // which in turn deletes this + } else { + NOTREACHED(); + } +} + void ExtensionView::HandleMouseEvent() { if (container_) container_->OnExtensionMouseEvent(this); diff --git a/chrome/browser/extensions/extension_view.h b/chrome/browser/extensions/extension_view.h index cf2fc40..837a737 100644 --- a/chrome/browser/extensions/extension_view.h +++ b/chrome/browser/extensions/extension_view.h @@ -8,6 +8,7 @@ #include "build/build_config.h" #include "base/scoped_ptr.h" +#include "chrome/common/notification_registrar.h" #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" #include "views/controls/native/native_view_host.h" @@ -28,7 +29,8 @@ class ExtensionContainer { }; // This handles the display portion of an ExtensionHost. -class ExtensionView : public views::NativeViewHost { +class ExtensionView : public views::NativeViewHost, + public NotificationObserver { public: ExtensionView(ExtensionHost* host, Browser* browser); ~ExtensionView(); @@ -56,6 +58,11 @@ class ExtensionView : public views::NativeViewHost { virtual void ViewHierarchyChanged(bool is_add, views::View *parent, views::View *child); + // NotificationObserver: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + private: friend class ExtensionHost; @@ -84,6 +91,9 @@ class ExtensionView : public views::NativeViewHost { // Note: the view does not own its container. ExtensionContainer* container_; + // So that we can track browser window closing. + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(ExtensionView); }; |