⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259655 in webkit


Ignore:
Timestamp:
Apr 7, 2020, 11:43:45 AM (6 years ago)
Author:
Kate Cheney
Message:

Return app-bound sessions for instances where WKAppBoundDomains is
empty
https://bugs.webkit.org/show_bug.cgi?id=210124
<rdar://problem/61276630>

Reviewed by Brent Fulgham.

Source/WebKit:

No new tests. Behavior confirmed by existing In-App Browser Privacy
tests.

  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(WebKit::NetworkSessionCocoa::sessionWrapperForTask):
Remove the flag checking if In-App Browser Privacy is enabled. We
should return an app-bound session if WKAppBoundDomains is empty so
we no longer need to check the flag here.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):

  • UIProcess/WebPageProxy.h:

As described above, we no longer need to check the flag in this
instance as we are determining behavior based on the WKAppBoundDomains
list. Also moved the logic for checking an empty list to setIsNavigatingToAppBoundDomain,
so it should take an Optional (WTF::nullopt indicates an empty list).

  • UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:

(WebKit::WebsiteDataStore::initializeAppBoundDomains):
Use the flag to enable internal debugging for testing purposes.

  • UIProcess/API/APIHTTPCookieStore.cpp:

(API::HTTPCookieStore::filterAppBoundCookies):
Flag no longer needed. This should be gated by whether the domains
list is empty or not.

Tools:

Cleaned up tests to turn the flag on at the start of each In-App
Browser Privacy test.

  • TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm:

