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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "core/html/track/TextTrackList.h" | 45 #include "core/html/track/TextTrackList.h" |
46 #include "core/layout/LayoutObject.h" | 46 #include "core/layout/LayoutObject.h" |
47 #include "core/layout/LayoutTheme.h" | 47 #include "core/layout/LayoutTheme.h" |
48 #include "core/page/SpatialNavigation.h" | 48 #include "core/page/SpatialNavigation.h" |
49 #include "core/resize_observer/ResizeObserver.h" | 49 #include "core/resize_observer/ResizeObserver.h" |
50 #include "core/resize_observer/ResizeObserverEntry.h" | 50 #include "core/resize_observer/ResizeObserverEntry.h" |
51 #include "modules/media_controls/MediaControlsMediaEventListener.h" | 51 #include "modules/media_controls/MediaControlsMediaEventListener.h" |
52 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" | 52 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" |
53 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" | 53 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" |
54 #include "modules/media_controls/MediaControlsWindowEventListener.h" | 54 #include "modules/media_controls/MediaControlsWindowEventListener.h" |
| 55 #include "modules/media_controls/MediaDownloadInProductHelpManager.h" |
55 #include "modules/media_controls/elements/MediaControlCastButtonElement.h" | 56 #include "modules/media_controls/elements/MediaControlCastButtonElement.h" |
56 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.
h" | 57 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.
h" |
57 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" | 58 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" |
58 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h" | 59 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h" |
59 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" | 60 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" |
60 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement.
h" | 61 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement.
h" |
61 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" | 62 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" |
62 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" | 63 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" |
63 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h
" | 64 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h
" |
64 #include "modules/media_controls/elements/MediaControlPanelElement.h" | 65 #include "modules/media_controls/elements/MediaControlPanelElement.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 toHTMLVideoElement(media_element)); | 315 toHTMLVideoElement(media_element)); |
315 } | 316 } |
316 if (RuntimeEnabledFeatures::VideoRotateToFullscreenEnabled() && | 317 if (RuntimeEnabledFeatures::VideoRotateToFullscreenEnabled() && |
317 media_element.IsHTMLVideoElement()) { | 318 media_element.IsHTMLVideoElement()) { |
318 // Initialize the rotate-to-fullscreen feature. | 319 // Initialize the rotate-to-fullscreen feature. |
319 controls->rotate_to_fullscreen_delegate_ = | 320 controls->rotate_to_fullscreen_delegate_ = |
320 new MediaControlsRotateToFullscreenDelegate( | 321 new MediaControlsRotateToFullscreenDelegate( |
321 toHTMLVideoElement(media_element)); | 322 toHTMLVideoElement(media_element)); |
322 } | 323 } |
323 | 324 |
| 325 // Initialize download in-product-help for video elements if enabled. |
| 326 if (media_element.GetDocument().GetSettings() && |
| 327 media_element.GetDocument() |
| 328 .GetSettings() |
| 329 ->GetMediaDownloadInProductHelpEnabled() && |
| 330 media_element.IsHTMLVideoElement()) { |
| 331 controls->download_iph_manager_ = |
| 332 new MediaDownloadInProductHelpManager(*controls); |
| 333 } |
| 334 |
324 shadow_root.AppendChild(controls); | 335 shadow_root.AppendChild(controls); |
325 return controls; | 336 return controls; |
326 } | 337 } |
327 | 338 |
328 // The media controls DOM structure looks like: | 339 // The media controls DOM structure looks like: |
329 // | 340 // |
330 // MediaControlsImpl | 341 // MediaControlsImpl |
331 // (-webkit-media-controls) | 342 // (-webkit-media-controls) |
332 // +-MediaControlOverlayEnclosureElement | 343 // +-MediaControlOverlayEnclosureElement |
333 // | (-webkit-media-controls-overlay-enclosure) | 344 // | (-webkit-media-controls-overlay-enclosure) |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } | 575 } |
565 | 576 |
566 void MediaControlsImpl::MaybeShow() { | 577 void MediaControlsImpl::MaybeShow() { |
567 panel_->SetIsWanted(true); | 578 panel_->SetIsWanted(true); |
568 panel_->SetIsDisplayed(true); | 579 panel_->SetIsDisplayed(true); |
569 if (overlay_play_button_) | 580 if (overlay_play_button_) |
570 overlay_play_button_->UpdateDisplayType(); | 581 overlay_play_button_->UpdateDisplayType(); |
571 // Only make the controls visible if they won't get hidden by OnTimeUpdate. | 582 // Only make the controls visible if they won't get hidden by OnTimeUpdate. |
572 if (MediaElement().paused() || !ShouldHideMediaControls()) | 583 if (MediaElement().paused() || !ShouldHideMediaControls()) |
573 MakeOpaque(); | 584 MakeOpaque(); |
| 585 if (download_iph_manager_) |
| 586 download_iph_manager_->SetControlsVisibility(true); |
574 } | 587 } |
575 | 588 |
576 void MediaControlsImpl::Hide() { | 589 void MediaControlsImpl::Hide() { |
577 panel_->SetIsWanted(false); | 590 panel_->SetIsWanted(false); |
578 panel_->SetIsDisplayed(false); | 591 panel_->SetIsDisplayed(false); |
579 if (overlay_play_button_) | 592 if (overlay_play_button_) |
580 overlay_play_button_->SetIsWanted(false); | 593 overlay_play_button_->SetIsWanted(false); |
| 594 if (download_iph_manager_) |
| 595 download_iph_manager_->SetControlsVisibility(false); |
581 } | 596 } |
582 | 597 |
583 bool MediaControlsImpl::IsVisible() const { | 598 bool MediaControlsImpl::IsVisible() const { |
584 return panel_->IsOpaque(); | 599 return panel_->IsOpaque(); |
585 } | 600 } |
586 | 601 |
587 void MediaControlsImpl::MakeOpaque() { | 602 void MediaControlsImpl::MakeOpaque() { |
588 panel_->MakeOpaque(); | 603 panel_->MakeOpaque(); |
589 } | 604 } |
590 | 605 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 const bool ignore_focus = behavior_flags & kIgnoreFocus; | 641 const bool ignore_focus = behavior_flags & kIgnoreFocus; |
627 if (!ignore_focus && (MediaElement().IsFocused() || | 642 if (!ignore_focus && (MediaElement().IsFocused() || |
628 contains(GetDocument().FocusedElement()))) { | 643 contains(GetDocument().FocusedElement()))) { |
629 return false; | 644 return false; |
630 } | 645 } |
631 | 646 |
632 // Don't hide the media controls when a panel is showing. | 647 // Don't hide the media controls when a panel is showing. |
633 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) | 648 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) |
634 return false; | 649 return false; |
635 | 650 |
| 651 // Don't hide the media controls while the in product help is showing. |
| 652 if (download_iph_manager_ && download_iph_manager_->IsShowingInProductHelp()) |
| 653 return false; |
| 654 |
636 return true; | 655 return true; |
637 } | 656 } |
638 | 657 |
639 void MediaControlsImpl::UpdatePlayState() { | 658 void MediaControlsImpl::UpdatePlayState() { |
640 if (is_paused_for_scrubbing_) | 659 if (is_paused_for_scrubbing_) |
641 return; | 660 return; |
642 | 661 |
643 if (overlay_play_button_) | 662 if (overlay_play_button_) |
644 overlay_play_button_->UpdateDisplayType(); | 663 overlay_play_button_->UpdateDisplayType(); |
645 play_button_->UpdateDisplayType(); | 664 play_button_->UpdateDisplayType(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 828 } |
810 | 829 |
811 return; | 830 return; |
812 } | 831 } |
813 | 832 |
814 if (event->type() == EventTypeNames::pointerover) { | 833 if (event->type() == EventTypeNames::pointerover) { |
815 if (!ContainsRelatedTarget(event)) { | 834 if (!ContainsRelatedTarget(event)) { |
816 is_mouse_over_controls_ = true; | 835 is_mouse_over_controls_ = true; |
817 if (!MediaElement().paused()) { | 836 if (!MediaElement().paused()) { |
818 MakeOpaque(); | 837 MakeOpaque(); |
819 if (ShouldHideMediaControls()) | 838 StartHideMediaControlsIfNecessary(); |
820 StartHideMediaControlsTimer(); | |
821 } | 839 } |
822 } | 840 } |
823 return; | 841 return; |
824 } | 842 } |
825 | 843 |
826 if (event->type() == EventTypeNames::pointerout) { | 844 if (event->type() == EventTypeNames::pointerout) { |
827 if (!ContainsRelatedTarget(event)) { | 845 if (!ContainsRelatedTarget(event)) { |
828 is_mouse_over_controls_ = false; | 846 is_mouse_over_controls_ = false; |
829 StopHideMediaControlsTimer(); | 847 StopHideMediaControlsTimer(); |
830 } | 848 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 UpdateCurrentTimeDisplay(); | 973 UpdateCurrentTimeDisplay(); |
956 | 974 |
957 // Update the timeline (the UI with the seek marker). | 975 // Update the timeline (the UI with the seek marker). |
958 timeline_->SetDuration(duration); | 976 timeline_->SetDuration(duration); |
959 } | 977 } |
960 | 978 |
961 void MediaControlsImpl::OnPlay() { | 979 void MediaControlsImpl::OnPlay() { |
962 UpdatePlayState(); | 980 UpdatePlayState(); |
963 timeline_->SetPosition(MediaElement().currentTime()); | 981 timeline_->SetPosition(MediaElement().currentTime()); |
964 UpdateCurrentTimeDisplay(); | 982 UpdateCurrentTimeDisplay(); |
| 983 |
| 984 if (download_iph_manager_) |
| 985 download_iph_manager_->SetIsPlaying(true); |
965 } | 986 } |
966 | 987 |
967 void MediaControlsImpl::OnPlaying() { | 988 void MediaControlsImpl::OnPlaying() { |
968 timeline_->OnPlaying(); | 989 timeline_->OnPlaying(); |
969 | 990 |
970 StartHideMediaControlsTimer(); | 991 StartHideMediaControlsTimer(); |
971 } | 992 } |
972 | 993 |
973 void MediaControlsImpl::OnPause() { | 994 void MediaControlsImpl::OnPause() { |
974 UpdatePlayState(); | 995 UpdatePlayState(); |
975 timeline_->SetPosition(MediaElement().currentTime()); | 996 timeline_->SetPosition(MediaElement().currentTime()); |
976 UpdateCurrentTimeDisplay(); | 997 UpdateCurrentTimeDisplay(); |
977 MakeOpaque(); | 998 MakeOpaque(); |
978 | 999 |
979 StopHideMediaControlsTimer(); | 1000 StopHideMediaControlsTimer(); |
| 1001 |
| 1002 if (download_iph_manager_) |
| 1003 download_iph_manager_->SetIsPlaying(false); |
980 } | 1004 } |
981 | 1005 |
982 void MediaControlsImpl::OnTextTracksAddedOrRemoved() { | 1006 void MediaControlsImpl::OnTextTracksAddedOrRemoved() { |
983 toggle_closed_captions_button_->SetIsWanted( | 1007 toggle_closed_captions_button_->SetIsWanted( |
984 MediaElement().HasClosedCaptions()); | 1008 MediaElement().HasClosedCaptions()); |
985 BatchedControlUpdate batch(this); | 1009 BatchedControlUpdate batch(this); |
986 } | 1010 } |
987 | 1011 |
988 void MediaControlsImpl::OnTextTracksChanged() { | 1012 void MediaControlsImpl::OnTextTracksChanged() { |
989 toggle_closed_captions_button_->UpdateDisplayType(); | 1013 toggle_closed_captions_button_->UpdateDisplayType(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 | 1237 |
1214 void MediaControlsImpl::HideAllMenus() { | 1238 void MediaControlsImpl::HideAllMenus() { |
1215 window_event_listener_->Stop(); | 1239 window_event_listener_->Stop(); |
1216 | 1240 |
1217 if (overflow_list_->IsWanted()) | 1241 if (overflow_list_->IsWanted()) |
1218 overflow_list_->SetIsWanted(false); | 1242 overflow_list_->SetIsWanted(false); |
1219 if (text_track_list_->IsWanted()) | 1243 if (text_track_list_->IsWanted()) |
1220 text_track_list_->SetVisible(false); | 1244 text_track_list_->SetVisible(false); |
1221 } | 1245 } |
1222 | 1246 |
| 1247 void MediaControlsImpl::StartHideMediaControlsIfNecessary() { |
| 1248 if (ShouldHideMediaControls()) |
| 1249 StartHideMediaControlsTimer(); |
| 1250 } |
| 1251 |
| 1252 const MediaControlDownloadButtonElement& MediaControlsImpl::DownloadButton() |
| 1253 const { |
| 1254 return *download_button_; |
| 1255 } |
| 1256 |
| 1257 void MediaControlsImpl::DidDismissDownloadInProductHelp() { |
| 1258 StartHideMediaControlsIfNecessary(); |
| 1259 } |
| 1260 |
| 1261 MediaDownloadInProductHelpManager* MediaControlsImpl::DownloadInProductHelp() { |
| 1262 return download_iph_manager_; |
| 1263 } |
| 1264 |
1223 DEFINE_TRACE(MediaControlsImpl) { | 1265 DEFINE_TRACE(MediaControlsImpl) { |
1224 visitor->Trace(element_mutation_callback_); | 1266 visitor->Trace(element_mutation_callback_); |
1225 visitor->Trace(resize_observer_); | 1267 visitor->Trace(resize_observer_); |
1226 visitor->Trace(panel_); | 1268 visitor->Trace(panel_); |
1227 visitor->Trace(overlay_play_button_); | 1269 visitor->Trace(overlay_play_button_); |
1228 visitor->Trace(overlay_enclosure_); | 1270 visitor->Trace(overlay_enclosure_); |
1229 visitor->Trace(play_button_); | 1271 visitor->Trace(play_button_); |
1230 visitor->Trace(current_time_display_); | 1272 visitor->Trace(current_time_display_); |
1231 visitor->Trace(timeline_); | 1273 visitor->Trace(timeline_); |
1232 visitor->Trace(mute_button_); | 1274 visitor->Trace(mute_button_); |
1233 visitor->Trace(volume_slider_); | 1275 visitor->Trace(volume_slider_); |
1234 visitor->Trace(toggle_closed_captions_button_); | 1276 visitor->Trace(toggle_closed_captions_button_); |
1235 visitor->Trace(fullscreen_button_); | 1277 visitor->Trace(fullscreen_button_); |
1236 visitor->Trace(download_button_); | 1278 visitor->Trace(download_button_); |
1237 visitor->Trace(duration_display_); | 1279 visitor->Trace(duration_display_); |
1238 visitor->Trace(enclosure_); | 1280 visitor->Trace(enclosure_); |
1239 visitor->Trace(text_track_list_); | 1281 visitor->Trace(text_track_list_); |
1240 visitor->Trace(overflow_menu_); | 1282 visitor->Trace(overflow_menu_); |
1241 visitor->Trace(overflow_list_); | 1283 visitor->Trace(overflow_list_); |
1242 visitor->Trace(cast_button_); | 1284 visitor->Trace(cast_button_); |
1243 visitor->Trace(overlay_cast_button_); | 1285 visitor->Trace(overlay_cast_button_); |
1244 visitor->Trace(media_event_listener_); | 1286 visitor->Trace(media_event_listener_); |
1245 visitor->Trace(window_event_listener_); | 1287 visitor->Trace(window_event_listener_); |
1246 visitor->Trace(orientation_lock_delegate_); | 1288 visitor->Trace(orientation_lock_delegate_); |
1247 visitor->Trace(rotate_to_fullscreen_delegate_); | 1289 visitor->Trace(rotate_to_fullscreen_delegate_); |
| 1290 visitor->Trace(download_iph_manager_); |
1248 MediaControls::Trace(visitor); | 1291 MediaControls::Trace(visitor); |
1249 HTMLDivElement::Trace(visitor); | 1292 HTMLDivElement::Trace(visitor); |
1250 } | 1293 } |
1251 | 1294 |
1252 } // namespace blink | 1295 } // namespace blink |
OLD | NEW |