| Index: content/browser/media/audio_stream_monitor.cc
|
| diff --git a/content/browser/media/audio_stream_monitor.cc b/content/browser/media/audio_stream_monitor.cc
|
| index 4c0bc0a5d720c6ce0debbadd6587ac96b8a0fa75..1d2f76f7f2c02f986f5b52122834363ff96be1e8 100644
|
| --- a/content/browser/media/audio_stream_monitor.cc
|
| +++ b/content/browser/media/audio_stream_monitor.cc
|
| @@ -21,36 +21,23 @@
|
| WebContentsImpl* const web_contents =
|
| static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(
|
| RenderFrameHost::FromID(render_process_id, render_frame_id)));
|
| -
|
| - if (!web_contents)
|
| - return nullptr;
|
| -
|
| - AudioStateProvider* audio_provider = web_contents->audio_state_provider();
|
| - return audio_provider ? audio_provider->audio_stream_monitor() : nullptr;
|
| + return web_contents ? web_contents->audio_stream_monitor() : NULL;
|
| }
|
|
|
| } // namespace
|
|
|
| AudioStreamMonitor::AudioStreamMonitor(WebContents* contents)
|
| - : AudioStateProvider(contents),
|
| - clock_(&default_tick_clock_)
|
| -{
|
| + : web_contents_(contents),
|
| + clock_(&default_tick_clock_),
|
| + was_recently_audible_(false) {
|
| + DCHECK(web_contents_);
|
| }
|
|
|
| AudioStreamMonitor::~AudioStreamMonitor() {}
|
|
|
| -bool AudioStreamMonitor::IsAudioStateAvailable() const {
|
| - return media::AudioOutputController::will_monitor_audio_levels();
|
| -}
|
| -
|
| -// This provider is the monitor.
|
| -AudioStreamMonitor* AudioStreamMonitor::audio_stream_monitor() {
|
| - return this;
|
| -}
|
| -
|
| bool AudioStreamMonitor::WasRecentlyAudible() const {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - return AudioStateProvider::WasRecentlyAudible();
|
| + return was_recently_audible_;
|
| }
|
|
|
| // static
|
| @@ -59,7 +46,7 @@
|
| int render_frame_id,
|
| int stream_id,
|
| const ReadPowerAndClipCallback& read_power_callback) {
|
| - if (!media::AudioOutputController::will_monitor_audio_levels())
|
| + if (!monitoring_available())
|
| return;
|
| BrowserThread::PostTask(BrowserThread::UI,
|
| FROM_HERE,
|
| @@ -74,7 +61,7 @@
|
| void AudioStreamMonitor::StopMonitoringStream(int render_process_id,
|
| int render_frame_id,
|
| int stream_id) {
|
| - if (!media::AudioOutputController::will_monitor_audio_levels())
|
| + if (!monitoring_available())
|
| return;
|
| BrowserThread::PostTask(BrowserThread::UI,
|
| FROM_HERE,
|
| @@ -151,12 +138,16 @@
|
| }
|
|
|
| void AudioStreamMonitor::MaybeToggle() {
|
| + const bool indicator_was_on = was_recently_audible_;
|
| const base::TimeTicks off_time =
|
| last_blurt_time_ + base::TimeDelta::FromMilliseconds(kHoldOnMilliseconds);
|
| const base::TimeTicks now = clock_->NowTicks();
|
| const bool should_indicator_be_on = now < off_time;
|
|
|
| - Notify(should_indicator_be_on);
|
| + if (should_indicator_be_on != indicator_was_on) {
|
| + was_recently_audible_ = should_indicator_be_on;
|
| + web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
|
| + }
|
|
|
| if (!should_indicator_be_on) {
|
| off_timer_.Stop();
|
|
|