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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Rebased. Created 3 years, 8 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
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 21 matching lines...) Expand all
32 #include "core/dom/Attribute.h" 32 #include "core/dom/Attribute.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/Fullscreen.h" 35 #include "core/dom/Fullscreen.h"
36 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/frame/ImageBitmap.h" 37 #include "core/frame/ImageBitmap.h"
38 #include "core/frame/LocalDOMWindow.h" 38 #include "core/frame/LocalDOMWindow.h"
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/html/media/MediaCustomControlsFullscreenDetector.h" 40 #include "core/html/media/MediaCustomControlsFullscreenDetector.h"
41 #include "core/html/parser/HTMLParserIdioms.h" 41 #include "core/html/parser/HTMLParserIdioms.h"
42 #include "core/html/shadow/MediaRemotingInterstitial.h"
42 #include "core/imagebitmap/ImageBitmapOptions.h" 43 #include "core/imagebitmap/ImageBitmapOptions.h"
43 #include "core/layout/LayoutImage.h" 44 #include "core/layout/LayoutImage.h"
44 #include "core/layout/LayoutVideo.h" 45 #include "core/layout/LayoutVideo.h"
45 #include "platform/Histogram.h" 46 #include "platform/Histogram.h"
46 #include "platform/RuntimeEnabledFeatures.h" 47 #include "platform/RuntimeEnabledFeatures.h"
47 #include "platform/UserGestureIndicator.h" 48 #include "platform/UserGestureIndicator.h"
48 #include "platform/graphics/GraphicsContext.h" 49 #include "platform/graphics/GraphicsContext.h"
49 #include "platform/graphics/ImageBuffer.h" 50 #include "platform/graphics/ImageBuffer.h"
50 #include "platform/graphics/gpu/Extensions3DUtil.h" 51 #include "platform/graphics/gpu/Extensions3DUtil.h"
51 #include "public/platform/WebCanvas.h" 52 #include "public/platform/WebCanvas.h"
52 53
53 namespace blink { 54 namespace blink {
54 55
55 using namespace HTMLNames; 56 using namespace HTMLNames;
56 57
57 namespace { 58 namespace {
58 59
59 // This enum is used to record histograms. Do not reorder. 60 // This enum is used to record histograms. Do not reorder.
60 enum VideoPersistenceControlsType { 61 enum VideoPersistenceControlsType {
61 kVideoPersistenceControlsTypeNative = 0, 62 kVideoPersistenceControlsTypeNative = 0,
62 kVideoPersistenceControlsTypeCustom, 63 kVideoPersistenceControlsTypeCustom,
63 kVideoPersistenceControlsTypeCount 64 kVideoPersistenceControlsTypeCount
64 }; 65 };
65 66
66 } // anonymous namespace 67 } // anonymous namespace
67 68
68 inline HTMLVideoElement::HTMLVideoElement(Document& document) 69 inline HTMLVideoElement::HTMLVideoElement(Document& document)
69 : HTMLMediaElement(videoTag, document) { 70 : HTMLMediaElement(videoTag, document),
71 media_remoting_status_(MediaRemotingStatus::kNotStarted),
72 remoting_interstitial_(nullptr) {
70 if (document.GetSettings()) { 73 if (document.GetSettings()) {
71 default_poster_url_ = 74 default_poster_url_ =
72 AtomicString(document.GetSettings()->GetDefaultVideoPosterURL()); 75 AtomicString(document.GetSettings()->GetDefaultVideoPosterURL());
73 } 76 }
74 77
75 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { 78 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) {
76 custom_controls_fullscreen_detector_ = 79 custom_controls_fullscreen_detector_ =
77 new MediaCustomControlsFullscreenDetector(*this); 80 new MediaCustomControlsFullscreenDetector(*this);
78 } 81 }
79 } 82 }
80 83
81 HTMLVideoElement* HTMLVideoElement::Create(Document& document) { 84 HTMLVideoElement* HTMLVideoElement::Create(Document& document) {
82 HTMLVideoElement* video = new HTMLVideoElement(document); 85 HTMLVideoElement* video = new HTMLVideoElement(document);
83 video->EnsureUserAgentShadowRoot(); 86 video->EnsureUserAgentShadowRoot();
84 video->SuspendIfNeeded(); 87 video->SuspendIfNeeded();
85 return video; 88 return video;
86 } 89 }
87 90
88 DEFINE_TRACE(HTMLVideoElement) { 91 DEFINE_TRACE(HTMLVideoElement) {
89 visitor->Trace(image_loader_); 92 visitor->Trace(image_loader_);
90 visitor->Trace(custom_controls_fullscreen_detector_); 93 visitor->Trace(custom_controls_fullscreen_detector_);
94 visitor->Trace(remoting_interstitial_);
91 HTMLMediaElement::Trace(visitor); 95 HTMLMediaElement::Trace(visitor);
92 } 96 }
93 97
94 Node::InsertionNotificationRequest HTMLVideoElement::InsertedInto( 98 Node::InsertionNotificationRequest HTMLVideoElement::InsertedInto(
95 ContainerNode* insertion_point) { 99 ContainerNode* insertion_point) {
96 if (insertion_point->isConnected() && custom_controls_fullscreen_detector_) 100 if (insertion_point->isConnected() && custom_controls_fullscreen_detector_)
97 custom_controls_fullscreen_detector_->Attach(); 101 custom_controls_fullscreen_detector_->Attach();
98 102
99 return HTMLMediaElement::InsertedInto(insertion_point); 103 return HTMLMediaElement::InsertedInto(insertion_point);
100 } 104 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (!image_loader_) 176 if (!image_loader_)
173 image_loader_ = HTMLImageLoader::Create(this); 177 image_loader_ = HTMLImageLoader::Create(this);
174 image_loader_->UpdateFromElement(ImageLoader::kUpdateIgnorePreviousError); 178 image_loader_->UpdateFromElement(ImageLoader::kUpdateIgnorePreviousError);
175 } else { 179 } else {
176 if (GetLayoutObject()) 180 if (GetLayoutObject())
177 ToLayoutImage(GetLayoutObject())->ImageResource()->SetImageResource(0); 181 ToLayoutImage(GetLayoutObject())->ImageResource()->SetImageResource(0);
178 } 182 }
179 // Notify the player when the poster image URL changes. 183 // Notify the player when the poster image URL changes.
180 if (GetWebMediaPlayer()) 184 if (GetWebMediaPlayer())
181 GetWebMediaPlayer()->SetPoster(PosterImageURL()); 185 GetWebMediaPlayer()->SetPoster(PosterImageURL());
186 // Media remoting doesn't show the original poster image, instead, it shows
187 // a grayscaled and blurred copy.
188 if (remoting_interstitial_)
189 remoting_interstitial_->OnPosterImageChanged();
182 } else { 190 } else {
183 HTMLMediaElement::ParseAttribute(params); 191 HTMLMediaElement::ParseAttribute(params);
184 } 192 }
185 } 193 }
186 194
187 unsigned HTMLVideoElement::videoWidth() const { 195 unsigned HTMLVideoElement::videoWidth() const {
188 if (!GetWebMediaPlayer()) 196 if (!GetWebMediaPlayer())
189 return 0; 197 return 0;
190 return GetWebMediaPlayer()->NaturalSize().width; 198 return GetWebMediaPlayer()->NaturalSize().width;
191 } 199 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 exception_state)) 484 exception_state))
477 return ScriptPromise(); 485 return ScriptPromise();
478 if (!ImageBitmap::IsResizeOptionValid(options, exception_state)) 486 if (!ImageBitmap::IsResizeOptionValid(options, exception_state))
479 return ScriptPromise(); 487 return ScriptPromise();
480 return ImageBitmapSource::FulfillImageBitmap( 488 return ImageBitmapSource::FulfillImageBitmap(
481 script_state, ImageBitmap::Create( 489 script_state, ImageBitmap::Create(
482 this, crop_rect, 490 this, crop_rect,
483 event_target.ToLocalDOMWindow()->document(), options)); 491 event_target.ToLocalDOMWindow()->document(), options));
484 } 492 }
485 493
494 void HTMLVideoElement::MediaRemotingStarted() {
495 DCHECK_EQ(media_remoting_status_, MediaRemotingStatus::kNotStarted);
496 media_remoting_status_ = MediaRemotingStatus::kStarted;
497 if (!remoting_interstitial_) {
498 remoting_interstitial_ = new MediaRemotingInterstitial(*this);
499 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot();
500 shadow_root.InsertBefore(remoting_interstitial_, shadow_root.FirstChild());
501 HTMLMediaElement::AssertShadowRootChildren(shadow_root);
502 }
503 remoting_interstitial_->Show();
504 }
505
506 void HTMLVideoElement::MediaRemotingStopped() {
507 if (media_remoting_status_ != MediaRemotingStatus::kDisabled)
508 media_remoting_status_ = MediaRemotingStatus::kNotStarted;
509 DCHECK(remoting_interstitial_);
510 remoting_interstitial_->Hide();
511 }
512
513 void HTMLVideoElement::DisableMediaRemoting() {
514 if (GetWebMediaPlayer())
515 GetWebMediaPlayer()->RequestRemotePlaybackDisabled(true);
516 media_remoting_status_ = MediaRemotingStatus::kDisabled;
517 MediaRemotingStopped();
518 }
519
486 } // namespace blink 520 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698