Title: [144495] trunk/Source
Revision
144495
Author
[email protected]
Date
2013-03-01 13:32:43 -0800 (Fri, 01 Mar 2013)

Log Message

Add SPI for marking a WebView as doing things on behalf of another process
https://bugs.webkit.org/show_bug.cgi?id=111125

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* platform/network/NetworkingContext.h:
(NetworkingContext):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::createCFURLConnection):
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::createNSURLConnection):
Set the sourceApplicationAuditData on the URL connection if available.

Source/WebKit/mac:

* WebCoreSupport/WebFrameNetworkingContext.h:
(WebFrameNetworkingContext):
* WebCoreSupport/WebFrameNetworkingContext.mm:
(WebFrameNetworkingContext::sourceApplicationAuditData):
* WebView/WebView.mm:
(-[WebView _setSourceApplicationAuditData:]):
(-[WebView _sourceApplicationAuditData]):
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
(-[WebViewPrivate dealloc]):
* WebView/WebViewPrivate.h:
Add SPI for setting a source application for a WebView.

Source/WebKit2:

* NetworkProcess/mac/RemoteNetworkingContext.h:
* NetworkProcess/mac/RemoteNetworkingContext.mm:
(WebKit::RemoteNetworkingContext::sourceApplicationAuditData):
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
(WebKit::WebFrameNetworkingContext::sourceApplicationAuditData):
Stub out sourceApplicationAuditData() client function.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (144494 => 144495)


--- trunk/Source/WebCore/ChangeLog	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebCore/ChangeLog	2013-03-01 21:32:43 UTC (rev 144495)
@@ -1,3 +1,18 @@
+2013-02-28  Sam Weinig  <[email protected]>
+
+        Add SPI for marking a WebView as doing things on behalf of another process
+        https://bugs.webkit.org/show_bug.cgi?id=111125
+
+        Reviewed by Alexey Proskuryakov.
+
+        * platform/network/NetworkingContext.h:
+        (NetworkingContext):
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::ResourceHandle::createCFURLConnection):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::createNSURLConnection):
+        Set the sourceApplicationAuditData on the URL connection if available.
+
 2013-03-01  Brent Fulgham  <[email protected]>
 
         [Windows] Unreviewed VS2010 build fix.

Modified: trunk/Source/WebCore/platform/network/NetworkingContext.h (144494 => 144495)


--- trunk/Source/WebCore/platform/network/NetworkingContext.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebCore/platform/network/NetworkingContext.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -77,6 +77,7 @@
     virtual bool localFileContentSniffingEnabled() const = 0; // FIXME: Reconcile with ResourceHandle::forceContentSniffing().
     virtual SchedulePairHashSet* scheduledRunLoopPairs() const { return 0; }
     virtual NSOperationQueue *scheduledOperationQueue() const { return 0; }
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const = 0;
     virtual ResourceError blockedError(const ResourceRequest&) const = 0;
 #endif
 

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (144494 => 144495)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2013-03-01 21:32:43 UTC (rev 144495)
@@ -379,22 +379,6 @@
     LOG(Network, "CFNet - Destroying job %p (%s)", this, d->m_firstRequest.url().string().utf8().data());
 }
 
