| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH | 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH |
| 6 // results | 6 // results |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/base64.h" | 12 #include "base/base64.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 20 #include "base/strings/string_tokenizer.h" | 20 #include "base/strings/string_tokenizer.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 25 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 26 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 26 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 28 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 29 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 32 #include "chrome/browser/ui/browser_tabstrip.h" | 33 #include "chrome/browser/ui/browser_tabstrip.h" |
| 33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
| 36 #include "chrome/test/base/in_process_browser_test.h" | 37 #include "chrome/test/base/in_process_browser_test.h" |
| 37 #include "components/browsing_data/core/browsing_data_utils.h" | 38 #include "components/browsing_data/core/browsing_data_utils.h" |
| 38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 407 } |
| 407 | 408 |
| 408 void BrowsingDataRemoveAndWait(int remove_mask) { | 409 void BrowsingDataRemoveAndWait(int remove_mask) { |
| 409 BrowsingDataRemover* remover = | 410 BrowsingDataRemover* remover = |
| 410 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 411 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); |
| 411 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 412 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 412 remover->RemoveAndReply(browsing_data::CalculateBeginDeleteTime( | 413 remover->RemoveAndReply(browsing_data::CalculateBeginDeleteTime( |
| 413 browsing_data::TimePeriod::LAST_HOUR), | 414 browsing_data::TimePeriod::LAST_HOUR), |
| 414 browsing_data::CalculateEndDeleteTime( | 415 browsing_data::CalculateEndDeleteTime( |
| 415 browsing_data::TimePeriod::LAST_HOUR), | 416 browsing_data::TimePeriod::LAST_HOUR), |
| 416 remove_mask, BrowsingDataHelper::UNPROTECTED_WEB, | 417 remove_mask, |
| 418 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, |
| 417 &completion_observer); | 419 &completion_observer); |
| 418 completion_observer.BlockUntilCompletion(); | 420 completion_observer.BlockUntilCompletion(); |
| 419 } | 421 } |
| 420 | 422 |
| 421 // Something of a cheat; nuke the dictionaries off the SdchManager without | 423 // Something of a cheat; nuke the dictionaries off the SdchManager without |
| 422 // touching the cache (which browsing data remover would do). | 424 // touching the cache (which browsing data remover would do). |
| 423 void NukeSdchDictionaries() { | 425 void NukeSdchDictionaries() { |
| 424 base::RunLoop run_loop; | 426 base::RunLoop run_loop; |
| 425 content::BrowserThread::PostTaskAndReply( | 427 content::BrowserThread::PostTaskAndReply( |
| 426 content::BrowserThread::IO, FROM_HERE, | 428 content::BrowserThread::IO, FROM_HERE, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 const char SdchBrowserTest::kTestHost[] = "our.test.host.com"; | 671 const char SdchBrowserTest::kTestHost[] = "our.test.host.com"; |
| 670 | 672 |
| 671 // Confirm that after getting a dictionary, calling the browsing | 673 // Confirm that after getting a dictionary, calling the browsing |
| 672 // data remover renders it unusable. Also (in calling | 674 // data remover renders it unusable. Also (in calling |
| 673 // ForceSdchDictionaryLoad()) servers as a smoke test for SDCH. | 675 // ForceSdchDictionaryLoad()) servers as a smoke test for SDCH. |
| 674 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, BrowsingDataRemover) { | 676 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, BrowsingDataRemover) { |
| 675 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); | 677 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); |
| 676 | 678 |
| 677 // Confirm browsing data remover without removing the cache leaves | 679 // Confirm browsing data remover without removing the cache leaves |
| 678 // SDCH alone. | 680 // SDCH alone. |
| 679 BrowsingDataRemoveAndWait(BrowsingDataRemover::REMOVE_ALL & | 681 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES & |
| 680 ~BrowsingDataRemover::REMOVE_CACHE); | 682 ~BrowsingDataRemover::DATA_TYPE_CACHE); |
| 681 bool sdch_encoding_used = false; | 683 bool sdch_encoding_used = false; |
| 682 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 684 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 683 EXPECT_TRUE(sdch_encoding_used); | 685 EXPECT_TRUE(sdch_encoding_used); |
| 684 | 686 |
| 685 // Confirm browsing data remover removing the cache clears SDCH state. | 687 // Confirm browsing data remover removing the cache clears SDCH state. |
| 686 BrowsingDataRemoveAndWait(BrowsingDataRemover::REMOVE_CACHE); | 688 BrowsingDataRemoveAndWait(BrowsingDataRemover::DATA_TYPE_CACHE); |
| 687 sdch_encoding_used = false; | 689 sdch_encoding_used = false; |
| 688 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 690 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 689 EXPECT_FALSE(sdch_encoding_used); | 691 EXPECT_FALSE(sdch_encoding_used); |
| 690 } | 692 } |
| 691 | 693 |
| 692 // Confirm dictionaries not visible in other profiles. | 694 // Confirm dictionaries not visible in other profiles. |
| 693 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { | 695 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { |
| 694 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); | 696 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); |
| 695 ASSERT_TRUE(SetupSecondBrowser()); | 697 ASSERT_TRUE(SetupSecondBrowser()); |
| 696 ASSERT_TRUE(SetupIncognitoBrowser()); | 698 ASSERT_TRUE(SetupIncognitoBrowser()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 714 ASSERT_TRUE(SetupIncognitoBrowser()); | 716 ASSERT_TRUE(SetupIncognitoBrowser()); |
| 715 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 717 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
| 716 | 718 |
| 717 // Data fetches on main browser should not be SDCH encoded. | 719 // Data fetches on main browser should not be SDCH encoded. |
| 718 bool sdch_encoding_used = true; | 720 bool sdch_encoding_used = true; |
| 719 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 721 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 720 EXPECT_FALSE(sdch_encoding_used); | 722 EXPECT_FALSE(sdch_encoding_used); |
| 721 } | 723 } |
| 722 | 724 |
| 723 } // namespace | 725 } // namespace |
| OLD | NEW |