Changeset 245025 in webkit


Ignore:
Timestamp:
May 7, 2019 12:55:29 PM (5 years ago)
Author:
wilander@apple.com
Message:

Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
https://bugs.webkit.org/show_bug.cgi?id=197648
<rdar://problem/50527493>

Reviewed by Chris Dumez.

Source/WebCore:

Developers have requested two minor changes to the Storage Access API:

  • Only consume the user gesture when the user explicitly denies access.
  • Make document.hasStorageAccess() return true instead of false when the feature is off.

In addition to this, we have refactoring and cleanup to do. Namely:

  • Make use of WebCore::RegistrableDomain all the way.
  • Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
  • Introduce boolean enums for state handling.
  • Break out the Storage Access API functionality into a supplement of WebCore::Document.

Reviewed by Chris Dumez.

Tests: http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html

http/tests/storageAccess/deny-without-prompt-preserves-gesture.html
http/tests/storageAccess/grant-with-prompt-preserves-gesture.html
http/tests/storageAccess/has-storage-access-true-if-feature-off.html

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Headers.cmake:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp:

(WebCore::Document::hasStorageAccess): Deleted.
(WebCore::Document::requestStorageAccess): Deleted.
(WebCore::Document::enableTemporaryTimeUserGesture): Deleted.
(WebCore::Document::consumeTemporaryTimeUserGesture): Deleted.
(WebCore::Document::hasFrameSpecificStorageAccess const): Deleted.
(WebCore::Document::setHasFrameSpecificStorageAccess): Deleted.

  • dom/Document.h:

(WebCore::Document::setUserGrantsStorageAccessOverride): Deleted.

All of this has been moved to the supplement WebCore::DocumentStorageAccess.

  • dom/Document.idl:

The Storage Access API has been moved to DocumentStorageAccess.idl.

  • dom/DocumentStorageAccess.cpp: Added.

(WebCore::DocumentStorageAccess::from):
(WebCore::DocumentStorageAccess::supplementName):
(WebCore::DocumentStorageAccess::hasStorageAccess):
(WebCore::DocumentStorageAccess::requestStorageAccess):
(WebCore::DocumentStorageAccess::enableTemporaryTimeUserGesture):
(WebCore::DocumentStorageAccess::consumeTemporaryTimeUserGesture):
(WebCore::DocumentStorageAccess::hasFrameSpecificStorageAccess const):
(WebCore::DocumentStorageAccess::setHasFrameSpecificStorageAccess):

  • dom/DocumentStorageAccess.h: Added.
  • dom/DocumentStorageAccess.idl: Added.
  • page/ChromeClient.h:
  • testing/Internals.cpp:

(WebCore::Internals::setUserGrantsStorageAccess): Deleted.

This was dead code.

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit:

Developers have requested two minor changes to the Storage Access API:

  • Only consume the user gesture when the user explicitly denies access.
  • Make document.hasStorageAccess() return true instead of false when the feature is off.

In addition to this, we have refactoring and cleanup to do. Namely:

  • Make use of WebCore::RegistrableDomain all the way.
  • Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
  • Introduce boolean enums for state handling.
  • Break out the Storage Access API functionality into a supplement of WebCore::Document.
  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
(WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:

(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
(WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown.

  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown.

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown.

(WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): Deleted.

This function is now no longer exposed and its functionality could be folded into
the existing WebResourceLoadStatisticsStore::requestStorageAccess() which is more
clearly named.

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
(WebKit::NetworkConnectionToWebProcess::requestStorageAccess):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown.

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/NetworkConnectionToWebProcess.messages.in:
  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::hasStorageAccessForFrame): Deleted.
(WebKit::NetworkProcess::hasStorageAccess): Deleted.
(WebKit::NetworkProcess::requestStorageAccess): Deleted.
(WebKit::NetworkProcess::requestStorageAccessGranted): Deleted.
(WebKit::NetworkProcess::grantStorageAccess): Deleted.
(WebKit::NetworkProcess::removeAllStorageAccess): Deleted.

These functions were left behind in the move of ITP to the network process.
This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • Scripts/webkit/messages.py:

Instructions for derived IPC code on how to include the new enums
WebCore::StorageAccessWasGranted and WebCore::StorageAccessPromptWasShown.

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::hasStorageAccessForFrame): Deleted.
(WebKit::NetworkProcessProxy::hasStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::requestStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::grantStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::removeAllStorageAccess): Deleted.

These functions were left behind in the move of ITP to the network process.
This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::hasStorageAccess): Deleted.
(WebKit::WebsiteDataStore::requestStorageAccess): Deleted.
(WebKit::WebsiteDataStore::grantStorageAccess): Deleted.

These functions were left behind in the move of ITP to the network process.
This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.

  • UIProcess/WebsiteData/WebsiteDataStore.h:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::hasStorageAccess):
(WebKit::WebChromeClient::requestStorageAccess):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
objects instead of Strings now.

  • WebProcess/WebCoreSupport/WebChromeClient.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::hasStorageAccess):
(WebKit::WebPage::requestStorageAccess):

These changes are due to the new enums WebCore::StorageAccessWasGranted and
WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
objects instead of Strings now.

  • WebProcess/WebPage/WebPage.h:

LayoutTests:

The changed test cases have had calls to WebCore::Internals::setUserGrantsStorageAccess() removed
since it was dead code.

One of the new tests, deny-with-prompt-does-not-preserve-gesture.html, is marked [ Skip ] for now since
we lack the ability to click "Don't allow" in the prompt. I wanted to include the test anyway so that
we have it. I have done a manual test to make sure the code does the right thing for this case.

  • http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture-expected.txt: Added.
  • http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
  • http/tests/storageAccess/deny-without-prompt-preserves-gesture-expected.txt: Added.
  • http/tests/storageAccess/deny-without-prompt-preserves-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
  • http/tests/storageAccess/grant-with-prompt-preserves-gesture-expected.txt: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window-expected.txt.
  • http/tests/storageAccess/grant-with-prompt-preserves-gesture.html: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
  • http/tests/storageAccess/has-storage-access-true-if-feature-off-expected.txt: Added.
  • http/tests/storageAccess/has-storage-access-true-if-feature-off.html: Added.
  • http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html:
  • http/tests/storageAccess/resources/request-storage-access-iframe-and-pop-window.html:
  • http/tests/storageAccess/resources/request-storage-access-iframe.html:
  • http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html:
  • http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html:
  • platform/mac-wk2/TestExpectations:

Added expectations for the new tests.