-static CFDictionaryRef createConnectionProperties(bool shouldUseCredentialStorage)
-{
-    static const CFStringRef webKitPrivateSessionCF = CFSTR("WebKitPrivateSession");
-    static const CFStringRef _kCFURLConnectionSessionID = CFSTR("_kCFURLConnectionSessionID");
-    static const CFStringRef kCFURLConnectionSocketStreamProperties = CFSTR("kCFURLConnectionSocketStreamProperties");
-
-    CFDictionaryRef sessionID = shouldUseCredentialStorage ?
-        CFDictionaryCreate(0, 0, 0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) :
-        CFDictionaryCreate(0, (const void**)&_kCFURLConnectionSessionID, (const void**)&webKitPrivateSessionCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-
-    CFDictionaryRef propertiesDictionary = CFDictionaryCreate(0, (const void**)&kCFURLConnectionSocketStreamProperties, (const void**)&sessionID, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-
-    CFRelease(sessionID);
-    return propertiesDictionary;
-}
-
 void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff)
 {
     if ((!d->m_user.isEmpty() || !d->m_pass.isEmpty()) && !firstRequest().url().protocolIsInHTTPFamily()) {
@@ -473,8 +457,21 @@
         0
 #endif
     };
-    RetainPtr<CFDictionaryRef> connectionProperties(AdoptCF, createConnectionProperties(shouldUseCredentialStorage));
 
+    CFMutableDictionaryRef streamProperties  = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (!shouldUseCredentialStorage)
+        CFDictionarySetValue(streamProperties, CFSTR("_kCFURLConnectionSessionID"), CFSTR("WebKitPrivateSession"));
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+    RetainPtr<CFDataRef> sourceApplicationAuditData = d->m_context->sourceApplicationAuditData();
+    if (sourceApplicationAuditData)
+        CFDictionarySetValue(streamProperties, CFSTR("kCFStreamPropertySourceApplication"), sourceApplicationAuditData.get());
+#endif
+
+    static const CFStringRef kCFURLConnectionSocketStreamProperties = CFSTR("kCFURLConnectionSocketStreamProperties");
+    RetainPtr<CFDictionaryRef> propertiesDictionary = adoptCF(CFDictionaryCreate(0, (const void**)&kCFURLConnectionSocketStreamProperties, (const void**)&streamProperties, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    CFRelease(streamProperties);
+
     d->m_connection.adoptCF(CFURLConnectionCreateWithProperties(0, request.get(), reinterpret_cast<CFURLConnectionClient*>(&client), connectionProperties.get()));
 }
 

Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (144494 => 144495)


--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2013-03-01 21:32:43 UTC (rev 144495)
@@ -177,26 +177,24 @@
         nsRequest = mutableRequest;
     }
 
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-    ASSERT([NSURLConnection instancesRespondToSelector:@selector(_initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:)]);
-    static bool supportsSettingConnectionProperties = true;
-#else
-    static bool supportsSettingConnectionProperties = [NSURLConnection instancesRespondToSelector:@selector(_initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:)];
-#endif
-
     if (d->m_storageSession)
         nsRequest = [wkCopyRequestWithStorageSession(d->m_storageSession.get(), nsRequest) autorelease];
 
-    if (supportsSettingConnectionProperties) {
-        NSDictionary *sessionID = shouldUseCredentialStorage ? [NSDictionary dictionary] : [NSDictionary dictionaryWithObject:@"WebKitPrivateSession" forKey:@"_kCFURLConnectionSessionID"];
-        NSDictionary *propertyDictionary = [NSDictionary dictionaryWithObject:sessionID forKey:@"kCFURLConnectionSocketStreamProperties"];
-        d->m_connection.adoptNS([[NSURLConnection alloc] _initWithRequest:nsRequest delegate:delegate usesCache:YES maxContentLength:0 startImmediately:NO connectionProperties:propertyDictionary]);
-        return;
-    }
+    ASSERT([NSURLConnection instancesRespondToSelector:@selector(_initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:)]);
 
-    d->m_connection.adoptNS([[NSURLConnection alloc] initWithRequest:nsRequest delegate:delegate startImmediately:NO]);
-    return;
+    NSMutableDictionary *streamProperties = [NSMutableDictionary dictionary];
 
+    if (!shouldUseCredentialStorage)
+        [streamProperties setObject:@"WebKitPrivateSession" forKey:@"_kCFURLConnectionSessionID"];
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    RetainPtr<CFDataRef> sourceApplicationAuditData = d->m_context->sourceApplicationAuditData();
+    if (sourceApplicationAuditData)
+        [streamProperties setObject:(NSData *)sourceApplicationAuditData.get() forKey:@"kCFStreamPropertySourceApplication"];
+#endif
+
+    NSDictionary *propertyDictionary = [NSDictionary dictionaryWithObject:streamProperties forKey:@"kCFURLConnectionSocketStreamProperties"];
+    d->m_connection.adoptNS([[NSURLConnection alloc] _initWithRequest:nsRequest delegate:delegate usesCache:YES maxContentLength:0 startImmediately:NO connectionProperties:propertyDictionary]);
 }
 
 bool ResourceHandle::start()

Modified: trunk/Source/WebKit/mac/ChangeLog (144494 => 144495)


--- trunk/Source/WebKit/mac/ChangeLog	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-03-01 21:32:43 UTC (rev 144495)
@@ -1,3 +1,23 @@
+2013-02-28  Sam Weinig  <[email protected]>
+
+        Add SPI for marking a WebView as doing things on behalf of another process
+        https://bugs.webkit.org/show_bug.cgi?id=111125
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebCoreSupport/WebFrameNetworkingContext.h:
+        (WebFrameNetworkingContext):
+        * WebCoreSupport/WebFrameNetworkingContext.mm:
+        (WebFrameNetworkingContext::sourceApplicationAuditData):
+        * WebView/WebView.mm:
+        (-[WebView _setSourceApplicationAuditData:]):
+        (-[WebView _sourceApplicationAuditData]):
+        * WebView/WebViewData.h:
+        * WebView/WebViewData.mm:
+        (-[WebViewPrivate dealloc]):
+        * WebView/WebViewPrivate.h:
+        Add SPI for setting a source application for a WebView.
+
 2013-03-01  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r144422 and r144424.

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h (144494 => 144495)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -40,5 +40,6 @@
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
     virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 };

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm (144494 => 144495)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm	2013-03-01 21:32:43 UTC (rev 144495)
@@ -20,6 +20,8 @@
 
 #import "WebFrameNetworkingContext.h"
 
