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

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

Issue 2898543002: media_controls: Add UI for showing a promo bubble on a control button. (Closed)
Patch Set: make animation work Created 3 years, 6 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/html/HTMLVideoElement.h" 44 #include "core/html/HTMLVideoElement.h"
45 #include "core/html/media/HTMLMediaElementControlsList.h" 45 #include "core/html/media/HTMLMediaElementControlsList.h"
46 #include "core/html/track/TextTrackContainer.h" 46 #include "core/html/track/TextTrackContainer.h"
47 #include "core/html/track/TextTrackList.h" 47 #include "core/html/track/TextTrackList.h"
48 #include "core/layout/LayoutObject.h" 48 #include "core/layout/LayoutObject.h"
49 #include "core/layout/LayoutTheme.h" 49 #include "core/layout/LayoutTheme.h"
50 #include "modules/media_controls/MediaControlsMediaEventListener.h" 50 #include "modules/media_controls/MediaControlsMediaEventListener.h"
51 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" 51 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h"
52 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" 52 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h"
53 #include "modules/media_controls/MediaControlsWindowEventListener.h" 53 #include "modules/media_controls/MediaControlsWindowEventListener.h"
54 #include "modules/media_controls/elements/MediaControlButtonPromoElements.h"
54 #include "modules/media_controls/elements/MediaControlCastButtonElement.h" 55 #include "modules/media_controls/elements/MediaControlCastButtonElement.h"
55 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h" 56 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h"
56 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" 57 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
57 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h" 58 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h"
58 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" 59 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h"
59 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h" 60 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h"
60 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" 61 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h"
61 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" 62 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h"
62 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h " 63 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h "
63 #include "modules/media_controls/elements/MediaControlPanelElement.h" 64 #include "modules/media_controls/elements/MediaControlPanelElement.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 panel_->AppendChild(mute_button_); 417 panel_->AppendChild(mute_button_);
417 418
418 volume_slider_ = new MediaControlVolumeSliderElement(*this); 419 volume_slider_ = new MediaControlVolumeSliderElement(*this);
419 panel_->AppendChild(volume_slider_); 420 panel_->AppendChild(volume_slider_);
420 if (PreferHiddenVolumeControls(GetDocument())) 421 if (PreferHiddenVolumeControls(GetDocument()))
421 volume_slider_->SetIsWanted(false); 422 volume_slider_->SetIsWanted(false);
422 423
423 fullscreen_button_ = new MediaControlFullscreenButtonElement(*this); 424 fullscreen_button_ = new MediaControlFullscreenButtonElement(*this);
424 panel_->AppendChild(fullscreen_button_); 425 panel_->AppendChild(fullscreen_button_);
425 426
427 download_button_container_ = new MediaControlDownloadButtonContainer(*this);
428 panel_->AppendChild(download_button_container_);
429
426 download_button_ = new MediaControlDownloadButtonElement(*this); 430 download_button_ = new MediaControlDownloadButtonElement(*this);
427 panel_->AppendChild(download_button_); 431 download_button_container_->AppendChild(download_button_);
428 432
429 cast_button_ = new MediaControlCastButtonElement(*this, false); 433 cast_button_ = new MediaControlCastButtonElement(*this, false);
430 panel_->AppendChild(cast_button_); 434 panel_->AppendChild(cast_button_);
431 435
432 toggle_closed_captions_button_ = 436 toggle_closed_captions_button_ =
433 new MediaControlToggleClosedCaptionsButtonElement(*this); 437 new MediaControlToggleClosedCaptionsButtonElement(*this);
434 panel_->AppendChild(toggle_closed_captions_button_); 438 panel_->AppendChild(toggle_closed_captions_button_);
435 439
436 enclosure_->AppendChild(panel_); 440 enclosure_->AppendChild(panel_);
437 441
(...skipping 20 matching lines...) Expand all
458 *this, new MediaControlDownloadButtonElement(*this))); 462 *this, new MediaControlDownloadButtonElement(*this)));
459 overflow_list_->AppendChild(mute_button_->CreateOverflowElement( 463 overflow_list_->AppendChild(mute_button_->CreateOverflowElement(
460 *this, new MediaControlMuteButtonElement(*this))); 464 *this, new MediaControlMuteButtonElement(*this)));
461 overflow_list_->AppendChild(cast_button_->CreateOverflowElement( 465 overflow_list_->AppendChild(cast_button_->CreateOverflowElement(
462 *this, new MediaControlCastButtonElement(*this, false))); 466 *this, new MediaControlCastButtonElement(*this, false)));
463 overflow_list_->AppendChild( 467 overflow_list_->AppendChild(
464 toggle_closed_captions_button_->CreateOverflowElement( 468 toggle_closed_captions_button_->CreateOverflowElement(
465 *this, new MediaControlToggleClosedCaptionsButtonElement(*this))); 469 *this, new MediaControlToggleClosedCaptionsButtonElement(*this)));
466 } 470 }
467 471
472 void MediaControlsImpl::CreateDownloadButtonPromoUI() {
473 download_promo_container_ = new MediaControlButtonPromoContainer(
474 *this, kMediaDownloadButtonPromoText,
475 WebLocalizedString::kDownloadButtonPromoText);
476 download_button_container_->AppendChild(download_promo_container_);
477 }
478
479 void MediaControlsImpl::UpdateDownloadButtonWantedState() {
480 bool should_display = download_button_->ShouldDisplayDownloadButton();
481 download_button_->SetIsWanted(should_display);
482 download_button_container_->SetIsWanted(should_display);
483 }
484
468 Node::InsertionNotificationRequest MediaControlsImpl::InsertedInto( 485 Node::InsertionNotificationRequest MediaControlsImpl::InsertedInto(
469 ContainerNode* root) { 486 ContainerNode* root) {
470 if (!MediaElement().isConnected()) 487 if (!MediaElement().isConnected())
471 return HTMLDivElement::InsertedInto(root); 488 return HTMLDivElement::InsertedInto(root);
472 489
473 // TODO(mlamouri): we should show the controls instead of having 490 // TODO(mlamouri): we should show the controls instead of having
474 // HTMLMediaElement do it. 491 // HTMLMediaElement do it.
475 492
476 // m_windowEventListener doesn't need to be re-attached as it's only needed 493 // m_windowEventListener doesn't need to be re-attached as it's only needed
477 // when a menu is visible. 494 // when a menu is visible.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 569
553 OnControlsListUpdated(); 570 OnControlsListUpdated();
554 } 571 }
555 572
556 void MediaControlsImpl::OnControlsListUpdated() { 573 void MediaControlsImpl::OnControlsListUpdated() {
557 BatchedControlUpdate batch(this); 574 BatchedControlUpdate batch(this);
558 575
559 fullscreen_button_->SetIsWanted(ShouldShowFullscreenButton(MediaElement())); 576 fullscreen_button_->SetIsWanted(ShouldShowFullscreenButton(MediaElement()));
560 577
561 RefreshCastButtonVisibilityWithoutUpdate(); 578 RefreshCastButtonVisibilityWithoutUpdate();
562 579 UpdateDownloadButtonWantedState();
563 download_button_->SetIsWanted(
564 download_button_->ShouldDisplayDownloadButton());
565 } 580 }
566 581
567 LayoutObject* MediaControlsImpl::PanelLayoutObject() { 582 LayoutObject* MediaControlsImpl::PanelLayoutObject() {
568 return panel_->GetLayoutObject(); 583 return panel_->GetLayoutObject();
569 } 584 }
570 585
571 LayoutObject* MediaControlsImpl::ContainerLayoutObject() { 586 LayoutObject* MediaControlsImpl::ContainerLayoutObject() {
572 return GetLayoutObject(); 587 return GetLayoutObject();
573 } 588 }
574 589
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 Invalidate(play_button_); 1177 Invalidate(play_button_);
1163 Invalidate(overlay_play_button_); 1178 Invalidate(overlay_play_button_);
1164 Invalidate(mute_button_); 1179 Invalidate(mute_button_);
1165 Invalidate(fullscreen_button_); 1180 Invalidate(fullscreen_button_);
1166 Invalidate(download_button_); 1181 Invalidate(download_button_);
1167 Invalidate(timeline_); 1182 Invalidate(timeline_);
1168 Invalidate(volume_slider_); 1183 Invalidate(volume_slider_);
1169 1184
1170 // Update the display state of the download button in case we now have a 1185 // Update the display state of the download button in case we now have a
1171 // source or no longer have a source. 1186 // source or no longer have a source.
1172 download_button_->SetIsWanted( 1187 UpdateDownloadButtonWantedState();
1173 download_button_->ShouldDisplayDownloadButton());
1174 } 1188 }
1175 1189
1176 bool MediaControlsImpl::OverflowMenuVisible() { 1190 bool MediaControlsImpl::OverflowMenuVisible() {
1177 return overflow_list_ ? overflow_list_->IsWanted() : false; 1191 return overflow_list_ ? overflow_list_->IsWanted() : false;
1178 } 1192 }
1179 1193
1180 void MediaControlsImpl::ToggleOverflowMenu() { 1194 void MediaControlsImpl::ToggleOverflowMenu() {
1181 DCHECK(overflow_list_); 1195 DCHECK(overflow_list_);
1182 1196
1183 if (!overflow_list_->IsWanted()) 1197 if (!overflow_list_->IsWanted())
(...skipping 17 matching lines...) Expand all
1201 visitor->Trace(overlay_play_button_); 1215 visitor->Trace(overlay_play_button_);
1202 visitor->Trace(overlay_enclosure_); 1216 visitor->Trace(overlay_enclosure_);
1203 visitor->Trace(play_button_); 1217 visitor->Trace(play_button_);
1204 visitor->Trace(current_time_display_); 1218 visitor->Trace(current_time_display_);
1205 visitor->Trace(timeline_); 1219 visitor->Trace(timeline_);
1206 visitor->Trace(mute_button_); 1220 visitor->Trace(mute_button_);
1207 visitor->Trace(volume_slider_); 1221 visitor->Trace(volume_slider_);
1208 visitor->Trace(toggle_closed_captions_button_); 1222 visitor->Trace(toggle_closed_captions_button_);
1209 visitor->Trace(fullscreen_button_); 1223 visitor->Trace(fullscreen_button_);
1210 visitor->Trace(download_button_); 1224 visitor->Trace(download_button_);
1225 visitor->Trace(download_button_container_);
1226 visitor->Trace(download_promo_container_);
1211 visitor->Trace(duration_display_); 1227 visitor->Trace(duration_display_);
1212 visitor->Trace(enclosure_); 1228 visitor->Trace(enclosure_);
1213 visitor->Trace(text_track_list_); 1229 visitor->Trace(text_track_list_);
1214 visitor->Trace(overflow_menu_); 1230 visitor->Trace(overflow_menu_);
1215 visitor->Trace(overflow_list_); 1231 visitor->Trace(overflow_list_);
1216 visitor->Trace(cast_button_); 1232 visitor->Trace(cast_button_);
1217 visitor->Trace(overlay_cast_button_); 1233 visitor->Trace(overlay_cast_button_);
1218 visitor->Trace(media_event_listener_); 1234 visitor->Trace(media_event_listener_);
1219 visitor->Trace(window_event_listener_); 1235 visitor->Trace(window_event_listener_);
1220 visitor->Trace(orientation_lock_delegate_); 1236 visitor->Trace(orientation_lock_delegate_);
1221 visitor->Trace(rotate_to_fullscreen_delegate_); 1237 visitor->Trace(rotate_to_fullscreen_delegate_);
1222 MediaControls::Trace(visitor); 1238 MediaControls::Trace(visitor);
1223 HTMLDivElement::Trace(visitor); 1239 HTMLDivElement::Trace(visitor);
1224 } 1240 }
1225 1241
1226 } // namespace blink 1242 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698