Make privateBrowsingStateDidChange take an explicit SessionID
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 10:25:00 +0000 (10:25 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 10:25:00 +0000 (10:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200666

Reviewed by Alex Christensen.

Instead of stating that the page session ID changed and get it from the page,
pass it directly to privateBrowsingStateDidChange.
No change of behavior.

* dom/Document.cpp:
(WebCore::Document::privateBrowsingStateDidChange):
* dom/Document.h:
* dom/Element.h:
(WebCore::Element::privateBrowsingStateDidChange):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::privateBrowsingStateDidChange):
* html/HTMLMediaElement.h:
* page/Page.cpp:
(WebCore::Page::setSessionID):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/Page.cpp

index 01d8415..b799701 100644 (file)
@@ -1,3 +1,25 @@
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
+        Make privateBrowsingStateDidChange take an explicit SessionID
+        https://bugs.webkit.org/show_bug.cgi?id=200666
+
+        Reviewed by Alex Christensen.
+
+        Instead of stating that the page session ID changed and get it from the page,
+        pass it directly to privateBrowsingStateDidChange.
+        No change of behavior.
+
+        * dom/Document.cpp:
+        (WebCore::Document::privateBrowsingStateDidChange):
+        * dom/Document.h:
+        * dom/Element.h:
+        (WebCore::Element::privateBrowsingStateDidChange):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::privateBrowsingStateDidChange):
+        * html/HTMLMediaElement.h:
+        * page/Page.cpp:
+        (WebCore::Page::setSessionID):
+
 2019-08-13  Sam Weinig  <weinig@apple.com>
 
         Fix the WPE build.
index d17ff2c..43c09a4 100644 (file)
@@ -5262,19 +5262,19 @@ void Document::storageBlockingStateDidChange()
     securityOrigin().setStorageBlockingPolicy(settings().storageBlockingPolicy());
 }
 
-void Document::privateBrowsingStateDidChange(
+void Document::privateBrowsingStateDidChange(PAL::SessionID sessionID)
 {
-    m_sessionID = SessionID::emptySessionID();
+    m_sessionID = sessionID;
     if (m_logger)
-        m_logger->setEnabled(this, sessionID().isAlwaysOnLoggingAllowed());
+        m_logger->setEnabled(this, sessionID.isAlwaysOnLoggingAllowed());
 
     for (auto* element : m_privateBrowsingStateChangedElements)
-        element->privateBrowsingStateDidChange();
+        element->privateBrowsingStateDidChange(sessionID);
 
 #if ENABLE(SERVICE_WORKER)
-    ASSERT(sessionID().isValid());
-    if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && m_serviceWorkerConnection && sessionID().isValid())
-        setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID()));
+    ASSERT(sessionID.isValid());
+    if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && m_serviceWorkerConnection && sessionID.isValid())
+        setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID));
 #endif
 }
 
index f97dbe7..0f538bf 100644 (file)
@@ -1092,7 +1092,7 @@ public:
     void registerForPrivateBrowsingStateChangedCallbacks(Element&);
     void unregisterForPrivateBrowsingStateChangedCallbacks(Element&);
     void storageBlockingStateDidChange();
-    void privateBrowsingStateDidChange();
+    void privateBrowsingStateDidChange(PAL::SessionID);
 
 #if ENABLE(VIDEO_TRACK)
     void registerForCaptionPreferencesChangedCallbacks(Element&);
index e64865f..13bbbe9 100644 (file)
@@ -419,7 +419,7 @@ public:
     virtual void mediaVolumeDidChange() { }
 
     // Use Document::registerForPrivateBrowsingStateChangedCallbacks() to subscribe to this.
-    virtual void privateBrowsingStateDidChange() { }
+    virtual void privateBrowsingStateDidChange(PAL::SessionID) { }
 
     virtual void willBecomeFullscreenElement();
     virtual void ancestorWillEnterFullscreen() { }
index f740cca..b55c469 100644 (file)
@@ -6436,13 +6436,12 @@ void HTMLMediaElement::resetMediaEngines()
     MediaPlayer::resetMediaEngines();
 }
 
-void HTMLMediaElement::privateBrowsingStateDidChange()
+void HTMLMediaElement::privateBrowsingStateDidChange(PAL::SessionID sessionID)
 {
     if (!m_player)
         return;
 
-    bool privateMode = document().page() && document().page()->usesEphemeralSession();
-    m_player->setPrivateBrowsingMode(privateMode);
+    m_player->setPrivateBrowsingMode(sessionID.isEphemeral());
 }
 
 MediaControls* HTMLMediaElement::mediaControls() const
index d0bab9f..6124541 100644 (file)
@@ -456,7 +456,7 @@ public:
     void sourceWasRemoved(HTMLSourceElement&);
     void sourceWasAdded(HTMLSourceElement&);
 
-    void privateBrowsingStateDidChange() override;
+    void privateBrowsingStateDidChange(PAL::SessionID) override;
 
     // Media cache management.
     WEBCORE_EXPORT static void setMediaCacheDirectory(const String&);
index eda7c5f..4d4a49c 100644 (file)
@@ -2517,7 +2517,7 @@ void Page::setSessionID(PAL::SessionID sessionID)
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (!frame->document())
             continue;
-        frame->document()->privateBrowsingStateDidChange();
+        frame->document()->privateBrowsingStateDidChange(m_sessionID);
     }
 
     // Collect the PluginViews in to a vector to ensure that action the plug-in takes