Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 14 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 18 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 18 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 19 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 19 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
| 20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 21 #include "chrome/browser/domain_reliability/service_factory.h" | 21 #include "chrome/browser/domain_reliability/service_factory.h" |
| 22 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 22 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 23 #include "chrome/browser/favicon/favicon_service_factory.h" | 23 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 24 #include "chrome/browser/history/history_service_factory.h" | 24 #include "chrome/browser/history/history_service_factory.h" |
| 25 #include "chrome/browser/password_manager/password_store_factory.h" | 25 #include "chrome/browser/password_manager/password_store_factory.h" |
| 26 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 26 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 28 #include "chrome/browser/storage/durable_storage_permission_context.h" | 28 #include "chrome/browser/storage/durable_storage_permission_context.h" |
| 29 #include "chrome/browser/translate/language_model_factory.h" | |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 32 #include "components/autofill/core/browser/autofill_profile.h" | 33 #include "components/autofill/core/browser/autofill_profile.h" |
| 33 #include "components/autofill/core/browser/autofill_test_utils.h" | 34 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 34 #include "components/autofill/core/browser/credit_card.h" | 35 #include "components/autofill/core/browser/credit_card.h" |
| 35 #include "components/autofill/core/browser/personal_data_manager.h" | 36 #include "components/autofill/core/browser/personal_data_manager.h" |
| 36 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 37 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 37 #include "components/autofill/core/common/autofill_constants.h" | 38 #include "components/autofill/core/common/autofill_constants.h" |
| 38 #include "components/bookmarks/browser/bookmark_model.h" | 39 #include "components/bookmarks/browser/bookmark_model.h" |
| 39 #include "components/bookmarks/test/bookmark_test_helpers.h" | 40 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 40 #include "components/browsing_data/core/browsing_data_utils.h" | 41 #include "components/browsing_data/core/browsing_data_utils.h" |
| 41 #include "components/content_settings/core/browser/host_content_settings_map.h" | 42 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 42 #include "components/content_settings/core/common/content_settings.h" | 43 #include "components/content_settings/core/common/content_settings.h" |
| 43 #include "components/content_settings/core/common/content_settings_pattern.h" | 44 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 44 #include "components/domain_reliability/clear_mode.h" | 45 #include "components/domain_reliability/clear_mode.h" |
| 45 #include "components/domain_reliability/monitor.h" | 46 #include "components/domain_reliability/monitor.h" |
| 46 #include "components/domain_reliability/service.h" | 47 #include "components/domain_reliability/service.h" |
| 47 #include "components/favicon/core/favicon_service.h" | 48 #include "components/favicon/core/favicon_service.h" |
| 48 #include "components/history/core/browser/history_service.h" | 49 #include "components/history/core/browser/history_service.h" |
| 49 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 50 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
| 50 #include "components/omnibox/browser/omnibox_pref_names.h" | 51 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 51 #include "components/os_crypt/os_crypt_mocker.h" | 52 #include "components/os_crypt/os_crypt_mocker.h" |
| 52 #include "components/password_manager/core/browser/mock_password_store.h" | 53 #include "components/password_manager/core/browser/mock_password_store.h" |
| 53 #include "components/password_manager/core/browser/password_manager_test_utils.h " | 54 #include "components/password_manager/core/browser/password_manager_test_utils.h " |
| 54 #include "components/password_manager/core/browser/password_store_consumer.h" | 55 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 55 #include "components/prefs/testing_pref_service.h" | 56 #include "components/prefs/testing_pref_service.h" |
| 57 #include "components/translate/core/browser/language_model.h" | |
| 56 #include "content/public/test/mock_download_manager.h" | 58 #include "content/public/test/mock_download_manager.h" |
| 57 #include "content/public/test/test_browser_thread_bundle.h" | 59 #include "content/public/test/test_browser_thread_bundle.h" |
| 58 #include "content/public/test/test_utils.h" | 60 #include "content/public/test/test_utils.h" |
| 59 #include "net/cookies/cookie_store.h" | 61 #include "net/cookies/cookie_store.h" |
| 60 #include "net/http/http_transaction_factory.h" | 62 #include "net/http/http_transaction_factory.h" |
| 61 #include "net/url_request/url_request_context.h" | 63 #include "net/url_request/url_request_context.h" |
| 62 #include "net/url_request/url_request_context_getter.h" | 64 #include "net/url_request/url_request_context_getter.h" |
| 63 #include "third_party/skia/include/core/SkBitmap.h" | 65 #include "third_party/skia/include/core/SkBitmap.h" |
| 64 #include "ui/gfx/favicon_size.h" | 66 #include "ui/gfx/favicon_size.h" |
| 65 | 67 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 83 | 85 |
| 84 using domain_reliability::CLEAR_BEACONS; | 86 using domain_reliability::CLEAR_BEACONS; |
| 85 using domain_reliability::CLEAR_CONTEXTS; | 87 using domain_reliability::CLEAR_CONTEXTS; |
| 86 using domain_reliability::DomainReliabilityClearMode; | 88 using domain_reliability::DomainReliabilityClearMode; |
| 87 using domain_reliability::DomainReliabilityMonitor; | 89 using domain_reliability::DomainReliabilityMonitor; |
| 88 using domain_reliability::DomainReliabilityService; | 90 using domain_reliability::DomainReliabilityService; |
| 89 using domain_reliability::DomainReliabilityServiceFactory; | 91 using domain_reliability::DomainReliabilityServiceFactory; |
| 90 using testing::_; | 92 using testing::_; |
| 91 using testing::ByRef; | 93 using testing::ByRef; |
| 92 using testing::Eq; | 94 using testing::Eq; |
| 95 using testing::FloatEq; | |
| 93 using testing::Invoke; | 96 using testing::Invoke; |
| 94 using testing::IsEmpty; | 97 using testing::IsEmpty; |
| 95 using testing::Matcher; | 98 using testing::Matcher; |
| 96 using testing::MakeMatcher; | 99 using testing::MakeMatcher; |
| 97 using testing::MatcherInterface; | 100 using testing::MatcherInterface; |
| 98 using testing::MatchResultListener; | 101 using testing::MatchResultListener; |
| 99 using testing::Not; | 102 using testing::Not; |
| 100 using testing::Return; | 103 using testing::Return; |
| 101 using testing::SizeIs; | 104 using testing::SizeIs; |
| 102 using testing::WithArgs; | 105 using testing::WithArgs; |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1722 completion_observer.BlockUntilCompletion(); | 1725 completion_observer.BlockUntilCompletion(); |
| 1723 | 1726 |
| 1724 // There should be only 1 recently visited bookmarks. | 1727 // There should be only 1 recently visited bookmarks. |
| 1725 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = | 1728 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = |
| 1726 ntp_snippets::GetRecentlyVisitedBookmarks( | 1729 ntp_snippets::GetRecentlyVisitedBookmarks( |
| 1727 bookmark_model, 3, base::Time::UnixEpoch(), | 1730 bookmark_model, 3, base::Time::UnixEpoch(), |
| 1728 /*consider_visits_from_desktop=*/true); | 1731 /*consider_visits_from_desktop=*/true); |
| 1729 EXPECT_THAT(remaining_nodes, SizeIs(1)); | 1732 EXPECT_THAT(remaining_nodes, SizeIs(1)); |
| 1730 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); | 1733 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); |
| 1731 } | 1734 } |
| 1735 | |
| 1736 // Test that the remover clears language model data (normally added by the | |
| 1737 // ChromeTranslateClient). | |
| 1738 TEST_F(ChromeBrowsingDataRemoverDelegateTest, | |
| 1739 LanguageModelClearedOnClearingCompleteHistory) { | |
| 1740 translate::LanguageModel* language_model = | |
| 1741 LanguageModelFactory::GetInstance()->GetForBrowserContext(GetProfile()); | |
| 1742 | |
| 1743 // Simulate browsing. | |
| 1744 for (int i = 0; i < 100; i++) { | |
| 1745 language_model->OnPageVisited("en"); | |
| 1746 language_model->OnPageVisited("es"); | |
| 1747 } | |
| 1748 | |
| 1749 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(2)); | |
| 1750 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.5)); | |
| 1751 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.5)); | |
| 1752 | |
| 1753 RegistrableDomainFilterBuilder builder( | |
| 1754 RegistrableDomainFilterBuilder::BLACKLIST); | |
| 1755 | |
| 1756 // Clearing the full history does the trick. | |
| 1757 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), | |
|
msramek
2017/01/24 15:35:34
You can just use BlockUntilBrowsingDataRemoved sin
jkrcal
2017/01/25 08:48:54
Done.
| |
| 1758 BrowsingDataRemover::REMOVE_HISTORY, builder); | |
| 1759 | |
| 1760 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(0)); | |
| 1761 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.0)); | |
| 1762 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.0)); | |
| 1763 } | |
| OLD | NEW |