summaryrefslogtreecommitdiffstats
path: root/content/browser/media/audio_state_provider.cc
blob: e09356a561f00cb43a524549eede96ea7c8caf2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/media/audio_state_provider.h"

#include "base/logging.h"
#include "content/browser/media/audio_stream_monitor.h"
#include "content/public/browser/web_contents.h"

namespace content {

AudioStateProvider::AudioStateProvider(WebContents* contents)
    : web_contents_(contents),
      was_recently_audible_(false) {
  DCHECK(web_contents_);
}

bool AudioStateProvider::WasRecentlyAudible() const {
  return was_recently_audible_;
}

void AudioStateProvider::Notify(bool new_state) {
  if (was_recently_audible_ != new_state) {
    was_recently_audible_ = new_state;
    web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
  }
}

} // namespace content