(cleanUpInAppBrowserPrivacyTestSettings):
(initializeInAppBrowserPrivacyTestSettings):
(TEST):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259648 r259655  
     12020-04-07  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Return app-bound sessions for instances where WKAppBoundDomains is
     4        empty
     5        https://bugs.webkit.org/show_bug.cgi?id=210124
     6        <rdar://problem/61276630>
     7
     8        Reviewed by Brent Fulgham.
     9
     10        No new tests. Behavior confirmed by existing In-App Browser Privacy
     11        tests.
     12
     13        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     14        (WebKit::NetworkSessionCocoa::sessionWrapperForTask):
     15        Remove the flag checking if In-App Browser Privacy is enabled. We
     16        should return an app-bound session if WKAppBoundDomains is empty so
     17        we no longer need to check the flag here.
     18
     19        * UIProcess/WebPageProxy.cpp:
     20        (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain):
     21        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
     22        * UIProcess/WebPageProxy.h:
     23        As described above, we no longer need to check the flag in this
     24        instance as we are determining behavior based on the WKAppBoundDomains
     25        list. Also moved the logic for checking an empty list to setIsNavigatingToAppBoundDomain,
     26        so it should take an Optional (WTF::nullopt indicates an empty list).
     27
     28        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
     29        (WebKit::WebsiteDataStore::initializeAppBoundDomains):
     30        Use the flag to enable internal debugging for testing purposes.
     31
     32        * UIProcess/API/APIHTTPCookieStore.cpp:
     33        (API::HTTPCookieStore::filterAppBoundCookies):
     34        Flag no longer needed. This should be gated by whether the domains
     35        list is empty or not.
     36
    1372020-04-07  Per Arne Vollan  <pvollan@apple.com>
    238
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r259076 r259655  
    6464#else
    6565#define NETWORK_SESSION_COCOA_ADDITIONS_1
    66 #define NETWORK_SESSION_COCOA_ADDITIONS_2 false
    6766#endif
    6867
     
    12121211#endif
    12131212
    1214     if (isNavigatingToAppBoundDomain == NavigatingToAppBoundDomain::Yes) {
    1215         if (m_isInAppBrowserPrivacyEnabled || NETWORK_SESSION_COCOA_ADDITIONS_2)
    1216             return appBoundSession(storedCredentialsPolicy);
    1217     }
     1213    if (isNavigatingToAppBoundDomain == NavigatingToAppBoundDomain::Yes)
     1214        return appBoundSession(storedCredentialsPolicy);
    12181215
    12191216    switch (storedCredentialsPolicy) {
  • trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp

    r259520 r259655  
    3939#include <WebKitAdditions/HTTPCookieStoreAdditions.h>
    4040#else
    41 #define IN_APP_BROWSER_PRIVACY_ENABLED false
    4241#define IMPLEMENT_IN_APP_BROWSER_PRIVACY_ENABLED
    4342#endif
     
    6766    Vector<WebCore::Cookie> appBoundCookies;
    6867#if PLATFORM(IOS_FAMILY)
    69     m_owningDataStore->getAppBoundDomains([this, protectedThis = makeRef(*this), cookies, appBoundCookies = WTFMove(appBoundCookies), completionHandler = WTFMove(completionHandler)] (auto& domains) mutable {
    70         if (m_owningDataStore->parameters().networkSessionParameters.isInAppBrowserPrivacyEnabled || IN_APP_BROWSER_PRIVACY_ENABLED) {
     68    m_owningDataStore->getAppBoundDomains([cookies, appBoundCookies = WTFMove(appBoundCookies), completionHandler = WTFMove(completionHandler)] (auto& domains) mutable {
     69        if (!domains.isEmpty()) {
    7170            IMPLEMENT_IN_APP_BROWSER_PRIVACY_ENABLED
    7271            for (auto& cookie : cookies) {
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r259615 r259655  
    283283#else
    284284#define WEB_PAGE_PROXY_ADDITIONS_SETISNAVIGATINGTOAPPBOUNDDOMAIN
    285 #define WEB_PAGE_PROXY_ADDITIONS_SETISNAVIGATINGTOAPPBOUNDDOMAIN_2 false
    286285#endif
    287286
     
    31203119};
    31213120
    3122 void WebPageProxy::setIsNavigatingToAppBoundDomain(bool isMainFrame, const URL& requestURL, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain)
     3121void WebPageProxy::setIsNavigatingToAppBoundDomain(bool isMainFrame, const URL& requestURL, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
    31233122{
    31243123#if PLATFORM(IOS_FAMILY)
    3125     if (isMainFrame && (m_preferences->isInAppBrowserPrivacyEnabled() || WEB_PAGE_PROXY_ADDITIONS_SETISNAVIGATINGTOAPPBOUNDDOMAIN_2)) {
     3124    if (isMainFrame) {
     3125        WEB_PAGE_PROXY_ADDITIONS_SETISNAVIGATINGTOAPPBOUNDDOMAIN
     3126        if (!isNavigatingToAppBoundDomain) {
     3127            m_isNavigatingToAppBoundDomain = NavigatingToAppBoundDomain::Yes;
     3128            return;
     3129        }
    31263130        if (m_ignoresAppBoundDomains)
    31273131            return;
    3128         WEB_PAGE_PROXY_ADDITIONS_SETISNAVIGATINGTOAPPBOUNDDOMAIN
    3129         if (isNavigatingToAppBoundDomain == NavigatingToAppBoundDomain::No) {
     3132        if (*isNavigatingToAppBoundDomain == NavigatingToAppBoundDomain::No) {
    31303133            m_configuration->setWebViewCategory(WebViewCategory::InAppBrowser);
    31313134            m_isNavigatingToAppBoundDomain = NavigatingToAppBoundDomain::No;
     
    51065109    auto listener = makeRef(frame.setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frame = makeRef(frame), sender = WTFMove(sender), navigation] (PolicyAction policyAction, API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient, RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning, Optional<NavigatingToAppBoundDomain> isAppBoundDomain) mutable {
    51075110
    5108         if (policyAction != PolicyAction::Ignore && isAppBoundDomain)
    5109             setIsNavigatingToAppBoundDomain(frame->isMainFrame(), navigation->currentRequest().url(), *isAppBoundDomain);
     5111        if (policyAction != PolicyAction::Ignore)
     5112            setIsNavigatingToAppBoundDomain(frame->isMainFrame(), navigation->currentRequest().url(), isAppBoundDomain);
    51105113
    51115114        auto completionHandler = [this, protectedThis = protectedThis.copyRef(), frame = frame.copyRef(), sender = WTFMove(sender), navigation, processSwapRequestedByClient, policies = makeRefPtr(policies)] (PolicyAction policyAction) mutable {
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r259523 r259655  
    22832283    void makeStorageSpaceRequest(WebCore::FrameIdentifier, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, CompletionHandler<void(uint64_t)>&&);
    22842284       
    2285     void setIsNavigatingToAppBoundDomain(bool isMainFrame, const URL&, NavigatingToAppBoundDomain);
     2285    void setIsNavigatingToAppBoundDomain(bool isMainFrame, const URL&, Optional<NavigatingToAppBoundDomain>);
    22862286    NavigatedAwayFromAppBoundDomain hasNavigatedAwayFromAppBoundDomain() const { return m_hasNavigatedAwayFromAppBoundDomain; }
    22872287       
  • trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm

    r259615 r259655  
    404404    static const auto maxAppBoundDomainCount = 10;
    405405   
    406     appBoundDomainQueue().dispatch([forceReinitialization] () mutable {
     406    appBoundDomainQueue().dispatch([isInAppBrowserPrivacyEnabled = parameters().networkSessionParameters.isInAppBrowserPrivacyEnabled, forceReinitialization] () mutable {
    407407        if (hasInitializedAppBoundDomains && forceReinitialization != ForceReinitialization::Yes)
    408408            return;
     
    410410        NSArray<NSString *> *domains = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"WKAppBoundDomains"];
    411411       
    412         RunLoop::main().dispatch([forceReinitialization , domains = retainPtr(domains)] {
     412        RunLoop::main().dispatch([isInAppBrowserPrivacyEnabled, forceReinitialization, domains = retainPtr(domains)] {
    413413            if (forceReinitialization == ForceReinitialization::Yes)
    414414                appBoundDomains().clear();
     
    427427                    break;
    428428            }
    429             WEBSITE_DATA_STORE_ADDITIONS
     429            if (isInAppBrowserPrivacyEnabled)
     430                WEBSITE_DATA_STORE_ADDITIONS
    430431            hasInitializedAppBoundDomains = true;
    431432        });
  • trunk/Tools/ChangeLog

    r259650 r259655  
     12020-04-07  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Return app-bound sessions for instances where WKAppBoundDomains is
     4        empty
     5        https://bugs.webkit.org/show_bug.cgi?id=210124
     6        <rdar://problem/61276630>
     7
     8        Reviewed by Brent Fulgham.
     9
     10        Cleaned up tests to turn the flag on at the start of each In-App
     11        Browser Privacy test.
     12
     13        * TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm:
     14        (cleanUpInAppBrowserPrivacyTestSettings):
     15        (initializeInAppBrowserPrivacyTestSettings):
     16        (TEST):
     17
    1182020-04-07  Timothy Hatcher  <timothy@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm

    r259520 r259655  
    8282static void cleanUpInAppBrowserPrivacyTestSettings()
    8383{
     84    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    8485    IN_APP_BROWSER_PRIVACY_ADDITIONS_2
    8586}
     
    8788static void initializeInAppBrowserPrivacyTestSettings()
    8889{
     90    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    8991    RunLoop::initializeMainRunLoop();
    9092    WebCore::clearApplicationBundleIdentifierTestingOverride();
     
    537539{
    538540    initializeInAppBrowserPrivacyTestSettings();
    539     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    540541
    541542    auto dataStore = [WKWebsiteDataStore defaultDataStore];
     
    582583
    583584    cleanUpInAppBrowserPrivacyTestSettings();
    584     [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    585585    gotFlag = false;
    586586
     
    608608    // Since we can't set non-app-bound cookies with In-App Browser privacy protections on,
    609609    // we can turn the protections off to set a cookie we will then try to get with protections enabled.
    610     [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
     610    cleanUpInAppBrowserPrivacyTestSettings();
    611611
    612612    setUpCookieTest();
     
    659659
    660660    // Now enable protections and ensure we can only retrieve the app-bound cookies.
    661     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    662661    initializeInAppBrowserPrivacyTestSettings();
    663662
     
    684683    [globalCookieStore deleteCookie:appBoundCookie.get() completionHandler:[]() {
    685684        // Reset flag.
    686         [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    687685        cleanUpInAppBrowserPrivacyTestSettings();
    688686        gotFlag = true;
     
    696694    // Since we can't set non-app-bound cookies with In-App Browser privacy protections on,
    697695    // we can turn the protections off to set a cookie we will then try to get with protections enabled.
    698     [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
     696    cleanUpInAppBrowserPrivacyTestSettings();
    699697    setUpCookieTest();
    700698
     
    721719
    722720            // Now enable protections and ensure we can only retrieve the app-bound cookies.
    723             [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    724721            initializeInAppBrowserPrivacyTestSettings();
    725722
     
    731728                    [globalCookieStore deleteCookie:nonAppBoundCookie completionHandler:^{
    732729                        [globalCookieStore deleteCookie:appBoundCookie completionHandler:^{
    733                             [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDebugIsInAppBrowserPrivacyEnabled"];
    734730                            cleanUpInAppBrowserPrivacyTestSettings();
    735731                            done = true;
Note: See TracChangeset for help on using the changeset viewer.