[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 14:03:23 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d11f4c551d49e435ac70d1191a37db2e15cb8fc2
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 1 23:28:17 2010 +0000

    Add proxy server query function proxyServersForURL and change the Mac plug-in code to use it
    https://bugs.webkit.org/show_bug.cgi?id=47022
    <rdar://problem/8504712>
    
    Reviewed by Dan Bernstein.
    
    WebCore:
    
    * WebCore.exp.in:
    Export proxyServersForURL and toString.
    
    * WebCore.vcproj/WebCore.vcproj:
    * WebCore.xcodeproj/project.pbxproj:
    Add new files.
    
    * platform/network/ProxyServer.cpp: Added.
    (WebCore::appendProxyServerString):
    (WebCore::toString):
    New function that converts a vector of ProxyServers into a PAC style string.
    
    * platform/network/ProxyServer.h: Added.
    (WebCore::ProxyServer::ProxyServer):
    (WebCore::ProxyServer::type):
    (WebCore::ProxyServer::hostName):
    (WebCore::ProxyServer::port):
    Add ProxyServer class.
    
    * platform/network/cf/ProxyServerCFNet.cpp: Added.
    (WebCore::proxyServersForURL):
    (WebCore::addProxyServersForURL):
    Query CFNetwork for the proxy servers given a URL.
    
    WebKit/mac:
    
    * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
    (WebKit::NetscapePluginInstanceProxy::getProxy):
    * Plugins/WebBaseNetscapePluginView.h:
    * Plugins/WebBaseNetscapePluginView.mm:
    * Plugins/WebNetscapePluginView.mm:
    (-[WebNetscapePluginView getVariable:forURL:value:length:]):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68951 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2fb9ebc..9ec840c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-10-01  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Add proxy server query function proxyServersForURL and change the Mac plug-in code to use it
+        https://bugs.webkit.org/show_bug.cgi?id=47022
+        <rdar://problem/8504712>
+
+        * WebCore.exp.in:
+        Export proxyServersForURL and toString.
+
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * platform/network/ProxyServer.cpp: Added.
+        (WebCore::appendProxyServerString):
+        (WebCore::toString):
+        New function that converts a vector of ProxyServers into a PAC style string.
+
+        * platform/network/ProxyServer.h: Added.
+        (WebCore::ProxyServer::ProxyServer):
+        (WebCore::ProxyServer::type):
+        (WebCore::ProxyServer::hostName):
+        (WebCore::ProxyServer::port):
+        Add ProxyServer class.
+
+        * platform/network/cf/ProxyServerCFNet.cpp: Added.
+        (WebCore::proxyServersForURL):
+        (WebCore::addProxyServersForURL):
+        Query CFNetwork for the proxy servers given a URL.
+
 2010-09-30  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 4078480..a045111 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -414,6 +414,7 @@ __ZN7WebCore17openTemporaryFileEPKcRi
 __ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
 __ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionE
 __ZN7WebCore18pluginScriptObjectEPN3JSC9ExecStateEPNS_13JSHTMLElementE
+__ZN7WebCore18proxyServersForURLERKNS_4KURLE
 __ZN7WebCore19AnimationController16resumeAnimationsEPNS_8DocumentE
 __ZN7WebCore19AnimationController17suspendAnimationsEPNS_8DocumentE
 __ZN7WebCore19AnimationController20pauseAnimationAtTimeEPNS_12RenderObjectERKN3WTF6StringEd
@@ -759,6 +760,7 @@ __ZN7WebCore8Settings40setTextDirectionSubmenuInclusionBehaviorENS_37TextDirecti
 __ZN7WebCore8Settings41setNeedsKeyboardEventDisambiguationQuirksEb
 __ZN7WebCore8blankURLEv
 __ZN7WebCore8makeRGBAEiiii
+__ZN7WebCore8toStringERKN3WTF6VectorINS_11ProxyServerELm0EEE
 __ZN7WebCore9DOMWindow30dispatchAllPendingUnloadEventsEv
 __ZN7WebCore9DOMWindow36dispatchAllPendingBeforeUnloadEventsEv
 __ZN7WebCore9FloatRectC1ERK7_NSRect
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 9155b4d..2be29a3 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -27384,6 +27384,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\platform\network\ProxyServer.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\platform\network\ProxyServer.h"
+					>
+				</File>
+				<File
 					RelativePath="..\platform\network\ResourceErrorBase.cpp"
 					>
 				</File>
@@ -27603,6 +27611,26 @@
 						>
 					</File>
 					<File
+						RelativePath="..\platform\network\cf\ProxyServerCFNet.cpp"
+						>
+						<FileConfiguration
+							Name="Debug_Cairo|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release_Cairo|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
 						RelativePath="..\platform\network\cf\ResourceError.h"
 						>
 						<FileConfiguration
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 9000726..33ab05b 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -594,6 +594,9 @@
 		1AE82FEC0CAB07EE002237AE /* JSSQLResultSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE82FEA0CAB07EE002237AE /* JSSQLResultSet.cpp */; };
 		1AE82FED0CAB07EE002237AE /* JSSQLResultSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE82FEB0CAB07EE002237AE /* JSSQLResultSet.h */; };
 		1AF326790D78B9440068F0C4 /* EditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF326770D78B9440068F0C4 /* EditorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF8E1191256592600230FF7 /* ProxyServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1AF8E13312565A4400230FF7 /* ProxyServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF8E13212565A4400230FF7 /* ProxyServer.cpp */; };
