Commit b630c92e authored by Illia Klimov's avatar Illia Klimov Committed by Chromium LUCI CQ

No ContentSettings registration for PERIODIC_BACKGROUND_SYNC.

PERIODIC_BACKGROUND_SYNC is registered in ContentSettingsRegistry but
does not contain any data. EphemeralProvider will be removed in the
future cleanup. Due to that reason, I remove the registration of
PERIODIC_BACKGROUND_SYNC.

Bug: 1149381
Change-Id: Ifdb68504733ee987115fe9801f0eadbb064c6c31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577471Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Commit-Queue: Illia Klimov <elklm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834690}
parent a4c00ba1
...@@ -1838,105 +1838,6 @@ void ReloadProviders(PrefService* pref_service, ...@@ -1838,105 +1838,6 @@ void ReloadProviders(PrefService* pref_service,
HostContentSettingsMap::EPHEMERAL_PROVIDER); HostContentSettingsMap::EPHEMERAL_PROVIDER);
} }
// Tests that restarting only removes ephemeral permissions.
TEST_F(HostContentSettingsMapTest, MixedEphemeralAndPersistentPermissions) {
TestingProfile profile;
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(&profile);
content_settings::ContentSettingsRegistry::GetInstance()->ResetForTest();
ReloadProviders(profile.GetPrefs(), map);
// The following two types are used as samples of ephemeral and persistent
// permission types. They can be replaced with any other type if required.
const ContentSettingsType ephemeral_type =
ContentSettingsType::PERIODIC_BACKGROUND_SYNC;
const ContentSettingsType persistent_type = ContentSettingsType::GEOLOCATION;
EXPECT_EQ(content_settings::ContentSettingsInfo::EPHEMERAL,
content_settings::ContentSettingsRegistry::GetInstance()
->Get(ephemeral_type)
->storage_behavior());
EXPECT_EQ(content_settings::ContentSettingsInfo::PERSISTENT,
content_settings::ContentSettingsRegistry::GetInstance()
->Get(persistent_type)
->storage_behavior());
const GURL url("https://example.com");
// |PERIODIC_BACKGROUND_SYNC| does not support ASK, set to ALLOW.
map->SetDefaultContentSetting(ephemeral_type, CONTENT_SETTING_ALLOW);
map->SetDefaultContentSetting(persistent_type, CONTENT_SETTING_ASK);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url, url, ephemeral_type));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(url, url, persistent_type));
// Set permission for both types and expect receiving it correctly.
map->SetContentSettingDefaultScope(url, url, ephemeral_type,
CONTENT_SETTING_BLOCK);
map->SetContentSettingDefaultScope(url, url, persistent_type,
CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(url, url, ephemeral_type));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(url, url, persistent_type));
// Restart and expect reset of ephemeral permission to |ALLOW|, while keeping
// the permission of persistent type.
ReloadProviders(profile.GetPrefs(), map);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url, url, ephemeral_type));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(url, url, persistent_type));
}
// Test that directly writing a value to PrefProvider doesn't affect ephmeral
// types.
TEST_F(HostContentSettingsMapTest, EphemeralTypeDoesntReadFromPrefProvider) {
TestingProfile profile;
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(&profile);
content_settings::ContentSettingsRegistry::GetInstance()->ResetForTest();
ReloadProviders(profile.GetPrefs(), map);
// ContentSettingsType::PERIODIC_BACKGROUND_SYNC is used as a sample of
// ephemeral permission type. It can be replaced with any other type if
// required.
const ContentSettingsType ephemeral_type =
ContentSettingsType::PERIODIC_BACKGROUND_SYNC;
EXPECT_EQ(content_settings::ContentSettingsInfo::EPHEMERAL,
content_settings::ContentSettingsRegistry::GetInstance()
->Get(ephemeral_type)
->storage_behavior());
const GURL url("https://example.com");
const ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url);
map->SetDefaultContentSetting(ephemeral_type, CONTENT_SETTING_ALLOW);
content_settings::PrefProvider pref_provider(profile.GetPrefs(), true, true,
false);
pref_provider.SetWebsiteSetting(
pattern, pattern, ephemeral_type,
std::make_unique<base::Value>(CONTENT_SETTING_BLOCK), {});
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url, url, ephemeral_type));
ReloadProviders(profile.GetPrefs(), map);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url, url, ephemeral_type));
pref_provider.ShutdownOnUIThread();
}
TEST_F(HostContentSettingsMapTest, GetPatternsFromScopingType) { TEST_F(HostContentSettingsMapTest, GetPatternsFromScopingType) {
const GURL primary_url("http://a.b.example1.com:8080"); const GURL primary_url("http://a.b.example1.com:8080");
const GURL secondary_url("http://a.b.example2.com:8080"); const GURL secondary_url("http://a.b.example2.com:8080");
......
...@@ -470,17 +470,6 @@ void ContentSettingsRegistry::Init() { ...@@ -470,17 +470,6 @@ void ContentSettingsRegistry::Init() {
ContentSettingsInfo::PERSISTENT, ContentSettingsInfo::PERSISTENT,
ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY);
Register(ContentSettingsType::PERIODIC_BACKGROUND_SYNC,
"periodic-background-sync", CONTENT_SETTING_ALLOW,
WebsiteSettingsInfo::UNSYNCABLE, AllowlistedSchemes(),
ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK),
WebsiteSettingsInfo::SINGLE_ORIGIN_ONLY_SCOPE,
WebsiteSettingsRegistry::DESKTOP |
WebsiteSettingsRegistry::PLATFORM_ANDROID,
ContentSettingsInfo::INHERIT_IN_INCOGNITO,
ContentSettingsInfo::EPHEMERAL,
ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY);
Register(ContentSettingsType::BLUETOOTH_SCANNING, "bluetooth-scanning", Register(ContentSettingsType::BLUETOOTH_SCANNING, "bluetooth-scanning",
CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE,
AllowlistedSchemes(), AllowlistedSchemes(),
......
...@@ -126,6 +126,8 @@ enum class ContentSettingsType : int32_t { ...@@ -126,6 +126,8 @@ enum class ContentSettingsType : int32_t {
// Nothing is stored in this setting at present. Please refer to // Nothing is stored in this setting at present. Please refer to
// PeriodicBackgroundSyncPermissionContext for details on how this permission // PeriodicBackgroundSyncPermissionContext for details on how this permission
// is ascertained. // is ascertained.
// This content setting is not registered because it does not require access
// to any existing providers.
PERIODIC_BACKGROUND_SYNC, PERIODIC_BACKGROUND_SYNC,
// Content setting which stores whether to allow sites to ask for permission // Content setting which stores whether to allow sites to ask for permission
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment