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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2756553002: Force the video to go fullscreen when setting persistent video (Closed)
Patch Set: addressed nits Created 3 years, 9 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) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * 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 18 matching lines...) Expand all
29 #include <limits> 29 #include <limits>
30 #include "bindings/core/v8/ExceptionState.h" 30 #include "bindings/core/v8/ExceptionState.h"
31 #include "bindings/core/v8/Microtask.h" 31 #include "bindings/core/v8/Microtask.h"
32 #include "bindings/core/v8/ScriptController.h" 32 #include "bindings/core/v8/ScriptController.h"
33 #include "bindings/core/v8/ScriptEventListener.h" 33 #include "bindings/core/v8/ScriptEventListener.h"
34 #include "bindings/core/v8/ScriptPromiseResolver.h" 34 #include "bindings/core/v8/ScriptPromiseResolver.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/css/MediaList.h" 36 #include "core/css/MediaList.h"
37 #include "core/dom/Attribute.h" 37 #include "core/dom/Attribute.h"
38 #include "core/dom/DOMException.h" 38 #include "core/dom/DOMException.h"
39 #include "core/dom/DocumentUserGestureToken.h"
39 #include "core/dom/ElementTraversal.h" 40 #include "core/dom/ElementTraversal.h"
40 #include "core/dom/ElementVisibilityObserver.h" 41 #include "core/dom/ElementVisibilityObserver.h"
41 #include "core/dom/Fullscreen.h" 42 #include "core/dom/Fullscreen.h"
42 #include "core/dom/TaskRunnerHelper.h" 43 #include "core/dom/TaskRunnerHelper.h"
43 #include "core/dom/shadow/ShadowRoot.h" 44 #include "core/dom/shadow/ShadowRoot.h"
44 #include "core/events/Event.h" 45 #include "core/events/Event.h"
45 #include "core/frame/FrameView.h" 46 #include "core/frame/FrameView.h"
46 #include "core/frame/LocalFrame.h" 47 #include "core/frame/LocalFrame.h"
47 #include "core/frame/LocalFrameClient.h" 48 #include "core/frame/LocalFrameClient.h"
48 #include "core/frame/Settings.h" 49 #include "core/frame/Settings.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 m_inOverlayFullscreenVideo(false), 459 m_inOverlayFullscreenVideo(false),
459 m_mostlyFillingViewport(false), 460 m_mostlyFillingViewport(false),
460 m_audioTracks(this, AudioTrackList::create(*this)), 461 m_audioTracks(this, AudioTrackList::create(*this)),
461 m_videoTracks(this, VideoTrackList::create(*this)), 462 m_videoTracks(this, VideoTrackList::create(*this)),
462 m_textTracks(this, nullptr), 463 m_textTracks(this, nullptr),
463 m_audioSourceNode(nullptr), 464 m_audioSourceNode(nullptr),
464 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), 465 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)),
465 m_remotePlaybackClient(nullptr), 466 m_remotePlaybackClient(nullptr),
466 m_autoplayVisibilityObserver(nullptr), 467 m_autoplayVisibilityObserver(nullptr),
467 m_mediaControls(nullptr), 468 m_mediaControls(nullptr),
468 m_controlsList(HTMLMediaElementControlsList::create(this)) { 469 m_controlsList(HTMLMediaElementControlsList::create(this)),
470 m_isPersistentVideo(false) {
469 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; 471 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")";
470 472
471 m_lockedPendingUserGesture = computeLockedPendingUserGesture(document); 473 m_lockedPendingUserGesture = computeLockedPendingUserGesture(document);
472 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled = 474 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled =
473 isDocumentCrossOrigin(document); 475 isDocumentCrossOrigin(document);
474 476
475 LocalFrame* frame = document.frame(); 477 LocalFrame* frame = document.frame();
476 if (frame) { 478 if (frame) {
477 m_remotePlaybackClient = 479 m_remotePlaybackClient =
478 frame->loader().client()->createWebRemotePlaybackClient(*this); 480 frame->loader().client()->createWebRemotePlaybackClient(*this);
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 void HTMLMediaElement::cancelledRemotePlaybackRequest() { 3229 void HTMLMediaElement::cancelledRemotePlaybackRequest() {
3228 if (remotePlaybackClient()) 3230 if (remotePlaybackClient())
3229 remotePlaybackClient()->promptCancelled(); 3231 remotePlaybackClient()->promptCancelled();
3230 } 3232 }
3231 3233
3232 void HTMLMediaElement::remotePlaybackStarted() { 3234 void HTMLMediaElement::remotePlaybackStarted() {
3233 if (remotePlaybackClient()) 3235 if (remotePlaybackClient())
3234 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); 3236 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected);
3235 } 3237 }
3236 3238
3239 // TODO(zqzhang): move logic for hiding controls here.
3240 void HTMLMediaElement::onBecamePersistentVideo(bool value) {
3241 if (!isHTMLVideoElement())
3242 return;
3243
3244 if (value) {
3245 if (isFullscreen())
3246 return;
3247
3248 UserGestureIndicator gestureIndicator(
3249 DocumentUserGestureToken::create(&document()));
3250 Fullscreen::requestFullscreen(*this);
3251 m_isPersistentVideo = true;
3252 } else {
3253 if (!m_isPersistentVideo)
3254 return;
3255
3256 Fullscreen::exitFullscreen(document());
3257 m_isPersistentVideo = false;
3258 }
3259 }
3260
3237 bool HTMLMediaElement::hasSelectedVideoTrack() { 3261 bool HTMLMediaElement::hasSelectedVideoTrack() {
3238 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); 3262 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled());
3239 3263
3240 return m_videoTracks && m_videoTracks->selectedIndex() != -1; 3264 return m_videoTracks && m_videoTracks->selectedIndex() != -1;
3241 } 3265 }
3242 3266
3243 WebMediaPlayer::TrackId HTMLMediaElement::getSelectedVideoTrackId() { 3267 WebMediaPlayer::TrackId HTMLMediaElement::getSelectedVideoTrackId() {
3244 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); 3268 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled());
3245 DCHECK(hasSelectedVideoTrack()); 3269 DCHECK(hasSelectedVideoTrack());
3246 3270
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
4198 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); 4222 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE);
4199 } 4223 }
4200 4224
4201 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { 4225 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) {
4202 m_mostlyFillingViewport = true; 4226 m_mostlyFillingViewport = true;
4203 if (m_webMediaPlayer) 4227 if (m_webMediaPlayer)
4204 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); 4228 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport);
4205 } 4229 }
4206 4230
4207 } // namespace blink 4231 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698