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

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

Issue 2330243002: Add CastMediaBlocker and BrowserTest (Closed)
Patch Set: State machine Created 4 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 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 : public content::WebContentsObserver {
17 public:
18 explicit CastMediaBlocker(content::WebContents* web_contents);
halliwell 2016/09/13 23:59:47 nit, forward-declare WebContents
derekjchow1 2016/09/14 00:14:05 Done.
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 state_ == 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 enum BlockState {
34 BLOCKED, // All media playback should be blocked.
35 UNBLOCKING, // Media playback should be resumed at next oppurtunity.
36 UNBLOCKED, // Media playback should not be blocked.
37 };
38
39 // content::WebContentsObserver implementation:
40 void MediaSessionStateChanged(
41 bool is_controllable,
42 bool is_suspended,
43 const base::Optional<content::MediaMetadata>& metadata) override;
44
45 // Whether or not media in the app can be controlled and if media is currently
46 // suspended. These variables cache arguments from MediaSessionStateChanged().
47 bool controllable_;
48 bool suspended_;
49
50 BlockState state_;
51
52 DISALLOW_COPY_AND_ASSIGN(CastMediaBlocker);
53 };
54
55 } // namespace shell
56 } // namespace chromecast
57
58 #endif // CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698