Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
|
Zhiqiang Zhang (Slow)
2016/10/26 12:50:37
This is the native user.
| |
| 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 CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | 5 #ifndef CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |
| 6 #define CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | 6 #define CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 9 #include "base/callback_forward.h" | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/callback_forward.h" | 11 #include "content/public/browser/media_session_observer.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 | |
| 12 namespace content { | |
| 13 class WebContents; | |
| 14 } // namespace content | |
| 15 | 12 |
| 16 namespace chromecast { | 13 namespace chromecast { |
| 17 namespace shell { | 14 namespace shell { |
| 18 | 15 |
| 19 // This class implements a blocking mode for web applications and is used in | 16 // This class implements a blocking mode for web applications and is used in |
| 20 // Chromecast internal code. Media is unblocked by default. | 17 // Chromecast internal code. Media is unblocked by default. |
| 21 class CastMediaBlocker : public content::WebContentsObserver { | 18 class CastMediaBlocker : public content::MediaSessionObserver { |
| 22 public: | 19 public: |
| 23 explicit CastMediaBlocker(content::WebContents* web_contents); | 20 explicit CastMediaBlocker(content::MediaSession* media_session); |
| 24 | 21 |
| 25 // Constructor for test. |suspend_cb| and |resume_cb| will be called when | 22 // Constructor for test. |suspend_cb| and |resume_cb| will be called when |
| 26 // Suspend() and Resume() are called. | 23 // Suspend() and Resume() are called. |
| 27 CastMediaBlocker(content::WebContents* web_contents, | 24 CastMediaBlocker(content::MediaSession* media_session, |
| 28 const base::Closure& suspend_cb, | 25 const base::Closure& suspend_cb, |
| 29 const base::Closure& resume_cb); | 26 const base::Closure& resume_cb); |
| 30 | 27 |
| 31 ~CastMediaBlocker() override; | 28 ~CastMediaBlocker() override; |
| 32 | 29 |
| 33 // Sets if the web contents is allowed to play media or not. If media is | 30 // Sets if the web contents is allowed to play media or not. If media is |
| 34 // unblocked, previously suspended elements should begin playing again. | 31 // unblocked, previously suspended elements should begin playing again. |
| 35 void BlockMediaLoading(bool blocked); | 32 void BlockMediaLoading(bool blocked); |
| 36 | 33 |
| 37 // content::WebContentsObserver implementation: | 34 // content::WebContentsObserver implementation: |
|
jam
2016/10/26 17:30:59
nit: update
Zhiqiang Zhang (Slow)
2016/10/26 18:44:25
Done in the splitted CL.
| |
| 38 void MediaSessionStateChanged(bool is_controllable, | 35 void MediaSessionStateChanged(bool is_controllable, |
| 39 bool is_suspended) override; | 36 bool is_suspended) override; |
| 40 | 37 |
| 41 protected: | 38 protected: |
| 42 bool media_loading_blocked() const { return blocked_; } | 39 bool media_loading_blocked() const { return blocked_; } |
| 43 | 40 |
| 44 // Blocks or unblocks the render process from loading new media | 41 // Blocks or unblocks the render process from loading new media |
| 45 // according to |media_loading_blocked_|. | 42 // according to |media_loading_blocked_|. |
| 46 virtual void UpdateMediaBlockedState() {} | 43 virtual void UpdateMediaBlockedState() {} |
| 47 | 44 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 65 bool suspended_; | 62 bool suspended_; |
| 66 bool controllable_; | 63 bool controllable_; |
| 67 | 64 |
| 68 DISALLOW_COPY_AND_ASSIGN(CastMediaBlocker); | 65 DISALLOW_COPY_AND_ASSIGN(CastMediaBlocker); |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 } // namespace shell | 68 } // namespace shell |
| 72 } // namespace chromecast | 69 } // namespace chromecast |
| 73 | 70 |
| 74 #endif // CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | 71 #endif // CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |
| OLD | NEW |