| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 FakeBackgroundModeManager() | 102 FakeBackgroundModeManager() |
| 103 : BackgroundModeManager( | 103 : BackgroundModeManager( |
| 104 CommandLine::ForCurrentProcess(), | 104 CommandLine::ForCurrentProcess(), |
| 105 &g_browser_process->profile_manager()->GetProfileInfoCache()), | 105 &g_browser_process->profile_manager()->GetProfileInfoCache()), |
| 106 background_mode_active_(false) {} | 106 background_mode_active_(false) {} |
| 107 | 107 |
| 108 void SetBackgroundModeActive(bool active) { | 108 void SetBackgroundModeActive(bool active) { |
| 109 background_mode_active_ = active; | 109 background_mode_active_ = active; |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual bool IsBackgroundModeActive() OVERRIDE { | 112 virtual bool IsBackgroundModeActive() override { |
| 113 return background_mode_active_; | 113 return background_mode_active_; |
| 114 } | 114 } |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 bool background_mode_active_; | 117 bool background_mode_active_; |
| 118 | 118 |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace | 121 } // namespace |
| 122 | 122 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 152 net::URLRequestFilter::GetInstance()->AddUrlHandler( | 152 net::URLRequestFilter::GetInstance()->AddUrlHandler( |
| 153 GURL(fake_server_address_ + test_path_ + *it), | 153 GURL(fake_server_address_ + test_path_ + *it), |
| 154 &URLRequestFaker); | 154 &URLRequestFaker); |
| 155 } | 155 } |
| 156 net::URLRequestFilter::GetInstance()->AddUrlHandler( | 156 net::URLRequestFilter::GetInstance()->AddUrlHandler( |
| 157 GURL(fake_server_address_ + test_path_ + "posted.php"), | 157 GURL(fake_server_address_ + test_path_ + "posted.php"), |
| 158 &URLRequestFakerForPostRequests); | 158 &URLRequestFakerForPostRequests); |
| 159 } | 159 } |
| 160 | 160 |
| 161 protected: | 161 protected: |
| 162 virtual void SetUpOnMainThread() OVERRIDE { | 162 virtual void SetUpOnMainThread() override { |
| 163 SessionServiceTestHelper helper( | 163 SessionServiceTestHelper helper( |
| 164 SessionServiceFactory::GetForProfile(browser()->profile())); | 164 SessionServiceFactory::GetForProfile(browser()->profile())); |
| 165 helper.SetForceBrowserNotAliveWithNoWindows(true); | 165 helper.SetForceBrowserNotAliveWithNoWindows(true); |
| 166 helper.ReleaseService(); | 166 helper.ReleaseService(); |
| 167 g_browser_process->set_background_mode_manager_for_test( | 167 g_browser_process->set_background_mode_manager_for_test( |
| 168 scoped_ptr<BackgroundModeManager>(new FakeBackgroundModeManager)); | 168 scoped_ptr<BackgroundModeManager>(new FakeBackgroundModeManager)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void StoreDataWithPage(const std::string& filename) { | 171 void StoreDataWithPage(const std::string& filename) { |
| 172 StoreDataWithPage(browser(), filename); | 172 StoreDataWithPage(browser(), filename); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 const base::string16 title_error_write_failed_; | 362 const base::string16 title_error_write_failed_; |
| 363 const base::string16 title_error_empty_; | 363 const base::string16 title_error_empty_; |
| 364 | 364 |
| 365 DISALLOW_COPY_AND_ASSIGN(BetterSessionRestoreTest); | 365 DISALLOW_COPY_AND_ASSIGN(BetterSessionRestoreTest); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 class ContinueWhereILeftOffTest : public BetterSessionRestoreTest { | 368 class ContinueWhereILeftOffTest : public BetterSessionRestoreTest { |
| 369 public: | 369 public: |
| 370 ContinueWhereILeftOffTest() { } | 370 ContinueWhereILeftOffTest() { } |
| 371 | 371 |
| 372 virtual void SetUpOnMainThread() OVERRIDE { | 372 virtual void SetUpOnMainThread() override { |
| 373 BetterSessionRestoreTest::SetUpOnMainThread(); | 373 BetterSessionRestoreTest::SetUpOnMainThread(); |
| 374 SessionStartupPref::SetStartupPref( | 374 SessionStartupPref::SetStartupPref( |
| 375 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); | 375 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); |
| 376 } | 376 } |
| 377 | 377 |
| 378 protected: | 378 protected: |
| 379 virtual Browser* QuitBrowserAndRestore(Browser* browser, | 379 virtual Browser* QuitBrowserAndRestore(Browser* browser, |
| 380 bool close_all_windows) OVERRIDE { | 380 bool close_all_windows) override { |
| 381 content::WindowedNotificationObserver session_restore_observer( | 381 content::WindowedNotificationObserver session_restore_observer( |
| 382 chrome::NOTIFICATION_SESSION_RESTORE_DONE, | 382 chrome::NOTIFICATION_SESSION_RESTORE_DONE, |
| 383 content::NotificationService::AllSources()); | 383 content::NotificationService::AllSources()); |
| 384 Browser* new_browser = BetterSessionRestoreTest::QuitBrowserAndRestore( | 384 Browser* new_browser = BetterSessionRestoreTest::QuitBrowserAndRestore( |
| 385 browser, close_all_windows); | 385 browser, close_all_windows); |
| 386 session_restore_observer.Wait(); | 386 session_restore_observer.Wait(); |
| 387 return new_browser; | 387 return new_browser; |
| 388 } | 388 } |
| 389 | 389 |
| 390 DISALLOW_COPY_AND_ASSIGN(ContinueWhereILeftOffTest); | 390 DISALLOW_COPY_AND_ASSIGN(ContinueWhereILeftOffTest); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // The form data contained passwords, so it's removed completely. | 656 // The form data contained passwords, so it's removed completely. |
| 657 CheckFormRestored(false, false); | 657 CheckFormRestored(false, false); |
| 658 } | 658 } |
| 659 | 659 |
| 660 // These tests ensure that the Better Session Restore features are not triggered | 660 // These tests ensure that the Better Session Restore features are not triggered |
| 661 // when they shouldn't be. | 661 // when they shouldn't be. |
| 662 class NoSessionRestoreTest : public BetterSessionRestoreTest { | 662 class NoSessionRestoreTest : public BetterSessionRestoreTest { |
| 663 public: | 663 public: |
| 664 NoSessionRestoreTest() { } | 664 NoSessionRestoreTest() { } |
| 665 | 665 |
| 666 virtual void SetUpOnMainThread() OVERRIDE { | 666 virtual void SetUpOnMainThread() override { |
| 667 BetterSessionRestoreTest::SetUpOnMainThread(); | 667 BetterSessionRestoreTest::SetUpOnMainThread(); |
| 668 SessionStartupPref::SetStartupPref( | 668 SessionStartupPref::SetStartupPref( |
| 669 browser()->profile(), SessionStartupPref(SessionStartupPref::DEFAULT)); | 669 browser()->profile(), SessionStartupPref(SessionStartupPref::DEFAULT)); |
| 670 } | 670 } |
| 671 | 671 |
| 672 private: | 672 private: |
| 673 DISALLOW_COPY_AND_ASSIGN(NoSessionRestoreTest); | 673 DISALLOW_COPY_AND_ASSIGN(NoSessionRestoreTest); |
| 674 }; | 674 }; |
| 675 | 675 |
| 676 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_SessionCookies) { | 676 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_SessionCookies) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 CookieSettings::Factory::GetForProfile(new_browser->profile())-> | 832 CookieSettings::Factory::GetForProfile(new_browser->profile())-> |
| 833 SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 833 SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
| 834 // ... even if background mode is active. | 834 // ... even if background mode is active. |
| 835 EnableBackgroundMode(); | 835 EnableBackgroundMode(); |
| 836 new_browser = QuitBrowserAndRestore(new_browser, true); | 836 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 837 StoreDataWithPage(new_browser, "cookies.html"); | 837 StoreDataWithPage(new_browser, "cookies.html"); |
| 838 DisableBackgroundMode(); | 838 DisableBackgroundMode(); |
| 839 new_browser = QuitBrowserAndRestore(new_browser, true); | 839 new_browser = QuitBrowserAndRestore(new_browser, true); |
| 840 StoreDataWithPage(new_browser, "cookies.html"); | 840 StoreDataWithPage(new_browser, "cookies.html"); |
| 841 } | 841 } |
| OLD | NEW |