Chromium Code Reviews| Index: chromecast/browser/cast_media_blocker.h |
| diff --git a/chromecast/browser/cast_media_blocker.h b/chromecast/browser/cast_media_blocker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6488f34aa62d379f2edd6658f05daf31f8552bc |
| --- /dev/null |
| +++ b/chromecast/browser/cast_media_blocker.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |
| +#define CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| + |
| +namespace chromecast { |
| +namespace shell { |
| + |
| +// This class implements a blocking mode for web applications and is used in |
| +// Chromecast internal code. |
| +class CastMediaBlocker : content::WebContentsObserver { |
| + public: |
| + explicit CastMediaBlocker(content::WebContents* web_contents); |
| + ~CastMediaBlocker() override; |
| + |
| + // Sets if the web contents is allowed to play media or not. If media is |
| + // unblocked, previously suspended elements should begin playing again. |
| + void BlockMediaLoading(bool blocked); |
| + |
| + protected: |
| + bool media_loading_blocked() const { return media_loading_blocked_; } |
| + |
| + // Blocks or unblocks the render process from loading new media |
| + // according to |media_loading_blocked_|. |
| + virtual void UpdateMediaBlockedState(); |
| + |
| + private: |
| + // content::WebContentsObserver implementation: |
| + void MediaSessionStateChanged( |
| + bool is_controllable, |
| + bool is_suspended, |
| + const content::MediaMetadata& metadata) override; |
| + |
| + // Whether or not media in the app can be controlled and if media is currently |
| + // suspended. These variables cache arguments from MediaSessionStateChanged(). |
| + bool controllable_; |
| + bool suspended_; |
| + |
| + // Whether or not if this web app should block media from loading. |
| + bool media_loading_blocked_; |
| + |
| + // 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.
|
| + // be set to true when media loading is unblocked, and should be cleared to |
| + // false when media is resumed or media loading is blocked again. |
| + bool pending_resume_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CastMediaBlocker); |
| +}; |
| + |
| +} // namespace shell |
| +} // namespace chromecast |
| + |
| +#endif // CHROMECAST_BROWSER_CAST_MEDIA_BLOCKER_H_ |