Location:
trunk
Files:
7 added
44 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245016 r245025  
     12019-05-07  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=197648
     5        <rdar://problem/50527493>
     6
     7        Reviewed by Chris Dumez.
     8
     9        The changed test cases have had calls to WebCore::Internals::setUserGrantsStorageAccess() removed
     10        since it was dead code.
     11
     12        One of the new tests, deny-with-prompt-does-not-preserve-gesture.html, is marked [ Skip ] for now since
     13        we lack the ability to click "Don't allow" in the prompt. I wanted to include the test anyway so that
     14        we have it. I have done a manual test to make sure the code does the right thing for this case.
     15
     16        * http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture-expected.txt: Added.
     17        * http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
     18        * http/tests/storageAccess/deny-without-prompt-preserves-gesture-expected.txt: Added.
     19        * http/tests/storageAccess/deny-without-prompt-preserves-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
     20        * http/tests/storageAccess/grant-with-prompt-preserves-gesture-expected.txt: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window-expected.txt.
     21        * http/tests/storageAccess/grant-with-prompt-preserves-gesture.html: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
     22        * http/tests/storageAccess/has-storage-access-true-if-feature-off-expected.txt: Added.
     23        * http/tests/storageAccess/has-storage-access-true-if-feature-off.html: Added.
     24        * http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html:
     25        * http/tests/storageAccess/resources/request-storage-access-iframe-and-pop-window.html:
     26        * http/tests/storageAccess/resources/request-storage-access-iframe.html:
     27        * http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html:
     28        * http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html:
     29        * platform/mac-wk2/TestExpectations:
     30            Added expectations for the new tests.
     31
    1322019-05-07  Antti Koivisto  <antti@apple.com>
    233
  • trunk/LayoutTests/http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html

    r245024 r245025  
    66    <script src="/resourceLoadStatistics/resources/util.js"></script>
    77    <script>
    8         description("Tests that cross-origin iframe can display a window if storage access is granted.");
     8        description("Tests that a cross-origin iframe can not open a window if storage access is explicitly denied.");
    99        jsTestIsAsync = true;
    1010
     
    1919                    testPassed(event.data.replace("PASS ", ""));
    2020                else
    21                     testFailed(event.data);
     21                    testFailed(event.data.replace("FAIL ", ""));
    2222            } else
    2323                testFailed("Received a message from an unexpected origin: " + event.origin);
     
    6161                            };
    6262                            iframeElement.id = "TheIframeThatRequestsStorageAccess";
    63                             iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,isNotSameOriginIframe";
     63                            iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldNotGrantAccess,userShouldBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe";
    6464                            document.body.appendChild(iframeElement);
    65 
    6665                        });
    6766                    });
  • trunk/LayoutTests/http/tests/storageAccess/deny-without-prompt-preserves-gesture.html

    r245024 r245025  
    66    <script src="/resourceLoadStatistics/resources/util.js"></script>
    77    <script>
    8         description("Tests that cross-origin iframe can display a window if storage access is granted.");
     8        description("Tests that a cross-origin iframe can open a window if storage access is denied without prompt.");
    99        jsTestIsAsync = true;
    1010
     
    1919                    testPassed(event.data.replace("PASS ", ""));
    2020                else
    21                     testFailed(event.data);
     21                    testFailed(event.data.replace("FAIL ", ""));
    2222            } else
    2323                testFailed("Received a message from an unexpected origin: " + event.origin);
     
    5252                    if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    5353                        testFailed("Host did not get set as prevalent resource.");
    54                     testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
    55                         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    56                             testFailed("Host did not get logged for user interaction.");
     54                    testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
     55                        if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     56                            testFailed("Host did get logged for user interaction.");
    5757                        testRunner.statisticsUpdateCookieBlocking(function() {
    5858                            let iframeElement = document.createElement("iframe");
     
    6161                            };
    6262                            iframeElement.id = "TheIframeThatRequestsStorageAccess";
    63                             iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,isNotSameOriginIframe";
     63                            iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldNotGrantAccess,userShouldNotBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe";
    6464                            document.body.appendChild(iframeElement);
    65 
    6665                        });
    6766                    });
  • trunk/LayoutTests/http/tests/storageAccess/grant-with-prompt-preserves-gesture.html

    r245024 r245025  
    1919                    testPassed(event.data.replace("PASS ", ""));
    2020                else
    21                     testFailed(event.data);
     21                    testFailed(event.data.replace("FAIL ", ""));
    2222            } else
    2323                testFailed("Received a message from an unexpected origin: " + event.origin);
     
    6363                            iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,isNotSameOriginIframe";
    6464                            document.body.appendChild(iframeElement);
    65 
    6665                        });
    6766                    });
  • trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html

    r241743 r245025  
    22<head>
    33    <script>
    4         if (internals)
    5             internals.setUserGrantsStorageAccess(true);
    6 
    74        function makeRequestWithUserGesture() {
    85            document.requestStorageAccess();
  • trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe-and-pop-window.html

    r231910 r245025  
    88        const isSameOriginIframe = hashArguments[3] === "isSameOriginIframe";
    99        const originIsNull = hashArguments[4] === "originIsNull";
    10 
    11         if (window.internals)
    12             internals.setUserGrantsStorageAccess(userShouldGrantAccess);
    1310
    1411        if (window.testRunner) {
     
    2623        function windowWasOpened()
    2724        {
    28             if (userShouldGrantAccess)
     25            if (userShouldBeConsulted && userShouldGrantAccess)
    2926                messageToTop("PASS Window was successfully opened with user interaction.");
     27            else if (userShouldBeConsulted && !userShouldGrantAccess)
     28                messageToTop("FAIL Window was opened even though the user explicitly declined permission.");
     29            else if (!userShouldBeConsulted && !userShouldGrantAccess)
     30                messageToTop("PASS Window was successfully opened with user interaction since the user was never consulted/prompted.");
    3031            else
    31                 messageToTop("Window was opened even though the user declined permission.");
     32                messageToTop("FAIL Conflicting instructions: !userShouldBeConsulted && userShouldGrantAccess .");
    3233        }
    3334
     
    4950            var win = window.open("request-storage-access-second-window.html", "test window");
    5051            if (!win) {
    51                 if (userShouldGrantAccess)
    52                     messageToTop("Window was not opened even though the user granted permission.");
     52                if (userShouldBeConsulted && userShouldGrantAccess)
     53                    messageToTop("FAIL Window was not opened even though the user explicitly granted permission.");
     54                else if (userShouldBeConsulted && !userShouldGrantAccess)
     55                    messageToTop("PASS Window was blocked from opening.");
     56                else if (!userShouldBeConsulted && !userShouldGrantAccess)
     57                    messageToTop("FAIL Window was blocked from opening even though the user was never consulted/prompted.");
    5358                else
    54                     messageToTop("PASS Window was blocked from opening.");
    55             } else if (!userShouldGrantAccess) {
    56                 messageToTop("Window was opened even though the user did not grant permission.");
     59                    messageToTop("FAIL Conflicting instructions: !userShouldBeConsulted && userShouldGrantAccess .");
    5760            }
    5861        }
  • trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html

    r226235 r245025  
    88        const isSameOriginIframe = hashArguments[3] === "isSameOriginIframe";
    99        const originIsNull = hashArguments[4] === "originIsNull";
    10 
    11         if (internals && userShouldGrantAccess)
    12                 internals.setUserGrantsStorageAccess(true);
    1310
    1411        var requestStorageAccessResolved;
  • trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html

    r225583 r245025  
    66        const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
    77        const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
    8 
    9         if (internals && userShouldGrantAccess)
    10                 internals.setUserGrantsStorageAccess(true);
    118
    129        var requestStorageAccessResolved;
  • trunk/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html

    r235569 r245025  
    77        const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
    88        const sameSiteNavigation = hashArguments[3] === "sameSiteNavigation";
    9 
    10         if (internals && userShouldGrantAccess)
    11             internals.setUserGrantsStorageAccess(true);
    129
    1310        var requestStorageAccessResolved;
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r245010 r245025  
    727727[ HighSierra+ ] http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
    728728[ HighSierra+ ] http/tests/storageAccess/deny-storage-access-under-opener-if-auto-dismiss.html [ Pass ]
     729[ HighSierra+ ] http/tests/storageAccess/grant-with-prompt-preserves-gesture.html [ Pass ]
     730[ HighSierra+ ] http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html [ Skip ]
     731[ HighSierra+ ] http/tests/storageAccess/deny-without-prompt-preserves-gesture.html [ Pass ]
    729732
    730733# As of https://trac.webkit.org/changeset/227762 the timestampResolution is just 5 seconds which makes this test flaky
  • trunk/Source/WebCore/ChangeLog

    r245020 r245025  
     12019-05-07  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=197648
     5        <rdar://problem/50527493>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Developers have requested two minor changes to the Storage Access API:
     10        - Only consume the user gesture when the user explicitly denies access.
     11        - Make document.hasStorageAccess() return true instead of false when the feature is off.
     12
     13        In addition to this, we have refactoring and cleanup to do. Namely:
     14        - Make use of WebCore::RegistrableDomain all the way.
     15        - Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
     16        - Introduce boolean enums for state handling.
     17        - Break out the Storage Access API functionality into a supplement of WebCore::Document.
     18
     19        Reviewed by Chris Dumez.
     20
     21        Tests: http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html
     22               http/tests/storageAccess/deny-without-prompt-preserves-gesture.html
     23               http/tests/storageAccess/grant-with-prompt-preserves-gesture.html
     24               http/tests/storageAccess/has-storage-access-true-if-feature-off.html
     25
     26        * DerivedSources-input.xcfilelist:
     27        * DerivedSources-output.xcfilelist:
     28        * DerivedSources.make:
     29        * Headers.cmake:
     30        * Sources.txt:
     31        * WebCore.xcodeproj/project.pbxproj:
     32        * dom/Document.cpp:
     33        (WebCore::Document::hasStorageAccess): Deleted.
     34        (WebCore::Document::requestStorageAccess): Deleted.
     35        (WebCore::Document::enableTemporaryTimeUserGesture): Deleted.
     36        (WebCore::Document::consumeTemporaryTimeUserGesture): Deleted.
     37        (WebCore::Document::hasFrameSpecificStorageAccess const): Deleted.
     38        (WebCore::Document::setHasFrameSpecificStorageAccess): Deleted.
     39        * dom/Document.h:
     40        (WebCore::Document::setUserGrantsStorageAccessOverride): Deleted.
     41            All of this has been moved to the supplement WebCore::DocumentStorageAccess.
     42        * dom/Document.idl:
     43            The Storage Access API has been moved to DocumentStorageAccess.idl.
     44        * dom/DocumentStorageAccess.cpp: Added.
     45        (WebCore::DocumentStorageAccess::from):
     46        (WebCore::DocumentStorageAccess::supplementName):
     47        (WebCore::DocumentStorageAccess::hasStorageAccess):
     48        (WebCore::DocumentStorageAccess::requestStorageAccess):
     49        (WebCore::DocumentStorageAccess::enableTemporaryTimeUserGesture):
     50        (WebCore::DocumentStorageAccess::consumeTemporaryTimeUserGesture):
     51        (WebCore::DocumentStorageAccess::hasFrameSpecificStorageAccess const):
     52        (WebCore::DocumentStorageAccess::setHasFrameSpecificStorageAccess):
     53        * dom/DocumentStorageAccess.h: Added.
     54        * dom/DocumentStorageAccess.idl: Added.
     55        * page/ChromeClient.h:
     56        * testing/Internals.cpp:
     57        (WebCore::Internals::setUserGrantsStorageAccess): Deleted.
     58            This was dead code.
     59        * testing/Internals.h:
     60        * testing/Internals.idl:
     61
    1622019-05-07  Antoine Quint  <graouts@apple.com>
    263
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r244782 r245025  
    563563$(PROJECT_DIR)/dom/DocumentFullscreen.idl
    564564$(PROJECT_DIR)/dom/DocumentOrShadowRoot.idl
     565$(PROJECT_DIR)/dom/DocumentStorageAccess.idl
    565566$(PROJECT_DIR)/dom/DocumentTouch.idl
    566567$(PROJECT_DIR)/dom/DocumentType.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r244782 r245025  
    474474$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentOrShadowRoot.cpp
    475475$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentOrShadowRoot.h
     476$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentStorageAccess.cpp
     477$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentStorageAccess.h
    476478$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentTimeline.cpp
    477479$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentTimeline.h
  • trunk/Source/WebCore/DerivedSources.make

    r244777 r245025  
    585585    $(WebCore)/dom/DocumentFragment.idl \
    586586    $(WebCore)/dom/DocumentOrShadowRoot.idl \
     587    $(WebCore)/dom/DocumentStorageAccess.idl \
    587588    $(WebCore)/dom/DocumentType.idl \
    588589    $(WebCore)/dom/Element.idl \
  • trunk/Source/WebCore/Headers.cmake

    r244445 r245025  
    369369    dom/DocumentMarker.h
    370370    dom/DocumentMarkerController.h
     371    dom/DocumentStorageAccess.h
    371372    dom/DocumentTiming.h
    372373    dom/DocumentType.h
  • trunk/Source/WebCore/Sources.txt

    r244977 r245025  
    845845dom/DocumentParser.cpp
    846846dom/DocumentSharedObjectPool.cpp
     847dom/DocumentStorageAccess.cpp
    847848dom/DocumentTouch.cpp @no-unify
    848849dom/DocumentType.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r244980 r245025  
    19761976                6B4E8613221B713F0022F389 /* RegistrableDomain.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B4E8612221B713F0022F389 /* RegistrableDomain.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19771977                6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1978                6BDB5DC2227BD3B800919770 /* DocumentStorageAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDB5DC0227BD3B800919770 /* DocumentStorageAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19781979                6C4C96DF1AD4483500363F64 /* JSReadableByteStreamController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500363F64 /* JSReadableByteStreamController.h */; };
    19791980                6C4C96DF1AD4483500365672 /* JSReadableStreamBYOBRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */; };
     
    90389039                6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
    90399040                6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
     9041                6BDB5DC0227BD3B800919770 /* DocumentStorageAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DocumentStorageAccess.h; sourceTree = "<group>"; };
     9042                6BDB5DC1227BD3B800919770 /* DocumentStorageAccess.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStorageAccess.cpp; sourceTree = "<group>"; };
     9043                6BDB5DC5227CA0EB00919770 /* DocumentStorageAccess.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DocumentStorageAccess.idl; sourceTree = "<group>"; };
    90409044                6C4C96DA1AD4483500363F64 /* JSReadableByteStreamController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableByteStreamController.cpp; sourceTree = "<group>"; };
    90419045                6C4C96DA1AD4483500365672 /* JSReadableStreamBYOBRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamBYOBRequest.cpp; sourceTree = "<group>"; };
     
    2592225926                                CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */,
    2592325927                                CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
     25928                                07C8AD121D073D630087C5CE /* AVAssetMIMETypeCache.h */,
     25929                                07C8AD111D073D630087C5CE /* AVAssetMIMETypeCache.mm */,
    2592425930                                CDECA8991EDF447D00DCB08B /* AVAssetTrackUtilities.h */,
    2592525931                                CDECA8981EDF447D00DCB08B /* AVAssetTrackUtilities.mm */,
    25926                                 07C8AD121D073D630087C5CE /* AVAssetMIMETypeCache.h */,
    25927                                 07C8AD111D073D630087C5CE /* AVAssetMIMETypeCache.mm */,
    2592825932                                CD11B3DF227CAAA90023AFC7 /* AVStreamDataParserMIMETypeCache.h */,
    2592925933                                CD11B3E0227CAAA90023AFC7 /* AVStreamDataParserMIMETypeCache.mm */,
     
    2722827232                                AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */,
    2722927233                                AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */,
     27234                                6BDB5DC1227BD3B800919770 /* DocumentStorageAccess.cpp */,
     27235                                6BDB5DC0227BD3B800919770 /* DocumentStorageAccess.h */,
     27236                                6BDB5DC5227CA0EB00919770 /* DocumentStorageAccess.idl */,
    2723027237                                86D982F6125C154000AD9E3D /* DocumentTiming.h */,
    2723127238                                7CE7FA5B1EF882300060C9D6 /* DocumentTouch.cpp */,
     
    2823528242                                45830D4E1679B4F800ACF8C3 /* AutoscrollController.h in Headers */,
    2823628243                                A8CFF04E0A154F09000A4234 /* AutoTableLayout.h in Headers */,
     28244                                07F4E93320B3587F002E3803 /* AVAssetMIMETypeCache.h in Headers */,
    2823728245                                CDECA89B1EDF447D00DCB08B /* AVAssetTrackUtilities.h in Headers */,
    2823828246                                CDC675271EAEA9D400727C84 /* AVAudioSessionCaptureDevice.h in Headers */,
    2823928247                                CDC675231EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h in Headers */,
    2824028248                                070363E2181A1CDC00C074A5 /* AVCaptureDeviceManager.h in Headers */,
    28241                                 07F4E93320B3587F002E3803 /* AVAssetMIMETypeCache.h in Headers */,
    2824228249                                CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */,
    2824328250                                070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */,
     
    2879628803                                4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */,
    2879728804                                AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */,
     28805                                6BDB5DC2227BD3B800919770 /* DocumentStorageAccess.h in Headers */,
    2879828806                                0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
    2879928807                                71025ED01F99F0CE004A250C /* DocumentTimeline.h in Headers */,
     
    3257632584                                CD54A762180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp in Sources */,
    3257732585                                A5F6E16B132ED46E008EDAE3 /* Autocapitalize.cpp in Sources */,
     32586                                0719427F1D088F21002AA51D /* AVAssetMIMETypeCache.mm in Sources */,
    3257832587                                CDECA89A1EDF447D00DCB08B /* AVAssetTrackUtilities.mm in Sources */,
    3257932588                                CDC675221EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.mm in Sources */,
    3258032589                                070363E3181A1CDC00C074A5 /* AVCaptureDeviceManager.mm in Sources */,
    32581                                 0719427F1D088F21002AA51D /* AVAssetMIMETypeCache.mm in Sources */,
     32590                                CD11B3E1227CE6F30023AFC7 /* AVStreamDataParserMIMETypeCache.mm in Sources */,
    3258232591                                CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */,
    3258332592                                070363E7181A1CDC00C074A5 /* AVVideoCaptureSource.mm in Sources */,
     
    3302233031                                DECA803A1F9FED6A00E3B661 /* UnifiedSource249.cpp in Sources */,
    3302333032                                DECA803B1F9FED6A00E3B661 /* UnifiedSource250.cpp in Sources */,
    33024                                 CD11B3E1227CE6F30023AFC7 /* AVStreamDataParserMIMETypeCache.mm in Sources */,
    3302533033                                DECA803C1F9FED6A00E3B661 /* UnifiedSource251.cpp in Sources */,
    3302633034                                DECA803D1F9FED6A00E3B661 /* UnifiedSource252.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.cpp

    r244998 r245025  
    113113#include "IntersectionObserver.h"
    114114#include "JSCustomElementInterface.h"
    115 #include "JSDOMPromiseDeferred.h"
    116115#include "JSLazyEventListener.h"
    117116#include "KeyboardEvent.h"
     
    77327731}
    77337732
    7734 void Document::hasStorageAccess(Ref<DeferredPromise>&& promise)
    7735 {
    7736     ASSERT(settings().storageAccessAPIEnabled());
    7737 
    7738 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    7739     if (m_frame && hasFrameSpecificStorageAccess()) {
    7740         promise->resolve<IDLBoolean>(true);
    7741         return;
    7742     }
    7743 
    7744     if (!m_frame || securityOrigin().isUnique()) {
    7745         promise->resolve<IDLBoolean>(false);
    7746         return;
    7747     }
    7748    
    7749     if (m_frame->isMainFrame()) {
    7750         promise->resolve<IDLBoolean>(true);
    7751         return;
    7752     }
    7753    
    7754     auto& securityOrigin = this->securityOrigin();
    7755     auto& topSecurityOrigin = topDocument().securityOrigin();
    7756     if (securityOrigin.equal(&topSecurityOrigin)) {
    7757         promise->resolve<IDLBoolean>(true);
    7758         return;
    7759     }
    7760 
    7761     auto frameID = m_frame->loader().client().frameID();
    7762     auto pageID = m_frame->loader().client().pageID();
    7763     if (!frameID || !pageID) {
    7764         promise->reject();
    7765         return;
    7766     }
    7767 
    7768     if (Page* page = this->page()) {
    7769         auto iframeHost = securityOrigin.host();
    7770         auto topHost = topSecurityOrigin.host();
    7771         page->chrome().client().hasStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = makeWeakPtr(*this), promise = WTFMove(promise)] (bool hasAccess) {
    7772             Document* document = documentReference.get();
    7773             if (!document)
    7774                 return;
    7775            
    7776             promise->resolve<IDLBoolean>(hasAccess);
    7777         });
    7778         return;
    7779     }
    7780 #endif
    7781 
    7782     promise->reject();
    7783 }
    7784 
    7785 void Document::requestStorageAccess(Ref<DeferredPromise>&& promise)
    7786 {
    7787     ASSERT(settings().storageAccessAPIEnabled());
    7788    
    7789 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    7790     if (m_frame && hasFrameSpecificStorageAccess()) {
    7791         promise->resolve();
    7792         return;
    7793     }
    7794    
    7795     if (!m_frame || securityOrigin().isUnique()) {
    7796         promise->reject();
    7797         return;
    7798     }
    7799    
    7800     if (m_frame->isMainFrame()) {
    7801         promise->resolve();
    7802         return;
    7803     }
    7804    
    7805     auto& topDocument = this->topDocument();
    7806     auto& topSecurityOrigin = topDocument.securityOrigin();
    7807     auto& securityOrigin = this->securityOrigin();
    7808     if (securityOrigin.equal(&topSecurityOrigin)) {
    7809         promise->resolve();
    7810         return;
    7811     }
    7812    
    7813     // If there is a sandbox, it has to allow the storage access API to be called.
    7814     if (sandboxFlags() != SandboxNone && isSandboxed(SandboxStorageAccessByUserActivation)) {
    7815         promise->reject();
    7816         return;
    7817     }
    7818 
    7819     // The iframe has to be a direct child of the top document.
    7820     if (&topDocument != parentDocument()) {
    7821         promise->reject();
    7822         return;
    7823     }
    7824 
    7825     if (!UserGestureIndicator::processingUserGesture()) {
    7826         promise->reject();
    7827         return;
    7828     }
    7829    
    7830     auto iframeHost = securityOrigin.host();
    7831     auto topHost = topSecurityOrigin.host();
    7832 
    7833     Page* page = this->page();
    7834     auto frameID = m_frame->loader().client().frameID();
    7835     auto pageID = m_frame->loader().client().pageID();
    7836     if (!page || !frameID || !pageID) {
    7837         promise->reject();
    7838         return;
    7839     }
    7840 
    7841     page->chrome().client().requestStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = makeWeakPtr(*this), promise = WTFMove(promise)] (bool wasGranted) mutable {
    7842         Document* document = documentReference.get();
    7843         if (!document)
    7844             return;
    7845        
    7846         if (wasGranted) {
    7847             document->setHasFrameSpecificStorageAccess(true);
    7848             MicrotaskQueue::mainThreadQueue().append(std::make_unique<VoidMicrotask>([documentReference = makeWeakPtr(*document)] () {
    7849                 if (auto* document = documentReference.get())
    7850                     document->enableTemporaryTimeUserGesture();
    7851             }));
    7852             promise->resolve();
    7853             MicrotaskQueue::mainThreadQueue().append(std::make_unique<VoidMicrotask>([documentReference = WTFMove(documentReference)] () {
    7854                 if (auto* document = documentReference.get())
    7855                     document->consumeTemporaryTimeUserGesture();
    7856             }));
    7857         } else
    7858             promise->reject();
    7859     });
    7860 #else
    7861     promise->reject();
    7862 #endif
    7863 }
    7864 
    7865 void Document::enableTemporaryTimeUserGesture()
    7866 {
    7867     m_temporaryUserGesture = std::make_unique<UserGestureIndicator>(ProcessingUserGesture, this);
    7868 }
    7869 
    7870 void Document::consumeTemporaryTimeUserGesture()
    7871 {
    7872     m_temporaryUserGesture = nullptr;
    7873 }
    7874 
    78757733void Document::registerArticleElement(Element& article)
    78767734{
     
    79407798
    79417799#if ENABLE(RESOURCE_LOAD_STATISTICS)
    7942 bool Document::hasFrameSpecificStorageAccess() const
    7943 {
    7944     return m_frame && m_frame->loader().client().hasFrameSpecificStorageAccess();
    7945 }
    7946    
    7947 void Document::setHasFrameSpecificStorageAccess(bool value)
    7948 {
    7949     if (m_frame)
    7950         m_frame->loader().client().setHasFrameSpecificStorageAccess(value);
    7951 }
    7952 
    79537800bool Document::hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain& domain)
    79547801{
  • trunk/Source/WebCore/dom/Document.h

    r244998 r245025  
    109109class Database;
    110110class DatabaseThread;
    111 class DeferredPromise;
    112111class DocumentFragment;
    113112class DocumentLoader;
     
    14661465    Logger& logger();
    14671466
    1468     void hasStorageAccess(Ref<DeferredPromise>&& passedPromise);
    1469     void requestStorageAccess(Ref<DeferredPromise>&& passedPromise);
    1470     void setUserGrantsStorageAccessOverride(bool value) { m_grantStorageAccessOverride = value; }
    1471 
    14721467    WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
    14731468
     
    15031498    String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&);
    15041499
    1505     void consumeTemporaryTimeUserGesture();
    1506 
    15071500    void registerArticleElement(Element&);
    15081501    void unregisterArticleElement(Element&);
     
    16451638
    16461639    void platformSuspendOrStopActiveDOMObjects();
    1647 
    1648     void enableTemporaryTimeUserGesture();
    16491640
    16501641    bool isBodyPotentiallyScrollable(HTMLBodyElement&);
     
    18521843    void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) final;
    18531844
    1854 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    1855     bool hasFrameSpecificStorageAccess() const;
    1856     void setHasFrameSpecificStorageAccess(bool);
    1857 #endif
    1858 
    18591845#if ENABLE(DEVICE_ORIENTATION)
    18601846#if PLATFORM(IOS_FAMILY)
     
    20342020    static bool hasEverCreatedAnAXObjectCache;
    20352021
    2036     bool m_grantStorageAccessOverride { false };
    2037 
    20382022    RefPtr<DocumentTimeline> m_timeline;
    20392023    DocumentIdentifier m_identifier;
     
    20492033#endif
    20502034   
    2051     std::unique_ptr<UserGestureIndicator> m_temporaryUserGesture;
    2052 
    20532035    CSSRegisteredCustomPropertySet m_CSSRegisteredPropertySet;
    20542036
  • trunk/Source/WebCore/dom/Document.idl

    r244440 r245025  
    174174    RenderingContext? getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
    175175
    176     // Non standard, to bring up with standards working group.
    177     [EnabledBySetting=StorageAccessAPI] Promise<bool> hasStorageAccess();
    178     [EnabledBySetting=StorageAccessAPI] Promise<void> requestStorageAccess();
    179 
    180176    // Obsolete features from https://html.spec.whatwg.org/multipage/obsolete.html
    181177
  • trunk/Source/WebCore/page/ChromeClient.h

    r244633 r245025  
    2929#include "DisabledAdaptations.h"
    3030#include "DisplayRefreshMonitor.h"
     31#include "DocumentStorageAccess.h"
    3132#include "FocusDirection.h"
    3233#include "FrameLoader.h"
     
    4142#include "PopupMenu.h"
    4243#include "PopupMenuClient.h"
     44#include "RegistrableDomain.h"
    4345#include "RenderEmbeddedObject.h"
    4446#include "ScrollTypes.h"
     
    484486    virtual RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) = 0;
    485487
    486     virtual void hasStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
    487     virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
     488#if ENABLE(RESOURCE_LOAD_STATISTICS)
     489    virtual void hasStorageAccess(RegistrableDomain&& /*subFrameDomain*/, RegistrableDomain&& /*topFrameDomain*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void(bool)>&& completionHandler) { completionHandler(false); }
     490    virtual void requestStorageAccess(RegistrableDomain&& /*subFrameDomain*/, RegistrableDomain&& /*topFrameDomain*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&& completionHandler) { completionHandler(StorageAccessWasGranted::No, StorageAccessPromptWasShown::No); }
     491#endif
    488492
    489493#if ENABLE(DEVICE_ORIENTATION)
  • trunk/Source/WebCore/testing/Internals.cpp

    r244823 r245025  
    43784378}
    43794379
    4380 void Internals::setUserGrantsStorageAccess(bool value)
    4381 {
    4382     Document* document = contextDocument();
    4383     if (!document)
    4384         return;
    4385 
    4386     document->setUserGrantsStorageAccessOverride(value);
    4387 }
    4388 
    43894380String Internals::composedTreeAsText(Node& node)
    43904381{
  • trunk/Source/WebCore/testing/Internals.h

    r244823 r245025  
    640640    String resourceLoadStatisticsForURL(const DOMURL&);
    641641    void setResourceLoadStatisticsEnabled(bool);
    642     void setUserGrantsStorageAccess(bool);
    643642
    644643#if ENABLE(STREAMS_API)
  • trunk/Source/WebCore/testing/Internals.idl

    r244823 r245025  
    626626    DOMString resourceLoadStatisticsForURL(DOMURL url);
    627627    void setResourceLoadStatisticsEnabled(boolean enable);
    628     [EnabledBySetting=StorageAccessAPI] void setUserGrantsStorageAccess(boolean value);
    629628
    630629    [MayThrowException] void setCanShowModalDialogOverride(boolean allow);
  • trunk/Source/WebKit/ChangeLog

    r245023 r245025  
     12019-05-07  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=197648
     5        <rdar://problem/50527493>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Developers have requested two minor changes to the Storage Access API:
     10        - Only consume the user gesture when the user explicitly denies access.
     11        - Make document.hasStorageAccess() return true instead of false when the feature is off.
     12
     13        In addition to this, we have refactoring and cleanup to do. Namely:
     14        - Make use of WebCore::RegistrableDomain all the way.
     15        - Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
     16        - Introduce boolean enums for state handling.
     17        - Break out the Storage Access API functionality into a supplement of WebCore::Document.
     18
     19        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     20        (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
     21        (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
     22        (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
     23        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
     24        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
     25        (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):
     26            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     27            WebCore::StorageAccessPromptWasShown.
     28        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
     29        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     30        (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
     31        (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
     32        (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
     33        (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
     34        (WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt):
     35            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     36            WebCore::StorageAccessPromptWasShown.
     37        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
     38        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
     39            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     40            WebCore::StorageAccessPromptWasShown.
     41        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     42        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
     43        (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
     44        (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
     45            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     46            WebCore::StorageAccessPromptWasShown.
     47        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): Deleted.
     48            This function is now no longer exposed and its functionality could be folded into
     49            the existing WebResourceLoadStatisticsStore::requestStorageAccess() which is more
     50            clearly named.
     51        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     52        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     53        (WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
     54        (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
     55            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     56            WebCore::StorageAccessPromptWasShown.
     57        * NetworkProcess/NetworkConnectionToWebProcess.h:
     58        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     59        * NetworkProcess/NetworkProcess.cpp:
     60        (WebKit::NetworkProcess::hasStorageAccessForFrame): Deleted.
     61        (WebKit::NetworkProcess::hasStorageAccess): Deleted.
     62        (WebKit::NetworkProcess::requestStorageAccess): Deleted.
     63        (WebKit::NetworkProcess::requestStorageAccessGranted): Deleted.
     64        (WebKit::NetworkProcess::grantStorageAccess): Deleted.
     65        (WebKit::NetworkProcess::removeAllStorageAccess): Deleted.
     66            These functions were left behind in the move of ITP to the network process.
     67            This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
     68        * NetworkProcess/NetworkProcess.h:
     69        * NetworkProcess/NetworkProcess.messages.in:
     70        * Scripts/webkit/messages.py:
     71            Instructions for derived IPC code on how to include the new enums
     72            WebCore::StorageAccessWasGranted and WebCore::StorageAccessPromptWasShown.
     73        * UIProcess/Network/NetworkProcessProxy.cpp:
     74        (WebKit::NetworkProcessProxy::hasStorageAccessForFrame): Deleted.
     75        (WebKit::NetworkProcessProxy::hasStorageAccess): Deleted.
     76        (WebKit::NetworkProcessProxy::requestStorageAccess): Deleted.
     77        (WebKit::NetworkProcessProxy::grantStorageAccess): Deleted.
     78        (WebKit::NetworkProcessProxy::removeAllStorageAccess): Deleted.
     79            These functions were left behind in the move of ITP to the network process.
     80            This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
     81        * UIProcess/Network/NetworkProcessProxy.h:
     82        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     83        (WebKit::WebsiteDataStore::hasStorageAccess): Deleted.
     84        (WebKit::WebsiteDataStore::requestStorageAccess): Deleted.
     85        (WebKit::WebsiteDataStore::grantStorageAccess): Deleted.
     86            These functions were left behind in the move of ITP to the network process.
     87            This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
     88        * UIProcess/WebsiteData/WebsiteDataStore.h:
     89        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     90        (WebKit::WebChromeClient::hasStorageAccess):
     91        (WebKit::WebChromeClient::requestStorageAccess):
     92            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     93            WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
     94            objects instead of Strings now.
     95        * WebProcess/WebCoreSupport/WebChromeClient.h:
     96        * WebProcess/WebPage/WebPage.cpp:
     97        (WebKit::WebPage::hasStorageAccess):
     98        (WebKit::WebPage::requestStorageAccess):
     99            These changes are due to the new enums WebCore::StorageAccessWasGranted and
     100            WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
     101            objects instead of Strings now.
     102        * WebProcess/WebPage/WebPage.h:
     103
    11042019-05-07  John Wilander  <wilander@apple.com>
    2105
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r243181 r245025  
    3838#include "WebResourceLoadStatisticsTelemetry.h"
    3939#include "WebsiteDataStore.h"
     40#include <WebCore/DocumentStorageAccess.h>
    4041#include <WebCore/KeyedCoding.h>
    4142#include <WebCore/NetworkStorageSession.h>
     
    454455}
    455456
    456 void ResourceLoadStatisticsDatabaseStore::insertDomainRelationships(const WebCore::ResourceLoadStatistics& loadStatistics)
     457void ResourceLoadStatisticsDatabaseStore::insertDomainRelationships(const ResourceLoadStatistics& loadStatistics)
    457458{
    458459    ASSERT(!RunLoop::isMain());
     
    769770
    770771    auto userWasPromptedEarlier = hasUserGrantedStorageAccessThroughPrompt(subFrameStatus.second, topFrameDomain);
    771     if (!userWasPromptedEarlier) {
     772    if (userWasPromptedEarlier == StorageAccessPromptWasShown::No) {
    772773#if !RELEASE_LOG_DISABLED
    773774        RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "About to ask the user whether they want to grant storage access to %{public}s under %{public}s or not.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data());
     
    778779
    779780#if !RELEASE_LOG_DISABLED
    780     if (userWasPromptedEarlier)
     781    if (userWasPromptedEarlier == StorageAccessPromptWasShown::Yes)
    781782        RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "Storage access was granted to %{public}s under %{public}s.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data());
    782783#endif
     
    789790    }
    790791   
    791     grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable {
    792         completionHandler(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
     792    grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (StorageAccessWasGranted wasGranted) mutable {
     793        completionHandler(wasGranted == StorageAccessWasGranted::Yes ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
    793794    });
    794795}
     
    810811    RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "[Temporary combatibility fix] Storage access was granted for %{public}s under opener page from %{public}s, with user interaction in the opened window.", domainInNeedOfStorageAccess.string().utf8().data(), openerDomain.string().utf8().data());
    811812#endif
    812     grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), WTF::nullopt, openerPageID, false, [](bool) { });
    813 }
    814 
    815 void ResourceLoadStatisticsDatabaseStore::grantStorageAccess(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler)
    816 {
    817     ASSERT(!RunLoop::isMain());
    818 
    819     if (userWasPromptedNow) {
     813    grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), WTF::nullopt, openerPageID, StorageAccessPromptWasShown::No, [](StorageAccessWasGranted) { });
     814}
     815
     816void ResourceLoadStatisticsDatabaseStore::grantStorageAccess(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, StorageAccessPromptWasShown promptWasShown, CompletionHandler<void(StorageAccessWasGranted)>&& completionHandler)
     817{
     818    ASSERT(!RunLoop::isMain());
     819
     820    if (promptWasShown == StorageAccessPromptWasShown::Yes) {
    820821        auto subFrameStatus = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    821822        ASSERT(subFrameStatus.first == AddedRecord::No);
     
    824825    }
    825826
    826     grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedNow, WTFMove(completionHandler));
    827 }
    828 
    829 void ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, Optional<FrameID> frameID, PageID pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback)
     827    grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, promptWasShown, WTFMove(completionHandler));
     828}
     829
     830void ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, Optional<FrameID> frameID, PageID pageID, StorageAccessPromptWasShown promptWasShownNowOrEarlier, CompletionHandler<void(StorageAccessWasGranted)>&& completionHandler)
    830831{
    831832    ASSERT(!RunLoop::isMain());
    832833
    833834    if (subFrameDomain == topFrameDomain) {
    834         callback(true);
    835         return;
    836     }
    837 
    838     if (userWasPromptedNowOrEarlier) {
     835        completionHandler(StorageAccessWasGranted::Yes);
     836        return;
     837    }
     838
     839    if (promptWasShownNowOrEarlier == StorageAccessPromptWasShown::Yes) {
    839840#ifndef NDEBUG
    840841        auto subFrameStatus = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    841842        ASSERT(subFrameStatus.first == AddedRecord::No);
    842843        ASSERT(hasHadUserInteraction(subFrameDomain, OperatingDatesWindow::Long));
    843         ASSERT(hasUserGrantedStorageAccessThroughPrompt(subFrameStatus.second, topFrameDomain));
     844        ASSERT(hasUserGrantedStorageAccessThroughPrompt(subFrameStatus.second, topFrameDomain) == StorageAccessPromptWasShown::Yes);
    844845#endif
    845846        setUserInteraction(subFrameDomain, true, WallTime::now());
    846847    }
    847848
    848     RunLoop::main().dispatch([subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, store = makeRef(store()), callback = WTFMove(callback)]() mutable {
    849         store->callGrantStorageAccessHandler(subFrameDomain, topFrameDomain, frameID, pageID, [callback = WTFMove(callback), store = store.copyRef()](bool value) mutable {
    850             store->statisticsQueue().dispatch([callback = WTFMove(callback), value] () mutable {
    851                 callback(value);
     849    RunLoop::main().dispatch([subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, store = makeRef(store()), completionHandler = WTFMove(completionHandler)]() mutable {
     850        store->callGrantStorageAccessHandler(subFrameDomain, topFrameDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler), store = store.copyRef()](StorageAccessWasGranted wasGranted) mutable {
     851            store->statisticsQueue().dispatch([wasGranted, completionHandler = WTFMove(completionHandler)] () mutable {
     852                completionHandler(wasGranted);
    852853            });
    853854        });
     
    13501351}
    13511352   
    1352 bool ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt(unsigned requestingDomainID, const RegistrableDomain& firstPartyDomain) const
     1353StorageAccessPromptWasShown ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt(unsigned requestingDomainID, const RegistrableDomain& firstPartyDomain) const
    13531354{
    13541355    ASSERT(!RunLoop::isMain());
     
    13591360    if (statement.prepare() != SQLITE_OK
    13601361        || statement.step() != SQLITE_ROW)
    1361         return false;
    1362 
    1363     return !statement.getColumnInt(0);
     1362        return StorageAccessPromptWasShown::No;
     1363
     1364    return !statement.getColumnInt(0) ? StorageAccessPromptWasShown::Yes : StorageAccessPromptWasShown::No;
    13641365}
    13651366
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h

    r244225 r245025  
    4040class SQLiteDatabase;
    4141class SQLiteStatement;
     42enum class StorageAccessPromptWasShown : bool;
     43enum class StorageAccessWasGranted : bool;
    4244struct ResourceLoadStatistics;
    4345}
     
    9294    void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&) override;
    9395    void requestStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, CompletionHandler<void(StorageAccessStatus)>&&) override;
    94     void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&) override;
     96    void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, WebCore::StorageAccessPromptWasShown, CompletionHandler<void(WebCore::StorageAccessWasGranted)>&&) override;
    9597
    9698    void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) override;
     
    129131    void clearExpiredUserInteractions();
    130132    void clearGrandfathering(Vector<unsigned>&&);
    131     bool hasUserGrantedStorageAccessThroughPrompt(unsigned domainID, const RegistrableDomain&) const;
     133    WebCore::StorageAccessPromptWasShown hasUserGrantedStorageAccessThroughPrompt(unsigned domainID, const RegistrableDomain&) const;
    132134    void incrementRecordsDeletedCountForDomains(HashSet<RegistrableDomain>&&) override;
    133135
     
    151153    unsigned recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain(unsigned primaryDomainID, StdSet<unsigned>& nonPrevalentRedirectionSources, unsigned numberOfRecursiveCalls);
    152154    void setDomainsAsPrevalent(StdSet<unsigned>&&);
    153     void grantStorageAccessInternal(SubFrameDomain&&, TopFrameDomain&&, Optional<FrameID>, PageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&);
     155    void grantStorageAccessInternal(SubFrameDomain&&, TopFrameDomain&&, Optional<FrameID>, PageID, WebCore::StorageAccessPromptWasShown, CompletionHandler<void(WebCore::StorageAccessWasGranted)>&&);
    154156    void markAsPrevalentIfHasRedirectedToPrevalent();
    155157    Vector<RegistrableDomain> ensurePrevalentResourcesForDebugMode() override;
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r243181 r245025  
    3838#include "WebResourceLoadStatisticsTelemetry.h"
    3939#include "WebsiteDataStore.h"
     40#include <WebCore/DocumentStorageAccess.h>
    4041#include <WebCore/KeyedCoding.h>
    4142#include <WebCore/NetworkStorageSession.h>
     
    245246
    246247    auto userWasPromptedEarlier = hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFrameDomain);
    247     if (!userWasPromptedEarlier) {
     248    if (userWasPromptedEarlier == StorageAccessPromptWasShown::No) {
    248249#if !RELEASE_LOG_DISABLED
    249250        RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "About to ask the user whether they want to grant storage access to %{public}s under %{public}s or not.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data());
     
    254255
    255256#if !RELEASE_LOG_DISABLED
    256     if (userWasPromptedEarlier)
     257    if (userWasPromptedEarlier == StorageAccessPromptWasShown::Yes)
    257258        RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "Storage access was granted to %{public}s under %{public}s.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data());
    258259#endif
     
    260261    subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++;
    261262
    262     grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable {
    263         completionHandler(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
     263    grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (StorageAccessWasGranted wasGranted) mutable {
     264        completionHandler(wasGranted == StorageAccessWasGranted::Yes ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
    264265    });
    265266}
     
    283284    RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ResourceLoadStatisticsDebug, "[Temporary combatibility fix] Storage access was granted for %{public}s under opener page from %{public}s, with user interaction in the opened window.", domainInNeedOfStorageAccess.string().utf8().data(), openerDomain.string().utf8().data());
    284285#endif
    285     grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), WTF::nullopt, openerPageID, false, [](bool) { });
    286 }
    287 
    288 void ResourceLoadStatisticsMemoryStore::grantStorageAccess(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler)
    289 {
    290     ASSERT(!RunLoop::isMain());
    291 
    292     if (userWasPromptedNow) {
     286    grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), WTF::nullopt, openerPageID, StorageAccessPromptWasShown::No, [](StorageAccessWasGranted) { });
     287}
     288
     289void ResourceLoadStatisticsMemoryStore::grantStorageAccess(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, StorageAccessPromptWasShown promptWasShown, CompletionHandler<void(StorageAccessWasGranted)>&& completionHandler)
     290{
     291    ASSERT(!RunLoop::isMain());
     292
     293    if (promptWasShown == StorageAccessPromptWasShown::Yes) {
    293294        auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    294295        ASSERT(subFrameStatistic.hadUserInteraction);
    295296        subFrameStatistic.storageAccessUnderTopFrameDomains.add(topFrameDomain);
    296297    }
    297     grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedNow, WTFMove(completionHandler));
    298 }
    299 
    300 void ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, Optional<FrameID> frameID, PageID pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback)
     298    grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, promptWasShown, WTFMove(completionHandler));
     299}
     300
     301void ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal(SubFrameDomain&& subFrameDomain, TopFrameDomain&& topFrameDomain, Optional<FrameID> frameID, PageID pageID, StorageAccessPromptWasShown promptWasShownNowOrEarlier, CompletionHandler<void(StorageAccessWasGranted)>&& completionHandler)
    301302{
    302303    ASSERT(!RunLoop::isMain());
    303304
    304305    if (subFrameDomain == topFrameDomain) {
    305         callback(true);
    306         return;
    307     }
    308 
    309     if (userWasPromptedNowOrEarlier) {
     306        completionHandler(StorageAccessWasGranted::Yes);
     307        return;
     308    }
     309
     310    if (promptWasShownNowOrEarlier == StorageAccessPromptWasShown::Yes) {
    310311        auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    311312        ASSERT(subFrameStatistic.hadUserInteraction);
     
    314315    }
    315316
    316     RunLoop::main().dispatch([subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, store = makeRef(store()), callback = WTFMove(callback)]() mutable {
    317         store->callGrantStorageAccessHandler(subFrameDomain, topFrameDomain, frameID, pageID, [callback = WTFMove(callback), store = store.copyRef()](bool value) mutable {
    318             store->statisticsQueue().dispatch([callback = WTFMove(callback), value] () mutable {
    319                 callback(value);
     317    RunLoop::main().dispatch([subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, store = makeRef(store()), completionHandler = WTFMove(completionHandler)]() mutable {
     318        store->callGrantStorageAccessHandler(subFrameDomain, topFrameDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler), store = store.copyRef()](StorageAccessWasGranted wasGranted) mutable {
     319            store->statisticsQueue().dispatch([wasGranted, completionHandler = WTFMove(completionHandler)] () mutable {
     320                completionHandler(wasGranted);
    320321            });
    321322        });
     
    742743}
    743744
    744 bool ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const RegistrableDomain& firstPartyDomain)
    745 {
    746     return statistic.storageAccessUnderTopFrameDomains.contains(firstPartyDomain);
     745StorageAccessPromptWasShown ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const RegistrableDomain& firstPartyDomain)
     746{
     747    return statistic.storageAccessUnderTopFrameDomains.contains(firstPartyDomain) ? StorageAccessPromptWasShown::Yes : StorageAccessPromptWasShown::No;
    747748}
    748749
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h

    r243181 r245025  
    3838class KeyedDecoder;
    3939class KeyedEncoder;
     40enum class StorageAccessPromptWasShown : bool;
     41enum class StorageAccessWasGranted : bool;
    4042struct ResourceLoadStatistics;
    4143}
     
    98100    void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&) override;
    99101    void requestStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, CompletionHandler<void(StorageAccessStatus)>&&) override;
    100     void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&) override;
     102    void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, WebCore::StorageAccessPromptWasShown, CompletionHandler<void(WebCore::StorageAccessWasGranted)>&&) override;
    101103
    102104    void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) override;
     
    114116    static bool shouldBlockAndKeepCookies(const ResourceLoadStatistics&);
    115117    static bool shouldBlockAndPurgeCookies(const ResourceLoadStatistics&);
    116     static bool hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics&, const RegistrableDomain&);
     118    static WebCore::StorageAccessPromptWasShown hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics&, const RegistrableDomain&);
    117119    bool hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics&, OperatingDatesWindow) const;
    118120    bool shouldRemoveAllWebsiteDataFor(ResourceLoadStatistics&, bool shouldCheckForGrandfathering) const;
     
    122124    void setPrevalentResource(ResourceLoadStatistics&, ResourceLoadPrevalence);
    123125    unsigned recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const ResourceLoadStatistics&, HashSet<RedirectedToDomain>&, unsigned numberOfRecursiveCalls) const;
    124     void grantStorageAccessInternal(SubFrameDomain&&, TopFrameDomain&&, Optional<FrameID>, PageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&);
     126    void grantStorageAccessInternal(SubFrameDomain&&, TopFrameDomain&&, Optional<FrameID>, PageID, WebCore::StorageAccessPromptWasShown, CompletionHandler<void(WebCore::StorageAccessWasGranted)>&&);
    125127    void markAsPrevalentIfHasRedirectedToPrevalent(ResourceLoadStatistics&);
    126128    bool isPrevalentDueToDebugMode(ResourceLoadStatistics&);
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h

    r243181 r245025  
    4242class KeyedDecoder;
    4343class KeyedEncoder;
     44enum class StorageAccessPromptWasShown : bool;
     45enum class StorageAccessWasGranted : bool;
    4446struct ResourceLoadStatistics;
    4547}
     
    162164    virtual void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&) = 0;
    163165    virtual void requestStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, CompletionHandler<void(StorageAccessStatus)>&&) = 0;
    164     virtual void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&) = 0;
     166    virtual void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, WebCore::StorageAccessPromptWasShown, CompletionHandler<void(WebCore::StorageAccessWasGranted)>&&) = 0;
    165167
    166168    virtual void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) = 0;
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r243671 r245025  
    4848#include <WebCore/DiagnosticLoggingClient.h>
    4949#include <WebCore/DiagnosticLoggingKeys.h>
     50#include <WebCore/DocumentStorageAccess.h>
    5051#include <WebCore/NetworkStorageSession.h>
    5152#include <WebCore/ResourceLoadStatistics.h>
     
    315316}
    316317
    317 void WebResourceLoadStatisticsStore::requestStorageAccessGranted(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    318 {
     318void WebResourceLoadStatisticsStore::requestStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&& completionHandler)
     319{
     320    if (subFrameDomain == topFrameDomain) {
     321        completionHandler(StorageAccessWasGranted::Yes, StorageAccessPromptWasShown::No);
     322        return;
     323    }
     324   
    319325    auto statusHandler = [this, protectedThis = makeRef(*this), subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {
    320326        switch (status) {
    321327        case StorageAccessStatus::CannotRequestAccess:
    322             completionHandler(false);
     328            completionHandler(StorageAccessWasGranted::No, StorageAccessPromptWasShown::No);
    323329            return;
    324330        case StorageAccessStatus::RequiresUserPrompt:
     
    326332            CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = protectedThis.copyRef(), subFrameDomain, topFrameDomain, frameID, pageID, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable {
    327333                if (userDidGrantAccess)
    328                     grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, userDidGrantAccess, WTFMove(completionHandler));
     334                    grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, StorageAccessPromptWasShown::Yes, WTFMove(completionHandler));
    329335                else
    330                     completionHandler(false);
     336                    completionHandler(StorageAccessWasGranted::No, StorageAccessPromptWasShown::Yes);
    331337            };
    332338            m_networkSession->networkProcess().parentProcessConnection()->sendWithAsyncReply(Messages::NetworkProcessProxy::RequestStorageAccessConfirm(pageID, frameID, subFrameDomain, topFrameDomain), WTFMove(requestConfirmationCompletionHandler));
     
    334340            return;
    335341        case StorageAccessStatus::HasAccess:
    336             completionHandler(true);
     342            completionHandler(StorageAccessWasGranted::Yes, StorageAccessPromptWasShown::No);
    337343            return;
    338344        }
    339345    };
    340346
    341     requestStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(statusHandler));
    342 }
    343 
    344 void WebResourceLoadStatisticsStore::requestStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
    345 {
    346     if (subFrameDomain == topFrameDomain) {
    347         completionHandler(StorageAccessStatus::HasAccess);
    348         return;
    349     }
    350 
    351     postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {
     347    postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, statusHandler = WTFMove(statusHandler)]() mutable {
    352348        if (!m_statisticsStore) {
    353             postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
    354                 completionHandler(StorageAccessStatus::CannotRequestAccess);
     349            postTaskReply([statusHandler = WTFMove(statusHandler)]() mutable {
     350                statusHandler(StorageAccessStatus::CannotRequestAccess);
    355351            });
    356352            return;
     
    358354
    359355        if (m_statisticsStore) {
    360             m_statisticsStore->requestStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID.value(), pageID, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {
    361                 postTaskReply([completionHandler = WTFMove(completionHandler), status]() mutable {
    362                     completionHandler(status);
     356            m_statisticsStore->requestStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, [statusHandler = WTFMove(statusHandler)](StorageAccessStatus status) mutable {
     357                postTaskReply([statusHandler = WTFMove(statusHandler), status]() mutable {
     358                    statusHandler(status);
    363359                });
    364360            });
     
    380376}
    381377
    382 void WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler)
    383 {
    384     ASSERT(RunLoop::isMain());
    385     postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)]() mutable {
     378void WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, StorageAccessPromptWasShown promptWasShown, CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&& completionHandler)
     379{
     380    ASSERT(RunLoop::isMain());
     381    postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, promptWasShown, completionHandler = WTFMove(completionHandler)]() mutable {
    386382        if (!m_statisticsStore) {
    387             postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
    388                 completionHandler(false);
     383            postTaskReply([promptWasShown, completionHandler = WTFMove(completionHandler)]() mutable {
     384                completionHandler(StorageAccessWasGranted::No, promptWasShown);
    389385            });
    390386            return;
     
    392388
    393389        if (m_statisticsStore) {
    394             m_statisticsStore->grantStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)](bool wasGrantedAccess) mutable {
    395                 postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess]() mutable {
    396                     completionHandler(wasGrantedAccess);
     390            m_statisticsStore->grantStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, promptWasShown, [promptWasShown, completionHandler = WTFMove(completionHandler)](StorageAccessWasGranted wasGrantedAccess) mutable {
     391                postTaskReply([wasGrantedAccess, promptWasShown, completionHandler = WTFMove(completionHandler)]() mutable {
     392                    completionHandler(wasGrantedAccess, promptWasShown);
    397393                });
    398394            });
     
    401397}
    402398
    403 bool WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)
     399StorageAccessWasGranted WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)
    404400{
    405401    bool isStorageGranted = false;
     
    411407    }
    412408
    413     return isStorageGranted;
    414 }
    415 
    416 void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback)
    417 {
    418     ASSERT(RunLoop::isMain());
    419 
    420     callback(grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID));
     409    return isStorageGranted ? StorageAccessWasGranted::Yes : StorageAccessWasGranted::No;
     410}
     411
     412void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(StorageAccessWasGranted)>&& completionHandler)
     413{
     414    ASSERT(RunLoop::isMain());
     415
     416    completionHandler(grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID));
    421417}
    422418
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r243671 r245025  
    4949enum class ShouldSample : bool;
    5050enum class IncludeHttpOnlyCookies : bool;
     51enum class StorageAccessPromptWasShown : bool;
     52enum class StorageAccessWasGranted : bool;
    5153}
    5254
     
    8486    using PageID = uint64_t;
    8587    using FrameID = uint64_t;
     88    using StorageAccessWasGranted = WebCore::StorageAccessWasGranted;
     89    using StorageAccessPromptWasShown = WebCore::StorageAccessPromptWasShown;
    8690
    8791    static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost)
     
    101105    void setShouldSubmitTelemetry(bool);
    102106
    103     void grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&);
     107    void grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, StorageAccessPromptWasShown, CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&&);
    104108
    105109    void applicationWillTerminate();
     
    115119    void deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, HashMap<RegistrableDomain, WebsiteDataToRemove>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
    116120    void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
    117     bool grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID);
     121    StorageAccessWasGranted grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID);
    118122    void hasHadUserInteraction(const RegistrableDomain&, CompletionHandler<void(bool)>&&);
    119     void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&& callback);
     123    void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&);
    120124    bool hasStorageAccessForFrame(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID);
    121     void requestStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(StorageAccessStatus)>&&);
    122     void requestStorageAccessGranted(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&);
     125    void requestStorageAccess(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&&);
    123126    void setLastSeen(const RegistrableDomain&, Seconds, CompletionHandler<void()>&&);
    124127    void setPrevalentResource(const RegistrableDomain&, CompletionHandler<void()>&&);
     
    163166
    164167    void logTestingEvent(const String&);
    165     void callGrantStorageAccessHandler(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&);
     168    void callGrantStorageAccessHandler(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(StorageAccessWasGranted)>&&);
    166169    void removeAllStorageAccess(CompletionHandler<void()>&&);
    167170    void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r244700 r245025  
    5858#include "WebSWServerToContextConnectionMessages.h"
    5959#include "WebsiteDataStoreParameters.h"
     60#include <WebCore/DocumentStorageAccess.h>
    6061#include <WebCore/NetworkStorageSession.h>
    6162#include <WebCore/ResourceLoadStatistics.h>
     
    681682void NetworkConnectionToWebProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    682683{
    683     networkProcess().hasStorageAccess(sessionID, subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
    684 }
    685 
    686 void NetworkConnectionToWebProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    687 {
    688     networkProcess().requestStorageAccessGranted(sessionID, subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
     684    if (auto networkSession = networkProcess().networkSession(sessionID)) {
     685        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     686            resourceLoadStatistics->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
     687    }
     688}
     689
     690void NetworkConnectionToWebProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(WebCore::StorageAccessWasGranted wasGranted, WebCore::StorageAccessPromptWasShown promptWasShown)>&& completionHandler)
     691{
     692    if (auto networkSession = networkProcess().networkSession(sessionID)) {
     693        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     694            resourceLoadStatistics->requestStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
     695    }
    689696}
    690697
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r244700 r245025  
    4949class ResourceError;
    5050class ResourceRequest;
     51enum class StorageAccessPromptWasShown : bool;
     52enum class StorageAccessWasGranted : bool;
    5153struct SameSiteInfo;
    5254
     
    222224    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
    223225    void hasStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    224     void requestStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     226    void requestStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&);
    225227    void requestStorageAccessUnderOpener(PAL::SessionID, WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, uint64_t openerPageID, WebCore::RegistrableDomain&& openerDomain);
    226228#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r243671 r245025  
    6565    ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics)
    6666    HasStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async
    67     RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (bool accessGranted) Async
     67    RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (enum:bool WebCore::StorageAccessWasGranted wasGranted, enum:bool WebCore::StorageAccessPromptWasShown promptWasShown) Async
    6868    RequestStorageAccessUnderOpener(PAL::SessionID sessionID, WebCore::RegistrableDomain domainInNeedOfStorageAccess, uint64_t openerPageID, WebCore::RegistrableDomain openerDomain)
    6969#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r244988 r245025  
    951951}
    952952
    953 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    954 {
    955     bool hasStorageAccess = false;
    956     if (auto* networkStorageSession = storageSession(sessionID))
    957         hasStorageAccess = networkStorageSession->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID);
    958     else
    959         ASSERT_NOT_REACHED();
    960 
    961     completionHandler(hasStorageAccess);
    962 }
    963 
    964953void NetworkProcess::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String> domains)>&& completionHandler)
    965954{
     
    972961}
    973962
    974 void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    975 {
    976     if (auto* networkSession = this->networkSession(sessionID)) {
    977         if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
    978             resourceLoadStatistics->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
    979         else
    980             completionHandler(false);
    981     } else {
    982         ASSERT_NOT_REACHED();
    983         completionHandler(false);
    984     }
    985 }
    986 
    987 void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
    988 {
    989     if (auto* networkSession = this->networkSession(sessionID)) {
    990         if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
    991             resourceLoadStatistics->requestStorageAccess(subFrameDomain, topFrameDomain, frameID.value(), pageID, WTFMove(completionHandler));
    992         else
    993             completionHandler(StorageAccessStatus::CannotRequestAccess);
    994     } else {
    995         ASSERT_NOT_REACHED();
    996         completionHandler(StorageAccessStatus::CannotRequestAccess);
    997     }
    998 }
    999 
    1000 void NetworkProcess::requestStorageAccessGranted(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    1001 {
    1002     if (auto* networkSession = this->networkSession(sessionID)) {
    1003         if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
    1004             resourceLoadStatistics->requestStorageAccessGranted(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
    1005         else
    1006             completionHandler(false);
    1007     } else {
    1008         ASSERT_NOT_REACHED();
    1009         completionHandler(false);
    1010     }
    1011 }
    1012 
    1013 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler)
    1014 {
    1015     // FIXME: We should not accept an optional frame ID since we call frameID.value() unconditionally.
    1016     if (!frameID) {
    1017         completionHandler(false);
    1018         return;
    1019     }
    1020 
    1021     if (auto* networkSession = this->networkSession(sessionID)) {
    1022         if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
    1023             resourceLoadStatistics->grantStorageAccess(subFrameDomain, topFrameDomain, frameID.value(), pageID, userWasPrompted, WTFMove(completionHandler));
    1024         else
    1025             completionHandler(false);
    1026     } else {
    1027         ASSERT_NOT_REACHED();
    1028         completionHandler(false);
    1029     }
    1030 }
    1031 
    1032963void NetworkProcess::logFrameNavigation(PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, const RegistrableDomain& sourceDomain, bool isRedirect, bool isMainFrame)
    1033964{
     
    10761007        completionHandler();
    10771008    }
    1078 }
    1079 
    1080 void NetworkProcess::removeAllStorageAccess(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
    1081 {
    1082     if (auto* networkStorageSession = storageSession(sessionID))
    1083         networkStorageSession->removeAllStorageAccess();
    1084     else
    1085         ASSERT_NOT_REACHED();
    1086     completionHandler();
    10871009}
    10881010
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r244883 r245025  
    8080enum class IncludeHttpOnlyCookies : bool;
    8181enum class StoredCredentialsPolicy : uint8_t;
     82enum class StorageAccessPromptWasShown : bool;
     83enum class StorageAccessWasGranted : bool;
    8284struct ClientOrigin;
    8385struct MessageWithMessagePorts;
     
    226228    void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&&);
    227229    void hadUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&);
    228     void hasStorageAccessForFrame(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&);
    229230    void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String> domains)>&&);
    230     void grantStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
    231     void hasStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&);
    232231    void logFrameNavigation(PAL::SessionID, const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame);
    233232    void logUserInteraction(PAL::SessionID, const TopFrameDomain&, CompletionHandler<void()>&&);
    234     void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&);
    235233    void removePrevalentDomains(PAL::SessionID, const Vector<RegistrableDomain>&);
    236     void requestStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(StorageAccessStatus)>&&);
    237     void requestStorageAccessGranted(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&);
    238234    void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
    239235    void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r244883 r245025  
    9999    SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async
    100100    HadUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> (bool hadUserInteraction) Async
    101     HasStorageAccessForFrame(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async
    102     HasStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (bool hasStorageAccess) Async
    103101    GetAllStorageAccessEntries(PAL::SessionID sessionID) -> (Vector<String> domains) Async
    104     GrantStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted) -> (bool accessGranted) Async
    105102    IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, WebCore::RegistrableDomain redirectedFromDomain, WebCore::RegistrableDomain redirectedToDomain) -> (bool isRedirectingTo) Async
    106103    IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubframeUnder) Async
     
    108105    LogFrameNavigation(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain sourceDomain, bool isRedirect, bool isMainFrame)
    109106    LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain) -> () Async
    110     RemoveAllStorageAccess(PAL::SessionID sessionID) -> () Async
    111107    RemovePrevalentDomains(PAL::SessionID sessionID, Vector<WebCore::RegistrableDomain> domainsWithInteraction)
    112     RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (enum:uint8_t WebKit::StorageAccessStatus storageAccessStatus) Async
    113108    ResetParametersToDefaultValues(PAL::SessionID sessionID) -> () Async
    114109    ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, enum:bool WebKit::ShouldGrandfatherStatistics shouldGrandfather) -> () Async
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r244540 r245025  
    457457        'WebCore::ShouldNotifyWhenResolved': ['<WebCore/ServiceWorkerTypes.h>'],
    458458        'WebCore::ShouldSample': ['<WebCore/DiagnosticLoggingClient.h>'],
     459        'WebCore::StorageAccessPromptWasShown': ['<WebCore/DocumentStorageAccess.h>'],
     460        'WebCore::StorageAccessWasGranted': ['<WebCore/DocumentStorageAccess.h>'],
    459461        'WebCore::SupportedPluginIdentifier': ['<WebCore/PluginData.h>'],
    460462        'WebCore::TextCheckingRequestData': ['<WebCore/TextChecking.h>'],
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r244288 r245025  
    727727}
    728728
    729 void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const RegistrableDomain& resourceDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    730 {
    731     if (!canSendMessage()) {
    732         completionHandler(false);
    733         return;
    734     }
    735 
    736     sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccessForFrame(sessionID, resourceDomain, topFrameDomain, frameID, pageID), WTFMove(completionHandler));
    737 }
    738 
    739 void NetworkProcessProxy::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& resourceDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    740 {
    741     if (!canSendMessage()) {
    742         completionHandler(false);
    743         return;
    744     }
    745    
    746     sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccess(sessionID, resourceDomain, topFrameDomain, frameID, pageID), WTFMove(completionHandler));
    747 }
    748 
    749 void NetworkProcessProxy::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& resourceDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
    750 {
    751     if (!canSendMessage()) {
    752         completionHandler(StorageAccessStatus::CannotRequestAccess);
    753         return;
    754     }
    755 
    756     sendWithAsyncReply(Messages::NetworkProcess::RequestStorageAccess(sessionID, resourceDomain, topFrameDomain, frameID, pageID), WTFMove(completionHandler));
    757 }
    758 
    759729void NetworkProcessProxy::requestStorageAccessConfirm(uint64_t pageID, uint64_t frameID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void(bool)>&& completionHandler)
    760730{
     
    766736   
    767737    page->requestStorageAccessConfirm(subFrameDomain, topFrameDomain, frameID, WTFMove(completionHandler));
    768 }
    769 
    770 void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& resourceDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler)
    771 {
    772     if (!canSendMessage()) {
    773         completionHandler(false);
    774         return;
    775     }
    776 
    777     // FIXME: We should not accept an optional frame ID since we call frameID.value() unconditionally.
    778     if (!frameID) {
    779         completionHandler(false);
    780         return;
    781     }
    782 
    783     sendWithAsyncReply(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, topFrameDomain, frameID.value(), pageID, userWasPrompted), WTFMove(completionHandler));
    784 }
    785 
    786 void NetworkProcessProxy::removeAllStorageAccess(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
    787 {
    788     if (!canSendMessage()) {
    789         completionHandler();
    790         return;
    791     }
    792 
    793     sendWithAsyncReply(Messages::NetworkProcess::RemoveAllStorageAccess(sessionID), WTFMove(completionHandler));
    794738}
    795739
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r244288 r245025  
    5050class ResourceRequest;
    5151enum class ShouldSample : bool;
     52enum class StorageAccessPromptWasShown : bool;
     53enum class StorageAccessWasGranted : bool;
    5254class SecurityOrigin;
    5355struct SecurityOriginData;
     
    126128    void setPrevalentResourceForDebugMode(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
    127129    void setVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
    128     void hasStorageAccessForFrame(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&);
    129130    void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String> domains)>&&);
    130     void grantStorageAccess(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
    131     void hasStorageAccess(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&);
    132     void requestStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(StorageAccessStatus)>&&);
    133131    void requestStorageAccessConfirm(PageID, FrameID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&);
    134132    void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
    135     void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&);
    136133    void scheduleClearInMemoryAndPersistent(PAL::SessionID, ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
    137134    void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r244883 r245025  
    16841684}
    16851685
    1686 void WebsiteDataStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    1687 {
    1688     if (!resourceLoadStatisticsEnabled()) {
    1689         completionHandler(false);
    1690         return;
    1691     }
    1692 
    1693     auto* webPage = WebProcessProxy::webPage(pageID);
    1694     if (!webPage) {
    1695         completionHandler(false);
    1696         return;
    1697     }
    1698 
    1699     if (auto networkProcess = webPage->process().processPool().networkProcess())
    1700         networkProcess->hasStorageAccess(m_sessionID, WebCore::RegistrableDomain::uncheckedCreateFromHost(subFrameHost), WebCore::RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, pageID, WTFMove(completionHandler));
    1701 }
    1702 
    1703 void WebsiteDataStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
    1704 {
    1705     if (!resourceLoadStatisticsEnabled()) {
    1706         completionHandler(StorageAccessStatus::CannotRequestAccess);
    1707         return;
    1708     }
    1709    
    1710     auto* webPage = WebProcessProxy::webPage(pageID);
    1711     if (!webPage) {
    1712         completionHandler(StorageAccessStatus::CannotRequestAccess);
    1713         return;
    1714     }
    1715 
    1716     if (auto networkProcess = webPage->process().processPool().networkProcess())
    1717         networkProcess->requestStorageAccess(m_sessionID, WebCore::RegistrableDomain::uncheckedCreateFromHost(subFrameHost), WebCore::RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, pageID, WTFMove(completionHandler));
    1718 }
    1719 
    1720 void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler)
    1721 {
    1722     if (!resourceLoadStatisticsEnabled()) {
    1723         completionHandler(false);
    1724         return;
    1725     }
    1726    
    1727     auto* webPage = WebProcessProxy::webPage(pageID);
    1728     if (!webPage) {
    1729         completionHandler(false);
    1730         return;
    1731     }
    1732 
    1733     if (auto networkProcess = webPage->process().processPool().networkProcess())
    1734         networkProcess->grantStorageAccess(m_sessionID, WebCore::RegistrableDomain::uncheckedCreateFromHost(subFrameHost), WebCore::RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
    1735 }
    17361686
    17371687void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler)
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r244382 r245025  
    170170    void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); }
    171171    void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&);
    172     void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    173     void requestStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(StorageAccessStatus)>&&);
    174     void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
    175172    void setSubframeUnderTopFrameDomain(const URL& subframe, const URL& topFrame);
    176173    void setCrossSiteLoadWithLinkDecorationForTesting(const URL& fromURL, const URL& toURL, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r244633 r245025  
    6363#include <WebCore/DatabaseTracker.h>
    6464#include <WebCore/DocumentLoader.h>
     65#include <WebCore/DocumentStorageAccess.h>
    6566#include <WebCore/FileChooser.h>
    6667#include <WebCore/FileIconLoader.h>
     
    7778#include <WebCore/NotImplemented.h>
    7879#include <WebCore/Page.h>
     80#include <WebCore/RegistrableDomain.h>
    7981#include <WebCore/ScriptController.h>
    8082#include <WebCore/SecurityOrigin.h>
     
    13121314
    13131315#if ENABLE(RESOURCE_LOAD_STATISTICS)
    1314 void WebChromeClient::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t, CompletionHandler<void(bool)>&& callback)
    1315 {
    1316     m_page.hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, WTFMove(callback));
    1317 }
    1318 
    1319 void WebChromeClient::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t, CompletionHandler<void(bool)>&& callback)
    1320 {
    1321     m_page.requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, WTFMove(callback));
     1316void WebChromeClient::hasStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t, CompletionHandler<void(bool)>&& completionHandler)
     1317{
     1318    m_page.hasStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, WTFMove(completionHandler));
     1319}
     1320
     1321void WebChromeClient::requestStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t, CompletionHandler<void(StorageAccessWasGranted, StorageAccessPromptWasShown)>&& completionHandler)
     1322{
     1323    m_page.requestStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, WTFMove(completionHandler));
    13221324}
    13231325#endif
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r244633 r245025  
    2929#include <WebCore/ChromeClient.h>
    3030
     31namespace WebCore {
     32class RegistrableDomain;
     33enum class StorageAccessPromptWasShown : bool;
     34enum class StorageAccessWasGranted : bool;
     35}
     36
    3137namespace WebKit {
    3238
     
    364370
    365371#if ENABLE(RESOURCE_LOAD_STATISTICS)
    366     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
    367     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
     372    void hasStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&&) final;
     373    void requestStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&) final;
    368374#endif
    369375
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r244993 r245025  
    148148#include <WebCore/DocumentLoader.h>
    149149#include <WebCore/DocumentMarkerController.h>
     150#include <WebCore/DocumentStorageAccess.h>
    150151#include <WebCore/DragController.h>
    151152#include <WebCore/DragData.h>
     
    64416442
    64426443#if ENABLE(RESOURCE_LOAD_STATISTICS)
    6443 void WebPage::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler)
    6444 {
    6445     WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::HasStorageAccess(sessionID(), RegistrableDomain::uncheckedCreateFromHost(subFrameHost), RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, m_pageID), WTFMove(completionHandler));
    6446 }
    6447    
    6448 void WebPage::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler)
    6449 {
    6450     WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), RegistrableDomain::uncheckedCreateFromHost(subFrameHost), RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, m_pageID), WTFMove(completionHandler));
     6444void WebPage::hasStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler)
     6445{
     6446    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::HasStorageAccess(sessionID(), WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, m_pageID), WTFMove(completionHandler));
     6447}
     6448
     6449void WebPage::requestStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&& completionHandler)
     6450{
     6451    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, m_pageID), WTFMove(completionHandler));
    64516452}
    64526453#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r244944 r245025  
    178178enum class DragHandlingMethod : uint8_t;
    179179enum class ShouldTreatAsContinuingLoad : bool;
     180enum class StorageAccessPromptWasShown : bool;
     181enum class StorageAccessWasGranted : bool;
    180182enum class TextIndicatorPresentationTransition : uint8_t;
    181183enum class WritingDirection : uint8_t;
     
    11191121
    11201122#if ENABLE(RESOURCE_LOAD_STATISTICS)
    1121     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& callback);
    1122     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& callback);
     1123    void hasStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&&);
     1124    void requestStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&);
    11231125#endif
    11241126
Note: See TracChangeset for help on using the changeset viewer.