Changeset 162166 in webkit


Ignore:
Timestamp:
Jan 16, 2014 4:33:35 PM (10 years ago)
Author:
ap@apple.com
Message:

[Mac] [iOS] Add support for CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain
https://bugs.webkit.org/show_bug.cgi?id=127139

Reviewed by Brady Eidson.

Source/WebCore:

  • platform/ios/WebCoreSystemInterfaceIOS.mm:
  • platform/mac/WebCoreSystemInterface.h:
  • platform/mac/WebCoreSystemInterface.mm:

Pass first party URL down, because reading cookies depends on it when this policy
in in action.

  • platform/network/cf/CookieJarCFNet.cpp:

(WebCore::copyCookiesForURLWithFirstPartyURL):
(WebCore::cookiesForDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
Use a new CFNetwork API that takes first party URL.

  • platform/network/mac/CookieJarMac.mm:

(WebCore::cookiesForDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
Pass first party URL (and null in deleteCookie, as there is none).

  • platform/network/mac/ResourceHandleMac.mm:

(WebCore::ResourceHandle::platformLoadResourceSynchronously):
Removed a call to shouldRelaxThirdPartyCookiePolicy(), which no longer exists
in trunk.

Source/WebKit/mac:

  • WebView/WebPreferences.mm: (-[WebPreferences _synchronizeWebStoragePolicyWithCookiePolicy]):

Handle the new case.

Source/WebKit2:

  • Shared/HTTPCookieAcceptPolicy.h:
  • UIProcess/API/C/WKAPICast.h:

(WebKit::toHTTPCookieAcceptPolicy):
(WebKit::toAPI):

  • UIProcess/API/C/WKCookieManager.h:

Added the policy to appropriate switches and enums.

WebKitLibraries:

  • WebKitSystemInterface.h:
  • libWebKitSystemInterfaceLion.a:
  • libWebKitSystemInterfaceMavericks.a:
  • libWebKitSystemInterfaceMountainLion.a:

Update WebKitSystemInterface.

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r162164 r162166  
     12014-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] [iOS] Add support for CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain
     4        https://bugs.webkit.org/show_bug.cgi?id=127139
     5
     6        Reviewed by Brady Eidson.
     7
     8        * platform/ios/WebCoreSystemInterfaceIOS.mm:
     9        * platform/mac/WebCoreSystemInterface.h:
     10        * platform/mac/WebCoreSystemInterface.mm:
     11        Pass first party URL down, because reading cookies depends on it when this policy
     12        in in action.
     13
     14        * platform/network/cf/CookieJarCFNet.cpp:
     15        (WebCore::copyCookiesForURLWithFirstPartyURL):
     16        (WebCore::cookiesForDOM):
     17        (WebCore::cookieRequestHeaderFieldValue):
     18        (WebCore::cookiesEnabled):
     19        (WebCore::getRawCookies):
     20        Use a new CFNetwork API that takes first party URL.
     21
     22        * platform/network/mac/CookieJarMac.mm:
     23        (WebCore::cookiesForDOM):
     24        (WebCore::cookieRequestHeaderFieldValue):
     25        (WebCore::cookiesEnabled):
     26        (WebCore::getRawCookies):
     27        (WebCore::deleteCookie):
     28        Pass first party URL (and null in deleteCookie, as there is none).
     29
     30        * platform/network/mac/ResourceHandleMac.mm:
     31        (WebCore::ResourceHandle::platformLoadResourceSynchronously):
     32        Removed a call to shouldRelaxThirdPartyCookiePolicy(), which no longer exists
     33        in trunk.
     34
    1352014-01-16  Andy Estes  <aestes@apple.com>
    236
  • trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm

    r162114 r162166  
    105105void (*wkSetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef, unsigned);
    106106NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
    107 NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
     107NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *, NSURL *);
    108108void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
    109109void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
  • trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h

    r161796 r162166  
    313313extern void (*wkSetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef, unsigned);
    314314extern NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
    315 extern NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
     315extern NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *, NSURL *);
    316316extern void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
    317317extern void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
  • trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm

    r161796 r162166  
    174174void (*wkSetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef, unsigned);
    175175NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
    176 NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
     176NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *, NSURL *);
    177177void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
    178178void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
  • trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp

    r156550 r162166  
    4242#endif
    4343
     44enum {
     45    CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain = 3;
     46};
     47
    4448namespace WebCore {
    4549
     
    9498}
    9599
     100static RetainPtr<CFArrayRef> copyCookiesForURLWithFirstPartyURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
     101{
     102    bool secure = url.protocolIs("https");
     103
     104#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100)
     105    RetainPtr<CFArrayRef> cookiesCF = adoptCF(_CFHTTPCookieStorageCopyCookiesForURLWithMainDocumentURL(session.cookieStorage().get(), url.createCFURL().get(), firstParty.createCFURL().get(), secure));
     106#else
     107    // _CFHTTPCookieStorageCopyCookiesForURLWithMainDocumentURL is not available on other platforms.
     108    UNUSED_PARAM(firstParty);
     109    RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), url.createCFURL().get(), secure));
     110#endif
     111}
     112
    96113void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value)
    97114{
     
    118135}
    119136
    120 String cookiesForDOM(const NetworkStorageSession& session, const URL&, const URL& url)
    121 {
    122     RetainPtr<CFURLRef> urlCF = url.createCFURL();
    123 
    124     bool secure = url.protocolIs("https");
    125     RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), secure));
     137String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
     138{
     139    RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url);
    126140    RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, filterCookies(cookiesCF.get()).get()));
    127141    return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
    128142}
    129143
    130 String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url)
    131 {
    132     RetainPtr<CFURLRef> urlCF = url.createCFURL();
    133 
    134     bool secure = url.protocolIs("https");
    135     RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), secure));
     144String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
     145{
     146    RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url);
    136147    RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get()));
    137148    return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
     
    141152{
    142153    CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(session.cookieStorage().get());
    143     return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
    144 }
    145 
    146 bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url, Vector<Cookie>& rawCookies)
     154    return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
     155}
     156
     157bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, Vector<Cookie>& rawCookies)
    147158{
    148159    rawCookies.clear();
    149160
    150     RetainPtr<CFURLRef> urlCF = url.createCFURL();
    151 
    152     bool sendSecureCookies = url.protocolIs("https");
    153     RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), sendSecureCookies));
     161    RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url);
    154162
    155163    CFIndex count = CFArrayGetCount(cookiesCF.get());
  • trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm

    r156550 r162166  
    3636#import "WebCoreSystemInterface.h"
    3737
     38enum {
     39    NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3
     40};
     41
    3842namespace WebCore {
    3943
     
    6266}
    6367
    64 String cookiesForDOM(const NetworkStorageSession& session, const URL&, const URL& url)
     68String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
    6569{
    6670    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    6771
    68     NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     72    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
    6973    return [[NSHTTPCookie requestHeaderFieldsWithCookies:filterCookies(cookies).get()] objectForKey:@"Cookie"];
    7074
     
    7377}
    7478
    75 String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url)
     79String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
    7680{
    7781    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    7882
    79     NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     83    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
    8084    return [[NSHTTPCookie requestHeaderFieldsWithCookies:cookies] objectForKey:@"Cookie"];
    8185
     
    111115
    112116    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(session.cookieStorage().get()));
    113     return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
     117    return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
    114118
    115119    END_BLOCK_OBJC_EXCEPTIONS;
     
    117121}
    118122
    119 bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url, Vector<Cookie>& rawCookies)
     123bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, Vector<Cookie>& rawCookies)
    120124{
    121125    rawCookies.clear();
    122126    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    123127
    124     NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     128    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
    125129    NSUInteger count = [cookies count];
    126130    rawCookies.reserveCapacity(count);
     
    140144    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    141145
    142     NSURL *cookieURL = url;
    143146    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
    144     NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), cookieURL);
     147    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), 0, url);
    145148
    146149    NSString *cookieNameString = cookieName;
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r161796 r162166  
    387387        handle->delegate(), // A synchronous request cannot turn into a download, so there is no need to proxy the delegate.
    388388        storedCredentials == AllowStoredCredentials,
    389         shouldRelaxThirdPartyCookiePolicy(context, request.url()),
    390389        handle->shouldContentSniff() || (context && context->localFileContentSniffingEnabled()),
    391390        SchedulingBehavior::Synchronous,
  • trunk/Source/WebKit/mac/ChangeLog

    r162162 r162166  
     12014-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] [iOS] Add support for CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain
     4        https://bugs.webkit.org/show_bug.cgi?id=127139
     5
     6        Reviewed by Brady Eidson.
     7
     8        * WebView/WebPreferences.mm: (-[WebPreferences _synchronizeWebStoragePolicyWithCookiePolicy]):
     9        Handle the new case.
     10
    1112014-01-16  Daniel Bates  <dabates@apple.com>
    212
  • trunk/Source/WebKit/mac/WebView/WebPreferences.mm

    r162094 r162166  
    5050#import <wtf/RunLoop.h>
    5151
     52enum {
     53    NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3
     54};
     55
    5256using namespace WebCore;
    5357
     
    23132317- (void)_synchronizeWebStoragePolicyWithCookiePolicy
    23142318{
     2319    // FIXME: This should be done in clients, WebKit shouldn't be making such policy decisions.
     2320
    23152321    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
    23162322    WebStorageBlockingPolicy storageBlockingPolicy;
     
    23202326        break;
    23212327    case NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
     2328    case NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
    23222329        storageBlockingPolicy = WebBlockThirdPartyStorage;
    23232330        break;
  • trunk/Source/WebKit2/ChangeLog

    r162163 r162166  
     12014-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] [iOS] Add support for CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain
     4        https://bugs.webkit.org/show_bug.cgi?id=127139
     5
     6        Reviewed by Brady Eidson.
     7
     8        * Shared/HTTPCookieAcceptPolicy.h:
     9        * UIProcess/API/C/WKAPICast.h:
     10        (WebKit::toHTTPCookieAcceptPolicy):
     11        (WebKit::toAPI):
     12        * UIProcess/API/C/WKCookieManager.h:
     13        Added the policy to appropriate switches and enums.
     14
    1152014-01-16  Jeffrey Pfau  <jpfau@apple.com>
    216
  • trunk/Source/WebKit2/Shared/HTTPCookieAcceptPolicy.h

    r95901 r162166  
    3333    HTTPCookieAcceptPolicyNever = 1,
    3434    HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2,
     35    HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3,
    3536};
    3637typedef unsigned HTTPCookieAcceptPolicy;
  • trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h

    r162141 r162166  
    393393    case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
    394394        return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
     395    case kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
     396        return HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
    395397    }
    396398
     
    408410    case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
    409411        return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
     412    case HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
     413        return kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
    410414    }
    411415
  • trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.h

    r160104 r162166  
    3636    kWKHTTPCookieAcceptPolicyAlways = 0,
    3737    kWKHTTPCookieAcceptPolicyNever = 1,
    38     kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2
     38    kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2,
     39    kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3
    3940};
    4041typedef uint32_t WKHTTPCookieAcceptPolicy;
  • trunk/WebKitLibraries/ChangeLog

    r162129 r162166  
     12014-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] [iOS] Add support for CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain
     4        https://bugs.webkit.org/show_bug.cgi?id=127139
     5
     6        Reviewed by Brady Eidson.
     7
     8        * WebKitSystemInterface.h:
     9        * libWebKitSystemInterfaceLion.a:
     10        * libWebKitSystemInterfaceMavericks.a:
     11        * libWebKitSystemInterfaceMountainLion.a:
     12        Update WebKitSystemInterface.
     13
    1142014-01-16  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/WebKitLibraries/WebKitSystemInterface.h

    r161796 r162166  
    173173CTLineRef WKCreateCTLineWithUniCharProvider(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
    174174
    175 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     175#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    176176enum {
    177177    WKCTFontTransformApplyShaping = (1 << 0),
     
    182182
    183183bool WKCTFontTransformGlyphs(CTFontRef font, CGGlyph glyphs[], CGSize advances[], CFIndex count, WKCTFontTransformOptions options);
    184 #endif
     184#endif // TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    185185
    186186CTTypesetterRef WKCreateCTTypesetterWithUniCharProviderAndOptions(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
     
    188188CGSize WKCTRunGetInitialAdvance(CTRunRef);
    189189
    190 #if !TARGET_IPHONE_SIMULATOR
     190#if (TARGET_OS_IPHONE && TARGET_OS_EMBEDDED) || MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    191191CGContextRef WKIOSurfaceContextCreate(IOSurfaceRef, unsigned width, unsigned height, CGColorSpaceRef);
    192192CGImageRef WKIOSurfaceContextCreateImage(CGContextRef context);
     
    276276void WKSetHTTPCookieAcceptPolicy(CFHTTPCookieStorageRef, unsigned policy);
    277277NSArray *WKHTTPCookies(CFHTTPCookieStorageRef);
    278 NSArray *WKHTTPCookiesForURL(CFHTTPCookieStorageRef, NSURL *);
     278NSArray *WKHTTPCookiesForURL(CFHTTPCookieStorageRef, NSURL *, NSURL *);
    279279void WKSetHTTPCookiesForURL(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
    280280void WKDeleteAllHTTPCookies(CFHTTPCookieStorageRef);
     
    536536void WKCFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
    537537
    538 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
     538#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
    539539bool WKIsPublicSuffix(NSString *domain);
    540540
Note: See TracChangeset for help on using the changeset viewer.