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

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: addressed 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 const bool ignore_focus = behavior_flags & kIgnoreFocus; 636 const bool ignore_focus = behavior_flags & kIgnoreFocus;
637 if (!ignore_focus && (MediaElement().IsFocused() || 637 if (!ignore_focus && (MediaElement().IsFocused() ||
638 contains(GetDocument().FocusedElement()))) { 638 contains(GetDocument().FocusedElement()))) {
639 return false; 639 return false;
640 } 640 }
641 641
642 // Don't hide the media controls when a panel is showing. 642 // Don't hide the media controls when a panel is showing.
643 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) 643 if (text_track_list_->IsWanted() || overflow_list_->IsWanted())
644 return false; 644 return false;
645 645
646 // Don't hide the media controls while the in product help is showing.
647 if (MediaElement().GetDocument().GetFrame() &&
648 MediaElement()
649 .GetDocument()
650 .GetFrame()
651 ->IsDownloadMediaInProductHelpVisibleForElement(MediaElement())) {
652 return false;
653 }
654
646 return true; 655 return true;
647 } 656 }
648 657
649 void MediaControlsImpl::UpdatePlayState() { 658 void MediaControlsImpl::UpdatePlayState() {
650 if (is_paused_for_scrubbing_) 659 if (is_paused_for_scrubbing_)
651 return; 660 return;
652 661
653 if (overlay_play_button_) 662 if (overlay_play_button_)
654 overlay_play_button_->UpdateDisplayType(); 663 overlay_play_button_->UpdateDisplayType();
655 play_button_->UpdateDisplayType(); 664 play_button_->UpdateDisplayType();
(...skipping 308 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 MaybeDispatchDownloadIPHTrigger();
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::MaybeDispatchDownloadIPHTrigger() {
1230 if (download_button_->IsWanted() && !MediaElement().paused() &&
1231 MediaElement().GetDocument().GetFrame()) {
1232 MediaElement().GetDocument().GetFrame()->ShowDownloadMediaInProductHelp(
1233 MediaElement());
1234 if (!ShouldHideMediaControls())
1235 MaybeShow();
1236 }
1237 }
1238
1239 bool MediaControlsImpl::GetDownloadButtonRect(IntRect& rect) {
1240 if (!IsVisible())
1241 return false;
1242 if (!download_button_->IsWanted())
1243 return false;
1244
1245 rect = download_button_->VisibleBoundsInVisualViewport();
1246 return true;
1247 }
1248
1249 void MediaControlsImpl::InProductHelpDisabled() {
1250 if (ShouldHideMediaControls())
1251 StartHideMediaControlsTimer();
1252 }
1253
1219 DEFINE_TRACE(MediaControlsImpl) { 1254 DEFINE_TRACE(MediaControlsImpl) {
1220 visitor->Trace(element_mutation_callback_); 1255 visitor->Trace(element_mutation_callback_);
1221 visitor->Trace(resize_observer_); 1256 visitor->Trace(resize_observer_);
1222 visitor->Trace(panel_); 1257 visitor->Trace(panel_);
1223 visitor->Trace(overlay_play_button_); 1258 visitor->Trace(overlay_play_button_);
1224 visitor->Trace(overlay_enclosure_); 1259 visitor->Trace(overlay_enclosure_);
1225 visitor->Trace(play_button_); 1260 visitor->Trace(play_button_);
1226 visitor->Trace(current_time_display_); 1261 visitor->Trace(current_time_display_);
1227 visitor->Trace(timeline_); 1262 visitor->Trace(timeline_);
1228 visitor->Trace(mute_button_); 1263 visitor->Trace(mute_button_);
(...skipping 10 matching lines...) Expand all
1239 visitor->Trace(overlay_cast_button_); 1274 visitor->Trace(overlay_cast_button_);
1240 visitor->Trace(media_event_listener_); 1275 visitor->Trace(media_event_listener_);
1241 visitor->Trace(window_event_listener_); 1276 visitor->Trace(window_event_listener_);
1242 visitor->Trace(orientation_lock_delegate_); 1277 visitor->Trace(orientation_lock_delegate_);
1243 visitor->Trace(rotate_to_fullscreen_delegate_); 1278 visitor->Trace(rotate_to_fullscreen_delegate_);
1244 MediaControls::Trace(visitor); 1279 MediaControls::Trace(visitor);
1245 HTMLDivElement::Trace(visitor); 1280 HTMLDivElement::Trace(visitor);
1246 } 1281 }
1247 1282
1248 } // namespace blink 1283 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698