Title: [170222] trunk/Source/WebKit2
Revision
170222
Author
[email protected]
Date
2014-06-20 16:37:38 -0700 (Fri, 20 Jun 2014)

Log Message

[Cocoa] No way to get the main frame’s main resource’s data
https://bugs.webkit.org/show_bug.cgi?id=134113

Reviewed by Sam Weinig.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _getMainResourceDataWithCompletionHandler:]): Added. Calls
WebPageProxy::getMainResourceDataOfFrame and invokes the completion handler form the
callback.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::getMainResourceDataOfFrame): Made it safe to pass a NULL frame into
this function.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170221 => 170222)


--- trunk/Source/WebKit2/ChangeLog	2014-06-20 23:21:51 UTC (rev 170221)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-20 23:37:38 UTC (rev 170222)
@@ -1,3 +1,20 @@
+2014-06-20  Dan Bernstein  <[email protected]>
+
+        [Cocoa] No way to get the main frame’s main resource’s data
+        https://bugs.webkit.org/show_bug.cgi?id=134113
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _getMainResourceDataWithCompletionHandler:]): Added. Calls
+        WebPageProxy::getMainResourceDataOfFrame and invokes the completion handler form the
+        callback.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::getMainResourceDataOfFrame): Made it safe to pass a NULL frame into
+        this function.
+
 2014-06-20  Anders Carlsson  <[email protected]>
 
         Introduce a WKSessionStateRef object

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (170221 => 170222)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-06-20 23:21:51 UTC (rev 170221)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-06-20 23:37:38 UTC (rev 170222)
@@ -1519,6 +1519,21 @@
     _page->listenForLayoutMilestones(layoutMilestones(observedRenderingProgressEvents));
 }
 
+- (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
+{
+    auto handler = adoptNS([completionHandler copy]);
+
+    _page->getMainResourceDataOfFrame(_page->mainFrame(), [handler](API::Data* data, WebKit::CallbackBase::Error error) {
+        void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
+        if (error != WebKit::CallbackBase::Error::None) {
+            // FIXME: Pipe a proper error in from the WebPageProxy.
+            RetainPtr<NSError> error = adoptNS([[NSError alloc] init]);
+            completionHandlerBlock(nil, error.get());
+        } else
+            completionHandlerBlock(wrapper(*data), nil);
+    });
+}
+
 - (void)_getWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
 {
     auto handler = adoptNS([completionHandler copy]);

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (170221 => 170222)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-06-20 23:21:51 UTC (rev 170221)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-06-20 23:37:38 UTC (rev 170222)
@@ -151,6 +151,7 @@
 @property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
 #endif
 
+- (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
 - (void)_getWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
 
 @property (nonatomic, setter=_setPaginationMode:) _WKPaginationMode _paginationMode;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (170221 => 170222)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-06-20 23:21:51 UTC (rev 170221)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-06-20 23:37:38 UTC (rev 170222)
@@ -2297,7 +2297,7 @@
 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
 {
     RefPtr<DataCallback> callback = DataCallback::create(std::move(callbackFunction));
-    if (!isValid()) {
+    if (!isValid() || !frame) {
         callback->invalidate();
         return;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to