timav | f6f6f69 | 2015-03-04 02:19:37 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/browser/media/audio_state_provider.h" |
| 6 | |
| 7 | #include "base/logging.h" |
| 8 | #include "content/browser/media/audio_stream_monitor.h" |
| 9 | #include "content/public/browser/web_contents.h" |
| 10 | |
| 11 | namespace content { |
| 12 | |
| 13 | AudioStateProvider::AudioStateProvider(WebContents* contents) |
| 14 | : web_contents_(contents), |
| 15 | was_recently_audible_(false) { |
| 16 | DCHECK(web_contents_); |
| 17 | } |
| 18 | |
| 19 | bool AudioStateProvider::WasRecentlyAudible() const { |
| 20 | return was_recently_audible_; |
| 21 | } |
| 22 | |
| 23 | void AudioStateProvider::Notify(bool new_state) { |
| 24 | if (was_recently_audible_ != new_state) { |
| 25 | was_recently_audible_ = new_state; |
| 26 | web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | } // namespace content |