OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/shadow/MediaRemotingInterstitial.h" | 5 #include "core/html/shadow/MediaRemotingInterstitial.h" |
6 | 6 |
7 #include "core/dom/TaskRunnerHelper.h" | 7 #include "core/dom/TaskRunnerHelper.h" |
8 #include "core/html/HTMLImageElement.h" | 8 #include "core/html/HTMLImageElement.h" |
9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
10 #include "core/html/shadow/MediaRemotingElements.h" | 10 #include "core/html/shadow/MediaRemotingElements.h" |
| 11 #include "platform/RuntimeEnabledFeatures.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 constexpr double kStyleChangeTransSeconds = 0.2; | 15 constexpr double kStyleChangeTransSeconds = 0.2; |
15 constexpr double kHiddenAnimationSeconds = 0.3; | 16 constexpr double kHiddenAnimationSeconds = 0.3; |
16 | 17 |
17 } // namespace | 18 } // namespace |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
(...skipping 12 matching lines...) Expand all Loading... |
33 AtomicString("-internal-media-remoting-background-image")); | 34 AtomicString("-internal-media-remoting-background-image")); |
34 background_image_->SetSrc(videoElement.getAttribute(HTMLNames::posterAttr)); | 35 background_image_->SetSrc(videoElement.getAttribute(HTMLNames::posterAttr)); |
35 AppendChild(background_image_); | 36 AppendChild(background_image_); |
36 | 37 |
37 cast_icon_ = new MediaRemotingCastIconElement(*this); | 38 cast_icon_ = new MediaRemotingCastIconElement(*this); |
38 AppendChild(cast_icon_); | 39 AppendChild(cast_icon_); |
39 | 40 |
40 cast_text_message_ = new MediaRemotingCastMessageElement(*this); | 41 cast_text_message_ = new MediaRemotingCastMessageElement(*this); |
41 AppendChild(cast_text_message_); | 42 AppendChild(cast_text_message_); |
42 | 43 |
43 exit_button_ = new MediaRemotingExitButtonElement(*this); | 44 if (!RuntimeEnabledFeatures::newRemotePlaybackPipelineEnabled()) { |
44 AppendChild(exit_button_); | 45 exit_button_ = new MediaRemotingExitButtonElement(*this); |
| 46 AppendChild(exit_button_); |
| 47 } |
45 } | 48 } |
46 | 49 |
47 void MediaRemotingInterstitial::Show() { | 50 void MediaRemotingInterstitial::Show() { |
48 DCHECK(!should_be_visible_); | 51 DCHECK(!should_be_visible_); |
49 if (toggle_insterstitial_timer_.IsActive()) | 52 if (toggle_insterstitial_timer_.IsActive()) |
50 toggle_insterstitial_timer_.Stop(); | 53 toggle_insterstitial_timer_.Stop(); |
51 should_be_visible_ = true; | 54 should_be_visible_ = true; |
52 RemoveInlineStyleProperty(CSSPropertyDisplay); | 55 RemoveInlineStyleProperty(CSSPropertyDisplay); |
53 exit_button_->OnShown(); | 56 if (exit_button_) |
| 57 exit_button_->OnShown(); |
54 toggle_insterstitial_timer_.StartOneShot(kStyleChangeTransSeconds, | 58 toggle_insterstitial_timer_.StartOneShot(kStyleChangeTransSeconds, |
55 BLINK_FROM_HERE); | 59 BLINK_FROM_HERE); |
56 } | 60 } |
57 | 61 |
58 void MediaRemotingInterstitial::Hide() { | 62 void MediaRemotingInterstitial::Hide() { |
59 DCHECK(should_be_visible_); | 63 DCHECK(should_be_visible_); |
60 if (toggle_insterstitial_timer_.IsActive()) | 64 if (toggle_insterstitial_timer_.IsActive()) |
61 toggle_insterstitial_timer_.Stop(); | 65 toggle_insterstitial_timer_.Stop(); |
62 should_be_visible_ = false; | 66 should_be_visible_ = false; |
63 SetInlineStyleProperty(CSSPropertyOpacity, 0, | 67 SetInlineStyleProperty(CSSPropertyOpacity, 0, |
64 CSSPrimitiveValue::UnitType::kNumber); | 68 CSSPrimitiveValue::UnitType::kNumber); |
65 exit_button_->OnHidden(); | 69 if (exit_button_) |
| 70 exit_button_->OnHidden(); |
66 toggle_insterstitial_timer_.StartOneShot(kHiddenAnimationSeconds, | 71 toggle_insterstitial_timer_.StartOneShot(kHiddenAnimationSeconds, |
67 BLINK_FROM_HERE); | 72 BLINK_FROM_HERE); |
68 } | 73 } |
69 | 74 |
70 void MediaRemotingInterstitial::ToggleInterstitialTimerFired(TimerBase*) { | 75 void MediaRemotingInterstitial::ToggleInterstitialTimerFired(TimerBase*) { |
71 toggle_insterstitial_timer_.Stop(); | 76 toggle_insterstitial_timer_.Stop(); |
72 if (should_be_visible_) { | 77 if (should_be_visible_) { |
73 SetInlineStyleProperty(CSSPropertyOpacity, 1, | 78 SetInlineStyleProperty(CSSPropertyOpacity, 1, |
74 CSSPrimitiveValue::UnitType::kNumber); | 79 CSSPrimitiveValue::UnitType::kNumber); |
75 } else { | 80 } else { |
(...skipping 16 matching lines...) Expand all Loading... |
92 DEFINE_TRACE(MediaRemotingInterstitial) { | 97 DEFINE_TRACE(MediaRemotingInterstitial) { |
93 visitor->Trace(video_element_); | 98 visitor->Trace(video_element_); |
94 visitor->Trace(background_image_); | 99 visitor->Trace(background_image_); |
95 visitor->Trace(exit_button_); | 100 visitor->Trace(exit_button_); |
96 visitor->Trace(cast_icon_); | 101 visitor->Trace(cast_icon_); |
97 visitor->Trace(cast_text_message_); | 102 visitor->Trace(cast_text_message_); |
98 HTMLDivElement::Trace(visitor); | 103 HTMLDivElement::Trace(visitor); |
99 } | 104 } |
100 | 105 |
101 } // namespace blink | 106 } // namespace blink |
OLD | NEW |