+		1AF8E1C3125673E000230FF7 /* ProxyServerCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF8E1C1125673E000230FF7 /* ProxyServerCFNet.cpp */; };
 		1AFE117D0CBFFB36003017FA /* SQLResultSetRowList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE117B0CBFFB36003017FA /* SQLResultSetRowList.cpp */; };
 		1AFE117E0CBFFB36003017FA /* SQLResultSetRowList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE117C0CBFFB36003017FA /* SQLResultSetRowList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1AFE11990CBFFCC4003017FA /* JSSQLResultSetRowList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE11970CBFFCC4003017FA /* JSSQLResultSetRowList.cpp */; };
@@ -6581,6 +6584,9 @@
 		1AE82FEA0CAB07EE002237AE /* JSSQLResultSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLResultSet.cpp; sourceTree = "<group>"; };
 		1AE82FEB0CAB07EE002237AE /* JSSQLResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLResultSet.h; sourceTree = "<group>"; };
 		1AF326770D78B9440068F0C4 /* EditorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorClient.h; sourceTree = "<group>"; };
+		1AF8E1191256592600230FF7 /* ProxyServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyServer.h; sourceTree = "<group>"; };
+		1AF8E13212565A4400230FF7 /* ProxyServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyServer.cpp; sourceTree = "<group>"; };
+		1AF8E1C1125673E000230FF7 /* ProxyServerCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyServerCFNet.cpp; sourceTree = "<group>"; };
 		1AFE117B0CBFFB36003017FA /* SQLResultSetRowList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLResultSetRowList.cpp; sourceTree = "<group>"; };
 		1AFE117C0CBFFB36003017FA /* SQLResultSetRowList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLResultSetRowList.h; sourceTree = "<group>"; };
 		1AFE118C0CBFFC4E003017FA /* SQLResultSetRowList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SQLResultSetRowList.idl; sourceTree = "<group>"; };
@@ -7285,9 +7291,9 @@
 		51A9267A0D53F0570063ECC2 /* OriginUsageRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OriginUsageRecord.cpp; sourceTree = "<group>"; };
 		51A9267B0D53F0570063ECC2 /* OriginUsageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OriginUsageRecord.h; sourceTree = "<group>"; };
 		51AA3F6E0BD5AA9E00892971 /* ResourceLoaderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoaderMac.mm; sourceTree = "<group>"; };
-		51ABAE1A103C18FF008C5260 /* SocketStreamError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocketStreamError.h; path = cf/SocketStreamError.h; sourceTree = "<group>"; };
-		51ABAE1C103C1913008C5260 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocketStreamHandle.h; path = cf/SocketStreamHandle.h; sourceTree = "<group>"; };
-		51ABAE1D103C1913008C5260 /* SocketStreamHandleCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SocketStreamHandleCFNet.cpp; path = cf/SocketStreamHandleCFNet.cpp; sourceTree = "<group>"; };
+		51ABAE1A103C18FF008C5260 /* SocketStreamError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamError.h; sourceTree = "<group>"; };
+		51ABAE1C103C1913008C5260 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocketStreamHandle.h; path = ../qt/SocketStreamHandle.h; sourceTree = "<group>"; };
+		51ABAE1D103C1913008C5260 /* SocketStreamHandleCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleCFNet.cpp; sourceTree = "<group>"; };
 		51ABAE421043AB4A008C5260 /* WebSocketHandshake.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketHandshake.cpp; sourceTree = "<group>"; };
 		51ABAE431043AB4A008C5260 /* WebSocketHandshake.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketHandshake.h; sourceTree = "<group>"; };
 		51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; };
@@ -10205,7 +10211,7 @@
 		B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGRenderTreeAsText.h; sourceTree = "<group>"; };
 		B2ED97700B1F55CE00257D0F /* GraphicsContextCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextCG.cpp; sourceTree = "<group>"; };
 		B2F34FE50E82F81400F627CD /* DNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNS.h; sourceTree = "<group>"; };
-		B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DNSCFNet.cpp; path = cf/DNSCFNet.cpp; sourceTree = "<group>"; };
+		B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSCFNet.cpp; sourceTree = "<group>"; };
 		B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimateColorElement.cpp; sourceTree = "<group>"; };
 		B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAnimateColorElement.h; sourceTree = "<group>"; };
 		B2FA3C500AB75A6E000E5AC4 /* JSSVGAnimatedAngle.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimatedAngle.cpp; sourceTree = "<group>"; };
@@ -12838,6 +12844,8 @@
 				1A7FA6180DDA3B3A0028F8A5 /* NetworkStateNotifier.h */,
 				514C765F0CE923A1007EF3CD /* ProtectionSpace.cpp */,
 				514C76600CE923A1007EF3CD /* ProtectionSpace.h */,
