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

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

Issue 2790493002: Implement permissions embargo for prompts which are repeatedly ignored. (Closed)
Patch Set: Not for plugins Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 : autoblocker_(PermissionDecisionAutoBlocker::GetForProfile(profile)) {} 577 : autoblocker_(PermissionDecisionAutoBlocker::GetForProfile(profile)) {}
578 578
579 int GetDismissCount(const GURL& url, ContentSettingsType permission) { 579 int GetDismissCount(const GURL& url, ContentSettingsType permission) {
580 return autoblocker_->GetDismissCount(url, permission); 580 return autoblocker_->GetDismissCount(url, permission);
581 } 581 }
582 582
583 int GetIgnoreCount(const GURL& url, ContentSettingsType permission) { 583 int GetIgnoreCount(const GURL& url, ContentSettingsType permission) {
584 return autoblocker_->GetIgnoreCount(url, permission); 584 return autoblocker_->GetIgnoreCount(url, permission);
585 } 585 }
586 586
587 int RecordIgnore(const GURL& url, ContentSettingsType permission) { 587 bool RecordIgnoreAndEmbargo(const GURL& url, ContentSettingsType permission) {
588 return autoblocker_->RecordIgnore(url, permission); 588 return autoblocker_->RecordIgnoreAndEmbargo(url, permission);
589 } 589 }
590 590
591 bool RecordDismissAndEmbargo(const GURL& url, 591 bool RecordDismissAndEmbargo(const GURL& url,
592 ContentSettingsType permission) { 592 ContentSettingsType permission) {
593 return autoblocker_->RecordDismissAndEmbargo(url, permission); 593 return autoblocker_->RecordDismissAndEmbargo(url, permission);
594 } 594 }
595 595
596 void CheckEmbargo(const GURL& url, 596 void CheckEmbargo(const GURL& url,
597 ContentSettingsType permission, 597 ContentSettingsType permission,
598 ContentSetting expected_setting) { 598 ContentSetting expected_setting) {
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 filter_builder_1->AddRegisterableDomain(kTestRegisterableDomain1); 1670 filter_builder_1->AddRegisterableDomain(kTestRegisterableDomain1);
1671 1671
1672 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder_2( 1672 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder_2(
1673 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST)); 1673 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST));
1674 filter_builder_2->AddRegisterableDomain(kTestRegisterableDomain1); 1674 filter_builder_2->AddRegisterableDomain(kTestRegisterableDomain1);
1675 base::test::ScopedFeatureList feature_list; 1675 base::test::ScopedFeatureList feature_list;
1676 feature_list.InitWithFeatures({features::kBlockPromptsIfDismissedOften}, {}); 1676 feature_list.InitWithFeatures({features::kBlockPromptsIfDismissedOften}, {});
1677 1677
1678 { 1678 {
1679 // Test REMOVE_HISTORY. 1679 // Test REMOVE_HISTORY.
1680 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, 1680 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1681 CONTENT_SETTINGS_TYPE_GEOLOCATION)); 1681 kOrigin1, CONTENT_SETTINGS_TYPE_GEOLOCATION));
1682 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, 1682 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1683 CONTENT_SETTINGS_TYPE_GEOLOCATION)); 1683 kOrigin1, CONTENT_SETTINGS_TYPE_GEOLOCATION));
1684 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, 1684 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1685 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1685 kOrigin1, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1686 EXPECT_FALSE(tester.RecordDismissAndEmbargo( 1686 EXPECT_FALSE(tester.RecordDismissAndEmbargo(
1687 kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); 1687 kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX));
1688 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, 1688 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1689 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE)); 1689 kOrigin2, CONTENT_SETTINGS_TYPE_DURABLE_STORAGE));
1690 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1690 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1691 CONTENT_SETTING_ASK); 1691 CONTENT_SETTING_ASK);
1692 EXPECT_FALSE(tester.RecordDismissAndEmbargo( 1692 EXPECT_FALSE(tester.RecordDismissAndEmbargo(
1693 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1693 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1694 EXPECT_FALSE(tester.RecordDismissAndEmbargo( 1694 EXPECT_FALSE(tester.RecordDismissAndEmbargo(
1695 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1695 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1696 EXPECT_TRUE(tester.RecordDismissAndEmbargo( 1696 EXPECT_TRUE(tester.RecordDismissAndEmbargo(
1697 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1697 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1698 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1698 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1699 CONTENT_SETTING_BLOCK); 1699 CONTENT_SETTING_BLOCK);
(...skipping 30 matching lines...) Expand all
1730 CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); 1730 CONTENT_SETTINGS_TYPE_MIDI_SYSEX));
1731 EXPECT_EQ(0, tester.GetIgnoreCount( 1731 EXPECT_EQ(0, tester.GetIgnoreCount(
1732 kOrigin2, CONTENT_SETTINGS_TYPE_DURABLE_STORAGE)); 1732 kOrigin2, CONTENT_SETTINGS_TYPE_DURABLE_STORAGE));
1733 EXPECT_EQ(0, tester.GetDismissCount( 1733 EXPECT_EQ(0, tester.GetDismissCount(
1734 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1734 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1735 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1735 tester.CheckEmbargo(kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1736 CONTENT_SETTING_ASK); 1736 CONTENT_SETTING_ASK);
1737 } 1737 }
1738 { 1738 {
1739 // Test REMOVE_SITE_DATA. 1739 // Test REMOVE_SITE_DATA.
1740 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, 1740 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1741 CONTENT_SETTINGS_TYPE_GEOLOCATION)); 1741 kOrigin1, CONTENT_SETTINGS_TYPE_GEOLOCATION));
1742 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, 1742 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1743 CONTENT_SETTINGS_TYPE_GEOLOCATION)); 1743 kOrigin1, CONTENT_SETTINGS_TYPE_GEOLOCATION));
1744 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, 1744 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1745 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1745 kOrigin1, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1746 EXPECT_FALSE(tester.RecordDismissAndEmbargo( 1746 EXPECT_FALSE(tester.RecordDismissAndEmbargo(
1747 kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); 1747 kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX));
1748 tester.CheckEmbargo(kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 1748 tester.CheckEmbargo(kOrigin1, CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
1749 CONTENT_SETTING_ASK); 1749 CONTENT_SETTING_ASK);
1750 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, 1750 EXPECT_FALSE(tester.RecordIgnoreAndEmbargo(
1751 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE)); 1751 kOrigin2, CONTENT_SETTINGS_TYPE_DURABLE_STORAGE));
1752 EXPECT_FALSE(tester.RecordDismissAndEmbargo( 1752 EXPECT_FALSE(tester.RecordDismissAndEmbargo(
1753 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1753 kOrigin2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1754 1754
1755 BlockUntilOriginDataRemoved( 1755 BlockUntilOriginDataRemoved(
1756 AnHourAgo(), base::Time::Max(), 1756 AnHourAgo(), base::Time::Max(),
1757 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_USAGE_DATA, 1757 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_USAGE_DATA,
1758 std::move(filter_builder_2)); 1758 std::move(filter_builder_2));
1759 1759
1760 // kOrigin2 should be gone, but kOrigin1 remains. 1760 // kOrigin2 should be gone, but kOrigin1 remains.
1761 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1, 1761 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 EXPECT_FALSE(Match(kOrigin1, kProtected, nullptr)); 1988 EXPECT_FALSE(Match(kOrigin1, kProtected, nullptr));
1989 EXPECT_FALSE(Match(kOriginExt, kProtected, nullptr)); 1989 EXPECT_FALSE(Match(kOriginExt, kProtected, nullptr));
1990 EXPECT_FALSE(Match(kOriginDevTools, kProtected, nullptr)); 1990 EXPECT_FALSE(Match(kOriginDevTools, kProtected, nullptr));
1991 1991
1992 #if BUILDFLAG(ENABLE_EXTENSIONS) 1992 #if BUILDFLAG(ENABLE_EXTENSIONS)
1993 EXPECT_FALSE(Match(kOrigin1, kExtension, nullptr)); 1993 EXPECT_FALSE(Match(kOrigin1, kExtension, nullptr));
1994 EXPECT_TRUE(Match(kOriginExt, kExtension, nullptr)); 1994 EXPECT_TRUE(Match(kOriginExt, kExtension, nullptr));
1995 EXPECT_FALSE(Match(kOriginDevTools, kExtension, nullptr)); 1995 EXPECT_FALSE(Match(kOriginDevTools, kExtension, nullptr));
1996 #endif 1996 #endif
1997 } 1997 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698