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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: mounir's comments. Created 3 years, 5 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) 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 574 }
575 575
576 void MediaControlsImpl::MaybeShow() { 576 void MediaControlsImpl::MaybeShow() {
577 panel_->SetIsWanted(true); 577 panel_->SetIsWanted(true);
578 panel_->SetIsDisplayed(true); 578 panel_->SetIsDisplayed(true);
579 if (overlay_play_button_) 579 if (overlay_play_button_)
580 overlay_play_button_->UpdateDisplayType(); 580 overlay_play_button_->UpdateDisplayType();
581 // Only make the controls visible if they won't get hidden by OnTimeUpdate. 581 // Only make the controls visible if they won't get hidden by OnTimeUpdate.
582 if (MediaElement().paused() || !ShouldHideMediaControls()) 582 if (MediaElement().paused() || !ShouldHideMediaControls())
583 MakeOpaque(); 583 MakeOpaque();
584 download_button_->MaybeDispatchInProductHelpTrigger();
584 } 585 }
585 586
586 void MediaControlsImpl::Hide() { 587 void MediaControlsImpl::Hide() {
587 panel_->SetIsWanted(false); 588 panel_->SetIsWanted(false);
588 panel_->SetIsDisplayed(false); 589 panel_->SetIsDisplayed(false);
589 if (overlay_play_button_) 590 if (overlay_play_button_)
590 overlay_play_button_->SetIsWanted(false); 591 overlay_play_button_->SetIsWanted(false);
592 download_button_->DismissInProductHelp();
593 }
594
595 bool MediaControlsImpl::CanShow() const {
596 return panel_->IsWanted();
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
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 (download_button_->IsShowingInProductHelp())
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 829 }
820 830
821 return; 831 return;
822 } 832 }
823 833
824 if (event->type() == EventTypeNames::mouseover) { 834 if (event->type() == EventTypeNames::mouseover) {
825 if (!ContainsRelatedTarget(event)) { 835 if (!ContainsRelatedTarget(event)) {
826 is_mouse_over_controls_ = true; 836 is_mouse_over_controls_ = true;
827 if (!MediaElement().paused()) { 837 if (!MediaElement().paused()) {
828 MakeOpaque(); 838 MakeOpaque();
829 if (ShouldHideMediaControls()) 839 StartHideMediaControlsIfNecessary();
830 StartHideMediaControlsTimer();
831 } 840 }
832 } 841 }
833 return; 842 return;
834 } 843 }
835 844
836 if (event->type() == EventTypeNames::mouseout) { 845 if (event->type() == EventTypeNames::mouseout) {
837 if (!ContainsRelatedTarget(event)) { 846 if (!ContainsRelatedTarget(event)) {
838 is_mouse_over_controls_ = false; 847 is_mouse_over_controls_ = false;
839 StopHideMediaControlsTimer(); 848 StopHideMediaControlsTimer();
840 } 849 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 UpdateCurrentTimeDisplay(); 973 UpdateCurrentTimeDisplay();
965 974
966 // Update the timeline (the UI with the seek marker). 975 // Update the timeline (the UI with the seek marker).
967 timeline_->SetDuration(duration); 976 timeline_->SetDuration(duration);
968 } 977 }
969 978
970 void MediaControlsImpl::OnPlay() { 979 void MediaControlsImpl::OnPlay() {
971 UpdatePlayState(); 980 UpdatePlayState();
972 timeline_->SetPosition(MediaElement().currentTime()); 981 timeline_->SetPosition(MediaElement().currentTime());
973 UpdateCurrentTimeDisplay(); 982 UpdateCurrentTimeDisplay();
983 download_button_->MaybeDispatchInProductHelpTrigger();
974 } 984 }
975 985
976 void MediaControlsImpl::OnPlaying() { 986 void MediaControlsImpl::OnPlaying() {
977 timeline_->OnPlaying(); 987 timeline_->OnPlaying();
978 988
979 StartHideMediaControlsTimer(); 989 StartHideMediaControlsTimer();
980 } 990 }
981 991
982 void MediaControlsImpl::OnPause() { 992 void MediaControlsImpl::OnPause() {
983 UpdatePlayState(); 993 UpdatePlayState();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1219
1210 void MediaControlsImpl::HideAllMenus() { 1220 void MediaControlsImpl::HideAllMenus() {
1211 window_event_listener_->Stop(); 1221 window_event_listener_->Stop();
1212 1222
1213 if (overflow_list_->IsWanted()) 1223 if (overflow_list_->IsWanted())
1214 overflow_list_->SetIsWanted(false); 1224 overflow_list_->SetIsWanted(false);
1215 if (text_track_list_->IsWanted()) 1225 if (text_track_list_->IsWanted())
1216 text_track_list_->SetVisible(false); 1226 text_track_list_->SetVisible(false);
1217 } 1227 }
1218 1228
1229 void MediaControlsImpl::StartHideMediaControlsIfNecessary() {
1230 if (ShouldHideMediaControls())
1231 StartHideMediaControlsTimer();
1232 }
1233
1219 DEFINE_TRACE(MediaControlsImpl) { 1234 DEFINE_TRACE(MediaControlsImpl) {
1220 visitor->Trace(element_mutation_callback_); 1235 visitor->Trace(element_mutation_callback_);
1221 visitor->Trace(resize_observer_); 1236 visitor->Trace(resize_observer_);
1222 visitor->Trace(panel_); 1237 visitor->Trace(panel_);
1223 visitor->Trace(overlay_play_button_); 1238 visitor->Trace(overlay_play_button_);
1224 visitor->Trace(overlay_enclosure_); 1239 visitor->Trace(overlay_enclosure_);
1225 visitor->Trace(play_button_); 1240 visitor->Trace(play_button_);
1226 visitor->Trace(current_time_display_); 1241 visitor->Trace(current_time_display_);
1227 visitor->Trace(timeline_); 1242 visitor->Trace(timeline_);
1228 visitor->Trace(mute_button_); 1243 visitor->Trace(mute_button_);
(...skipping 10 matching lines...) Expand all
1239 visitor->Trace(overlay_cast_button_); 1254 visitor->Trace(overlay_cast_button_);
1240 visitor->Trace(media_event_listener_); 1255 visitor->Trace(media_event_listener_);
1241 visitor->Trace(window_event_listener_); 1256 visitor->Trace(window_event_listener_);
1242 visitor->Trace(orientation_lock_delegate_); 1257 visitor->Trace(orientation_lock_delegate_);
1243 visitor->Trace(rotate_to_fullscreen_delegate_); 1258 visitor->Trace(rotate_to_fullscreen_delegate_);
1244 MediaControls::Trace(visitor); 1259 MediaControls::Trace(visitor);
1245 HTMLDivElement::Trace(visitor); 1260 HTMLDivElement::Trace(visitor);
1246 } 1261 }
1247 1262
1248 } // namespace blink 1263 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698