summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 21:15:48 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 21:15:48 +0000
commit32a66aed0e57642c8f0da0a4a34383bbc9250a32 (patch)
tree68d9c7919f9d148cfa8a2537f734143db7e6e94f /chrome/views
parentf8bddcfb577500d541351efa8986cc89d8859d02 (diff)
downloadchromium_src-32a66aed0e57642c8f0da0a4a34383bbc9250a32.zip
chromium_src-32a66aed0e57642c8f0da0a4a34383bbc9250a32.tar.gz
chromium_src-32a66aed0e57642c8f0da0a4a34383bbc9250a32.tar.bz2
window.cc should not include browser_list.h ... dependent (non-browser) windows are closed when they receive a notification rather than by being called directly from BrowserList. Also browser_list.cc should not include window.h, required for porting.
TEST=Open browser. Open options dialog box. Close browser. Options dialog should close too. Review URL: http://codereview.chromium.org/18328 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/window.cc25
-rw-r--r--chrome/views/window.h14
2 files changed, 34 insertions, 5 deletions
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index c09ffd0..1a3ad56 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -6,8 +6,6 @@
#include "base/win_util.h"
#include "chrome/app/chrome_dll_resource.h"
-// TODO(beng): some day make this unfortunate dependency not exist.
-#include "chrome/browser/browser_list.h"
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/icon_util.h"
#include "chrome/common/l10n_util.h"
@@ -36,7 +34,10 @@ static const int kMonitorEdgePadding = 10;
// Window, public:
Window::~Window() {
- BrowserList::RemoveDependentWindow(this);
+ if (!IsAppWindow()) {
+ NotificationService::current()->RemoveObserver(
+ this, NOTIFY_ALL_APPWINDOWS_CLOSED, NotificationService::AllSources());
+ }
}
// static
@@ -227,6 +228,19 @@ gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
GetLocalizedContentsHeight(row_resource_id));
}
+////////////////////////////////////////////////////////////////////////////////
+// Window, NotificationObserver implementation:
+
+void Window::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ // This window is closed when the last app window is closed.
+ DCHECK(type == NOTIFY_ALL_APPWINDOWS_CLOSED);
+ // Only registered as an observer when we're not an app window.
+ DCHECK(!IsAppWindow());
+ Close();
+}
+
///////////////////////////////////////////////////////////////////////////////
// Window, protected:
@@ -251,7 +265,10 @@ Window::Window(WindowDelegate* window_delegate)
// behavior before calling Init.
set_window_style(0);
set_window_ex_style(0);
- BrowserList::AddDependentWindow(this);
+ if (!IsAppWindow()) {
+ NotificationService::current()->AddObserver(
+ this, NOTIFY_ALL_APPWINDOWS_CLOSED, NotificationService::AllSources());
+ }
}
void Window::Init(HWND parent, const gfx::Rect& bounds) {
diff --git a/chrome/views/window.h b/chrome/views/window.h
index bdd3d6d..c1c097f 100644
--- a/chrome/views/window.h
+++ b/chrome/views/window.h
@@ -5,6 +5,7 @@
#ifndef CHROME_VIEWS_WINDOW_H__
#define CHROME_VIEWS_WINDOW_H__
+#include "chrome/common/notification_service.h"
#include "chrome/views/widget_win.h"
namespace gfx {
@@ -30,7 +31,8 @@ class WindowDelegate;
// rendered by the operating system.
//
///////////////////////////////////////////////////////////////////////////////
-class Window : public WidgetWin {
+class Window : public WidgetWin,
+ public NotificationObserver {
public:
virtual ~Window();
@@ -121,6 +123,11 @@ class Window : public WidgetWin {
static gfx::Size GetLocalizedContentsSize(int col_resource_id,
int row_resource_id);
+ // NotificationObserver overrides:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
protected:
// Constructs the Window. |window_delegate| cannot be NULL.
explicit Window(WindowDelegate* window_delegate);
@@ -143,6 +150,11 @@ class Window : public WidgetWin {
// Sizes the window to the default size specified by its ClientView.
virtual void SizeWindowToDefault();
+ // Returns true if the Window is considered to be an "app window" - i.e. any
+ // window which when it is the last of its type closed causes the application
+ // to exit.
+ virtual bool IsAppWindow() const { return false; }
+
void set_client_view(ClientView* client_view) { client_view_ = client_view; }
// Shows the system menu at the specified screen point.