summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-17 19:20:55 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-17 19:20:55 +0000
commitbd643c33bcb438c8f1db8664bfc851f580a42070 (patch)
treee4d8bb33481c48656f3ef86f595755cbb44fc9c7
parent591dffa8428e10000118206d45de1ce58e4420da (diff)
downloadchromium_src-bd643c33bcb438c8f1db8664bfc851f580a42070.zip
chromium_src-bd643c33bcb438c8f1db8664bfc851f580a42070.tar.gz
chromium_src-bd643c33bcb438c8f1db8664bfc851f580a42070.tar.bz2
Use a Window instead of a Widget for the hidden tab host window.
Also don't close that window on WM_CLOSE, and don't hold a reference to it after the window is closed. BUG=78595, 81730 TEST=none Review URL: http://codereview.chromium.org/7088001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89539 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc50
1 files changed, 37 insertions, 13 deletions
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
index 0a21719..b0f91c6 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
@@ -6,10 +6,11 @@
#include "chrome/browser/renderer_host/render_widget_host_view_win.h"
#include "chrome/browser/tab_contents/web_drop_target_win.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h"
+#include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
+#include "views/widget/widget.h"
namespace {
@@ -26,25 +27,47 @@ namespace {
// window that interact poorly with us.
//
// See: http://crbug.com/16476
-HWND GetHiddenTabHostWindow() {
- static views::Widget* widget = NULL;
+class HiddenTabHostWindow : public views::Widget {
+ public:
+ static HWND Instance();
+
+ private:
+ HiddenTabHostWindow() {}
+
+ ~HiddenTabHostWindow() {
+ instance_ = NULL;
+ }
- if (!widget) {
- widget = new views::Widget;
+ // Do nothing when asked to close. External applications (notably
+ // installers) try to close Chrome by sending WM_CLOSE to Chrome's
+ // top level windows. We don't want the tab host to close due to
+ // those messages. Instead the browser will close when the browser
+ // window receives a WM_CLOSE.
+ virtual void Close() OVERRIDE {}
+
+ static HiddenTabHostWindow* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(HiddenTabHostWindow);
+};
+
+HiddenTabHostWindow* HiddenTabHostWindow::instance_ = NULL;
+
+HWND HiddenTabHostWindow::Instance() {
+ if (instance_ == NULL) {
+ instance_ = new HiddenTabHostWindow;
// We don't want this widget to be closed automatically, this causes
// problems in tests that close the last non-secondary window.
- widget->set_is_secondary_widget(false);
+ instance_->set_is_secondary_widget(false);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
- widget->Init(params);
+ instance_->Init(params);
// If a background window requests focus, the hidden tab host will
- // be activated to focus the tab. Use WS_DISABLED to prevent
+ // be activated to focus the tab. Disable the window to prevent
// this.
- EnableWindow(widget->GetNativeView(), FALSE);
+ EnableWindow(instance_->GetNativeView(), FALSE);
}
- return widget->GetNativeView();
+ return instance_->GetNativeView();
}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -76,7 +99,7 @@ void NativeTabContentsViewWin::InitNativeTabContentsView() {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
params.native_widget = this;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.parent = GetHiddenTabHostWindow();
+ params.parent = HiddenTabHostWindow::Instance();
GetWidget()->Init(params);
// Remove the root view drop target so we can register our own.
@@ -88,7 +111,8 @@ void NativeTabContentsViewWin::InitNativeTabContentsView() {
void NativeTabContentsViewWin::Unparent() {
// Note that we do not DCHECK on focus_manager_ as it may be NULL when used
// with an external tab container.
- views::Widget::ReparentNativeView(GetNativeView(), GetHiddenTabHostWindow());
+ views::Widget::ReparentNativeView(GetNativeView(),
+ HiddenTabHostWindow::Instance());
}
RenderWidgetHostView* NativeTabContentsViewWin::CreateRenderWidgetHostView(