| 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 "base/test/scoped_feature_list.h" | |
| 17 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 18 #include "chrome/browser/background/background_mode_manager.h" | 17 #include "chrome/browser/background/background_mode_manager.h" |
| 19 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 19 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 21 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
| 22 #include "chrome/browser/infobars/infobar_service.h" | 21 #include "chrome/browser/infobars/infobar_service.h" |
| 23 #include "chrome/browser/lifetime/keep_alive_types.h" | 22 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 24 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 23 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 25 #include "chrome/browser/prefs/session_startup_pref.h" | 24 #include "chrome/browser/prefs/session_startup_pref.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/profiles/profile_impl.h" | 26 #include "chrome/browser/profiles/profile_impl.h" |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/browser/sessions/session_restore_test_helper.h" | 28 #include "chrome/browser/sessions/session_restore_test_helper.h" |
| 30 #include "chrome/browser/sessions/session_service_factory.h" | 29 #include "chrome/browser/sessions/session_service_factory.h" |
| 31 #include "chrome/browser/sessions/session_service_test_helper.h" | 30 #include "chrome/browser/sessions/session_service_test_helper.h" |
| 32 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 33 #include "chrome/browser/ui/browser_commands.h" | 32 #include "chrome/browser/ui/browser_commands.h" |
| 34 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
| 35 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 35 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 38 #include "chrome/browser/ui/webui/md_history_ui.h" | 37 #include "chrome/browser/ui/webui/md_history_ui.h" |
| 39 #include "chrome/common/chrome_features.h" | |
| 40 #include "chrome/common/chrome_switches.h" | |
| 41 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 42 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 43 #include "chrome/test/base/in_process_browser_test.h" | 40 #include "chrome/test/base/in_process_browser_test.h" |
| 44 #include "chrome/test/base/ui_test_utils.h" | 41 #include "chrome/test/base/ui_test_utils.h" |
| 45 #include "components/content_settings/core/browser/cookie_settings.h" | 42 #include "components/content_settings/core/browser/cookie_settings.h" |
| 46 #include "components/content_settings/core/common/content_settings.h" | 43 #include "components/content_settings/core/common/content_settings.h" |
| 47 #include "components/infobars/core/confirm_infobar_delegate.h" | 44 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 48 #include "components/prefs/pref_service.h" | 45 #include "components/prefs/pref_service.h" |
| 49 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 50 #include "content/public/common/url_constants.h" | 47 #include "content/public/common/url_constants.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, SessionCookiesBrowserClose) { | 490 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, SessionCookiesBrowserClose) { |
| 494 // Set the startup preference to "continue where I left off" and visit a page | 491 // Set the startup preference to "continue where I left off" and visit a page |
| 495 // which stores a session cookie. | 492 // which stores a session cookie. |
| 496 StoreDataWithPage("session_cookies.html"); | 493 StoreDataWithPage("session_cookies.html"); |
| 497 Browser* new_browser = QuitBrowserAndRestore(browser(), false); | 494 Browser* new_browser = QuitBrowserAndRestore(browser(), false); |
| 498 // The browsing session will be continued; just wait for the page to reload | 495 // The browsing session will be continued; just wait for the page to reload |
| 499 // and check the stored data. | 496 // and check the stored data. |
| 500 CheckReloadedPageRestored(new_browser); | 497 CheckReloadedPageRestored(new_browser); |
| 501 } | 498 } |
| 502 | 499 |
| 503 // Test that switching MD History on behaves correctly with session restore. | |
| 504 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, MDHistoryUpgrade) { | |
| 505 MdHistoryUI::use_test_title_ = true; | |
| 506 Browser* current_browser = browser(); | |
| 507 { | |
| 508 base::test::ScopedFeatureList feature_list; | |
| 509 feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); | |
| 510 content::WebContents* web_contents = | |
| 511 current_browser->tab_strip_model()->GetActiveWebContents(); | |
| 512 content::TitleWatcher title_watcher(web_contents, | |
| 513 base::ASCIIToUTF16("History")); | |
| 514 ui_test_utils::NavigateToURL(current_browser, GURL("chrome://history")); | |
| 515 base::string16 final_title = title_watcher.WaitAndGetTitle(); | |
| 516 EXPECT_EQ(3u, current_browser->tab_strip_model() | |
| 517 ->GetActiveWebContents() | |
| 518 ->GetAllFrames() | |
| 519 .size()); | |
| 520 } | |
| 521 { | |
| 522 base::test::ScopedFeatureList feature_list; | |
| 523 feature_list.InitAndEnableFeature(features::kMaterialDesignHistory); | |
| 524 current_browser = QuitBrowserAndRestore(browser(), false); | |
| 525 // The new history page should have loaded. | |
| 526 CheckTitle(current_browser, base::ASCIIToUTF16("MD History")); | |
| 527 EXPECT_EQ(1u, current_browser->tab_strip_model() | |
| 528 ->GetActiveWebContents() | |
| 529 ->GetAllFrames() | |
| 530 .size()); | |
| 531 } | |
| 532 { | |
| 533 base::test::ScopedFeatureList feature_list; | |
| 534 feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); | |
| 535 current_browser = QuitBrowserAndRestore(current_browser, false); | |
| 536 // The old history page should have loaded. | |
| 537 CheckTitle(current_browser, base::ASCIIToUTF16("History")); | |
| 538 EXPECT_EQ(3u, current_browser->tab_strip_model() | |
| 539 ->GetActiveWebContents() | |
| 540 ->GetAllFrames() | |
| 541 .size()); | |
| 542 } | |
| 543 } | |
| 544 | |
| 545 // Test that leaving a popup open will not prevent session restore. | 500 // Test that leaving a popup open will not prevent session restore. |
| 546 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, | 501 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, |
| 547 SessionCookiesBrowserCloseWithPopupOpen) { | 502 SessionCookiesBrowserCloseWithPopupOpen) { |
| 548 // Set the startup preference to "continue where I left off" and visit a page | 503 // Set the startup preference to "continue where I left off" and visit a page |
| 549 // which stores a session cookie. | 504 // which stores a session cookie. |
| 550 StoreDataWithPage("session_cookies.html"); | 505 StoreDataWithPage("session_cookies.html"); |
| 551 Browser* popup = new Browser( | 506 Browser* popup = new Browser( |
| 552 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true)); | 507 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true)); |
| 553 popup->window()->Show(); | 508 popup->window()->Show(); |
| 554 | 509 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 CookieSettingsFactory::GetForProfile(new_browser->profile()) | 871 CookieSettingsFactory::GetForProfile(new_browser->profile()) |
| 917 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 872 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
| 918 // ... even if background mode is active. | 873 // ... even if background mode is active. |
| 919 EnableBackgroundMode(); | 874 EnableBackgroundMode(); |
| 920 new_browser = QuitBrowserAndRestore(new_browser, true); | 875 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 921 StoreDataWithPage(new_browser, "cookies.html"); | 876 StoreDataWithPage(new_browser, "cookies.html"); |
| 922 DisableBackgroundMode(); | 877 DisableBackgroundMode(); |
| 923 new_browser = QuitBrowserAndRestore(new_browser, true); | 878 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 924 StoreDataWithPage(new_browser, "cookies.html"); | 879 StoreDataWithPage(new_browser, "cookies.html"); |
| 925 } | 880 } |
| OLD | NEW |