Reviewed by Maciej.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Aug 2007 01:08:35 +0000 (01:08 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Aug 2007 01:08:35 +0000 (01:08 +0000)
        - fix <rdar://problem/5414518> Use root URL as origin URL when quarantining downloads

        * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::setOriginalURLForDownload):
        Extract only the scheme and host name and make the originating URL from that.

        * WebKit/StringsNotToBeLocalized.txt: Updated for recent changes.

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

WebKit/ChangeLog
WebKit/StringsNotToBeLocalized.txt
WebKit/WebCoreSupport/WebFrameLoaderClient.mm

index 5a219a9..b5f062a 100644 (file)
@@ -1,3 +1,14 @@
+2007-08-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej.
+
+        - fix <rdar://problem/5414518> Use root URL as origin URL when quarantining downloads
+
+        * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::setOriginalURLForDownload):
+        Extract only the scheme and host name and make the originating URL from that.
+
+        * WebKit/StringsNotToBeLocalized.txt: Updated for recent changes.
+
 2007-08-17  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin.
index 589d555..1855559 100644 (file)
@@ -32,6 +32,7 @@
 "%@:%u"
 "%@://%@"
 "%@://%@/%@"
+"%@://%@:%d"
 "%d"
 "%dpx"
 "%ld"
@@ -43,7 +44,6 @@
 "-1px"
 "-khtml-text-decorations-in-effect"
 "."
-".3"
 "._"
 ".download"
 ".html"
 "CLSID\\{########-####-####-####-############}\\VersionIndependentProgID"
 "CSS"
 "Cache-Control"
+"Content-Encoding"
 "Content-Length"
 "Content-Type"
 "Courier"
 "Library/Internet Plug-Ins"
 "Lucida Grande"
 "MIME\\Database\\Content Type"
-"MoveBackward"
-"MoveBackwardAndModifySelection"
 "MoveDown"
 "MoveDownAndModifySelection"
 "MoveDownByPageAndModifyCaret"
-"MoveForward"
-"MoveForwardAndModifySelection"
 "MoveLeft"
 "MoveLeftAndModifySelection"
-"MoveParagraphBackwardAndModifySelection"
-"MoveParagraphForwardAndModifySelection"
 "MoveRight"
 "MoveRightAndModifySelection"
 "MoveToBeginningOfDocument"
 "MoveToBeginningOfDocumentAndModifySelection"
 "MoveToBeginningOfLine"
 "MoveToBeginningOfLineAndModifySelection"
-"MoveToBeginningOfParagraph"
-"MoveToBeginningOfParagraphAndModifySelection"
-"MoveToBeginningOfSentence"
-"MoveToBeginningOfSentenceAndModifySelection"
 "MoveToEndOfDocument"
 "MoveToEndOfDocumentAndModifySelection"
 "MoveToEndOfLine"
 "MoveToEndOfLineAndModifySelection"
-"MoveToEndOfParagraph"
-"MoveToEndOfParagraphAndModifySelection"
-"MoveToEndOfSentence"
-"MoveToEndOfSentenceAndModifySelection"
 "MoveUp"
 "MoveUpAndModifySelection"
 "MoveUpByPageAndModifyCaret"
-"MoveWordBackward"
-"MoveWordBackwardAndModifySelection"
-"MoveWordForward"
-"MoveWordForwardAndModifySelection"
 "MoveWordLeft"
 "MoveWordLeftAndModifySelection"
 "MoveWordRight"
 "NSEvent"
 "NSView"
 "NeXT smart paste pasteboard type"
-"OpenSource"
 "PDFDocument"
 "PDFPreviewView"
 "PDFView"
+"PDFViewChangedPage"
 "PDFViewDisplayModeChanged"
 "PDFViewScaleChanged"
 "PNG"
 "WebInspectorWindowClass"
 "WebJavaScriptCollector"
 "WebJavaScriptTextInputPanel"
-"WebKit."
 "WebKitDeveloperExtras"
 "WebKitErrorDomain"
 "WebKitErrorMIMETypeKey"
 "WebPluginAttributes"
 "WebPluginBaseURL"
 "WebPluginContainer"
