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

Unified Diff: chrome/browser/permissions/permission_util_unittest.cc

Issue 2165733003: Add revocation reporter to permission util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-source-ui-to-permission-report
Patch Set: Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/permissions/permission_util_unittest.cc
diff --git a/chrome/browser/permissions/permission_util_unittest.cc b/chrome/browser/permissions/permission_util_unittest.cc
index def5eb91764dbbe6b4bcf1c1fedef2e8b0818ef3..17252f879295873a1ee1855ba28d83423719ce6b 100644
--- a/chrome/browser/permissions/permission_util_unittest.cc
+++ b/chrome/browser/permissions/permission_util_unittest.cc
@@ -15,7 +15,7 @@ class PermissionUtilTest : public testing::Test {
content::TestBrowserThreadBundle thread_bundle_;
};
-TEST_F(PermissionUtilTest, SetContentSettingRecordRevocation) {
+TEST_F(PermissionUtilTest, ScopedRevocationReporter) {
TestingProfile profile;
// TODO(tsergeant): Add more comprehensive tests of PermissionUmaUtil.
base::HistogramTester histograms;
@@ -23,32 +23,49 @@ TEST_F(PermissionUtilTest, SetContentSettingRecordRevocation) {
HostContentSettingsMapFactory::GetForProfile(&profile);
GURL host("https://example.com");
ContentSettingsType type = CONTENT_SETTINGS_TYPE_GEOLOCATION;
+ PermissionSourceUI source_ui = PermissionSourceUI::SITE_SETTINGS;
// Allow->Block triggers a revocation.
map->SetContentSettingDefaultScope(host, host, type, std::string(),
CONTENT_SETTING_ALLOW);
- PermissionUtil::SetContentSettingAndRecordRevocation(
- &profile, host, host, type, std::string(), CONTENT_SETTING_BLOCK);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host, host, type, source_ui);
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_BLOCK);
+ }
histograms.ExpectBucketCount("Permissions.Action.Geolocation",
PermissionAction::REVOKED, 1);
// Block->Allow does not trigger a revocation.
- PermissionUtil::SetContentSettingAndRecordRevocation(
- &profile, host, host, type, std::string(), CONTENT_SETTING_ALLOW);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host, host, type, source_ui);
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_ALLOW);
+ }
histograms.ExpectBucketCount("Permissions.Action.Geolocation",
PermissionAction::REVOKED, 1);
// Allow->Default triggers a revocation when default is 'ask'.
map->SetDefaultContentSetting(type, CONTENT_SETTING_ASK);
- PermissionUtil::SetContentSettingAndRecordRevocation(
- &profile, host, host, type, std::string(), CONTENT_SETTING_DEFAULT);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host, host, type, source_ui);
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_DEFAULT);
+ }
histograms.ExpectBucketCount("Permissions.Action.Geolocation",
PermissionAction::REVOKED, 2);
// Allow->Default does not trigger a revocation when default is 'allow'.
map->SetDefaultContentSetting(type, CONTENT_SETTING_ALLOW);
- PermissionUtil::SetContentSettingAndRecordRevocation(
- &profile, host, host, type, std::string(), CONTENT_SETTING_DEFAULT);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host, host, type, source_ui);
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_DEFAULT);
+ }
histograms.ExpectBucketCount("Permissions.Action.Geolocation",
PermissionAction::REVOKED, 2);
}
« no previous file with comments | « chrome/browser/permissions/permission_util.cc ('k') | chrome/browser/ui/content_settings/content_setting_bubble_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698