OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | |
6 #define CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "content/public/browser/web_contents_observer.h" | |
10 | |
11 namespace chromecast { | |
12 namespace shell { | |
13 | |
14 // This class implements a blocking mode for web applications and is used in | |
15 // Chromecast internal code. | |
16 class CastMediaBlocker : content::WebContentsObserver { | |
17 public: | |
18 explicit CastMediaBlocker(content::WebContents* web_contents); | |
19 ~CastMediaBlocker() override; | |
20 | |
21 // Sets if the web contents is allowed to play media or not. If media is | |
22 // unblocked, previously suspended elements should begin playing again. | |
23 void BlockMediaLoading(bool blocked); | |
24 | |
25 protected: | |
26 bool media_loading_blocked() const { return media_loading_blocked_; } | |
27 | |
28 // Blocks or unblocks the render process from loading new media | |
29 // according to |media_loading_blocked_|. | |
30 virtual void UpdateMediaBlockedState(); | |
31 | |
32 private: | |
33 // content::WebContentsObserver implementation: | |
34 void MediaSessionStateChanged( | |
35 bool is_controllable, | |
36 bool is_suspended, | |
37 const content::MediaMetadata& metadata) override; | |
38 | |
39 // Whether or not media in the app can be controlled and if media is currently | |
40 // suspended. These variables cache arguments from MediaSessionStateChanged(). | |
41 bool controllable_; | |
42 bool suspended_; | |
43 | |
44 // Whether or not if this web app should block media from loading. | |
45 bool media_loading_blocked_; | |
46 | |
47 // Whether or not this web app should try to resume playing media. Should only | |
byungchul
2016/09/12 23:32:59
"resume playing media when media loading is unbloc
derekjchow1
2016/09/13 17:36:44
Done. Take a look at the most recent patchset.
| |
48 // be set to true when media loading is unblocked, and should be cleared to | |
49 // false when media is resumed or media loading is blocked again. | |
50 bool pending_resume_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(CastMediaBlocker); | |
53 }; | |
54 | |
55 } // namespace shell | |
56 } // namespace chromecast | |
57 | |
58 #endif // CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ | |
OLD | NEW |