diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:53:09 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:53:09 +0000 |
commit | a8830e8cf4bbe75f48f8b0873d9825c835c88f6b (patch) | |
tree | 6b168b8eaf06e5274604eab50837cdfcb03f06f4 | |
parent | 0b0b5c0c217b16d2f4109afdae83823f587d382c (diff) | |
download | chromium_src-a8830e8cf4bbe75f48f8b0873d9825c835c88f6b.zip chromium_src-a8830e8cf4bbe75f48f8b0873d9825c835c88f6b.tar.gz chromium_src-a8830e8cf4bbe75f48f8b0873d9825c835c88f6b.tar.bz2 |
Merge 129873 - Make ChromeOS follow the same model as MacOS. Opening a new window from the launcher does not trigger session recovery.
Thus,
closing all browser windows and creating a new window via the launcher or the uber tray will not recover previously opened tabs
Tests:
Tested the following scenerios:
1) When "On Startup" state is: "continue where I left off"
a) User signs out having 1 browser open, expect browser with restored tabs to be opened upon sign in
b) User signs out after having closed all browsers, expect browser with NTP to be opened upon sign in
2) When "On Startup" state is: "Open the New Tab page"
a) User signs having 1 browser open, expect 1 browser with new tab page on signing back in
b) User signs out after having closed all browsers, expect 1 browser with new tab page on signing back in
Bug=119913
Test=Manual, see above
Review URL: http://codereview.chromium.org/9836092
TBR=pkotwicz@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9963033
git-svn-id: svn://svn.chromium.org/chrome/branches/1084/src@129956 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/defaults.cc | 2 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore_browsertest.cc | 53 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/sessions/session_service.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/browser_init_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/test/perf/startup_test.cc | 2 |
6 files changed, 71 insertions, 7 deletions
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index b4997d7..9487745 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -71,7 +71,7 @@ const bool kShowOtherBrowsersInAboutMemory = true; const bool kAlwaysOpenIncognitoWindow = false; #endif -#if defined(OS_MACOSX) +#if defined(OS_CHROMEOS) || defined(OS_MACOSX) const bool kBrowserAliveWithNoWindows = true; #else const bool kBrowserAliveWithNoWindows = false; diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 0a77d2b..3af38ff 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/defaults.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sessions/session_restore.h" #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_service_factory.h" @@ -18,6 +19,7 @@ #include "chrome/browser/ui/browser_init.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/common/url_constants.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -62,6 +64,51 @@ class SessionRestoreTest : public InProcessBrowserTest { } }; +#if defined(OS_CHROMEOS) +// Verify that session restore does not occur when a user opens a browser window +// when no other browser windows are open on ChromeOS. +// TODO(pkotwicz): Add test which doesn't open incognito browser once +// disable-zero-browsers-open-for-tests is removed. +// (http://crbug.com/119175) +// TODO(pkotwicz): Mac should have the behavior outlined by this test. It should +// not do session restore if an incognito window is already open. +// (http://crbug.com/120927) +IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoSessionRestoreNewWindowChromeOS) { + // Turn on session restore. + SessionStartupPref pref(SessionStartupPref::LAST); + SessionStartupPref::SetStartupPref(browser()->profile(), pref); + + GURL url(ui_test_utils::GetTestUrl( + FilePath(FilePath::kCurrentDirectory), + FilePath(FILE_PATH_LITERAL("title1.html")))); + + // Add a single tab. + ui_test_utils::NavigateToURL(browser(), url); + + Browser* incognito_browser = CreateIncognitoBrowser(); + incognito_browser->AddBlankTab(true); + incognito_browser->window()->Show(); + + // Close the normal browser. After this we only have the incognito window + // open. + CloseBrowserSynchronously(browser()); + + // Create a new window, which should open NTP. + ui_test_utils::BrowserAddedObserver browser_added_observer; + incognito_browser->NewWindow(); + Browser* new_browser = browser_added_observer.WaitForSingleNewBrowser(); + + ASSERT_TRUE(new_browser); + EXPECT_EQ(1, new_browser->tab_count()); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + new_browser->GetWebContentsAt(0)->GetURL()); +} +#endif // OS_CHROMEOS + +#if !defined(OS_CHROMEOS) +// This test does not apply to ChromeOS as it does not do session restore when +// a new window is opened. + #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) // Crashes on Linux Views: http://crbug.com/39476 #define MAYBE_RestoreOnNewWindowWithNoTabbedBrowsers \ @@ -109,6 +156,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, // And the first url should be url. EXPECT_EQ(url, new_browser->GetWebContentsAt(0)->GetURL()); } +#endif // !OS_CHROMEOS IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) { GURL url1(ui_test_utils::GetTestUrl( @@ -199,6 +247,10 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) { EXPECT_EQ(0U, service->entries().size()); } +#if !defined(OS_CHROMEOS) +// This test does not apply to ChromeOS as ChromeOS does not do session +// restore when a new window is open. + // Verifies we remember the last browser window when closing the last // non-incognito window while an incognito window is open. IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) { @@ -231,6 +283,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) { ASSERT_TRUE(new_browser); EXPECT_EQ(url, new_browser->GetWebContentsAt(0)->GetURL()); } +#endif // !OS_CHROMEOS IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { Profile* profile = browser()->profile(); diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc index 3a00595..d3d3a01 100644 --- a/chrome/browser/sessions/session_restore_uitest.cc +++ b/chrome/browser/sessions/session_restore_uitest.cc @@ -34,7 +34,7 @@ class SessionRestoreUITest : public UITest { } virtual void QuitBrowserAndRestore(int expected_tab_count) { -#if defined(OS_MACOSX) +#if defined(OS_CHROMEOS) || defined(OS_MACOSX) set_shutdown_type(ProxyLauncher::USER_QUIT); #endif UITest::TearDown(); diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index fbd025d..5cafd82 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -493,19 +493,22 @@ void SessionService::Init() { } bool SessionService::ShouldNewWindowStartSession() { + // ChromeOS and OSX have different ideas of application lifetime than + // the other platforms. + // On ChromeOS opening a new window should never start a new session. +#if !defined(OS_CHROMEOS) if (!has_open_trackable_browsers_ && !BrowserInit::InSynchronousProfileLaunch() && !SessionRestore::IsRestoring(profile()) #if defined(OS_MACOSX) - // OSX has a fairly different idea of application lifetime than the - // other platforms. We need to check that we aren't opening a window + // On OSX, a new window should not start a new session if it was opened // from the dock or the menubar. && !app_controller_mac::IsOpeningNewWindow() -#endif +#endif // OS_MACOSX ) { return true; } - +#endif // !OS_CHROMEOS return false; } diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc index f922136..e6c7abd 100644 --- a/chrome/browser/ui/browser_init_browsertest.cc +++ b/chrome/browser/ui/browser_init_browsertest.cc @@ -139,6 +139,10 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) { BrowserList::RemoveObserver(&observer); } +// We don't do non-process-startup browser launches on ChromeOS. +// Session restore for process-startup browser launches is tested +// in session_restore_uitest. +#if !defined(OS_CHROMEOS) // Verify that startup URLs are honored when the process already exists but has // no tabbed browser windows (eg. as if the process is running only due to a // background application. @@ -332,6 +336,8 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutPanel) { #endif // !defined(OS_MACOSX) +#endif // !defined(OS_CHROMEOS) + IN_PROC_BROWSER_TEST_F(BrowserInitTest, ReadingWasRestartedAfterRestart) { // Tests that BrowserInit::WasRestarted reads and resets the preference // kWasRestarted correctly. @@ -354,6 +360,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, ReadingWasRestartedAfterNormalStart) { EXPECT_FALSE(BrowserInit::WasRestarted()); } +#if !defined(OS_CHROMEOS) IN_PROC_BROWSER_TEST_F(BrowserInitTest, StartupURLsForTwoProfiles) { Profile* default_profile = browser()->profile(); @@ -672,3 +679,4 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, ProfilesLaunchedAfterCrash) { EXPECT_EQ(1U, new_browser->GetTabContentsWrapperAt(0)->infobar_tab_helper()-> infobar_count()); } +#endif // !OS_CHROMEOS diff --git a/chrome/test/perf/startup_test.cc b/chrome/test/perf/startup_test.cc index 7f71879..f4cdfa9 100644 --- a/chrome/test/perf/startup_test.cc +++ b/chrome/test/perf/startup_test.cc @@ -316,7 +316,7 @@ void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, // Start the browser with these urls so we can save the session and exit. UITest::SetUp(); // Set flags to ensure profile is saved and can be restored. -#if defined(OS_MACOSX) +#if defined(OS_CHROMEOS) || defined(OS_MACOSX) set_shutdown_type(ProxyLauncher::USER_QUIT); #endif clear_profile_ = false; |