| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/background/background_mode_manager.h" | 17 #include "chrome/browser/background/background_mode_manager.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 19 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 20 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
| 21 #include "chrome/browser/infobars/infobar_service.h" | 21 #include "chrome/browser/infobars/infobar_service.h" |
| 22 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 23 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 23 #include "chrome/browser/prefs/session_startup_pref.h" | 24 #include "chrome/browser/prefs/session_startup_pref.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_impl.h" | 26 #include "chrome/browser/profiles/profile_impl.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/sessions/session_restore_test_helper.h" | 28 #include "chrome/browser/sessions/session_restore_test_helper.h" |
| 28 #include "chrome/browser/sessions/session_service_factory.h" | 29 #include "chrome/browser/sessions/session_service_factory.h" |
| 29 #include "chrome/browser/sessions/session_service_test_helper.h" | 30 #include "chrome/browser/sessions/session_service_test_helper.h" |
| 30 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_commands.h" | 32 #include "chrome/browser/ui/browser_commands.h" |
| 32 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 EXPECT_EQ(password_present, | 311 EXPECT_EQ(password_present, |
| 311 post_interceptor_->DidLastUploadContain("posted-password")); | 312 post_interceptor_->DidLastUploadContain("posted-password")); |
| 312 EXPECT_EQ(password_present, | 313 EXPECT_EQ(password_present, |
| 313 post_interceptor_->DidLastUploadContain("password-entered")); | 314 post_interceptor_->DidLastUploadContain("password-entered")); |
| 314 } | 315 } |
| 315 | 316 |
| 316 virtual Browser* QuitBrowserAndRestore(Browser* browser, | 317 virtual Browser* QuitBrowserAndRestore(Browser* browser, |
| 317 bool close_all_windows) { | 318 bool close_all_windows) { |
| 318 Profile* profile = browser->profile(); | 319 Profile* profile = browser->profile(); |
| 319 | 320 |
| 321 ScopedKeepAlive test_keep_alive(KeepAliveOrigin::PANEL_VIEW, |
| 322 KeepAliveRestartOption::DISABLED); |
| 323 |
| 320 // Close the browser. | 324 // Close the browser. |
| 321 chrome::IncrementKeepAliveCount(); | |
| 322 if (close_all_windows) | 325 if (close_all_windows) |
| 323 CloseAllBrowsers(); | 326 CloseAllBrowsers(); |
| 324 else | 327 else |
| 325 CloseBrowserSynchronously(browser); | 328 CloseBrowserSynchronously(browser); |
| 326 | 329 |
| 327 SessionServiceTestHelper helper; | 330 SessionServiceTestHelper helper; |
| 328 helper.SetService( | 331 helper.SetService( |
| 329 SessionServiceFactory::GetForProfileForSessionRestore(profile)); | 332 SessionServiceFactory::GetForProfileForSessionRestore(profile)); |
| 330 helper.SetForceBrowserNotAliveWithNoWindows(true); | 333 helper.SetForceBrowserNotAliveWithNoWindows(true); |
| 331 helper.ReleaseService(); | 334 helper.ReleaseService(); |
| 332 | 335 |
| 333 // Create a new window, which should trigger session restore. | 336 // Create a new window, which should trigger session restore. |
| 334 ui_test_utils::BrowserAddedObserver window_observer; | 337 ui_test_utils::BrowserAddedObserver window_observer; |
| 335 chrome::NewEmptyWindow(profile); | 338 chrome::NewEmptyWindow(profile); |
| 336 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); | 339 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); |
| 337 chrome::DecrementKeepAliveCount(); | |
| 338 | 340 |
| 339 return new_browser; | 341 return new_browser; |
| 340 } | 342 } |
| 341 | 343 |
| 342 std::string fake_server_address() { | 344 std::string fake_server_address() { |
| 343 return fake_server_address_; | 345 return fake_server_address_; |
| 344 } | 346 } |
| 345 | 347 |
| 346 std::string test_path() { | 348 std::string test_path() { |
| 347 return test_path_; | 349 return test_path_; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 CookieSettingsFactory::GetForProfile(new_browser->profile()) | 840 CookieSettingsFactory::GetForProfile(new_browser->profile()) |
| 839 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 841 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
| 840 // ... even if background mode is active. | 842 // ... even if background mode is active. |
| 841 EnableBackgroundMode(); | 843 EnableBackgroundMode(); |
| 842 new_browser = QuitBrowserAndRestore(new_browser, true); | 844 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 843 StoreDataWithPage(new_browser, "cookies.html"); | 845 StoreDataWithPage(new_browser, "cookies.html"); |
| 844 DisableBackgroundMode(); | 846 DisableBackgroundMode(); |
| 845 new_browser = QuitBrowserAndRestore(new_browser, true); | 847 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 846 StoreDataWithPage(new_browser, "cookies.html"); | 848 StoreDataWithPage(new_browser, "cookies.html"); |
| 847 } | 849 } |
| OLD | NEW |