+				1AF8E13212565A4400230FF7 /* ProxyServer.cpp */,
+				1AF8E1191256592600230FF7 /* ProxyServer.h */,
 				51A052551058874000CC9E95 /* ProtectionSpaceHash.h */,
 				934F713D0D5A6F2800018D69 /* ResourceErrorBase.cpp */,
 				934F713B0D5A6F1900018D69 /* ResourceErrorBase.h */,
@@ -16497,11 +16505,12 @@
 			isa = PBXGroup;
 			children = (
 				B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */,
+				1AF8E1C1125673E000230FF7 /* ProxyServerCFNet.cpp */,
 				51ABAE1A103C18FF008C5260 /* SocketStreamError.h */,
 				51ABAE1C103C1913008C5260 /* SocketStreamHandle.h */,
 				51ABAE1D103C1913008C5260 /* SocketStreamHandleCFNet.cpp */,
 			);
-			name = cf;
+			path = cf;
 			sourceTree = "<group>";
 		};
 		B5320D68122A24E9002D1440 /* cocoa */ = {
@@ -20951,6 +20960,7 @@
 				081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */,
 				080E49261255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h in Headers */,
 				080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */,
+				1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -21010,6 +21020,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
 			compatibilityVersion = "Xcode 2.4";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
@@ -23479,6 +23490,8 @@
 				081093DB1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp in Sources */,
 				080E49251255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.cpp in Sources */,
 				080E49271255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.cpp in Sources */,
+				1AF8E13312565A4400230FF7 /* ProxyServer.cpp in Sources */,
+				1AF8E1C3125673E000230FF7 /* ProxyServerCFNet.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/platform/network/ProxyServer.cpp b/WebCore/platform/network/ProxyServer.cpp
new file mode 100644
index 0000000..ef08d6c
--- /dev/null
+++ b/WebCore/platform/network/ProxyServer.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ProxyServer.h"
+
+#include "StringBuilder.h"
+
+namespace WebCore {
+
+static void appendProxyServerString(StringBuilder &builder, const ProxyServer& proxyServer)
+{
+    switch (proxyServer.type()) {
+    case ProxyServer::Direct:
+        builder.append("DIRECT");
+        return;
+    case ProxyServer::HTTP:
+    case ProxyServer::HTTPS:
+        builder.append("PROXY");
+        break;
+    case ProxyServer::SOCKS:
+        builder.append("SOCKS");
+        break;
+    }
+    
+    builder.append(' ');
+
+    ASSERT(!proxyServer.hostName().isNull());
+    builder.append(proxyServer.hostName());
+
+    builder.append(':');
+    ASSERT(proxyServer.port() != -1);
+    builder.append(String::number(proxyServer.port()));
+}
+
+String toString(const Vector<ProxyServer>& proxyServers)
+{
+    if (proxyServers.isEmpty())
+        return "DIRECT";
+
+    StringBuilder stringBuilder;
+    for (size_t i = 0; i < proxyServers.size(); ++i) {
+        if (i)
+            stringBuilder.append("; ");
+
+        appendProxyServerString(stringBuilder, proxyServers[i]);
+    }
+
+    return stringBuilder.toString();
+}
+
+
+} // namespace WebCore
diff --git a/WebCore/platform/network/ProxyServer.h b/WebCore/platform/network/ProxyServer.h
new file mode 100644
index 0000000..f740114
--- /dev/null
+++ b/WebCore/platform/network/ProxyServer.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ProxyServer_h
+#define ProxyServer_h
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class KURL;
+
+// Represents a single proxy server.
+class ProxyServer {
+public:
+    enum Type {
+        Direct,
+        HTTP,
+        HTTPS,
+        SOCKS,
+    };
+
+    ProxyServer()
+        : m_type(Direct)
+        , m_port(-1)
+    {
+    }
+
+    ProxyServer(Type type, const String& hostName, int port)
+        : m_type(type)
+        , m_hostName(hostName)
+        , m_port(port)
+    {
+    }
+        
+    Type type() const { return m_type; }
+    const String& hostName() const { return m_hostName; }
+    int port() const { return m_port; }
+
+private:
+    Type m_type;
+    String m_hostName;
+    int m_port;
+};
+
+// Return a vector of proxy servers for the given URL.
+Vector<ProxyServer> proxyServersForURL(const KURL&);
+
+// Converts the given vector of proxy servers to a PAC string, as described in
+// http://web.archive.org/web/20060424005037/wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
+String toString(const Vector<ProxyServer>&);
+    
+} // namespace WebCore
+
+#endif // ProxyServer_h
diff --git a/WebCore/platform/network/cf/ProxyServerCFNet.cpp b/WebCore/platform/network/cf/ProxyServerCFNet.cpp
new file mode 100644
index 0000000..338c009
--- /dev/null
+++ b/WebCore/platform/network/cf/ProxyServerCFNet.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ProxyServer.h"
+
+#include "KURL.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+static void addProxyServersForURL(Vector<ProxyServer>& proxyServers, const KURL& url)
+{
+    RetainPtr<CFDictionaryRef> proxySettings(AdoptCF, CFNetworkCopySystemProxySettings());
+    if (!proxySettings)
+        return;
+
+    RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
+    RetainPtr<CFArrayRef> proxiesForURL(AdoptCF, CFNetworkCopyProxiesForURL(cfURL.get(), proxySettings.get()));
+    if (!proxiesForURL)
+        return;
+
+    CFIndex numProxies = CFArrayGetCount(proxiesForURL.get());
+    for (CFIndex i = 0; i < numProxies; ++i) {
+        CFDictionaryRef proxyDictionary = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(proxiesForURL.get(), i));
+
+        ProxyServer::Type type = ProxyServer::Direct;
+        CFStringRef typeString = static_cast<CFStringRef>(CFDictionaryGetValue(proxyDictionary, kCFProxyTypeKey));
+        if (CFEqual(typeString, kCFProxyTypeAutoConfigurationURL)) {
+            // FIXME: Handle PAC URLs.
+            continue;
+        } 
+        
+        if (CFEqual(typeString, kCFProxyTypeNone)) {
+            proxyServers.append(ProxyServer(ProxyServer::Direct, String(), -1));
+            continue;
+        }
+        
+        if (CFEqual(typeString, kCFProxyTypeHTTP))
+            type = ProxyServer::HTTP;
+        else if (CFEqual(typeString, kCFProxyTypeHTTPS))
+            type = ProxyServer::HTTPS;
+        else if (CFEqual(typeString, kCFProxyTypeSOCKS))
+            type = ProxyServer::SOCKS;
+        else {
+            // We don't know how to handle this type.
+            continue;
+        }
+
+        CFStringRef host = static_cast<CFStringRef>(CFDictionaryGetValue(proxyDictionary, kCFProxyHostNameKey));
+        CFNumberRef port = static_cast<CFNumberRef>(CFDictionaryGetValue(proxyDictionary, kCFProxyPortNumberKey));
+        SInt32 portValue;
+        CFNumberGetValue(port, kCFNumberSInt32Type, &portValue);
+
+        proxyServers.append(ProxyServer(type, host, portValue));
+    }
+}
+
+Vector<ProxyServer> proxyServersForURL(const KURL& url)
+{
+    Vector<ProxyServer> proxyServers;
+    
+    addProxyServersForURL(proxyServers, url);
+    return proxyServers;
+    
+}
+#else
+Vector<ProxyServer> proxyServersForURL(const KURL&)
+{
+    // FIXME: Implement.
+    return Vector<ProxyServer>();
+}
+#endif
+
+} // namespace WebCore
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 080cf0d..da26c37 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,18 @@
+2010-10-01  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Add proxy server query function proxyServersForURL and change the Mac plug-in code to use it
+        https://bugs.webkit.org/show_bug.cgi?id=47022
+        <rdar://problem/8504712>
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::getProxy):
+        * Plugins/WebBaseNetscapePluginView.h:
+        * Plugins/WebBaseNetscapePluginView.mm:
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView getVariable:forURL:value:length:]):
+
 2010-09-30  Darin Adler  <darin at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
index e03bc27..6ad0ae3 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
@@ -50,6 +50,7 @@
 #import <WebCore/FrameLoader.h>
 #import <WebCore/FrameTree.h>
 #import <WebCore/KURL.h>
+#import <WebCore/ProxyServer.h>
 #import <WebCore/SecurityOrigin.h>
 #import <WebCore/ScriptController.h>
 #import <WebCore/ScriptValue.h>
@@ -1557,7 +1558,8 @@ bool NetscapePluginInstanceProxy::getProxy(data_t urlData, mach_msg_type_number_
     if (!url)
         return false;
 
-    WTF::CString proxyStringUTF8 = proxiesForURL(url);
+    Vector<ProxyServer> proxyServers = proxyServersForURL(URL);
+    WTF::CString proxyStringUTF8 = toString(proxyServers).utf8();
 
     proxyLength = proxyStringUTF8.length();
     mig_allocate(reinterpret_cast<vm_address_t*>(&proxyData), proxyLength);
diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
index 9a29cc2..1a4b6bb 100644
--- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
+++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
@@ -145,10 +145,6 @@ class WebHaltablePlugin;
 
 
 namespace WebKit {
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
-WTF::CString proxiesForURL(NSURL *);
-#endif
-    
 bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
                            WTF::CString& username, WTF::CString& password);
 } 
diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
index 4966716..708b017 100644
--- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
@@ -960,66 +960,6 @@ String WebHaltablePlugin::pluginName() const
 
 namespace WebKit {
 
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
-CString proxiesForURL(NSURL *url)
-{
-    RetainPtr<CFDictionaryRef> systemProxies(AdoptCF, CFNetworkCopySystemProxySettings());
-    if (!systemProxies)
-        return "DIRECT";
-    
-    RetainPtr<CFArrayRef> proxiesForURL(AdoptCF, CFNetworkCopyProxiesForURL((CFURLRef)url, systemProxies.get()));
-    CFIndex proxyCount = proxiesForURL ? CFArrayGetCount(proxiesForURL.get()) : 0;
-    if (!proxyCount)
-        return "DIRECT";
- 
-    // proxiesForURL is a CFArray of CFDictionaries. Each dictionary represents a proxy.
-    // The format of the result should be:
-    // "PROXY host[:port]" (for HTTP proxy) or
-    // "SOCKS host[:port]" (for SOCKS proxy) or
-    // A combination of the above, separated by semicolon, in the order that they should be tried.
-    String proxies;
-    for (CFIndex i = 0; i < proxyCount; ++i) {
-        CFDictionaryRef proxy = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(proxiesForURL.get(), i));
-        if (!proxy)
-            continue;
-
-        CFStringRef type = static_cast<CFStringRef>(CFDictionaryGetValue(proxy, kCFProxyTypeKey));
-        bool isHTTP = type == kCFProxyTypeHTTP || type == kCFProxyTypeHTTPS;
-        bool isSOCKS = type == kCFProxyTypeSOCKS;
-        
-        // We can only report HTTP and SOCKS proxies.
-        if (!isHTTP && !isSOCKS)
-            continue;
-        
-        CFStringRef host = static_cast<CFStringRef>(CFDictionaryGetValue(proxy, kCFProxyHostNameKey));
-        CFNumberRef port = static_cast<CFNumberRef>(CFDictionaryGetValue(proxy, kCFProxyPortNumberKey));
-        
-        // If we are inserting multiple entries, add a separator
-        if (!proxies.isEmpty())
-            proxies += ";";
-        
-        if (isHTTP)
-            proxies += "PROXY ";
-        else if (isSOCKS)
-            proxies += "SOCKS ";
-        
-        proxies += host;
-
-        if (port) {
-            SInt32 intPort;
-            CFNumberGetValue(port, kCFNumberSInt32Type, &intPort);
-            
-            proxies += ":" + String::number(intPort);
-        }
-    }
-    
-    if (proxies.isEmpty())
-        return "DIRECT";
-    
-    return proxies.utf8();
-}
-#endif
-
 bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
                            CString& username, CString& password)
 {
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm
index ff0ca77..542d59d 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm
@@ -66,6 +66,7 @@
 #import <WebCore/HTMLPlugInElement.h>
 #import <WebCore/Page.h> 
 #import <WebCore/PluginMainThreadScheduler.h>
+#import <WebCore/ProxyServer.h>
 #import <WebCore/ScriptController.h>
 #import <WebCore/SecurityOrigin.h>
 #import <WebCore/SoftLinking.h> 
@@ -2239,7 +2240,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
             if (!URL)
                 break;
 
-            CString proxiesUTF8 = proxiesForURL(URL);
+            Vector<ProxyServer> proxyServers = proxyServersForURL(URL);
+            CString proxiesUTF8 = toString(proxyServers).utf8();
             
             *value = static_cast<char*>(NPN_MemAlloc(proxiesUTF8.length()));
             memcpy(*value, proxiesUTF8.data(), proxiesUTF8.length());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list