Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: content/browser/media/audio_stream_monitor.cc

Issue 1215713021: Reverted the code for the non-interactive audible tab notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification
Patch Set: Fixed indent Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 bcc1e7649b955fbf4a9170a49582bcd5f480f622..2f6a7e45ce0eb1205a10417d1d81cc7d1cf712bd 100644
--- a/content/browser/media/audio_stream_monitor.cc
+++ b/content/browser/media/audio_stream_monitor.cc
@@ -22,35 +22,24 @@ AudioStreamMonitor* AudioStreamMonitorFromRenderFrame(int render_process_id,
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() : nullptr;
}
} // 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 +48,7 @@ void AudioStreamMonitor::StartMonitoringStream(
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,
@@ -152,12 +141,16 @@ void AudioStreamMonitor::Poll() {
}
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();
« no previous file with comments | « content/browser/media/audio_stream_monitor.h ('k') | content/browser/media/audio_stream_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698