-"WebPluginDescription"
-"WebPluginExtensions"
-"WebPluginLocalizationName"
-"WebPluginMIMETypes"
-"WebPluginMIMETypesFilename"
-"WebPluginName"
-"WebPluginTypeDescription"
-"WebPluginTypeEnabled"
 "WebPluginWillPresentNativeUserInterface"
 "WebPreferences"
 "WebPreferences%d"
 "WebURLProtectionSpace"
 "WebURLRequest"
 "WebURLResponse"
-"WebURLsWithTitlesPboardType"
 "WebView"
 "WebViewDidBeginEditingNotification"
 "WebViewDidChangeNotification"
 "com.RealNetworks.RealOne Player"
 "com.adobe.Acrobat"
 "com.adobe.Acrobat.Pro"
+"com.adobe.Contribute"
+"com.adobe.InCopy"
+"com.adobe.InDesign"
 "com.adobe.Installers.Setup"
 "com.adobe.Reader"
+"com.adobe.Soundbooth"
 "com.adobe.distiller"
+"com.adobe.dreamweaver-9.0"
 "com.apple.Aperture"
 "com.apple.AppKit"
 "com.apple.HIWebView"
 "com.apple.quicktime.webplugin"
 "com.apple.universalaccess"
 "com.lizardtech.NPDjVu"
+"com.macromedia.fireworks"
 "com.microsoft.WMP.defaultplugin"
 "com.vitalsource.bookshelf"
 "dir"
@@ -532,12 +511,12 @@ WebKit/History/WebHistoryItem.mm:" in \"%@\""
 WebKit/History/WebHistoryItem.mm:"children"
 WebKit/History/WebHistoryItem.mm:"title"
 WebKit/Misc/WebCache.mm:"Images"
-WebKit/Misc/WebKitLogging.h:"<not running on main thread>"
 WebKit/Misc/WebKitVersionChecks.m:"WebKit"
-WebKit/Misc/WebNSURLExtras.m:"file"
+WebKit/Misc/WebNSURLExtras.mm:"file"
 WebKit/Plugins/WebBaseNetscapePluginStream.mm:" OK\n"
 WebKit/Plugins/WebBaseNetscapePluginStream.mm:": "
 WebKit/Plugins/WebBaseNetscapePluginStream.mm:"HTTP "
+WebKit/Plugins/WebBaseNetscapePluginStream.mm:"identity"
 WebKit/Plugins/WebBaseNetscapePluginView.mm:"height"
 WebKit/Plugins/WebBaseNetscapePluginView.mm:"width"
 WebKit/Plugins/WebBasePluginPackage.m:"Java Applet Plugin Enabler"
@@ -579,7 +558,6 @@ WebKit/WebView/WebHTMLView.mm:"super"
 WebKit/WebView/WebHTMLView.mm:"transparent"
 WebKit/WebView/WebHTMLView.mm:"underline"
 WebKit/WebView/WebHTMLView.mm:"white"
-WebKit/WebView/WebPreferenceKeysPrivate.h
 WebKit/WebView/WebPreferences.m:"Identifier"
 WebKit/WebView/WebPreferences.m:"Values"
 WebKit/WebView/WebView.mm:"Preferences"
@@ -596,7 +574,6 @@ WebKit/win/WebInspectorClient.cpp:"Web Inspector "
 WebKit/win/WebInspectorClient.cpp:"Web Inspector"
 WebKit/win/WebInspectorClient.cpp:"inspector"
 WebKit/win/WebKitDLL.cpp:"Apartment"
-WebKit/win/WebPreferenceKeysPrivate.h
 WebKit/win/WebPreferences.cpp:"Arial"
 WebKit/win/WebPreferences.cpp:"Comic Sans MS"
 WebKit/win/WebPreferences.cpp:"Courier New"
index a98c535..c345f85 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -103,17 +103,11 @@ using namespace WebCore;
 // SPI for NSURLDownload
 // Needed for <rdar://problem/5121850> 
 @interface NSURLDownload (NSURLDownloadPrivate)
