OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "core/dom/Fullscreen.h" | 31 #include "core/dom/Fullscreen.h" |
32 #include "core/dom/MutationCallback.h" | 32 #include "core/dom/MutationCallback.h" |
33 #include "core/dom/MutationObserver.h" | 33 #include "core/dom/MutationObserver.h" |
34 #include "core/dom/MutationObserverInit.h" | 34 #include "core/dom/MutationObserverInit.h" |
35 #include "core/dom/MutationRecord.h" | 35 #include "core/dom/MutationRecord.h" |
36 #include "core/dom/ResizeObserver.h" | 36 #include "core/dom/ResizeObserver.h" |
37 #include "core/dom/ResizeObserverEntry.h" | 37 #include "core/dom/ResizeObserverEntry.h" |
38 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
39 #include "core/events/KeyboardEvent.h" | 39 #include "core/events/KeyboardEvent.h" |
40 #include "core/events/MouseEvent.h" | 40 #include "core/events/MouseEvent.h" |
41 #include "core/frame/LocalFrameClient.h" | |
41 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
42 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
43 #include "core/html/HTMLMediaElement.h" | 44 #include "core/html/HTMLMediaElement.h" |
44 #include "core/html/HTMLVideoElement.h" | 45 #include "core/html/HTMLVideoElement.h" |
45 #include "core/html/media/AutoplayPolicy.h" | 46 #include "core/html/media/AutoplayPolicy.h" |
46 #include "core/html/media/HTMLMediaElementControlsList.h" | 47 #include "core/html/media/HTMLMediaElementControlsList.h" |
47 #include "core/html/track/TextTrackContainer.h" | 48 #include "core/html/track/TextTrackContainer.h" |
48 #include "core/html/track/TextTrackList.h" | 49 #include "core/html/track/TextTrackList.h" |
49 #include "core/layout/LayoutObject.h" | 50 #include "core/layout/LayoutObject.h" |
50 #include "core/layout/LayoutTheme.h" | 51 #include "core/layout/LayoutTheme.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
67 #include "modules/media_controls/elements/MediaControlPlayButtonElement.h" | 68 #include "modules/media_controls/elements/MediaControlPlayButtonElement.h" |
68 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen t.h" | 69 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen t.h" |
69 #include "modules/media_controls/elements/MediaControlTextTrackListElement.h" | 70 #include "modules/media_controls/elements/MediaControlTextTrackListElement.h" |
70 #include "modules/media_controls/elements/MediaControlTimelineElement.h" | 71 #include "modules/media_controls/elements/MediaControlTimelineElement.h" |
71 #include "modules/media_controls/elements/MediaControlToggleClosedCaptionsButton Element.h" | 72 #include "modules/media_controls/elements/MediaControlToggleClosedCaptionsButton Element.h" |
72 #include "modules/media_controls/elements/MediaControlVolumeSliderElement.h" | 73 #include "modules/media_controls/elements/MediaControlVolumeSliderElement.h" |
73 #include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h" | 74 #include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h" |
74 #include "modules/remoteplayback/RemotePlayback.h" | 75 #include "modules/remoteplayback/RemotePlayback.h" |
75 #include "platform/EventDispatchForbiddenScope.h" | 76 #include "platform/EventDispatchForbiddenScope.h" |
76 #include "platform/RuntimeEnabledFeatures.h" | 77 #include "platform/RuntimeEnabledFeatures.h" |
78 #include "platform/wtf/Functional.h" | |
79 #include "services/service_manager/public/cpp/interface_provider.h" | |
77 | 80 |
78 namespace blink { | 81 namespace blink { |
79 | 82 |
80 namespace { | 83 namespace { |
81 | 84 |
82 // TODO(steimel): should have better solution than hard-coding pixel values. | 85 // TODO(steimel): should have better solution than hard-coding pixel values. |
83 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, | 86 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, |
84 // and core/paint/MediaControlsPainter.cpp. | 87 // and core/paint/MediaControlsPainter.cpp. |
85 constexpr int kOverlayPlayButtonWidth = 48; | 88 constexpr int kOverlayPlayButtonWidth = 48; |
86 constexpr int kOverlayPlayButtonHeight = 48; | 89 constexpr int kOverlayPlayButtonHeight = 48; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 | 559 |
557 void MediaControlsImpl::OnControlsListUpdated() { | 560 void MediaControlsImpl::OnControlsListUpdated() { |
558 BatchedControlUpdate batch(this); | 561 BatchedControlUpdate batch(this); |
559 | 562 |
560 fullscreen_button_->SetIsWanted(ShouldShowFullscreenButton(MediaElement())); | 563 fullscreen_button_->SetIsWanted(ShouldShowFullscreenButton(MediaElement())); |
561 | 564 |
562 RefreshCastButtonVisibilityWithoutUpdate(); | 565 RefreshCastButtonVisibilityWithoutUpdate(); |
563 | 566 |
564 download_button_->SetIsWanted( | 567 download_button_->SetIsWanted( |
565 download_button_->ShouldDisplayDownloadButton()); | 568 download_button_->ShouldDisplayDownloadButton()); |
569 UpdateDownloadInProductHelpState(); | |
566 } | 570 } |
567 | 571 |
568 LayoutObject* MediaControlsImpl::PanelLayoutObject() { | 572 LayoutObject* MediaControlsImpl::PanelLayoutObject() { |
569 return panel_->GetLayoutObject(); | 573 return panel_->GetLayoutObject(); |
570 } | 574 } |
571 | 575 |
572 LayoutObject* MediaControlsImpl::ContainerLayoutObject() { | 576 LayoutObject* MediaControlsImpl::ContainerLayoutObject() { |
573 return GetLayoutObject(); | 577 return GetLayoutObject(); |
574 } | 578 } |
575 | 579 |
576 void MediaControlsImpl::MaybeShow() { | 580 void MediaControlsImpl::MaybeShow() { |
577 panel_->SetIsWanted(true); | 581 panel_->SetIsWanted(true); |
578 panel_->SetIsDisplayed(true); | 582 panel_->SetIsDisplayed(true); |
579 if (overlay_play_button_) | 583 if (overlay_play_button_) |
580 overlay_play_button_->UpdateDisplayType(); | 584 overlay_play_button_->UpdateDisplayType(); |
581 // Only make the controls visible if they won't get hidden by OnTimeUpdate. | 585 // Only make the controls visible if they won't get hidden by OnTimeUpdate. |
582 if (MediaElement().paused() || !ShouldHideMediaControls()) | 586 if (MediaElement().paused() || !ShouldHideMediaControls()) |
583 MakeOpaque(); | 587 MakeOpaque(); |
588 UpdateDownloadInProductHelpState(); | |
584 } | 589 } |
585 | 590 |
586 void MediaControlsImpl::Hide() { | 591 void MediaControlsImpl::Hide() { |
587 panel_->SetIsWanted(false); | 592 panel_->SetIsWanted(false); |
588 panel_->SetIsDisplayed(false); | 593 panel_->SetIsDisplayed(false); |
589 if (overlay_play_button_) | 594 if (overlay_play_button_) |
590 overlay_play_button_->SetIsWanted(false); | 595 overlay_play_button_->SetIsWanted(false); |
596 UpdateDownloadInProductHelpState(); | |
591 } | 597 } |
592 | 598 |
593 bool MediaControlsImpl::IsVisible() const { | 599 bool MediaControlsImpl::IsVisible() const { |
594 return panel_->IsOpaque(); | 600 return panel_->IsOpaque(); |
595 } | 601 } |
596 | 602 |
597 void MediaControlsImpl::MakeOpaque() { | 603 void MediaControlsImpl::MakeOpaque() { |
598 panel_->MakeOpaque(); | 604 panel_->MakeOpaque(); |
599 } | 605 } |
600 | 606 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 const bool ignore_focus = behavior_flags & kIgnoreFocus; | 642 const bool ignore_focus = behavior_flags & kIgnoreFocus; |
637 if (!ignore_focus && (MediaElement().IsFocused() || | 643 if (!ignore_focus && (MediaElement().IsFocused() || |
638 contains(GetDocument().FocusedElement()))) { | 644 contains(GetDocument().FocusedElement()))) { |
639 return false; | 645 return false; |
640 } | 646 } |
641 | 647 |
642 // Don't hide the media controls when a panel is showing. | 648 // Don't hide the media controls when a panel is showing. |
643 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) | 649 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) |
644 return false; | 650 return false; |
645 | 651 |
652 // Don't hide the media controls while the in product help is showing. | |
653 if (media_in_product_help_) | |
654 return false; | |
655 | |
646 return true; | 656 return true; |
647 } | 657 } |
648 | 658 |
649 void MediaControlsImpl::UpdatePlayState() { | 659 void MediaControlsImpl::UpdatePlayState() { |
650 if (is_paused_for_scrubbing_) | 660 if (is_paused_for_scrubbing_) |
651 return; | 661 return; |
652 | 662 |
653 if (overlay_play_button_) | 663 if (overlay_play_button_) |
654 overlay_play_button_->UpdateDisplayType(); | 664 overlay_play_button_->UpdateDisplayType(); |
655 play_button_->UpdateDisplayType(); | 665 play_button_->UpdateDisplayType(); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
964 UpdateCurrentTimeDisplay(); | 974 UpdateCurrentTimeDisplay(); |
965 | 975 |
966 // Update the timeline (the UI with the seek marker). | 976 // Update the timeline (the UI with the seek marker). |
967 timeline_->SetDuration(duration); | 977 timeline_->SetDuration(duration); |
968 } | 978 } |
969 | 979 |
970 void MediaControlsImpl::OnPlay() { | 980 void MediaControlsImpl::OnPlay() { |
971 UpdatePlayState(); | 981 UpdatePlayState(); |
972 timeline_->SetPosition(MediaElement().currentTime()); | 982 timeline_->SetPosition(MediaElement().currentTime()); |
973 UpdateCurrentTimeDisplay(); | 983 UpdateCurrentTimeDisplay(); |
984 MaybeDispatchDownloadIPHTrigger(); | |
974 } | 985 } |
975 | 986 |
976 void MediaControlsImpl::OnPlaying() { | 987 void MediaControlsImpl::OnPlaying() { |
977 timeline_->OnPlaying(); | 988 timeline_->OnPlaying(); |
978 | 989 |
979 StartHideMediaControlsTimer(); | 990 StartHideMediaControlsTimer(); |
980 } | 991 } |
981 | 992 |
982 void MediaControlsImpl::OnPause() { | 993 void MediaControlsImpl::OnPause() { |
983 UpdatePlayState(); | 994 UpdatePlayState(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1209 | 1220 |
1210 void MediaControlsImpl::HideAllMenus() { | 1221 void MediaControlsImpl::HideAllMenus() { |
1211 window_event_listener_->Stop(); | 1222 window_event_listener_->Stop(); |
1212 | 1223 |
1213 if (overflow_list_->IsWanted()) | 1224 if (overflow_list_->IsWanted()) |
1214 overflow_list_->SetIsWanted(false); | 1225 overflow_list_->SetIsWanted(false); |
1215 if (text_track_list_->IsWanted()) | 1226 if (text_track_list_->IsWanted()) |
1216 text_track_list_->SetVisible(false); | 1227 text_track_list_->SetVisible(false); |
1217 } | 1228 } |
1218 | 1229 |
1230 void MediaControlsImpl::MaybeDispatchDownloadIPHTrigger() { | |
whywhat
2017/07/10 15:29:28
nit: I think we should either use IPH or InProduct
Khushal
2017/07/10 20:38:02
Done.
| |
1231 if (!media_download_in_product_trigger_observed_ && | |
1232 download_button_->IsWanted() && | |
1233 MediaElement().GetDocument().GetSettings() && | |
1234 MediaElement() | |
1235 .GetDocument() | |
1236 .GetSettings() | |
1237 ->GetMediaDownloadInProductHelpEnabled()) { | |
1238 DCHECK(!media_in_product_help_); | |
1239 | |
1240 media_download_in_product_trigger_observed_ = true; | |
1241 media_in_product_help_ = | |
1242 WTF::MakeUnique<mojom::blink::MediaInProductHelpPtr>(); | |
1243 MediaElement() | |
1244 .GetDocument() | |
1245 .GetFrame() | |
1246 ->Client() | |
1247 ->GetInterfaceProvider() | |
1248 ->GetInterface(mojo::MakeRequest(media_in_product_help_.get())); | |
1249 media_in_product_help_->set_connection_error_handler(ConvertToBaseCallback( | |
1250 WTF::Bind(&MediaControlsImpl::DismissDownloadInProductHelp, | |
1251 WrapWeakPersistent(this)))); | |
1252 MaybeShow(); | |
1253 } | |
1254 } | |
1255 | |
1256 void MediaControlsImpl::UpdateDownloadInProductHelpState() { | |
1257 if (!media_in_product_help_) | |
1258 return; | |
1259 | |
1260 if (IsVisible() && download_button_->IsWanted()) { | |
1261 (*media_in_product_help_) | |
1262 ->ShowInProductHelpWidget( | |
1263 download_button_->VisibleBoundsInVisualViewport()); | |
1264 return; | |
1265 } | |
1266 | |
1267 DismissDownloadInProductHelp(); | |
1268 } | |
1269 | |
1270 void MediaControlsImpl::DismissDownloadInProductHelp() { | |
1271 media_in_product_help_.reset(); | |
1272 if (ShouldHideMediaControls()) | |
1273 StartHideMediaControlsTimer(); | |
1274 } | |
1275 | |
1219 DEFINE_TRACE(MediaControlsImpl) { | 1276 DEFINE_TRACE(MediaControlsImpl) { |
1220 visitor->Trace(element_mutation_callback_); | 1277 visitor->Trace(element_mutation_callback_); |
1221 visitor->Trace(resize_observer_); | 1278 visitor->Trace(resize_observer_); |
1222 visitor->Trace(panel_); | 1279 visitor->Trace(panel_); |
1223 visitor->Trace(overlay_play_button_); | 1280 visitor->Trace(overlay_play_button_); |
1224 visitor->Trace(overlay_enclosure_); | 1281 visitor->Trace(overlay_enclosure_); |
1225 visitor->Trace(play_button_); | 1282 visitor->Trace(play_button_); |
1226 visitor->Trace(current_time_display_); | 1283 visitor->Trace(current_time_display_); |
1227 visitor->Trace(timeline_); | 1284 visitor->Trace(timeline_); |
1228 visitor->Trace(mute_button_); | 1285 visitor->Trace(mute_button_); |
(...skipping 10 matching lines...) Expand all Loading... | |
1239 visitor->Trace(overlay_cast_button_); | 1296 visitor->Trace(overlay_cast_button_); |
1240 visitor->Trace(media_event_listener_); | 1297 visitor->Trace(media_event_listener_); |
1241 visitor->Trace(window_event_listener_); | 1298 visitor->Trace(window_event_listener_); |
1242 visitor->Trace(orientation_lock_delegate_); | 1299 visitor->Trace(orientation_lock_delegate_); |
1243 visitor->Trace(rotate_to_fullscreen_delegate_); | 1300 visitor->Trace(rotate_to_fullscreen_delegate_); |
1244 MediaControls::Trace(visitor); | 1301 MediaControls::Trace(visitor); |
1245 HTMLDivElement::Trace(visitor); | 1302 HTMLDivElement::Trace(visitor); |
1246 } | 1303 } |
1247 | 1304 |
1248 } // namespace blink | 1305 } // namespace blink |
OLD | NEW |