Commit 54b245ad authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Autoplay] Fix check on Page Info UI

The pref does not sync automatically with the default content
setting anymore so we should only use "Automatic" if the pref
is enabled and if the effective setting is allow.

BUG=865548

Change-Id: I869f82ac53ab5d5986e89eabdd03519ae11f38d5
Reviewed-on: https://chromium-review.googlesource.com/1175206
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583104}
parent 0182b0ff
......@@ -339,12 +339,12 @@ base::string16 PageInfoUI::PermissionActionToUIString(
#if !defined(OS_ANDROID)
if (type == CONTENT_SETTINGS_TYPE_SOUND &&
base::FeatureList::IsEnabled(media::kAutoplaySoundSettings)) {
// If the block autoplay enabled preference is enabled then the
// sound default setting has to be ALLOW and we will return a custom
// string indicating that Chrome is controlling autoplay and sound
// If the block autoplay enabled preference is enabled and the
// sound default setting is ALLOW, we will return a custom string
// indicating that Chrome is controlling autoplay and sound
// automatically.
if (profile->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled)) {
DCHECK_EQ(ContentSetting::CONTENT_SETTING_ALLOW, effective_setting);
if (profile->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled) &&
effective_setting == ContentSetting::CONTENT_SETTING_ALLOW) {
return l10n_util::GetStringUTF16(
IDS_PAGE_INFO_BUTTON_TEXT_AUTOMATIC_BY_DEFAULT);
}
......
......@@ -1160,10 +1160,29 @@ TEST_F(UnifiedAutoplaySoundSettingsPageInfoTest, DefaultAllow_PrefOff) {
GetSoundSettingString(CONTENT_SETTING_BLOCK));
}
// This test checks that the strings for the sound settings dropdown when
// This test checks the strings for the sound settings dropdown when
// the default sound setting is block. The three options should be
// Block (default), Allow and Mute.
TEST_F(UnifiedAutoplaySoundSettingsPageInfoTest, DefaultBlock_PrefOn) {
SetDefaultSoundContentSetting(CONTENT_SETTING_BLOCK);
SetAutoplayPrefValue(true);
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_PAGE_INFO_BUTTON_TEXT_MUTED_BY_DEFAULT),
GetDefaultSoundSettingString());
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_PAGE_INFO_BUTTON_TEXT_ALLOWED_BY_USER),
GetSoundSettingString(CONTENT_SETTING_ALLOW));
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PAGE_INFO_BUTTON_TEXT_MUTED_BY_USER),
GetSoundSettingString(CONTENT_SETTING_BLOCK));
}
// This test checks the strings for the sound settings dropdown when
// the default sound setting is block. The three options should be
// Block (default), Allow and Mute.
TEST_F(UnifiedAutoplaySoundSettingsPageInfoTest, DefaultBlock) {
TEST_F(UnifiedAutoplaySoundSettingsPageInfoTest, DefaultBlock_PrefOff) {
SetDefaultSoundContentSetting(CONTENT_SETTING_BLOCK);
SetAutoplayPrefValue(false);
......
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