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

Side by Side Diff: content/browser/android/media_players_observer.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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
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/android/media_players_observer.h"
6
7 #include <climits>
8
9 #include "base/logging.h"
10 #include "content/public/browser/web_contents.h"
11
12 namespace content {
13
14 MediaPlayersObserver::MediaPlayersObserver(WebContents* web_contents)
15 : AudioStateProvider(web_contents) {
16 }
17
18 MediaPlayersObserver::~MediaPlayersObserver() {}
19
20 bool MediaPlayersObserver::IsAudioStateAvailable() const {
21 return true;
22 }
23
24 // This audio state provider does not have a monitor
25 AudioStreamMonitor* MediaPlayersObserver::audio_stream_monitor() {
26 return nullptr;
27 }
28
29 void MediaPlayersObserver::OnAudibleStateChanged(RenderFrameHost* rfh,
30 int player_id,
31 bool is_audible) {
32 audio_status_map_[Key(rfh, player_id)] = is_audible;
33 UpdateStatusAndNotify();
34 }
35
36 void MediaPlayersObserver::RemovePlayer(RenderFrameHost* rfh, int player_id) {
37 audio_status_map_.erase(Key(rfh, player_id));
38 UpdateStatusAndNotify();
39 }
40
41 void MediaPlayersObserver::RenderFrameDeleted(RenderFrameHost* rfh) {
42 StatusMap::iterator begin = audio_status_map_.lower_bound(Key(rfh, 0));
43 StatusMap::iterator end = audio_status_map_.upper_bound(Key(rfh, INT_MAX));
44 audio_status_map_.erase(begin, end);
45 UpdateStatusAndNotify();
46 }
47
48 void MediaPlayersObserver::UpdateStatusAndNotify() {
49 for (const auto& player_status : audio_status_map_) {
50 if (player_status.second) {
51 Notify(true); // at least one player is making noise
52 return;
53 }
54 }
55
56 Notify(false);
57 }
58
59 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/media_players_observer.h ('k') | content/browser/media/android/browser_media_player_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698