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

Unified Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 1803973002: Content Settings: Add RevocationObserver to measure when permissions are revoked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 9 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/content_settings/host_content_settings_map_unittest.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index a530604fa391bb10f4a810f8d0d1ca8218e66834..0f13c951b4679901ebd97b520038b248bfac5a38 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -1070,6 +1070,74 @@ TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) {
CONTENT_SETTING_DEFAULT);
}
+TEST_F(HostContentSettingsMapTest, RevocationObserver) {
+ TestingProfile profile;
+ HostContentSettingsMap* map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
+ content_settings::MockRevocationObserver mock_observer;
+ map->AddObserver(&mock_observer);
+
+ GURL host("http://example.com/");
+
+ ContentSettingsPattern pattern =
+ ContentSettingsPattern::FromURLNoWildcard(host);
+
+ // Allow->Block triggers a revocation.
+
+ EXPECT_CALL(mock_observer,
+ OnContentSettingRevoked(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
+
+ map->SetContentSettingDefaultScope(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, "", CONTENT_SETTING_ALLOW);
+
+ map->SetContentSettingDefaultScope(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, "", CONTENT_SETTING_BLOCK);
+
+ ::testing::Mock::VerifyAndClearExpectations(&mock_observer);
+
+ // Block->Allow does not trigger a revocation.
+ EXPECT_CALL(mock_observer,
+ OnContentSettingRevoked(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, ""))
+ .Times(0);
+
+ map->SetContentSettingDefaultScope(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, "", CONTENT_SETTING_ALLOW);
+
+ ::testing::Mock::VerifyAndClearExpectations(&mock_observer);
+
+ // Allow->Default triggers a revocation when default is 'ask'.
+ EXPECT_CALL(mock_observer,
+ OnContentSettingRevoked(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
+
+ map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ CONTENT_SETTING_ASK);
+
+ map->SetContentSettingDefaultScope(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, "",
+ CONTENT_SETTING_DEFAULT);
+
+ // Allow->Default does not trigger a revocation when default is 'allow'.
+ EXPECT_CALL(mock_observer,
+ OnContentSettingRevoked(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, ""))
+ .Times(0);
+
+ map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ CONTENT_SETTING_ALLOW);
+
+ map->SetContentSettingDefaultScope(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, "",
+ CONTENT_SETTING_ALLOW);
+ map->SetContentSettingDefaultScope(host, host,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, "",
+ CONTENT_SETTING_DEFAULT);
+
+ ::testing::Mock::VerifyAndClearExpectations(&mock_observer);
+}
+
TEST_F(HostContentSettingsMapTest, GuestProfile) {
TestingProfile profile;
profile.SetGuestSession(true);

Powered by Google App Engine
This is Rietveld 408576698