Commit 08e823a5 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Do not unmute when muted by audio indicator

This CL adds a check in SoundContentSettingObserver to avoid unmuting a
tab if muted by the audio indicator.

Bug: 806482
Change-Id: I433c1fcb7a8e8034a9b100077e2f876e88a7d409
Reviewed-on: https://chromium-review.googlesource.com/891259Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532861}
parent 1cb5c0e6
...@@ -69,6 +69,10 @@ void SoundContentSettingObserver::MuteOrUnmuteIfNecessary() { ...@@ -69,6 +69,10 @@ void SoundContentSettingObserver::MuteOrUnmuteIfNecessary() {
if (!mute && reason == TabMutedReason::MEDIA_CAPTURE) if (!mute && reason == TabMutedReason::MEDIA_CAPTURE)
return; return;
// Do not unmute if we're muted due to audio indicator.
if (!mute && reason == TabMutedReason::AUDIO_INDICATOR)
return;
// Do not override the decisions of an extension. // Do not override the decisions of an extension.
if (reason == TabMutedReason::EXTENSION) if (reason == TabMutedReason::EXTENSION)
return; return;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/ukm/content/source_url_recorder.h" #include "components/ukm/content/source_url_recorder.h"
...@@ -189,6 +190,19 @@ TEST_F(SoundContentSettingObserverTest, DontUnmuteWhenMutedForMediaCapture) { ...@@ -189,6 +190,19 @@ TEST_F(SoundContentSettingObserverTest, DontUnmuteWhenMutedForMediaCapture) {
EXPECT_TRUE(web_contents()->IsAudioMuted()); EXPECT_TRUE(web_contents()->IsAudioMuted());
} }
TEST_F(SoundContentSettingObserverTest, DontUnmuteWhenMutedByAudioIndicator) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableTabAudioMuting);
EXPECT_FALSE(web_contents()->IsAudioMuted());
SetMuteStateForReason(true, TabMutedReason::AUDIO_INDICATOR);
EXPECT_TRUE(web_contents()->IsAudioMuted());
// Navigating to a new URL should not unmute the tab muted by audio indicator.
NavigateAndCommit(GURL(kURL2));
EXPECT_TRUE(web_contents()->IsAudioMuted());
}
TEST_F(SoundContentSettingObserverTest, DontUnmuteChromeTabWhenMuted) { TEST_F(SoundContentSettingObserverTest, DontUnmuteChromeTabWhenMuted) {
NavigateAndCommit(GURL(kChromeURL)); NavigateAndCommit(GURL(kChromeURL));
EXPECT_FALSE(web_contents()->IsAudioMuted()); EXPECT_FALSE(web_contents()->IsAudioMuted());
......
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