WebKit Bugzilla
Attachment 339763 Details for
Bug 185224
: [Curl] Remove unused SystemProxyWin.cpp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
FIX
185224.diff (text/plain), 6.46 KB, created by
Basuke Suzuki
on 2018-05-07 16:09:51 PDT
(
hide
)
Description:
FIX
Filename:
MIME Type:
Creator:
Basuke Suzuki
Created:
2018-05-07 16:09:51 PDT
Size:
6.46 KB
patch
obsolete
>diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ee8fb7d26db..a10f2fcb904 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-07 Basuke Suzuki <Basuke.Suzuki@sony.com> >+ >+ [Curl] Fix to follow the interface change of ProxySettings. >+ https://bugs.webkit.org/show_bug.cgi?id=185224 >+ >+ Fix the signature change. Also modernize the Windows register value query. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * NetworkProcess/win/SystemProxyWin.cpp: >+ (WindowsSystemProxy::getSystemHttpProxy): >+ (normalizedHost): >+ (buildHttpProxyUrl): >+ (WindowsSystemProxy::setCurlHttpProxy): >+ (WindowsSystemProxy::parseProxyString): >+ (WindowsSystemProxy::readRegistryValue): >+ * NetworkProcess/win/SystemProxyWin.h: >+ > 2018-05-07 Don Olmstead <don.olmstead@sony.com> > > [Win] Add missing methods to WebChromeClient >diff --git a/Source/WebKit/NetworkProcess/win/SystemProxyWin.cpp b/Source/WebKit/NetworkProcess/win/SystemProxyWin.cpp >index d1732ddb4b5..0bd5f49bea0 100644 >--- a/Source/WebKit/NetworkProcess/win/SystemProxyWin.cpp >+++ b/Source/WebKit/NetworkProcess/win/SystemProxyWin.cpp >@@ -27,70 +27,82 @@ > #include "SystemProxyWin.h" > > #include <WebCore/CurlContext.h> >+#include <wtf/text/StringBuilder.h> > >-bool WindowsSystemProxy::getSystemHttpProxy(char* buffer, int bufferLen, int* port) >+std::optional<std::pair<String, unsigned>> WindowsSystemProxy::getSystemHttpProxy() > { >- Vector<TCHAR> tRegBuffer(bufferLen); >- Vector<TCHAR> tHost(bufferLen); >- DWORD type; >- DWORD size; >- HKEY key; >+ const auto InternetSettingPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; >+ const auto ProxyServerName = L"ProxyServer"; > >- LONG ret = RegOpenKeyEx(HKEY_CURRENT_USER, >- L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", >- 0, >- KEY_READ, >- &key); >- if (ret != ERROR_SUCCESS) >- return false; >+ if (auto buffer = readRegistryValue(InternetSettingPath, ProxyServerName)) >+ return parseProxyString(WTFMove(*buffer)); > >- size = bufferLen - 1; >- ret = RegQueryValueEx(key, >- L"ProxyServer", >- nullptr, >- &type, >- (LPBYTE)tRegBuffer.data(), >- &size); >+ return std::nullopt; >+} > >- if (ret != ERROR_SUCCESS) >- return false; >+static String normalizedHost(const String& host) >+{ >+ StringBuilder buffer; > >- if (!parseProxyString(tRegBuffer.data(), tHost.data(), bufferLen, port)) >- return false; >+ buffer.append("http://"); >+ buffer.append(host); > >- wcstombs(buffer, tHost.data(), bufferLen); >- buffer[bufferLen-1] = '\0'; >- return true; >+ WebCore::URL url { WebCore::URL(), buffer.toString() }; >+ return url.host(); > } > >-void WindowsSystemProxy::setCurlHttpProxy(char* proxy, int port) >+static WebCore::URL buildHttpProxyUrl(const String& host, unsigned port) > { >- WebCore::CurlContext::singleton().setProxyInfo(proxy, port); >+ StringBuilder buffer; >+ >+ buffer.append("http://"); >+ buffer.append(normalizedHost(host)); >+ buffer.append(':'); >+ buffer.appendNumber(port); >+ >+ return WebCore::URL { WebCore::ParsedURLString, buffer.toString() }; >+} >+ >+void WindowsSystemProxy::setCurlHttpProxy(const String& host, unsigned port) >+{ >+ WebCore::CurlProxySettings settings(buildHttpProxyUrl(host, port), String()); >+ WebCore::CurlContext::singleton().setProxySettings(settings); > } > > void WindowsSystemProxy::setCurlHttpProxy() > { >- char proxy[ProxyServerNameLength]; >- int port; >- if (getSystemHttpProxy(proxy, ProxyServerNameLength, &port)) >- setCurlHttpProxy(proxy, port); >+ if (auto result = getSystemHttpProxy()) >+ setCurlHttpProxy(result->first, result->second); > } > >-bool WindowsSystemProxy::parseProxyString(const TCHAR* regProxyString, TCHAR* hostString, int hostStringLen, int* port) >+std::optional<std::pair<String, unsigned>> WindowsSystemProxy::parseProxyString(Vector<TCHAR>&& buffer) > { >- const TCHAR* found = wcschr(regProxyString, L':'); >- if (!found) >- return false; >+ unsigned size = buffer.find(L':'); >+ if (size == notFound) >+ return std::nullopt; > >- int len = found - regProxyString; >- if (len >= hostStringLen) >- return false; >+ bool ok; >+ auto port = WTF::charactersToUIntStrict(&buffer[size + 1], buffer.size() - size - 1, &ok); >+ if (!ok) >+ return std::nullopt; > >- wcsncpy(hostString, regProxyString, hostStringLen); >- hostString[len] = L'\0'; >+ return std::make_pair(String { buffer.begin(), size }, port); >+} > >- TCHAR* portStr = const_cast<TCHAR*>(found) + 1; >- *port = _wtoi(portStr); >+std::optional<Vector<TCHAR>> WindowsSystemProxy::readRegistryValue(const TCHAR* path, const TCHAR* valueName) >+{ >+ HKEY key; >+ LONG ret = RegOpenKeyEx(HKEY_CURRENT_USER, path, 0, KEY_READ, &key); >+ if (ret != ERROR_SUCCESS) >+ return std::nullopt; > >- return true; >+ Vector<TCHAR> buffer(ProxyServerNameLength); >+ DWORD size = buffer.size() - 1; >+ DWORD type; >+ ret = RegQueryValueEx(key, valueName, nullptr, &type, reinterpret_cast<LPBYTE>(buffer.begin()), &size); >+ if (ret != ERROR_SUCCESS) >+ return std::nullopt; >+ >+ return WTFMove(buffer); > } >+ >diff --git a/Source/WebKit/NetworkProcess/win/SystemProxyWin.h b/Source/WebKit/NetworkProcess/win/SystemProxyWin.h >index 95609288be6..ec8e6483616 100644 >--- a/Source/WebKit/NetworkProcess/win/SystemProxyWin.h >+++ b/Source/WebKit/NetworkProcess/win/SystemProxyWin.h >@@ -26,17 +26,17 @@ > #pragma once > > #include <windows.h> >+#include <wtf/text/WTFString.h> > > class WindowsSystemProxy { > static const int ProxyServerNameLength = 512; > public: >- static bool getSystemHttpProxy(char* buffer, int bufferLen, int* port); >- static bool getSystemHttpsProxy(char* buffer, int bufferLen, int* port); >- static bool getSystemFtpProxy(char* buffer, int bufferLen, int* port); >+ static std::optional<std::pair<String, unsigned>> getSystemHttpProxy(); > >- static void setCurlHttpProxy(char* proxy, int port); >+ static void setCurlHttpProxy(const String& host, unsigned port); > static void setCurlHttpProxy(); > > private: >- static bool parseProxyString(const TCHAR* regProxyString, TCHAR* hostString, int hostStringLen, int* port); >+ static std::optional<std::pair<String, unsigned>> parseProxyString(Vector<TCHAR>&& proxyString); >+ static std::optional<Vector<TCHAR>> readRegistryValue(const TCHAR* path, const TCHAR* valueName); > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185224
:
339360
|
339763
|
340680