| 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 "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "components/bookmarks/test/bookmark_test_helpers.h" | 57 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 58 #include "components/browsing_data/core/browsing_data_utils.h" | 58 #include "components/browsing_data/core/browsing_data_utils.h" |
| 59 #include "components/content_settings/core/browser/host_content_settings_map.h" | 59 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 60 #include "components/content_settings/core/common/content_settings.h" | 60 #include "components/content_settings/core/common/content_settings.h" |
| 61 #include "components/content_settings/core/common/content_settings_pattern.h" | 61 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 62 #include "components/domain_reliability/clear_mode.h" | 62 #include "components/domain_reliability/clear_mode.h" |
| 63 #include "components/domain_reliability/monitor.h" | 63 #include "components/domain_reliability/monitor.h" |
| 64 #include "components/domain_reliability/service.h" | 64 #include "components/domain_reliability/service.h" |
| 65 #include "components/favicon/core/favicon_service.h" | 65 #include "components/favicon/core/favicon_service.h" |
| 66 #include "components/history/core/browser/history_service.h" | 66 #include "components/history/core/browser/history_service.h" |
| 67 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
| 67 #include "components/omnibox/browser/omnibox_pref_names.h" | 68 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 68 #include "components/os_crypt/os_crypt_mocker.h" | 69 #include "components/os_crypt/os_crypt_mocker.h" |
| 69 #include "components/password_manager/core/browser/mock_password_store.h" | 70 #include "components/password_manager/core/browser/mock_password_store.h" |
| 70 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 71 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 71 #include "components/password_manager/core/browser/password_store_consumer.h" | 72 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 72 #include "components/prefs/testing_pref_service.h" | 73 #include "components/prefs/testing_pref_service.h" |
| 73 #include "content/public/browser/browser_context.h" | 74 #include "content/public/browser/browser_context.h" |
| 74 #include "content/public/browser/cookie_store_factory.h" | 75 #include "content/public/browser/cookie_store_factory.h" |
| 75 #include "content/public/browser/dom_storage_context.h" | 76 #include "content/public/browser/dom_storage_context.h" |
| 76 #include "content/public/browser/local_storage_usage_info.h" | 77 #include "content/public/browser/local_storage_usage_info.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 using content::StoragePartition; | 125 using content::StoragePartition; |
| 125 using domain_reliability::CLEAR_BEACONS; | 126 using domain_reliability::CLEAR_BEACONS; |
| 126 using domain_reliability::CLEAR_CONTEXTS; | 127 using domain_reliability::CLEAR_CONTEXTS; |
| 127 using domain_reliability::DomainReliabilityClearMode; | 128 using domain_reliability::DomainReliabilityClearMode; |
| 128 using domain_reliability::DomainReliabilityMonitor; | 129 using domain_reliability::DomainReliabilityMonitor; |
| 129 using domain_reliability::DomainReliabilityService; | 130 using domain_reliability::DomainReliabilityService; |
| 130 using domain_reliability::DomainReliabilityServiceFactory; | 131 using domain_reliability::DomainReliabilityServiceFactory; |
| 131 using testing::_; | 132 using testing::_; |
| 132 using testing::ByRef; | 133 using testing::ByRef; |
| 133 using testing::Invoke; | 134 using testing::Invoke; |
| 135 using testing::IsEmpty; |
| 134 using testing::Matcher; | 136 using testing::Matcher; |
| 135 using testing::MakeMatcher; | 137 using testing::MakeMatcher; |
| 136 using testing::MatcherInterface; | 138 using testing::MatcherInterface; |
| 137 using testing::MatchResultListener; | 139 using testing::MatchResultListener; |
| 140 using testing::Not; |
| 138 using testing::Return; | 141 using testing::Return; |
| 139 using testing::WithArgs; | 142 using testing::WithArgs; |
| 140 | 143 |
| 141 namespace { | 144 namespace { |
| 142 | 145 |
| 143 const char kTestOrigin1[] = "http://host1.com:1/"; | 146 const char kTestOrigin1[] = "http://host1.com:1/"; |
| 144 const char kTestRegisterableDomain1[] = "host1.com"; | 147 const char kTestRegisterableDomain1[] = "host1.com"; |
| 145 const char kTestOrigin2[] = "http://host2.com:1/"; | 148 const char kTestOrigin2[] = "http://host2.com:1/"; |
| 146 const char kTestOrigin3[] = "http://host3.com:1/"; | 149 const char kTestOrigin3[] = "http://host3.com:1/"; |
| 147 const char kTestRegisterableDomain3[] = "host3.com"; | 150 const char kTestRegisterableDomain3[] = "host3.com"; |
| (...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3037 EXPECT_TRUE(remover->is_removing()); | 3040 EXPECT_TRUE(remover->is_removing()); |
| 3038 | 3041 |
| 3039 // Add one more deletion and wait for it. | 3042 // Add one more deletion and wait for it. |
| 3040 BlockUntilBrowsingDataRemoved( | 3043 BlockUntilBrowsingDataRemoved( |
| 3041 browsing_data::ALL_TIME, | 3044 browsing_data::ALL_TIME, |
| 3042 BrowsingDataRemover::REMOVE_COOKIES, | 3045 BrowsingDataRemover::REMOVE_COOKIES, |
| 3043 BrowsingDataHelper::UNPROTECTED_WEB); | 3046 BrowsingDataHelper::UNPROTECTED_WEB); |
| 3044 | 3047 |
| 3045 EXPECT_FALSE(remover->is_removing()); | 3048 EXPECT_FALSE(remover->is_removing()); |
| 3046 } | 3049 } |
| 3050 |
| 3051 // Test that the remover clears bookmark meta data (normally added in a tab |
| 3052 // helper). |
| 3053 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { |
| 3054 TestingProfile profile; |
| 3055 profile.CreateBookmarkModel(true); |
| 3056 |
| 3057 bookmarks::BookmarkModel* bookmark_model = |
| 3058 BookmarkModelFactory::GetForBrowserContext(&profile); |
| 3059 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
| 3060 |
| 3061 // Create a couple of bookmarks. |
| 3062 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, |
| 3063 base::string16(), |
| 3064 GURL("http://foo.org/desktop")); |
| 3065 bookmark_model->AddURL(bookmark_model->mobile_node(), 0, |
| 3066 base::string16(), |
| 3067 GURL("http://foo.org/mobile")); |
| 3068 |
| 3069 // Simulate their visits. |
| 3070 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( |
| 3071 bookmark_model, GURL("http://foo.org/desktop"), |
| 3072 /*is_mobile_platform=*/false); |
| 3073 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( |
| 3074 bookmark_model, GURL("http://foo.org/mobile"), |
| 3075 /*is_mobile_platform=*/true); |
| 3076 |
| 3077 // There should be some recently visited bookmarks. |
| 3078 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
| 3079 bookmark_model, 2, base::Time::UnixEpoch(), |
| 3080 /*consider_visits_from_desktop=*/false), |
| 3081 Not(IsEmpty())); |
| 3082 |
| 3083 // Inject the bookmark model into the remover. |
| 3084 BrowsingDataRemover* remover = |
| 3085 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); |
| 3086 |
| 3087 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 3088 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), |
| 3089 BrowsingDataRemover::REMOVE_HISTORY, |
| 3090 BrowsingDataHelper::ALL, &completion_observer); |
| 3091 completion_observer.BlockUntilCompletion(); |
| 3092 |
| 3093 // There should be no recently visited bookmarks. |
| 3094 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
| 3095 bookmark_model, 2, base::Time::UnixEpoch(), |
| 3096 /*consider_visits_from_desktop=*/false), |
| 3097 IsEmpty()); |
| 3098 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
| 3099 bookmark_model, 2, base::Time::UnixEpoch(), |
| 3100 /*consider_visits_from_desktop=*/true), |
| 3101 IsEmpty()); |
| 3102 } |
| OLD | NEW |