summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/pref_proxy_config_tracker_impl.cc5
-rw-r--r--chrome/browser/net/proxy_service_factory.cc8
-rw-r--r--net/net.gyp12
-rw-r--r--net/proxy/proxy_config_service_ios.cc113
-rw-r--r--net/proxy/proxy_config_service_ios.h34
-rw-r--r--net/proxy/proxy_resolver_mac.cc7
-rw-r--r--net/proxy/proxy_service.cc5
7 files changed, 180 insertions, 4 deletions
diff --git a/chrome/browser/net/pref_proxy_config_tracker_impl.cc b/chrome/browser/net/pref_proxy_config_tracker_impl.cc
index 6b4c30f..47b1078 100644
--- a/chrome/browser/net/pref_proxy_config_tracker_impl.cc
+++ b/chrome/browser/net/pref_proxy_config_tracker_impl.cc
@@ -314,6 +314,10 @@ void PrefProxyConfigTrackerImpl::Observe(
ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
net::ProxyConfig* config) {
+#if defined(OS_IOS)
+ return ProxyPrefs::CONFIG_UNSET;
+#else
+
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Clear the configuration and source.
@@ -342,4 +346,5 @@ ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
}
return config_state;
+#endif // defined(OS_IOS)
}
diff --git a/chrome/browser/net/proxy_service_factory.cc b/chrome/browser/net/proxy_service_factory.cc
index 24f46eb..6a60a2f 100644
--- a/chrome/browser/net/proxy_service_factory.cc
+++ b/chrome/browser/net/proxy_service_factory.cc
@@ -78,6 +78,9 @@ net::ProxyService* ProxyServiceFactory::CreateProxyService(
const CommandLine& command_line) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+#if defined(OS_IOS)
+ bool use_v8 = false;
+#else
bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver);
if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) {
// See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h
@@ -85,6 +88,7 @@ net::ProxyService* ProxyServiceFactory::CreateProxyService(
LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode.";
use_v8 = false; // Fallback to non-v8 implementation.
}
+#endif // defined(OS_IOS)
size_t num_pac_threads = 0u; // Use default number of threads.
@@ -104,6 +108,9 @@ net::ProxyService* ProxyServiceFactory::CreateProxyService(
net::ProxyService* proxy_service;
if (use_v8) {
+#if defined(OS_IOS)
+ NOTREACHED();
+#else
net::DhcpProxyScriptFetcherFactory dhcp_factory;
if (command_line.HasSwitch(switches::kDisableDhcpWpad)) {
dhcp_factory.set_enabled(false);
@@ -117,6 +124,7 @@ net::ProxyService* ProxyServiceFactory::CreateProxyService(
context->host_resolver(),
net_log,
context->network_delegate());
+#endif // defined(OS_IOS)
} else {
proxy_service = net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service,
diff --git a/net/net.gyp b/net/net.gyp
index e11caf8..90b5e8f 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -569,6 +569,8 @@
'proxy/proxy_config_service_android.h',
'proxy/proxy_config_service_fixed.cc',
'proxy/proxy_config_service_fixed.h',
+ 'proxy/proxy_config_service_ios.cc',
+ 'proxy/proxy_config_service_ios.h',
'proxy/proxy_config_service_linux.cc',
'proxy/proxy_config_service_linux.h',
'proxy/proxy_config_service_mac.cc',
@@ -1090,6 +1092,11 @@
['include', '^http/http_util_icu\\.cc$'],
['include', '^http/http_version\\.h$'],
['include', '^url_request/url_request_job_manager\\.'],
+ ['include', '^proxy/dhcp_proxy_script_fetcher\\.'],
+ ['include', '^proxy/polling_proxy_config_service\\.'],
+ ['include', '^proxy/proxy_config\\.'],
+ ['include', '^proxy/proxy_config_service_ios\\.'],
+ ['include', '^proxy/proxy_service\\.'],
],
},
],
@@ -1132,6 +1139,7 @@
['include', 'base/network_change_notifier_mac\\.cc$'],
['include', 'base/network_config_watcher_mac\\.cc$'],
['include', 'base/platform_mime_util_mac\\.mm$'],
+ ['include', 'proxy/proxy_resolver_mac\\.cc$'],
],
}],
],
@@ -1529,9 +1537,6 @@
'dependencies': [
'../testing/gtest.gyp:gtest_main',
],
- 'dependencies!': [
- 'net_test_support',
- ],
'sources/': [
['exclude', '.*'],
['include', '^base/dns_util_unittest\\.cc$'],
@@ -1543,6 +1548,7 @@
['include', '^http/http_byte_range_unittest\\.cc$'],
['include', '^http/http_content_disposition_unittest\\.cc$'],
['include', '^http/http_util_unittest\\.cc$'],
+ ['include', '^proxy/proxy_config_service_common_unittest\\.cc$'],
],
}],
[ 'OS == "linux"', {
diff --git a/net/proxy/proxy_config_service_ios.cc b/net/proxy/proxy_config_service_ios.cc
new file mode 100644
index 0000000..050505e
--- /dev/null
+++ b/net/proxy/proxy_config_service_ios.cc
@@ -0,0 +1,113 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/proxy/proxy_config_service_ios.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CFNetwork/CFProxySupport.h>
+
+#include "base/message_loop.h"
+#include "base/mac/foundation_util.h"
+#include "base/mac/scoped_cftyperef.h"
+#include "base/sys_string_conversions.h"
+#include "net/proxy/proxy_config.h"
+
+namespace net {
+
+namespace {
+
+const int kPollIntervalSec = 10;
+
+// Utility function to pull out a boolean value from a dictionary and return it,
+// returning a default value if the key is not present.
+bool GetBoolFromDictionary(CFDictionaryRef dict,
+ CFStringRef key,
+ bool default_value) {
+ CFNumberRef number =
+ base::mac::GetValueFromDictionary<CFNumberRef>(dict, key);
+ if (!number)
+ return default_value;
+
+ int int_value;
+ if (CFNumberGetValue(number, kCFNumberIntType, &int_value))
+ return int_value;
+ else
+ return default_value;
+}
+
+void GetCurrentProxyConfig(ProxyConfig* config) {
+ base::mac::ScopedCFTypeRef<CFDictionaryRef> config_dict(
+ CFNetworkCopySystemProxySettings());
+ DCHECK(config_dict);
+
+ // Auto-detect is not supported.
+ // The kCFNetworkProxiesProxyAutoDiscoveryEnable key is not available on iOS.
+
+ // PAC file
+
+ if (GetBoolFromDictionary(config_dict.get(),
+ kCFNetworkProxiesProxyAutoConfigEnable,
+ false)) {
+ CFStringRef pac_url_ref = base::mac::GetValueFromDictionary<CFStringRef>(
+ config_dict.get(), kCFNetworkProxiesProxyAutoConfigURLString);
+ if (pac_url_ref)
+ config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref)));
+ }
+
+ // Proxies (for now http).
+
+ // The following keys are not available on iOS:
+ // kCFNetworkProxiesFTPEnable
+ // kCFNetworkProxiesFTPProxy
+ // kCFNetworkProxiesFTPPort
+ // kCFNetworkProxiesHTTPSEnable
+ // kCFNetworkProxiesHTTPSProxy
+ // kCFNetworkProxiesHTTPSPort
+ // kCFNetworkProxiesSOCKSEnable
+ // kCFNetworkProxiesSOCKSProxy
+ // kCFNetworkProxiesSOCKSPort
+ if (GetBoolFromDictionary(config_dict.get(),
+ kCFNetworkProxiesHTTPEnable,
+ false)) {
+ ProxyServer proxy_server =
+ ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP,
+ config_dict.get(),
+ kCFNetworkProxiesHTTPProxy,
+ kCFNetworkProxiesHTTPPort);
+ if (proxy_server.is_valid()) {
+ config->proxy_rules().type =
+ ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
+ config->proxy_rules().proxy_for_http = proxy_server;
+ // Desktop Safari applies the HTTP proxy to http:// URLs only, but
+ // Mobile Safari applies the HTTP proxy to https:// URLs as well.
+ config->proxy_rules().proxy_for_https = proxy_server;
+ }
+ }
+
+ // Proxy bypass list is not supported.
+ // The kCFNetworkProxiesExceptionsList key is not available on iOS.
+
+ // Proxy bypass boolean is not supported.
+ // The kCFNetworkProxiesExcludeSimpleHostnames key is not available on iOS.
+
+ // Source
+ config->set_source(PROXY_CONFIG_SOURCE_SYSTEM);
+}
+
+} // namespace
+
+ProxyConfigServiceIOS::ProxyConfigServiceIOS(
+ base::SingleThreadTaskRunner* io_thread_task_runner)
+ : PollingProxyConfigService(
+ base::TimeDelta::FromSeconds(kPollIntervalSec),
+ GetCurrentProxyConfig),
+ io_thread_task_runner_(io_thread_task_runner) {
+ DCHECK(io_thread_task_runner_);
+}
+
+ProxyConfigServiceIOS::~ProxyConfigServiceIOS() {
+ DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
+}
+
+} // namespace net
diff --git a/net/proxy/proxy_config_service_ios.h b/net/proxy/proxy_config_service_ios.h
new file mode 100644
index 0000000..fff917a
--- /dev/null
+++ b/net/proxy/proxy_config_service_ios.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_PROXY_PROXY_CONFIG_SERVICE_IOS_H_
+#define NET_PROXY_PROXY_CONFIG_SERVICE_IOS_H_
+
+#include "net/proxy/polling_proxy_config_service.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace net {
+
+class ProxyConfigServiceIOS : public PollingProxyConfigService {
+ public:
+ // Constructs a ProxyConfigService that watches the iOS system proxy settings.
+ // This instance is expected to be operated and deleted on the IO thread
+ // (however it may be constructed from a different thread).
+ explicit ProxyConfigServiceIOS(
+ base::SingleThreadTaskRunner* io_thread_task_runner);
+ virtual ~ProxyConfigServiceIOS();
+
+ private:
+ // The thread that we expect to be operated on.
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceIOS);
+};
+
+} // namespace net
+
+#endif // NET_PROXY_PROXY_CONFIG_SERVICE_IOS_H_
diff --git a/net/proxy/proxy_resolver_mac.cc b/net/proxy/proxy_resolver_mac.cc
index b3e2f7e..a5a05af 100644
--- a/net/proxy/proxy_resolver_mac.cc
+++ b/net/proxy/proxy_resolver_mac.cc
@@ -5,7 +5,6 @@
#include "net/proxy/proxy_resolver_mac.h"
#include <CoreFoundation/CoreFoundation.h>
-#include <CoreServices/CoreServices.h>
#include "base/logging.h"
#include "base/mac/foundation_util.h"
@@ -16,6 +15,12 @@
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_server.h"
+#if defined(OS_IOS)
+#include <CFNetwork/CFProxySupport.h>
+#else
+#include <CoreServices/CoreServices.h>
+#endif
+
namespace {
// Utility function to map a CFProxyType to a ProxyServer::Scheme.
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 248c64c..98cf46b 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -34,6 +34,9 @@
#if defined(OS_WIN)
#include "net/proxy/proxy_config_service_win.h"
#include "net/proxy/proxy_resolver_winhttp.h"
+#elif defined(OS_IOS)
+#include "net/proxy/proxy_config_service_ios.h"
+#include "net/proxy/proxy_resolver_mac.h"
#elif defined(OS_MACOSX)
#include "net/proxy/proxy_config_service_mac.h"
#include "net/proxy/proxy_resolver_mac.h"
@@ -1319,6 +1322,8 @@ ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
MessageLoop* file_loop) {
#if defined(OS_WIN)
return new ProxyConfigServiceWin();
+#elif defined(OS_IOS)
+ return new ProxyConfigServiceIOS(io_thread_task_runner);
#elif defined(OS_MACOSX)
return new ProxyConfigServiceMac(io_thread_task_runner);
#elif defined(OS_CHROMEOS)