Chromium Code Reviews| 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..042c0a8a7756ecac4e89d26e0d552bd9b651071b 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::MockObserver mock_observer; | 
| + map->AddRevocationObserver(&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'. | 
| 
 
kcarattini
2016/03/17 02:51:22
There's no way to clear or reset all permissions f
 
tsergeant
2016/03/17 06:25:40
Hmm, good point. Under this system the 'Clear & Re
 
 | 
| + 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); |