diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/qtwebengine.gypi | 1 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 31 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.h | 2 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 87 |
4 files changed, 78 insertions, 43 deletions
diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index 4b627a626..cca2bd73f 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -23,6 +23,7 @@ '<(chromium_src_dir)/media/media.gyp:media', '<(chromium_src_dir)/net/net.gyp:net', '<(chromium_src_dir)/net/net.gyp:net_resources', + '<(chromium_src_dir)/net/net.gyp:net_with_v8', '<(chromium_src_dir)/skia/skia.gyp:skia', '<(chromium_src_dir)/third_party/WebKit/Source/web/web.gyp:blink_web', '<(chromium_src_dir)/ui/base/ui_base.gyp:ui_base', diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 4f893175a..10923e4cb 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -36,12 +36,14 @@ #include "url_request_context_getter_qt.h" +#include "base/command_line.h" #include "base/strings/string_util.h" #include "base/threading/worker_pool.h" #include "base/threading/sequenced_worker_pool.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_crypto_delegate.h" #include "content/public/browser/cookie_store_factory.h" +#include "content/public/common/content_switches.h" #include "net/base/cache_type.h" #include "net/cert/cert_verifier.h" #include "net/dns/host_resolver.h" @@ -50,7 +52,11 @@ #include "net/http/http_cache.h" #include "net/http/http_network_session.h" #include "net/http/http_server_properties_impl.h" +#include "net/proxy/dhcp_proxy_script_fetcher_factory.h" +#include "net/proxy/proxy_script_fetcher_impl.h" #include "net/proxy/proxy_service.h" +#include "net/proxy/proxy_service_v8.h" +#include "net/proxy/proxy_resolver_v8.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/default_channel_id_store.h" #include "net/ssl/ssl_config_service_defaults.h" @@ -149,11 +155,32 @@ void URLRequestContextGetterQt::generateStorage() base::WorkerPool::GetTaskRunner(true))); m_storage->set_cert_verifier(net::CertVerifier::CreateDefault()); - m_storage->set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver(proxyConfigService, 0, NULL)); + + scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); + + // The System Proxy Resolver has issues on Windows with unconfigured network cards, + // which is why we want to use the v8 one. However, V8ProxyResolver doesn't work reliably with + // --single-process (See also the warnings in net/proxy/proxy_resolver_v8.h). + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kSingleProcess)) { + m_storage->set_proxy_service( + net::ProxyService::CreateUsingSystemProxyResolver(proxyConfigService, 0, NULL)); + } else { + if (!m_dhcpProxyScriptFetcherFactory) + m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory); + + net::ProxyResolverV8::EnsureIsolateCreated(); + m_storage->set_proxy_service(net::CreateProxyServiceUsingV8ProxyResolver( + proxyConfigService, + new net::ProxyScriptFetcherImpl(m_urlRequestContext.get()), + m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()), + host_resolver.get(), + NULL /* NetLog */, + m_networkDelegate.get())); + } m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); m_storage->set_transport_security_state(new net::TransportSecurityState()); - scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); m_storage->set_http_server_properties(scoped_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl)); diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index d08836714..38cfd7957 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -47,6 +47,7 @@ #include "content/public/common/url_constants.h" #include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_job_factory_impl.h" +#include "net/proxy/dhcp_proxy_script_fetcher_factory.h" #include "qglobal.h" #include <qatomic.h> @@ -95,6 +96,7 @@ private: scoped_ptr<net::NetworkDelegate> m_networkDelegate; scoped_ptr<net::URLRequestContextStorage> m_storage; scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory; + scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory; }; } // namespace QtWebEngineCore diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 4710b0266..980e9a39a 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -112,58 +112,73 @@ static QString getResourcesPath(CFBundleRef frameworkBundle) QString subProcessPath() { - static bool initialized = false; + static QString processPath; + if (processPath.isEmpty()) { #if defined(OS_WIN) - static QString processBinary (QLatin1String(QTWEBENGINEPROCESS_NAME) % QLatin1String(".exe")); + const QString processBinary = QLatin1String(QTWEBENGINEPROCESS_NAME) % QLatin1String(".exe"); #else - static QString processBinary (QLatin1String(QTWEBENGINEPROCESS_NAME)); + const QString processBinary = QLatin1String(QTWEBENGINEPROCESS_NAME); #endif + + QStringList candidatePaths; + const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH"); + if (!fromEnv.isEmpty()) { + // Only search in QTWEBENGINEPROCESS_PATH if set + candidatePaths << QString::fromLocal8Bit(fromEnv); + } else { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - static QString processPath (getPath(frameworkBundle()) - % QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME)); + candidatePaths << getPath(frameworkBundle()) + % QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME); #else - static QString processPath (QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath) - % QLatin1Char('/') % processBinary); + candidatePaths << QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath) + % QLatin1Char('/') % processBinary; + candidatePaths << QCoreApplication::applicationDirPath() + % QLatin1Char('/') % processBinary; #endif - if (!initialized) { - // Allow overriding at runtime for the time being. - const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH"); - if (!fromEnv.isEmpty()) - processPath = QString::fromLatin1(fromEnv); - if (!QFileInfo(processPath).exists()) { - qWarning("QtWebEngineProcess not found at location %s. Trying fallback path...", qPrintable(processPath)); - processPath = QCoreApplication::applicationDirPath() % QLatin1Char('/') % processBinary; } - if (!QFileInfo(processPath).exists()) - qFatal("QtWebEngineProcess not found at location %s. Try setting the QTWEBENGINEPROCESS_PATH environment variable.", qPrintable(processPath)); - initialized = true; + + Q_FOREACH (const QString &candidate, candidatePaths) { + if (QFileInfo(candidate).exists()) { + processPath = candidate; + break; + } + } + if (processPath.isEmpty()) + qFatal("Could not find %s", processBinary.toUtf8().constData()); + } + return processPath; } QString pluginsPath() { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - return getPath(frameworkBundle()) % QLatin1String("/Libraries"); + static QString pluginsPath = getPath(frameworkBundle()) % QLatin1String("/Libraries"); #else static bool initialized = false; - static QString potentialPluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath) % QDir::separator() % QLatin1String("qtwebengine"); + static QString pluginsPath; if (!initialized) { initialized = true; - if (!QFileInfo::exists(potentialPluginsPath)) { - qWarning("Installed Qt plugins directory not found at location %s. Trying application directory...", qPrintable(potentialPluginsPath)); - potentialPluginsPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine"); + + const QStringList directories = QCoreApplication::libraryPaths(); + Q_FOREACH (const QString &dir, directories) { + const QString candidate = dir % "/" % QLatin1String("qtwebengine"); + if (QFileInfo(candidate).exists()) { + pluginsPath = candidate; + break; + } } - if (!QFileInfo::exists(potentialPluginsPath)) { - qWarning("Qt WebEngine Plugins directory not found at location %s. Trying fallback directory... Plugins as for example video codecs MAY NOT work.", qPrintable(potentialPluginsPath)); - potentialPluginsPath = fallbackDir(); + + if (pluginsPath.isEmpty()) { + qWarning("Qt WebEngine Plugins directory not found. Trying fallback directory... Plugins as for example video codecs MAY NOT work."); + pluginsPath = fallbackDir(); } } - - return potentialPluginsPath; #endif + return pluginsPath; } QString localesPath() @@ -214,26 +229,16 @@ QString libraryDataPath() } } // namespace -static QString pakResourcesDir() -{ -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - static QString dir = getResourcesPath(frameworkBundle()); -#else - static QString dir = QLibraryInfo::location(QLibraryInfo::DataPath); -#endif - return dir; -} - base::FilePath WebEngineLibraryInfo::getPath(int key) { QString directory; switch (key) { case QT_RESOURCES_PAK: - return toFilePath(pakResourcesDir() % QLatin1String("/qtwebengine_resources.pak")); + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources.pak")); case QT_RESOURCES_100P_PAK: - return toFilePath(pakResourcesDir() % QLatin1String("/qtwebengine_resources_100p.pak")); + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_100p.pak")); case QT_RESOURCES_200P_PAK: - return toFilePath(pakResourcesDir() % QLatin1String("/qtwebengine_resources_200p.pak")); + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_200p.pak")); case base::FILE_EXE: case content::CHILD_PROCESS_EXE: return toFilePath(subProcessPath()); |