[Fullscreen] Suspend page (and pause video) while phishing warning is presented
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2018 18:47:46 +0000 (18:47 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2018 18:47:46 +0000 (18:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186856
<rdar://problem/41212444>

Reviewed by Tim Horton.

Source/WebCore:

Pause the media element when the page is suspended, and unpause when the page resumes.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
* html/HTMLMediaElement.h:

Source/WebKit:

* UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController _showPhishingAlert]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233049 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm

index 2edaebb..e992677 100644 (file)
@@ -1,3 +1,19 @@
+2018-06-21  Jer Noble  <jer.noble@apple.com>
+
+        [Fullscreen] Suspend page (and pause video) while phishing warning is presented
+        https://bugs.webkit.org/show_bug.cgi?id=186856
+        <rdar://problem/41212444>
+
+        Reviewed by Tim Horton.
+
+        Pause the media element when the page is suspended, and unpause when the page resumes.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::HTMLMediaElement::suspend):
+        (WebCore::HTMLMediaElement::resume):
+        * html/HTMLMediaElement.h:
+
 2018-06-21  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Bad optional access in WebCore::ContentSecurityPolicySource::portMatches
index f6b5e36..44a0d18 100644 (file)
@@ -490,6 +490,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
     , m_haveSetUpCaptionContainer(false)
 #endif
     , m_isScrubbingRemotely(false)
+    , m_shouldUnpauseInternalOnResume(false)
 #if ENABLE(VIDEO_TRACK)
     , m_tracksAreReady(true)
     , m_haveVisibleTextTrack(false)
@@ -5596,8 +5597,13 @@ void HTMLMediaElement::suspend(ReasonForSuspension why)
             setShouldBufferData(false);
             m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePageConsentToResumeMedia);
             break;
-        case JavaScriptDebuggerPaused:
         case PageWillBeSuspended:
+            if (!m_pausedInternal) {
+                m_shouldUnpauseInternalOnResume = true;
+                setPausedInternal(true);
+            }
+            break;
+        case JavaScriptDebuggerPaused:
         case WillDeferLoading:
             // Do nothing, we don't pause media playback in these cases.
             break;
@@ -5612,6 +5618,11 @@ void HTMLMediaElement::resume()
 
     m_asyncEventQueue.resume();
 
+    if (m_shouldUnpauseInternalOnResume) {
+        m_shouldUnpauseInternalOnResume = false;
+        setPausedInternal(false);
+    }
+
     setShouldBufferData(true);
 
     if (!m_mediaSession->pageAllowsPlaybackAfterResuming())
index 3ee881a..5660df9 100644 (file)
@@ -1083,6 +1083,7 @@ private:
 
     bool m_isScrubbingRemotely : 1;
     bool m_waitingToEnterFullscreen : 1;
+    bool m_shouldUnpauseInternalOnResume : 1;
 
 #if ENABLE(VIDEO_TRACK)
     bool m_tracksAreReady : 1;
index 656da6e..02ea074 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-21  Jer Noble  <jer.noble@apple.com>
+
+        [Fullscreen] Suspend page (and pause video) while phishing warning is presented
+        https://bugs.webkit.org/show_bug.cgi?id=186856
+        <rdar://problem/41212444>
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
+        (-[WKFullScreenViewController _showPhishingAlert]):
+
 2018-06-21  David Fenton  <david_fenton@apple.com>
 
         Unreviewed, rolling out r232989.
index 2d0e244..472fe3a 100644 (file)
@@ -428,11 +428,18 @@ private:
     NSString *alertMessage = [NSString stringWithFormat:WEB_UI_STRING("The website \"%@\" may be a deceptive website. Would you like to exit fullscreen?", "Fullscreen Deceptive Website Warning Sheet Content Text") , (NSString *)self.location];
     UIAlertController* alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];
 
+    if (auto* page = [self._webView _page])
+        page->suspendActiveDOMObjectsAndAnimations();
+
     UIAlertAction* exitAction = [UIAlertAction actionWithTitle:WEB_UI_STRING("Exit Fullscreen", "Fullscreen Deceptive Website Exit Action") style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
         [self _cancelAction:action];
+        if (auto* page = [self._webView _page])
+            page->resumeActiveDOMObjectsAndAnimations();
     }];
 
     UIAlertAction* stayAction = [UIAlertAction actionWithTitle:WEB_UI_STRING("Stay in Fullscreen", "Fullscreen Deceptive Website Stay Action") style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
+        if (auto* page = [self._webView _page])
+            page->resumeActiveDOMObjectsAndAnimations();
         _secheuristic.reset();
     }];