summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 23:33:55 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 23:33:55 +0000
commit4070a6b1efcb2dbea12508a0b912cfa3bc86f47e (patch)
treebdf564c66c7a2d63d5d5bafdcccb27c233b969af /chrome
parentd57baa939d66854a7f6d4e8e149ddf16578a46df (diff)
downloadchromium_src-4070a6b1efcb2dbea12508a0b912cfa3bc86f47e.zip
chromium_src-4070a6b1efcb2dbea12508a0b912cfa3bc86f47e.tar.gz
chromium_src-4070a6b1efcb2dbea12508a0b912cfa3bc86f47e.tar.bz2
Mac: don't restore explicitly closed windows.
With "On startup"/"Restore the pages that were open last" set (in Preferences), a window which was explicitly closed (using the red button, Cmd-Shift-W, the menu item -- but not due to quit) should not be restored on startup. This is the behaviour of Firefox and Camino (Safari doesn't appear to implement this feature). Note about this patch: Depending on how we decide things will work for App mode, much more code could be disabled on Mac. BUG=13341 TEST=Set the browser to restore pages on start (see above). Navigate somewhere interesting; close window; quit; restart; should open a browser with default window (NTP or homepage or whatever). Navigate somewhere; quit; restart; should open previously opened stuff. Make sure that session restore (also crash recovery) still work as expected. Review URL: http://codereview.chromium.org/362016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/defaults.cc6
-rw-r--r--chrome/browser/defaults.h3
-rw-r--r--chrome/browser/sessions/session_service.cc4
-rw-r--r--chrome/browser/sessions/session_service.h13
4 files changed, 24 insertions, 2 deletions
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
index 916a50f..fdc261a 100644
--- a/chrome/browser/defaults.cc
+++ b/chrome/browser/defaults.cc
@@ -47,4 +47,10 @@ const bool kRestorePopups = false;
#endif
+#if defined(OS_MACOSX)
+const bool kBrowserAliveWithNoWindows = true;
+#else
+const bool kBrowserAliveWithNoWindows = false;
+#endif
+
} // namespace browser_defaults
diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h
index 45862c2..a701fa2 100644
--- a/chrome/browser/defaults.h
+++ b/chrome/browser/defaults.h
@@ -37,6 +37,9 @@ extern const int kPinnedTabWidth;
// Should session restore restore popup windows?
extern const bool kRestorePopups;
+// Can the browser be alive without any browser windows?
+extern const bool kBrowserAliveWithNoWindows;
+
} // namespace browser_defaults
#endif // CHROME_BROWSER_DEFAULTS_H_
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 6b9bd65..8b2575d 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -238,7 +238,7 @@ void SessionService::WindowClosing(const SessionID& window_id) {
// false to true, so only update it if already true.
has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id);
}
- if (!has_open_trackable_browsers_)
+ if (should_record_close_as_pending())
pending_window_close_ids_.insert(window_id.id());
else
window_closing_ids_.insert(window_id.id());
@@ -257,7 +257,7 @@ void SessionService::WindowClosed(const SessionID& window_id) {
pending_window_close_ids_.end()) {
// We'll hit this if user closed the last tab in a window.
has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id);
- if (!has_open_trackable_browsers_)
+ if (should_record_close_as_pending())
pending_window_close_ids_.insert(window_id.id());
else
ScheduleCommand(CreateWindowClosedCommand(window_id.id()));
diff --git a/chrome/browser/sessions/session_service.h b/chrome/browser/sessions/session_service.h
index d1b5f05..98276fe 100644
--- a/chrome/browser/sessions/session_service.h
+++ b/chrome/browser/sessions/session_service.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/sessions/base_session_service.h"
#include "chrome/browser/sessions/session_id.h"
@@ -330,6 +331,18 @@ class SessionService : public BaseSessionService,
(type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups);
}
+ // Returns true if we should record a window close as pending.
+ // |has_open_trackable_browsers_| must be up-to-date before calling this.
+ bool should_record_close_as_pending() const {
+ // When this is called, the browser window being closed is still open, hence
+ // still in the browser list. If there is a browser window other than the
+ // one being closed but no trackable windows, then the others must be App
+ // windows or similar. In this case, we record the close as pending.
+ return !has_open_trackable_browsers_ &&
+ (!browser_defaults::kBrowserAliveWithNoWindows ||
+ BrowserList::size() > 1);
+ }
+
// Convert back/forward between the Browser and SessionService DB window
// types.
static WindowType WindowTypeForBrowserType(Browser::Type type);