Reviewed by Jon Honeycutt.
authoralice.liu@apple.com <alice.liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 19:51:57 +0000 (19:51 +0000)
committeralice.liu@apple.com <alice.liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 19:51:57 +0000 (19:51 +0000)
        Fall back to the default Policy Delegate in these functions,
        as is already done in dispatchDecidePolicyForNavigationAction

        * WebFrame.cpp:
        (WebFrame::dispatchDecidePolicyForMIMEType):
        (WebFrame::dispatchDecidePolicyForNewWindowAction):
        (WebFrame::dispatchUnableToImplementPolicy):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28046 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebFrame.cpp

index 4f073380b01fc9e8037d2f51468123af3cf251be..ac1bff1b509a0202678f0f942491bf48f7fd4a67 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-26  Alice Liu  <alice.liu@apple.com>
+
+        Reviewed by Jon Honeycutt.
+
+        Fall back to the default Policy Delegate in these functions, 
+        as is already done in dispatchDecidePolicyForNavigationAction
+
+        * WebFrame.cpp:
+        (WebFrame::dispatchDecidePolicyForMIMEType):
+        (WebFrame::dispatchDecidePolicyForNewWindowAction):
+        (WebFrame::dispatchUnableToImplementPolicy):
+
 2007-11-25  Adam Roben  <aroben@apple.com>
 
         Fix a leak pointed out by Alexey
index 31c1f7b8af3319c2bbc00c86c43d020c21a36f5e..b6e12bb8d88f5e0144efdb91ff3e4d24857df366 100644 (file)
@@ -2046,23 +2046,19 @@ void WebFrame::committedLoad(DocumentLoader* loader, const char* data, int lengt
 
 void WebFrame::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimeType, const ResourceRequest& request)
 {
-    COMPtr<IWebPolicyDelegate> policyDelegate;
-    if (SUCCEEDED(d->webView->policyDelegate(&policyDelegate))) {
-        COMPtr<IWebURLRequest> urlRequest;
-        urlRequest.adoptRef(WebMutableURLRequest::createInstance(request));
-        if (SUCCEEDED(policyDelegate->decidePolicyForMIMEType(d->webView, BString(mimeType), urlRequest.get(), this, setUpPolicyListener(function).get())))
-            return;
-    }
-
     Frame* coreFrame = core(this);
     ASSERT(coreFrame);
 
-    // FIXME: This is a stopgap default implementation to tide us over until
-    // <rdar://4911042/> is taken care of
-    if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) || MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
-        (coreFrame->loader()->*function)(PolicyUse);
-    else
-        (coreFrame->loader()->*function)(PolicyDownload);
+    COMPtr<IWebPolicyDelegate> policyDelegate;
+    if (FAILED(d->webView->policyDelegate(&policyDelegate)))
+        policyDelegate = DefaultPolicyDelegate::sharedInstance();
+
+    COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
+
+    if (SUCCEEDED(policyDelegate->decidePolicyForMIMEType(d->webView, BString(mimeType), urlRequest.get(), this, setUpPolicyListener(function).get())))
+        return;
+
+    (coreFrame->loader()->*function)(PolicyUse);
 }
 
 void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, const String& frameName)
@@ -2071,17 +2067,15 @@ void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction functi
     ASSERT(coreFrame);
 
     COMPtr<IWebPolicyDelegate> policyDelegate;
-    if (SUCCEEDED(d->webView->policyDelegate(&policyDelegate))) {
-        COMPtr<IWebURLRequest> urlRequest;
-        urlRequest.adoptRef(WebMutableURLRequest::createInstance(request));
-        COMPtr<WebActionPropertyBag> actionInformation;
-        actionInformation.adoptRef(WebActionPropertyBag::createInstance(action, coreFrame));
+    if (FAILED(d->webView->policyDelegate(&policyDelegate)))
+        policyDelegate = DefaultPolicyDelegate::sharedInstance();
 
-        if (SUCCEEDED(policyDelegate->decidePolicyForNewWindowAction(d->webView, actionInformation.get(), urlRequest.get(), BString(frameName), setUpPolicyListener(function).get())))
-            return;
-    }
+    COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
+    COMPtr<WebActionPropertyBag> actionInformation(AdoptCOM, WebActionPropertyBag::createInstance(action, coreFrame));
+
+    if (SUCCEEDED(policyDelegate->decidePolicyForNewWindowAction(d->webView, actionInformation.get(), urlRequest.get(), BString(frameName), setUpPolicyListener(function).get())))
+        return;
 
-    // FIXME: Add a sane default implementation
     (coreFrame->loader()->*function)(PolicyUse);
 }
 
@@ -2106,11 +2100,11 @@ void WebFrame::dispatchDecidePolicyForNavigationAction(FramePolicyFunction funct
 void WebFrame::dispatchUnableToImplementPolicy(const ResourceError& error)
 {
     COMPtr<IWebPolicyDelegate> policyDelegate;
-    if (SUCCEEDED(d->webView->policyDelegate(&policyDelegate))) {
-        COMPtr<IWebError> webError;
-        webError.adoptRef(WebError::createInstance(error));
-        policyDelegate->unableToImplementPolicyWithError(d->webView, webError.get(), this);
-    }
+    if (FAILED(d->webView->policyDelegate(&policyDelegate)))
+        policyDelegate = DefaultPolicyDelegate::sharedInstance();
+
+    COMPtr<IWebError> webError(AdoptCOM, WebError::createInstance(error));
+    policyDelegate->unableToImplementPolicyWithError(d->webView, webError.get(), this);
 }
 
 void WebFrame::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response)