summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-17 00:01:57 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-17 00:01:57 +0000
commitf92a69826846102dfe32ac44bc36df79f803beb6 (patch)
tree35995131920888be482b8eea6cbce3d96803e15b
parentcb1cdf49dfef2a86f5616be04f07381ec00ce1b9 (diff)
downloadchromium_src-f92a69826846102dfe32ac44bc36df79f803beb6.zip
chromium_src-f92a69826846102dfe32ac44bc36df79f803beb6.tar.gz
chromium_src-f92a69826846102dfe32ac44bc36df79f803beb6.tar.bz2
revert r8217 until memory tests are fixed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8245 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_list.cc39
-rw-r--r--chrome/browser/browser_list.h21
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.h3
-rw-r--r--chrome/browser/views/frame/opaque_frame.h1
-rw-r--r--chrome/common/notification_types.h5
-rw-r--r--chrome/views/window.cc25
-rw-r--r--chrome/views/window.h14
7 files changed, 61 insertions, 47 deletions
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 90ccb56..69fb122 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -14,9 +14,11 @@
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/notification_service.h"
+#include "chrome/views/window.h"
BrowserList::list_type BrowserList::browsers_;
std::vector<BrowserList::Observer*> BrowserList::observers_;
+BrowserList::DependentWindowList BrowserList::dependent_windows_;
// static
void BrowserList::AddBrowser(Browser* browser) {
@@ -58,12 +60,27 @@ void BrowserList::RemoveBrowser(Browser* browser) {
// If the last Browser object was destroyed, make sure we try to close any
// remaining dependent windows too.
- if (browsers_.empty()) {
- NotificationService::current()->Notify(NOTIFY_ALL_APPWINDOWS_CLOSED,
- NotificationService::AllSources(),
- NotificationService::NoDetails());
- }
+ if (browsers_.empty())
+ CloseAllDependentWindows();
+
+ g_browser_process->ReleaseModule();
+}
+
+// static
+void BrowserList::AddDependentWindow(views::Window* window) {
+ DependentWindowList::const_iterator existing =
+ find(dependent_windows_.begin(), dependent_windows_.end(), window);
+ DCHECK(existing == dependent_windows_.end());
+ dependent_windows_.push_back(window);
+ g_browser_process->AddRefModule();
+}
+// static
+void BrowserList::RemoveDependentWindow(views::Window* window) {
+ DependentWindowList::iterator existing =
+ find(dependent_windows_.begin(), dependent_windows_.end(), window);
+ DCHECK(existing != dependent_windows_.end());
+ dependent_windows_.erase(existing);
g_browser_process->ReleaseModule();
}
@@ -225,6 +242,18 @@ bool BrowserList::IsOffTheRecordSessionActive() {
}
// static
+void BrowserList::CloseAllDependentWindows() {
+ // Note that |dependent_windows_| is guaranteed to be consistent for the
+ // duration of this operation because windows are not actually closed
+ // (destroyed, then deleted, and thus removed from this list) until we return
+ // to the message loop. So this basically just schedules a bunch of close
+ // operations to be performed asynchronously.
+ DependentWindowList::iterator window = dependent_windows_.begin();
+ for (; window != dependent_windows_.end(); ++window)
+ (*window)->Close();
+}
+
+// static
void BrowserList::RemoveBrowserFrom(Browser* browser, list_type* browser_list) {
const iterator remove_browser =
find(browser_list->begin(), browser_list->end(), browser);
diff --git a/chrome/browser/browser_list.h b/chrome/browser/browser_list.h
index 72262a9..cda32a9 100644
--- a/chrome/browser/browser_list.h
+++ b/chrome/browser/browser_list.h
@@ -10,6 +10,12 @@
#include "chrome/browser/browser.h"
+namespace views {
+class AppModalDialogDelegate;
+class Window;
+};
+class WebContents;
+
// Stores a list of all Browser objects.
class BrowserList {
public:
@@ -35,6 +41,13 @@ class BrowserList {
static void AddBrowser(Browser* browser);
static void RemoveBrowser(Browser* browser);
+ // Adds and removes non-browser dependent windows. These are windows that are
+ // top level, but whose lifetime is associated wtih the existence of at least
+ // one active Browser. When the last Browser is destroyed, all open dependent
+ // windows are closed.
+ static void AddDependentWindow(views::Window* window);
+ static void RemoveDependentWindow(views::Window* window);
+
static void AddObserver(Observer* observer);
static void RemoveObserver(Observer* observer);
@@ -100,12 +113,20 @@ class BrowserList {
static bool IsOffTheRecordSessionActive();
private:
+ // Closes all registered dependent windows.
+ static void CloseAllDependentWindows();
+
// Helper method to remove a browser instance from a list of browsers
static void RemoveBrowserFrom(Browser* browser, list_type* browser_list);
static list_type browsers_;
static std::vector<Observer*> observers_;
static list_type last_active_browsers_;
+ typedef std::vector<views::Window*> DependentWindowList;
+ static DependentWindowList dependent_windows_;
+
+ // Set to the currently showing modal dialog delegate if any, NULL otherwise.
+ static views::AppModalDialogDelegate* app_modal_dialog_;
};
class WebContents;
diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h
index 4ff6288..7daa04a 100644
--- a/chrome/browser/views/frame/aero_glass_frame.h
+++ b/chrome/browser/views/frame/aero_glass_frame.h
@@ -53,9 +53,8 @@ class AeroGlassFrame : public BrowserFrame,
virtual LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
virtual LRESULT OnNCHitTest(const CPoint& pt);
- // Overridden from views::Window:
+ // Overridden from views::CustomFrameWindow:
virtual int GetShowState() const;
- virtual bool IsAppWindow() const { return true; }
private:
// Updates the DWM with the frame bounds.
diff --git a/chrome/browser/views/frame/opaque_frame.h b/chrome/browser/views/frame/opaque_frame.h
index e5d2f552..13c20d2 100644
--- a/chrome/browser/views/frame/opaque_frame.h
+++ b/chrome/browser/views/frame/opaque_frame.h
@@ -43,7 +43,6 @@ class OpaqueFrame : public BrowserFrame,
// Overridden from views::CustomFrameWindow:
virtual void UpdateWindowIcon();
virtual int GetShowState() const;
- virtual bool IsAppWindow() const { return true; }
// Overridden from views::WidgetWin:
virtual bool AcceleratorPressed(views::Accelerator* accelerator);
diff --git a/chrome/common/notification_types.h b/chrome/common/notification_types.h
index e6e2e2e..c2a0c09 100644
--- a/chrome/common/notification_types.h
+++ b/chrome/common/notification_types.h
@@ -155,11 +155,6 @@ enum NotificationType {
// only valid for the duration of this call.
NOTIFY_BROWSER_CLOSED,
- // This message is sent when the last window considered to be an "application
- // window" has been closed. Dependent/dialog/utility windows can use this as
- // a way to know that they should also close. No source or details are passed.
- NOTIFY_ALL_APPWINDOWS_CLOSED,
-
// Indicates that a top window has been closed. The source is the HWND that
// was closed, no details are expected.
NOTIFY_WINDOW_CLOSED,
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index 1a3ad56..c09ffd0 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -6,6 +6,8 @@
#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"
@@ -34,10 +36,7 @@ static const int kMonitorEdgePadding = 10;
// Window, public:
Window::~Window() {
- if (!IsAppWindow()) {
- NotificationService::current()->RemoveObserver(
- this, NOTIFY_ALL_APPWINDOWS_CLOSED, NotificationService::AllSources());
- }
+ BrowserList::RemoveDependentWindow(this);
}
// static
@@ -228,19 +227,6 @@ 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:
@@ -265,10 +251,7 @@ Window::Window(WindowDelegate* window_delegate)
// behavior before calling Init.
set_window_style(0);
set_window_ex_style(0);
- if (!IsAppWindow()) {
- NotificationService::current()->AddObserver(
- this, NOTIFY_ALL_APPWINDOWS_CLOSED, NotificationService::AllSources());
- }
+ BrowserList::AddDependentWindow(this);
}
void Window::Init(HWND parent, const gfx::Rect& bounds) {
diff --git a/chrome/views/window.h b/chrome/views/window.h
index c1c097f..bdd3d6d 100644
--- a/chrome/views/window.h
+++ b/chrome/views/window.h
@@ -5,7 +5,6 @@
#ifndef CHROME_VIEWS_WINDOW_H__
#define CHROME_VIEWS_WINDOW_H__
-#include "chrome/common/notification_service.h"
#include "chrome/views/widget_win.h"
namespace gfx {
@@ -31,8 +30,7 @@ class WindowDelegate;
// rendered by the operating system.
//
///////////////////////////////////////////////////////////////////////////////
-class Window : public WidgetWin,
- public NotificationObserver {
+class Window : public WidgetWin {
public:
virtual ~Window();
@@ -123,11 +121,6 @@ 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);
@@ -150,11 +143,6 @@ 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.