Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 1402783005: Remove safe_browsing=2 functionality, replace with =3 mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix up histograms Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 quit_closure_.Run(); 332 quit_closure_.Run();
333 } 333 }
334 334
335 bool get_cookie_success_ = false; 335 bool get_cookie_success_ = false;
336 base::Closure quit_closure_; 336 base::Closure quit_closure_;
337 net::CookieStore* cookie_store_ = nullptr; 337 net::CookieStore* cookie_store_ = nullptr;
338 338
339 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); 339 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester);
340 }; 340 };
341 341
342 #if defined(SAFE_BROWSING_SERVICE)
343 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { 342 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester {
344 public: 343 public:
345 RemoveSafeBrowsingCookieTester() 344 RemoveSafeBrowsingCookieTester()
346 : browser_process_(TestingBrowserProcess::GetGlobal()) { 345 : browser_process_(TestingBrowserProcess::GetGlobal()) {
347 scoped_refptr<SafeBrowsingService> sb_service = 346 scoped_refptr<SafeBrowsingService> sb_service =
348 SafeBrowsingService::CreateSafeBrowsingService(); 347 SafeBrowsingService::CreateSafeBrowsingService();
349 browser_process_->SetSafeBrowsingService(sb_service.get()); 348 browser_process_->SetSafeBrowsingService(sb_service.get());
350 sb_service->Initialize(); 349 sb_service->Initialize();
351 base::MessageLoop::current()->RunUntilIdle(); 350 base::MessageLoop::current()->RunUntilIdle();
352 351
(...skipping 10 matching lines...) Expand all
363 browser_process_->safe_browsing_service()->ShutDown(); 362 browser_process_->safe_browsing_service()->ShutDown();
364 base::MessageLoop::current()->RunUntilIdle(); 363 base::MessageLoop::current()->RunUntilIdle();
365 browser_process_->SetSafeBrowsingService(nullptr); 364 browser_process_->SetSafeBrowsingService(nullptr);
366 } 365 }
367 366
368 private: 367 private:
369 TestingBrowserProcess* browser_process_; 368 TestingBrowserProcess* browser_process_;
370 369
371 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); 370 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester);
372 }; 371 };
373 #endif
374 372
375 class RemoveChannelIDTester : public net::SSLConfigService::Observer { 373 class RemoveChannelIDTester : public net::SSLConfigService::Observer {
376 public: 374 public:
377 explicit RemoveChannelIDTester(TestingProfile* profile) { 375 explicit RemoveChannelIDTester(TestingProfile* profile) {
378 channel_id_service_ = profile->GetRequestContext()-> 376 channel_id_service_ = profile->GetRequestContext()->
379 GetURLRequestContext()->channel_id_service(); 377 GetURLRequestContext()->channel_id_service();
380 ssl_config_service_ = profile->GetSSLConfigService(); 378 ssl_config_service_ = profile->GetSSLConfigService();
381 ssl_config_service_->AddObserver(this); 379 ssl_config_service_->AddObserver(this);
382 } 380 }
383 381
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 EXPECT_EQ(removal_data.remove_mask, 1061 EXPECT_EQ(removal_data.remove_mask,
1064 StoragePartition::REMOVE_DATA_MASK_COOKIES); 1062 StoragePartition::REMOVE_DATA_MASK_COOKIES);
1065 // Removing with time period other than EVERYTHING should not clear 1063 // Removing with time period other than EVERYTHING should not clear
1066 // persistent storage data. 1064 // persistent storage data.
1067 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1065 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1068 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); 1066 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT);
1069 EXPECT_TRUE(removal_data.remove_origin.is_empty()); 1067 EXPECT_TRUE(removal_data.remove_origin.is_empty());
1070 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 1068 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
1071 } 1069 }
1072 1070
1073 #if defined(SAFE_BROWSING_SERVICE)
1074 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { 1071 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) {
1075 RemoveSafeBrowsingCookieTester tester; 1072 RemoveSafeBrowsingCookieTester tester;
1076 1073
1077 tester.AddCookie(); 1074 tester.AddCookie();
1078 ASSERT_TRUE(tester.ContainsCookie()); 1075 ASSERT_TRUE(tester.ContainsCookie());
1079 1076
1080 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, 1077 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING,
1081 BrowsingDataRemover::REMOVE_COOKIES, false); 1078 BrowsingDataRemover::REMOVE_COOKIES, false);
1082 1079
1083 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); 1080 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask());
1084 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1081 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1085 EXPECT_FALSE(tester.ContainsCookie()); 1082 EXPECT_FALSE(tester.ContainsCookie());
1086 } 1083 }
1087 1084
1088 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) { 1085 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) {
1089 RemoveSafeBrowsingCookieTester tester; 1086 RemoveSafeBrowsingCookieTester tester;
1090 1087
1091 tester.AddCookie(); 1088 tester.AddCookie();
1092 ASSERT_TRUE(tester.ContainsCookie()); 1089 ASSERT_TRUE(tester.ContainsCookie());
1093 1090
1094 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, 1091 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR,
1095 BrowsingDataRemover::REMOVE_COOKIES, false); 1092 BrowsingDataRemover::REMOVE_COOKIES, false);
1096 1093
1097 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); 1094 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask());
1098 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1095 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1099 // Removing with time period other than EVERYTHING should not clear safe 1096 // Removing with time period other than EVERYTHING should not clear safe
1100 // browsing cookies. 1097 // browsing cookies.
1101 EXPECT_TRUE(tester.ContainsCookie()); 1098 EXPECT_TRUE(tester.ContainsCookie());
1102 } 1099 }
1103 #endif
1104 1100
1105 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { 1101 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) {
1106 RemoveChannelIDTester tester(GetProfile()); 1102 RemoveChannelIDTester tester(GetProfile());
1107 1103
1108 tester.AddChannelID(kTestOrigin1); 1104 tester.AddChannelID(kTestOrigin1);
1109 EXPECT_EQ(0, tester.ssl_config_changed_count()); 1105 EXPECT_EQ(0, tester.ssl_config_changed_count());
1110 EXPECT_EQ(1, tester.ChannelIDCount()); 1106 EXPECT_EQ(1, tester.ChannelIDCount());
1111 1107
1112 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, 1108 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING,
1113 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); 1109 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false);
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 TEST_F(BrowsingDataRemoverTest, RemoveSameOriginDownloads) { 2107 TEST_F(BrowsingDataRemoverTest, RemoveSameOriginDownloads) {
2112 RemoveDownloadsTester tester(GetProfile()); 2108 RemoveDownloadsTester tester(GetProfile());
2113 const url::Origin expectedOrigin(kOrigin1); 2109 const url::Origin expectedOrigin(kOrigin1);
2114 2110
2115 EXPECT_CALL(*tester.download_manager(), 2111 EXPECT_CALL(*tester.download_manager(),
2116 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _)); 2112 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _));
2117 2113
2118 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, 2114 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING,
2119 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1); 2115 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1);
2120 } 2116 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698