diff options
author | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 19:12:03 +0000 |
---|---|---|
committer | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 19:12:03 +0000 |
commit | 81cacede51c21fef6dddc4bccba0d6baba9c5822 (patch) | |
tree | af2d56921773545676bcb8eb568b30435fe280cd /chrome/browser/chromeos | |
parent | ea1771720662c3fdcf8a26c4d99fd3ce57fc0415 (diff) | |
download | chromium_src-81cacede51c21fef6dddc4bccba0d6baba9c5822.zip chromium_src-81cacede51c21fef6dddc4bccba0d6baba9c5822.tar.gz chromium_src-81cacede51c21fef6dddc4bccba0d6baba9c5822.tar.bz2 |
Disallows opening non-incognito windows in BWSI mode. Also disables 'New window' menu item, but not the shortkey - 'CTRL+N' opens new incognito window.
BUG=chromium-os:6025
TEST=Start BWSI session. Note that only incognito windows could be opened.
Review URL: http://codereview.chromium.org/3235011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r-- | chrome/browser/chromeos/login/login_utils.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/tab_closeable_state_watcher.cc | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/tab_closeable_state_watcher.h | 14 |
3 files changed, 23 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 9ec92d02..1de9bfc 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -255,6 +255,7 @@ void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { kForwardSwitches, arraysize(kForwardSwitches)); command_line.AppendSwitch(switches::kBWSI); + command_line.AppendSwitch(switches::kIncognito); command_line.AppendSwitch(switches::kEnableTabbedOptions); command_line.AppendSwitchASCII( switches::kLoginUser, diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.cc b/chrome/browser/chromeos/tab_closeable_state_watcher.cc index d5a01b0..536ba9b 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.cc +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.cc @@ -4,6 +4,8 @@ #include "chrome/browser/chromeos/tab_closeable_state_watcher.h" +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" #include "chrome/browser/defaults.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -63,7 +65,9 @@ void TabCloseableStateWatcher::TabStripWatcher::TabChangedAt( TabCloseableStateWatcher::TabCloseableStateWatcher() : can_close_tab_(true), - signing_off_(false) { + signing_off_(false), + bwsi_session_( + CommandLine::ForCurrentProcess()->HasSwitch(switches::kBWSI)) { BrowserList::AddObserver(this); notification_registrar_.Add(this, NotificationType::APP_EXITING, NotificationService::AllSources()); @@ -183,7 +187,7 @@ void TabCloseableStateWatcher::CheckAndUpdateState( } else { // There's only 1 normal browser. if (!browser_to_check) browser_to_check = tabstrip_watchers_[0]->browser(); - if (browser_to_check->profile()->IsOffTheRecord()) { + if (browser_to_check->profile()->IsOffTheRecord() && !bwsi_session_) { new_can_close = true; } else { TabStripModel* tabstrip_model = browser_to_check->tabstrip_model(); @@ -232,8 +236,8 @@ bool TabCloseableStateWatcher::CanCloseBrowserImpl(const Browser* browser, return true; // If last normal browser is incognito, open a non-incognito window, - // and allow closing of incognito one. - if (browser->profile()->IsOffTheRecord()) { + // and allow closing of incognito one (if not BWSI). + if (browser->profile()->IsOffTheRecord() && !bwsi_session_) { *action_type = OPEN_WINDOW; return true; } diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.h b/chrome/browser/chromeos/tab_closeable_state_watcher.h index facadc5..2951d6d 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.h +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.h @@ -18,6 +18,8 @@ namespace chromeos { // This class overrides ::TabCloseableStateWatcher to allow or disallow tabs or // browsers to be closed based on increase or decrease in number of tabs or // browsers. We only do this on Chromeos and only for non-tests. +// +// Normal session: // 1) A tab, and hence its containing browser, is not closeable if the tab is // the last NewTabPage in the last normal non-incognito browser and user is not // signing off. @@ -27,6 +29,15 @@ namespace chromeos { // 3) Or, if user closes a normal incognito browser or the last tab in it, the // browser closes, a new non-incognito normal browser is opened with a // NewTabPage (which, by rule 1, will not be closeable). +// +// BWSI session (all browsers are incognito): +// Almost the same as in the normal session, but +// 1) A tab, and hence its containing browser, is not closeable if the tab is +// the last NewTabPage in the last browser (again, all browsers are incognito +// browsers). +// 2-3) Otherwise, if user closes a normal incognito browser or the last tab in +// it, the browser stays open, the existing tabs are closed, and a new +// NewTabPage is open. class TabCloseableStateWatcher : public ::TabCloseableStateWatcher, public BrowserList::Observer, @@ -87,6 +98,9 @@ class TabCloseableStateWatcher : public ::TabCloseableStateWatcher, // allow closing of all tabs and browsers in this situation. bool signing_off_; + // In BWSI session? + bool bwsi_session_; + NotificationRegistrar notification_registrar_; // TabStripWatcher is a TabStripModelObserver that funnels all interesting |