| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class PowerSaveBlocker; | 21 class PowerSaveBlocker; |
| 21 | 22 |
| 22 // This class manages all RenderFrame based media related managers at the | 23 // This class manages all RenderFrame based media related managers at the |
| 23 // browser side. It receives IPC messages from media RenderFrameObservers and | 24 // browser side. It receives IPC messages from media RenderFrameObservers and |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 void WasHidden() override; | 41 void WasHidden() override; |
| 41 | 42 |
| 42 bool has_audio_power_save_blocker_for_testing() const { | 43 bool has_audio_power_save_blocker_for_testing() const { |
| 43 return audio_power_save_blocker_; | 44 return audio_power_save_blocker_; |
| 44 } | 45 } |
| 45 | 46 |
| 46 bool has_video_power_save_blocker_for_testing() const { | 47 bool has_video_power_save_blocker_for_testing() const { |
| 47 return video_power_save_blocker_; | 48 return video_power_save_blocker_; |
| 48 } | 49 } |
| 49 | 50 |
| 51 // Executes |on_focus_cb| once the given render frame has audio focus. Will |
| 52 // be run on the calling thread. Clients are responsible for invalidating |
| 53 // |on_focus_cb| if their lifetime changes or the callback is unnecessary. |
| 54 static void HasAudioFocus(int render_process_id, |
| 55 int render_frame_id, |
| 56 const base::Closure& on_focus_cb); |
| 57 |
| 58 protected: |
| 59 virtual void CheckFocus(int render_frame_id, |
| 60 const base::Closure& on_focus_cb); |
| 61 |
| 50 private: | 62 private: |
| 51 void OnMediaDestroyedNotification(RenderFrameHost* render_frame_host, | 63 void OnMediaDestroyedNotification(RenderFrameHost* render_frame_host, |
| 52 int64_t player_cookie); | 64 int64_t player_cookie); |
| 53 void OnMediaPlayingNotification(RenderFrameHost* render_frame_host, | 65 void OnMediaPlayingNotification(RenderFrameHost* render_frame_host, |
| 54 int64_t player_cookie, | 66 int64_t player_cookie, |
| 55 bool has_video, | 67 bool has_video, |
| 56 bool has_audio, | 68 bool has_audio, |
| 57 bool is_remote, | 69 bool is_remote, |
| 58 base::TimeDelta duration); | 70 base::TimeDelta duration); |
| 59 void OnMediaPausedNotification(RenderFrameHost* render_frame_host, | 71 void OnMediaPausedNotification(RenderFrameHost* render_frame_host, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 ActiveMediaPlayerMap active_video_players_; | 103 ActiveMediaPlayerMap active_video_players_; |
| 92 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | 104 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; |
| 93 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | 105 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; |
| 94 | 106 |
| 95 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 107 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
| 96 }; | 108 }; |
| 97 | 109 |
| 98 } // namespace content | 110 } // namespace content |
| 99 | 111 |
| 100 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 112 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |