Chromium Code Reviews

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

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Updated with new UX design. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "core/html/shadow/MediaRemotingInterstitial.h"
6
7 #include "core/InputTypeNames.h"
8 #include "core/html/HTMLImageElement.h"
9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/shadow/MediaRemotingElements.h"
11 #include "platform/text/PlatformLocale.h"
12
13 namespace blink {
14
15 MediaRemotingInterstitialElements::MediaRemotingInterstitialElements(
16 MediaRemotingInterstitial& interstitial)
17 : HTMLDivElement(interstitial.GetDocument()), interstitial_(interstitial) {
18 SetShadowPseudoId(
19 AtomicString("-internal-media-remoting-interstitial-elements"));
20
21 cast_icon_ = HTMLInputElement::Create(interstitial.GetDocument(), false);
22 cast_icon_->setType(InputTypeNames::button);
23 cast_icon_->SetShadowPseudoId(
24 AtomicString("-internal-media-remoting-cast-icon"));
25 AppendChild(cast_icon_);
26
27 cast_text_message_ =
28 HTMLInputElement::Create(interstitial.GetDocument(), false);
29 cast_text_message_->setType(InputTypeNames::text);
30 cast_text_message_->setValue(VideoElement().GetLocale().QueryString(
31 WebLocalizedString::kMediaRemotingCastText));
32 cast_text_message_->SetShadowPseudoId(
33 AtomicString("-internal-media-remoting-cast-text-message"));
34 AppendChild(cast_text_message_);
35
36 disable_button_ = new MediaRemotingDisableButtonElement(*this);
37 AppendChild(disable_button_);
38 }
39
40 void MediaRemotingInterstitialElements::OnShown() {
41 disable_button_->OnShown();
42 }
43
44 void MediaRemotingInterstitialElements::OnHidden() {
45 disable_button_->OnHidden();
46 }
47
48 HTMLVideoElement& MediaRemotingInterstitialElements::VideoElement() const {
49 return interstitial_->VideoElement();
50 }
51
52 DEFINE_TRACE(MediaRemotingInterstitialElements) {
53 visitor->Trace(interstitial_);
54 visitor->Trace(disable_button_);
55 visitor->Trace(cast_icon_);
56 visitor->Trace(cast_text_message_);
57 HTMLDivElement::Trace(visitor);
58 }
59
60 MediaRemotingInterstitial::MediaRemotingInterstitial(
61 HTMLVideoElement& videoElement)
62 : HTMLDivElement(videoElement.GetDocument()),
63 video_element_(&videoElement) {
64 SetShadowPseudoId(AtomicString("-internal-media-remoting-interstitial"));
65 background_image_ = HTMLImageElement::Create(videoElement.GetDocument());
66 background_image_->SetShadowPseudoId(
67 AtomicString("-internal-media-remoting-background-image"));
68 background_image_->SetSrc(videoElement.getAttribute(HTMLNames::posterAttr));
69 AppendChild(background_image_);
70 interstitial_elements_ = new MediaRemotingInterstitialElements(*this);
71 AppendChild(interstitial_elements_);
72 }
73
74 void MediaRemotingInterstitial::Show() {
75 RemoveInlineStyleProperty(CSSPropertyDisplay);
76 interstitial_elements_->OnShown();
77 }
78
79 void MediaRemotingInterstitial::Hide() {
80 SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
81 interstitial_elements_->OnHidden();
82 }
83
84 void MediaRemotingInterstitial::OnPosterImageChanged() {
85 background_image_->SetSrc(VideoElement().getAttribute(HTMLNames::posterAttr));
86 }
87
88 DEFINE_TRACE(MediaRemotingInterstitial) {
89 visitor->Trace(video_element_);
90 visitor->Trace(interstitial_elements_);
91 visitor->Trace(background_image_);
92 HTMLDivElement::Trace(visitor);
93 }
94
95 } // namespace blink
OLDNEW

Powered by Google App Engine