[GTK] Provide API to set proxy settings
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 09:03:25 +0000 (09:03 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 09:03:25 +0000 (09:03 +0000)
commit87963ed46415f8077e7a35e43b6b1d3352ca4c6d
treea7ddb0e0d7d41d604f72a59110f79236fbf9ff58
parentf7f22aac806685511b3a152acb22ff1c5d9ab2fa
[GTK] Provide API to set proxy settings
https://bugs.webkit.org/show_bug.cgi?id=128674

Reviewed by Michael Catanzaro.

Source/WebCore:

Add SoupNetworkProxySettings struct to store proxy settings.

* platform/network/soup/SoupNetworkProxySettings.h: Added.
(WebCore::SoupNetworkProxySettings::SoupNetworkProxySettings):
(WebCore::SoupNetworkProxySettings::operator=):
(WebCore::SoupNetworkProxySettings::isEmpty):
* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::SoupNetworkSession::SoupNetworkSession): Setup the proxy if user provided proxy settings.
(WebCore::SoupNetworkSession::setupProxy): Set the proxy-resolver property of the SoupSession according to the
global SoupNetworkProxySettings.
(WebCore::SoupNetworkSession::setProxySettingsFromEnvironment): Update the global SoupNetworkProxySettings with
values from environment.
(WebCore::SoupNetworkSession::setProxySettings): Set the global SoupNetworkProxySettings.
* platform/network/soup/SoupNetworkSession.h:

Source/WebKit2:

Add new method webkit_web_context_set_network_proxy_settings() that allows to set proxy settings in a
WebKitWebContext. It receives an enum WebKitNetworkProxyMode with modes Default, NoProxy and Custom, and an
optional WebKitNetworkProxySettings that is used when mode is Custom. WebKitNetworkProxySettings is a simple
boxed type that user can create to set proxy settins with a similar API to GSimpleProxyResolver.

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in: Add SetNetworkProxySettings message.
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode): Encode proxy settings.
(WebKit::NetworkProcessCreationParameters::decode): Decode proxy settings.
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/efl/NetworkProcessMainEfl.cpp: Use SoupNetworkSession::setProxySettingsFromEnvironment().
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformInitializeNetworkProcess): Set proxy settings if provided by the user.
(WebKit::NetworkProcess::setNetworkProxySettings): Set global proxy settings and setup the proxy for all
existing contexts.
* PlatformGTK.cmake: Add new files to compilation.
* Shared/WebCoreArgumentCoders.h:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode): Encode proxy settings.
(WebKit::WebProcessCreationParameters::decode): Decode proxy settings.
* Shared/WebProcessCreationParameters.h:
* Shared/soup/WebCoreArgumentCodersSoup.cpp:
(IPC::ArgumentCoder<SoupNetworkProxySettings>::encode): Add encoder implementation for SoupNetworkProxySettings.
(IPC::ArgumentCoder<SoupNetworkProxySettings>::decode): add decoder implementation for SoupNetworkProxySettings.
* UIProcess/API/gtk/WebKitNetworkProxySettings.cpp: Added.
(_WebKitNetworkProxySettings::_WebKitNetworkProxySettings):
(webkitNetworkProxySettingsGetNetworkProxySettings):
(webkit_network_proxy_settings_new): Create a new WebKitNetworkProxySettings with optional default proxy uri and
ignore hosts list.
(webkit_network_proxy_settings_copy):
(webkit_network_proxy_settings_free):
(webkit_network_proxy_settings_add_proxy): Add a proxy uri for a given uri scheme.
* UIProcess/API/gtk/WebKitNetworkProxySettings.h: Added.
* UIProcess/API/gtk/WebKitNetworkProxySettingsPrivate.h: Added.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_set_network_proxy_settings): Set proxy settings.
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols to the documentation.
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for WebKitNetworkProxySettings.
* UIProcess/API/gtk/webkit2.h: Include WebKitNetworkProxySettings.h.
* UIProcess/WebProcessPool.h: Add m_networkProxySettings and a setter for soup.
* UIProcess/efl/WebProcessPoolEfl.cpp:
(WebKit::WebProcessPool::platformInitializeWebProcess): Set m_networkProxySettings to parameters.
* UIProcess/gtk/WebProcessPoolGtk.cpp:
(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::WebProcessPool::platformInitializeNetworkProcess): Ditto.
(WebKit::WebProcessPool::setNetworkProxySettings): Update m_networkProxySettings and notify all processes.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in: Add SetNetworkProxySettings message.
* WebProcess/efl/WebProcessMainEfl.cpp: Use SoupNetworkSession::setProxySettingsFromEnvironment().
* WebProcess/soup/WebProcessSoup.cpp:
(WebKit::WebProcess::platformSetCacheModel): Remove comment that is no longer true.
(WebKit::WebProcess::platformInitializeWebProcess): Set proxy settings if provided by the user.
(WebKit::WebProcess::setNetworkProxySettings): Set global proxy settings and setup the proxy for all
existing contexts.

Tools:

Add tests for new proxy settings API.

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
(serverCallback):
(ProxyTest::ProxyTest):
(ProxyTest::~ProxyTest):
(ProxyTest::loadURIAndGetMainResourceData):
(ProxyTest::proxyServerPortAsString):
(testWebContextProxySettings):
(beforeAll):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/soup/SoupNetworkProxySettings.h [new file with mode: 0644]
Source/WebCore/platform/network/soup/SoupNetworkSession.cpp
Source/WebCore/platform/network/soup/SoupNetworkSession.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h
Source/WebKit2/NetworkProcess/efl/NetworkProcessMainEfl.cpp
Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitNetworkProxySettings.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitNetworkProxySettings.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitNetworkProxySettingsPrivate.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit2/UIProcess/API/gtk/webkit2.h
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/UIProcess/efl/WebProcessPoolEfl.cpp
Source/WebKit2/UIProcess/gtk/WebProcessPoolGtk.cpp
Source/WebKit2/UIProcess/soup/WebProcessPoolSoup.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in
Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp
Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp