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

Side by Side Diff: chromecast/browser/cast_media_blocker.h

Issue 2450433002: Let CastMediaBlocker observe MediaSession instead of WebContents (Closed)
Patch Set: fixed tests Created 4 years, 1 month 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 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"
derekjchow1 2016/10/24 18:50:33 callback & callback_forward seems redundant.
Zhiqiang Zhang (Slow) 2016/10/28 10:36:52 They are all removed since we don't use callback a
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 {
derekjchow1 2016/10/24 18:50:33 We actually inherit from this class internally, an
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:
(...skipping 27 matching lines...) Expand all
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_
OLDNEW
« no previous file with comments | « no previous file | chromecast/browser/cast_media_blocker.cc » ('j') | chromecast/browser/cast_media_blocker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698