+#import "WebFrameInternal.h"
+#import "WebViewPrivate.h"
 #import <WebCore/FrameLoaderClient.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/Page.h>
@@ -50,6 +52,21 @@
     return frame() && frame()->page() ? frame()->page()->scheduledRunLoopPairs() : 0;
 }
 
+RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() const
+{
+    if (!frame())
+        return nil;
+
+    if (!frame()->page())
+        return nil;
+
+    WebView *webView = kit(frame()->page());
+    if (!webView)
+        return nil;
+
+    return (CFDataRef)webView._sourceApplicationAuditData;
+}
+
 ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return frame()->loader()->client()->blockedError(request);

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (144494 => 144495)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2013-03-01 21:32:43 UTC (rev 144495)
@@ -3087,6 +3087,19 @@
     ResourceRequest::setHTTPPipeliningEnabled(enabled);
 }
 
+- (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData
+{
+    if (_private->sourceApplicationAuditData == sourceApplicationAuditData)
+        return;
+
+    _private->sourceApplicationAuditData = adoptNS([sourceApplicationAuditData copy]);
+}
+
+- (NSData *)_sourceApplicationAuditData
+{
+    return _private->sourceApplicationAuditData.get();
+}
+
 @end
 
 @implementation _WebSafeForwarder

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (144494 => 144495)


--- trunk/Source/WebKit/mac/WebView/WebViewData.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -205,5 +205,7 @@
 #if USE(DICTATION_ALTERNATIVES)
     OwnPtr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
 #endif
+
+    RetainPtr<NSData> sourceApplicationAuditData;
 }
 @end

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (144494 => 144495)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -635,6 +635,8 @@
  */
 + (void)_setHTTPPipeliningEnabled:(BOOL)enabled;
 
+@property (nonatomic, copy, getter=_sourceApplicationAuditData, setter=_setSourceApplicationAuditData:) NSData *sourceApplicationAuditData;
+
 @end
 
 @interface WebView (WebViewPrintingPrivate)

Modified: trunk/Source/WebKit2/ChangeLog (144494 => 144495)


--- trunk/Source/WebKit2/ChangeLog	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit2/ChangeLog	2013-03-01 21:32:43 UTC (rev 144495)
@@ -1,3 +1,18 @@
+2013-02-28  Sam Weinig  <[email protected]>
+
+        Add SPI for marking a WebView as doing things on behalf of another process
+        https://bugs.webkit.org/show_bug.cgi?id=111125
+
+        Reviewed by Alexey Proskuryakov.
+
+        * NetworkProcess/mac/RemoteNetworkingContext.h:
+        * NetworkProcess/mac/RemoteNetworkingContext.mm:
+        (WebKit::RemoteNetworkingContext::sourceApplicationAuditData):
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
+        (WebKit::WebFrameNetworkingContext::sourceApplicationAuditData):
+        Stub out sourceApplicationAuditData() client function.
+
 2013-03-01  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r144422 and r144424.

Modified: trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h (144494 => 144495)


--- trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -55,6 +55,7 @@
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
     virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual NSOperationQueue *scheduledOperationQueue() const OVERRIDE;
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 
     bool m_needsSiteSpecificQuirks;

Modified: trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm (144494 => 144495)


--- trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm	2013-03-01 21:32:43 UTC (rev 144495)
@@ -26,8 +26,8 @@
 #import "config.h"
 #import "RemoteNetworkingContext.h"
 
-#import "WebCore/ResourceError.h"
 #import "WebErrors.h"
+#import <WebCore/ResourceError.h>
 #import <WebKitSystemInterface.h>
 #import <wtf/MainThread.h>
 
@@ -101,6 +101,11 @@
     return queue;
 }
 
+RetainPtr<CFDataRef> RemoteNetworkingContext::sourceApplicationAuditData() const
+{
+    return nil;
+}
+
 ResourceError RemoteNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return WebKit::blockedError(request);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h (144494 => 144495)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h	2013-03-01 21:32:43 UTC (rev 144495)
@@ -48,6 +48,7 @@
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
     virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 };
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm (144494 => 144495)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm	2013-03-01 21:31:34 UTC (rev 144494)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm	2013-03-01 21:32:43 UTC (rev 144495)
@@ -52,6 +52,11 @@
     return frame() && frame()->page() ? frame()->page()->scheduledRunLoopPairs() : 0;
 }
 
+RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() const
+{
+    return nil;
+}
+
 ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return frame()->loader()->client()->blockedError(request);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to