| 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 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 41 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
| 42 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 42 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 43 #include "chrome/browser/domain_reliability/service_factory.h" | 43 #include "chrome/browser/domain_reliability/service_factory.h" |
| 44 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 44 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 45 #include "chrome/browser/favicon/favicon_service_factory.h" | 45 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 46 #include "chrome/browser/history/history_service_factory.h" | 46 #include "chrome/browser/history/history_service_factory.h" |
| 47 #include "chrome/browser/password_manager/password_store_factory.h" | 47 #include "chrome/browser/password_manager/password_store_factory.h" |
| 48 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 48 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 50 #include "chrome/browser/storage/durable_storage_permission_context.h" | 50 #include "chrome/browser/storage/durable_storage_permission_context.h" |
| 51 #include "chrome/browser/translate/language_model_factory.h" |
| 51 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
| 52 #include "chrome/test/base/testing_browser_process.h" | 53 #include "chrome/test/base/testing_browser_process.h" |
| 53 #include "chrome/test/base/testing_profile.h" | 54 #include "chrome/test/base/testing_profile.h" |
| 54 #include "components/autofill/core/browser/autofill_profile.h" | 55 #include "components/autofill/core/browser/autofill_profile.h" |
| 55 #include "components/autofill/core/browser/autofill_test_utils.h" | 56 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 56 #include "components/autofill/core/browser/credit_card.h" | 57 #include "components/autofill/core/browser/credit_card.h" |
| 57 #include "components/autofill/core/browser/personal_data_manager.h" | 58 #include "components/autofill/core/browser/personal_data_manager.h" |
| 58 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 59 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 59 #include "components/autofill/core/common/autofill_constants.h" | 60 #include "components/autofill/core/common/autofill_constants.h" |
| 60 #include "components/bookmarks/browser/bookmark_model.h" | 61 #include "components/bookmarks/browser/bookmark_model.h" |
| 61 #include "components/bookmarks/test/bookmark_test_helpers.h" | 62 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 62 #include "components/browsing_data/core/browsing_data_utils.h" | 63 #include "components/browsing_data/core/browsing_data_utils.h" |
| 63 #include "components/content_settings/core/browser/host_content_settings_map.h" | 64 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 64 #include "components/content_settings/core/common/content_settings.h" | 65 #include "components/content_settings/core/common/content_settings.h" |
| 65 #include "components/content_settings/core/common/content_settings_pattern.h" | 66 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 66 #include "components/domain_reliability/clear_mode.h" | 67 #include "components/domain_reliability/clear_mode.h" |
| 67 #include "components/domain_reliability/monitor.h" | 68 #include "components/domain_reliability/monitor.h" |
| 68 #include "components/domain_reliability/service.h" | 69 #include "components/domain_reliability/service.h" |
| 69 #include "components/favicon/core/favicon_service.h" | 70 #include "components/favicon/core/favicon_service.h" |
| 70 #include "components/history/core/browser/history_service.h" | 71 #include "components/history/core/browser/history_service.h" |
| 71 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 72 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
| 72 #include "components/omnibox/browser/omnibox_pref_names.h" | 73 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 73 #include "components/os_crypt/os_crypt_mocker.h" | 74 #include "components/os_crypt/os_crypt_mocker.h" |
| 74 #include "components/password_manager/core/browser/mock_password_store.h" | 75 #include "components/password_manager/core/browser/mock_password_store.h" |
| 75 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 76 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 76 #include "components/password_manager/core/browser/password_store_consumer.h" | 77 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 77 #include "components/prefs/testing_pref_service.h" | 78 #include "components/prefs/testing_pref_service.h" |
| 79 #include "components/translate/core/browser/language_model.h" |
| 78 #include "content/public/browser/browser_context.h" | 80 #include "content/public/browser/browser_context.h" |
| 79 #include "content/public/browser/cookie_store_factory.h" | 81 #include "content/public/browser/cookie_store_factory.h" |
| 80 #include "content/public/browser/dom_storage_context.h" | 82 #include "content/public/browser/dom_storage_context.h" |
| 81 #include "content/public/browser/local_storage_usage_info.h" | 83 #include "content/public/browser/local_storage_usage_info.h" |
| 82 #include "content/public/browser/permission_type.h" | 84 #include "content/public/browser/permission_type.h" |
| 83 #include "content/public/browser/storage_partition.h" | 85 #include "content/public/browser/storage_partition.h" |
| 84 #include "content/public/test/mock_download_manager.h" | 86 #include "content/public/test/mock_download_manager.h" |
| 85 #include "content/public/test/test_browser_thread.h" | 87 #include "content/public/test/test_browser_thread.h" |
| 86 #include "content/public/test/test_browser_thread_bundle.h" | 88 #include "content/public/test/test_browser_thread_bundle.h" |
| 87 #include "content/public/test/test_utils.h" | 89 #include "content/public/test/test_utils.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 using content::StoragePartition; | 131 using content::StoragePartition; |
| 130 using domain_reliability::CLEAR_BEACONS; | 132 using domain_reliability::CLEAR_BEACONS; |
| 131 using domain_reliability::CLEAR_CONTEXTS; | 133 using domain_reliability::CLEAR_CONTEXTS; |
| 132 using domain_reliability::DomainReliabilityClearMode; | 134 using domain_reliability::DomainReliabilityClearMode; |
| 133 using domain_reliability::DomainReliabilityMonitor; | 135 using domain_reliability::DomainReliabilityMonitor; |
| 134 using domain_reliability::DomainReliabilityService; | 136 using domain_reliability::DomainReliabilityService; |
| 135 using domain_reliability::DomainReliabilityServiceFactory; | 137 using domain_reliability::DomainReliabilityServiceFactory; |
| 136 using testing::_; | 138 using testing::_; |
| 137 using testing::ByRef; | 139 using testing::ByRef; |
| 138 using testing::Eq; | 140 using testing::Eq; |
| 141 using testing::FloatEq; |
| 139 using testing::Invoke; | 142 using testing::Invoke; |
| 140 using testing::IsEmpty; | 143 using testing::IsEmpty; |
| 141 using testing::Matcher; | 144 using testing::Matcher; |
| 142 using testing::MakeMatcher; | 145 using testing::MakeMatcher; |
| 143 using testing::MatcherInterface; | 146 using testing::MatcherInterface; |
| 144 using testing::MatchResultListener; | 147 using testing::MatchResultListener; |
| 145 using testing::Not; | 148 using testing::Not; |
| 146 using testing::Return; | 149 using testing::Return; |
| 147 using testing::SizeIs; | 150 using testing::SizeIs; |
| 148 using testing::WithArgs; | 151 using testing::WithArgs; |
| (...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 completion_observer.BlockUntilCompletion(); | 3132 completion_observer.BlockUntilCompletion(); |
| 3130 | 3133 |
| 3131 // There should be only 1 recently visited bookmarks. | 3134 // There should be only 1 recently visited bookmarks. |
| 3132 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = | 3135 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = |
| 3133 ntp_snippets::GetRecentlyVisitedBookmarks( | 3136 ntp_snippets::GetRecentlyVisitedBookmarks( |
| 3134 bookmark_model, 3, base::Time::UnixEpoch(), | 3137 bookmark_model, 3, base::Time::UnixEpoch(), |
| 3135 /*consider_visits_from_desktop=*/true); | 3138 /*consider_visits_from_desktop=*/true); |
| 3136 EXPECT_THAT(remaining_nodes, SizeIs(1)); | 3139 EXPECT_THAT(remaining_nodes, SizeIs(1)); |
| 3137 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); | 3140 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); |
| 3138 } | 3141 } |
| 3142 |
| 3143 // Test that the remover clears language model data (normally added by the |
| 3144 // ChromeTranslateClient). |
| 3145 TEST_F(BrowsingDataRemoverTest, |
| 3146 LanguageModelClearedOnClearingCompleteHistory) { |
| 3147 translate::LanguageModel* language_model = |
| 3148 LanguageModelFactory::GetInstance()->GetForBrowserContext(GetProfile()); |
| 3149 |
| 3150 // Simulate browsing. |
| 3151 for (int i = 0; i < 100; i++) { |
| 3152 language_model->OnPageVisited("en"); |
| 3153 language_model->OnPageVisited("en"); |
| 3154 language_model->OnPageVisited("en"); |
| 3155 language_model->OnPageVisited("es"); |
| 3156 } |
| 3157 |
| 3158 // Clearing a part of the history has no effect. |
| 3159 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
| 3160 BrowsingDataRemover::REMOVE_HISTORY, false); |
| 3161 |
| 3162 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(2)); |
| 3163 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.75)); |
| 3164 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.25)); |
| 3165 |
| 3166 // Clearing the full history does the trick. |
| 3167 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
| 3168 BrowsingDataRemover::REMOVE_HISTORY, false); |
| 3169 |
| 3170 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(0)); |
| 3171 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.0)); |
| 3172 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.0)); |
| 3173 } |
| OLD | NEW |