-
-- (void)_setOriginatingURL:(NSURL *)url;
-- (NSURL *)_originatingURL;
-
+- (void)_setOriginatingURL:(NSURL *)originatingURL;
 @end
 
-// FIXME: This is unnecessary after <rdar://problem/5208329>
 @interface WebHistoryItem (WebHistoryItemPrivate)
-
 - (BOOL)_wasUserGesture;
-
 @end
 
 @interface WebFramePolicyListener : NSObject <WebPolicyDecisionListener, WebFormSubmissionListener>
@@ -259,34 +253,46 @@ void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceReques
     setOriginalURLForDownload(download, initialRequest);    
 }
 
-void WebFrameLoaderClient::setOriginalURLForDownload(WebDownload *download, const WebCore::ResourceRequest& initialRequest) const
+void WebFrameLoaderClient::setOriginalURLForDownload(WebDownload *download, const ResourceRequest& initialRequest) const
 {
-    WebView *webView = getWebView(m_webFrame.get());
     NSURLRequest *initialURLRequest = initialRequest.nsURLRequest();
     NSURL *originalURL = nil;
-    WebBackForwardList *history = [webView backForwardList];
-    WebHistoryItem *currentItem = nil;
-    int backListCount = [history backListCount];
     
-    // if there was no referrer, don't traverse the backforward history
-    // since this download was initiated directly
-    // <rdar://problem/5294691>
+    // If there was no referrer, don't traverse the back/forward history
+    // since this download was initiated directly. <rdar://problem/5294691>
     if ([initialURLRequest valueForHTTPHeaderField:@"Referer"]) {
-        // find the first item in the history that was originated
-        // by the user
+        // find the first item in the history that was originated by the user
+        WebView *webView = getWebView(m_webFrame.get());
+        WebBackForwardList *history = [webView backForwardList];
+        int backListCount = [history backListCount];
         for (int backIndex = 0; backIndex <= backListCount && !originalURL; backIndex++) {
-            currentItem = [history itemAtIndex:-backIndex];
-
+            WebHistoryItem *currentItem = [history itemAtIndex:-backIndex];
             if (![currentItem respondsToSelector:@selector(_wasUserGesture)] || [currentItem _wasUserGesture])
                 originalURL = [currentItem URL];
         }
     }
-    
+
     if (!originalURL)
         originalURL = [initialURLRequest URL];
-    
-    if ([download respondsToSelector:@selector(_setOriginatingURL:)])
-        [download _setOriginatingURL:originalURL];
+
+    if ([download respondsToSelector:@selector(_setOriginatingURL:)]) {
+        NSString *scheme = [originalURL scheme];
+        NSString *host = [originalURL host];
+        if (scheme && host && [scheme length] && [host length]) {
+            NSNumber *port = [originalURL port];
+            if (port && [port intValue] < 0)
+                port = nil;
+            NSString *hostOnlyURLString;
+            if (port)
+                hostOnlyURLString = [[NSString alloc] initWithFormat:@"%@://%@:%d", scheme, host, [port intValue]];
+            else
+                hostOnlyURLString = [[NSString alloc] initWithFormat:@"%@://%@", scheme, host];
+            NSURL *hostOnlyURL = [[NSURL alloc] initWithString:hostOnlyURLString];
+            [hostOnlyURLString release];
+            [download _setOriginatingURL:hostOnlyURL];
+            [hostOnlyURL release];
+        }
+    }
 }
 
 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader* loader, const ResourceRequest& request, const ResourceResponse& response, int length)
@@ -425,7 +431,7 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, unsi
     static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount(identifier);
 }
 
-void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const WebCore::ResourceError& error)
+void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
 {
     WebView *webView = getWebView(m_webFrame.get());
     id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
@@ -1240,7 +1246,7 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-WebCore::Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, Element* element, const KURL& baseURL, 
+Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, Element* element, const KURL& baseURL, 
                                                               const Vector<String>& paramNames, const Vector<String>& paramValues)
 {
     Widget* result = new Widget;