Title: [122803] trunk/Source/WebKit2
Revision
122803
Author
[email protected]
Date
2012-07-16 20:51:21 -0700 (Mon, 16 Jul 2012)

Log Message

[EFL][WK2] Implement decidePolicyForResponse in policy client
https://bugs.webkit.org/show_bug.cgi?id=91401

Patch by Christophe Dumez <[email protected]> on 2012-07-16
Reviewed by Kenneth Rohde Christiansen.

Provide implementation for decidePolicyForResponse callback
in WebKit2 EFL's policy client.

* UIProcess/API/efl/ewk_view_policy_client.cpp:
(decidePolicyForResponseCallback):
(ewk_view_policy_client_attach):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122802 => 122803)


--- trunk/Source/WebKit2/ChangeLog	2012-07-17 03:26:00 UTC (rev 122802)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-17 03:51:21 UTC (rev 122803)
@@ -1,3 +1,17 @@
+2012-07-16  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Implement decidePolicyForResponse in policy client
+        https://bugs.webkit.org/show_bug.cgi?id=91401
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide implementation for decidePolicyForResponse callback
+        in WebKit2 EFL's policy client.
+
+        * UIProcess/API/efl/ewk_view_policy_client.cpp:
+        (decidePolicyForResponseCallback):
+        (ewk_view_policy_client_attach):
+
 2012-07-16  Ryuan Choi  <[email protected]>
 
         [EFL][WK2] Add APIs to support theme.

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp (122802 => 122803)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp	2012-07-17 03:26:00 UTC (rev 122802)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp	2012-07-17 03:51:21 UTC (rev 122803)
@@ -26,12 +26,14 @@
 #include "config.h"
 
 #include "WKFrame.h"
+#include "WKFramePolicyListener.h"
 #include "ewk_navigation_policy_decision.h"
 #include "ewk_navigation_policy_decision_private.h"
 #include "ewk_view_policy_client_private.h"
 #include "ewk_view_private.h"
 #include <wtf/text/CString.h>
 
+using namespace WebCore;
 using namespace WebKit;
 
 static inline Evas_Object* toEwkView(const void* clientInfo)
@@ -53,6 +55,39 @@
     ewk_navigation_policy_decision_unref(decision);
 }
 
+static void decidePolicyForResponseCallback(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
+{
+    const ResourceResponse resourceResponse = toImpl(response)->resourceResponse();
+    // If the URL Response has "Content-Disposition: attachment;" header, then
+    // we should download it.
+    if (resourceResponse.isAttachment()) {
+        WKFramePolicyListenerDownload(listener);
+        return;
+    }
+
+    String mimeType = toImpl(response)->resourceResponse().mimeType().lower();
+    bool canShowMIMEType = toImpl(frame)->canShowMIMEType(mimeType);
+    if (WKFrameIsMainFrame(frame)) {
+        if (canShowMIMEType) {
+            WKFramePolicyListenerUse(listener);
+            return;
+        }
+
+        // If we can't use (show) it then we should download it.
+        WKFramePolicyListenerDownload(listener);
+        return;
+    }
+
+    // We should ignore downloadable top-level content for subframes, with an exception for text/xml and application/xml so we can still support Acid3 test.
+    // It makes the browser intentionally behave differently when it comes to text(application)/xml content in subframes vs. mainframe.
+    if (!canShowMIMEType && !(mimeType == "text/xml" || mimeType == "application/xml")) {
+        WKFramePolicyListenerIgnore(listener);
+        return;
+    }
+
+    WKFramePolicyListenerUse(listener);
+}
+
 void ewk_view_policy_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
 {
     WKPagePolicyClient policyClient;
@@ -61,6 +96,7 @@
     policyClient.clientInfo = ewkView;
     policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
     policyClient.decidePolicyForNewWindowAction = decidePolicyForNewWindowAction;
+    policyClient.decidePolicyForResponse = decidePolicyForResponseCallback;
 
     WKPageSetPagePolicyClient(pageRef, &policyClient);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to