Move ProxyServiceFactory to components/proxy_service/ios.

ProxyServiceFactory does not require any code from ios/chrome and moving
it will allow for it’s reuse by ios/web_view.

BUG=none

Review-Url: https://codereview.chromium.org/2888583002
Cr-Commit-Position: refs/heads/master@{#473417}
diff --git a/components/proxy_config/ios/BUILD.gn b/components/proxy_config/ios/BUILD.gn
new file mode 100644
index 0000000..aafa2d3e8
--- /dev/null
+++ b/components/proxy_config/ios/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2017 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.
+
+component("ios") {
+  configs += [ "//build/config/compiler:enable_arc" ]
+
+  deps = [
+    "//base",
+    "//components/proxy_config",
+    "//ios/web",
+    "//net",
+  ]
+
+  sources = [
+    "proxy_service_factory.cc",
+    "proxy_service_factory.h",
+  ]
+}
diff --git a/components/proxy_config/ios/DEPS b/components/proxy_config/ios/DEPS
new file mode 100644
index 0000000..c11101cf
--- /dev/null
+++ b/components/proxy_config/ios/DEPS
@@ -0,0 +1,5 @@
+include_rules = [
+  "+ios/public/provider/web",
+  "+ios/web/public",
+  "+net/proxy"
+]
diff --git a/ios/chrome/browser/net/proxy_service_factory.cc b/components/proxy_config/ios/proxy_service_factory.cc
similarity index 95%
rename from ios/chrome/browser/net/proxy_service_factory.cc
rename to components/proxy_config/ios/proxy_service_factory.cc
index 2d49db1..600191a 100644
--- a/ios/chrome/browser/net/proxy_service_factory.cc
+++ b/components/proxy_config/ios/proxy_service_factory.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "ios/chrome/browser/net/proxy_service_factory.h"
+#include "components/proxy_config/ios/proxy_service_factory.h"
 
 #include <utility>
 
@@ -12,8 +12,6 @@
 #include "net/proxy/proxy_config_service.h"
 #include "net/proxy/proxy_service.h"
 
-namespace ios {
-
 // static
 std::unique_ptr<net::ProxyConfigService>
 ProxyServiceFactory::CreateProxyConfigService(PrefProxyConfigTracker* tracker) {
@@ -57,5 +55,3 @@
   proxy_service->set_quick_check_enabled(quick_check_enabled);
   return proxy_service;
 }
-
-}  // namespace ios
diff --git a/ios/chrome/browser/net/proxy_service_factory.h b/components/proxy_config/ios/proxy_service_factory.h
similarity index 83%
rename from ios/chrome/browser/net/proxy_service_factory.h
rename to components/proxy_config/ios/proxy_service_factory.h
index a7cefa1..dfa00ca5 100644
--- a/ios/chrome/browser/net/proxy_service_factory.h
+++ b/components/proxy_config/ios/proxy_service_factory.h
@@ -2,12 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef IOS_CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
-#define IOS_CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
+#ifndef COMPONENTS_PROXY_CONFIG_IOS_PROXY_SERVICE_FACTORY_H_
+#define COMPONENTS_PROXY_CONFIG_IOS_PROXY_SERVICE_FACTORY_H_
 
 #include <memory>
 
 #include "base/macros.h"
+#include "components/proxy_config/proxy_config_export.h"
 
 class PrefProxyConfigTracker;
 class PrefService;
@@ -20,9 +21,7 @@
 class URLRequestContext;
 }
 
-namespace ios {
-
-class ProxyServiceFactory {
+class PROXY_CONFIG_EXPORT ProxyServiceFactory {
  public:
   // Creates a ProxyConfigService that delivers the system preferences.
   static std::unique_ptr<net::ProxyConfigService> CreateProxyConfigService(
@@ -50,6 +49,4 @@
   DISALLOW_COPY_AND_ASSIGN(ProxyServiceFactory);
 };
 
-}  // namespace ios
-
-#endif  // IOS_CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
+#endif  // COMPONENTS_PROXY_CONFIG_IOS_PROXY_SERVICE_FACTORY_H_
diff --git a/ios/chrome/browser/BUILD.gn b/ios/chrome/browser/BUILD.gn
index 7779b47..6d12808 100644
--- a/ios/chrome/browser/BUILD.gn
+++ b/ios/chrome/browser/BUILD.gn
@@ -97,6 +97,7 @@
     "//components/pref_registry",
     "//components/prefs",
     "//components/proxy_config",
+    "//components/proxy_config/ios",
     "//components/reading_list/ios",
     "//components/search_engines",
     "//components/signin/core/browser",
diff --git a/ios/chrome/browser/browser_state/BUILD.gn b/ios/chrome/browser/browser_state/BUILD.gn
index 359a3ad..cfee3e0 100644
--- a/ios/chrome/browser/browser_state/BUILD.gn
+++ b/ios/chrome/browser/browser_state/BUILD.gn
@@ -69,6 +69,7 @@
     "//components/pref_registry",
     "//components/prefs",
     "//components/proxy_config",
+    "//components/proxy_config/ios",
     "//components/signin/core/browser",
     "//components/signin/core/common",
     "//components/sync",
diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_impl.cc b/ios/chrome/browser/browser_state/chrome_browser_state_impl.cc
index 97bdec2..b13131e 100644
--- a/ios/chrome/browser/browser_state/chrome_browser_state_impl.cc
+++ b/ios/chrome/browser/browser_state/chrome_browser_state_impl.cc
@@ -16,6 +16,7 @@
 #include "components/pref_registry/pref_registry_syncable.h"
 #include "components/prefs/json_pref_store.h"
 #include "components/prefs/pref_service.h"
+#include "components/proxy_config/ios/proxy_service_factory.h"
 #include "components/proxy_config/pref_proxy_config_tracker.h"
 #include "components/sync_preferences/pref_service_syncable.h"
 #include "components/user_prefs/user_prefs.h"
@@ -27,7 +28,6 @@
 #include "ios/chrome/browser/chrome_paths_internal.h"
 #include "ios/chrome/browser/file_metadata_util.h"
 #include "ios/chrome/browser/net/ios_chrome_url_request_context_getter.h"
-#include "ios/chrome/browser/net/proxy_service_factory.h"
 #include "ios/chrome/browser/pref_names.h"
 #include "ios/chrome/browser/prefs/browser_prefs.h"
 #include "ios/chrome/browser/prefs/ios_chrome_pref_service_factory.h"
@@ -244,7 +244,7 @@
 PrefProxyConfigTracker* ChromeBrowserStateImpl::GetProxyConfigTracker() {
   if (!pref_proxy_config_tracker_) {
     pref_proxy_config_tracker_ =
-        ios::ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
+        ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
             GetPrefs(), GetApplicationContext()->GetLocalState());
   }
   return pref_proxy_config_tracker_.get();
diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc
index 27c20c15..16fb60e0 100644
--- a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc
+++ b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc
@@ -32,6 +32,7 @@
 #include "components/metrics/metrics_pref_names.h"
 #include "components/net_log/chrome_net_log.h"
 #include "components/prefs/pref_service.h"
+#include "components/proxy_config/ios/proxy_service_factory.h"
 #include "components/signin/core/common/signin_pref_names.h"
 #include "components/sync/base/pref_names.h"
 #include "ios/chrome/browser/application_context.h"
@@ -43,7 +44,6 @@
 #include "ios/chrome/browser/net/ios_chrome_http_user_agent_settings.h"
 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h"
 #include "ios/chrome/browser/net/ios_chrome_url_request_context_getter.h"
-#include "ios/chrome/browser/net/proxy_service_factory.h"
 #include "ios/web/public/web_thread.h"
 #include "net/cert/cert_verifier.h"
 #include "net/cert/multi_log_ct_verifier.h"
@@ -100,9 +100,8 @@
       ios::HostContentSettingsMapFactory::GetForBrowserState(browser_state);
   params->ssl_config_service = browser_state->GetSSLConfigService();
 
-  params->proxy_config_service =
-      ios::ProxyServiceFactory::CreateProxyConfigService(
-          browser_state->GetProxyConfigTracker());
+  params->proxy_config_service = ProxyServiceFactory::CreateProxyConfigService(
+      browser_state->GetProxyConfigTracker());
 
   params->browser_state = browser_state;
   profile_params_.reset(params.release());
@@ -352,7 +351,7 @@
 
   // NOTE: Proxy service uses the default io thread network delegate, not the
   // delegate just created.
-  proxy_service_ = ios::ProxyServiceFactory::CreateProxyService(
+  proxy_service_ = ProxyServiceFactory::CreateProxyService(
       io_thread->net_log(), nullptr,
       io_thread_globals->system_network_delegate.get(),
       std::move(profile_params_->proxy_config_service),
diff --git a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_impl.cc b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_impl.cc
index a3ec449..e9e9dc5 100644
--- a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_impl.cc
+++ b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_impl.cc
@@ -6,12 +6,12 @@
 
 #include "base/logging.h"
 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
+#include "components/proxy_config/ios/proxy_service_factory.h"
 #include "components/proxy_config/pref_proxy_config_tracker.h"
 #include "components/sync_preferences/pref_service_syncable.h"
 #include "components/user_prefs/user_prefs.h"
 #include "ios/chrome/browser/application_context.h"
 #include "ios/chrome/browser/net/ios_chrome_url_request_context_getter.h"
-#include "ios/chrome/browser/net/proxy_service_factory.h"
 #include "ios/web/public/web_thread.h"
 
 OffTheRecordChromeBrowserStateImpl::OffTheRecordChromeBrowserStateImpl(
@@ -78,7 +78,7 @@
 OffTheRecordChromeBrowserStateImpl::GetProxyConfigTracker() {
   if (!pref_proxy_config_tracker_) {
     pref_proxy_config_tracker_ =
-        ios::ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
+        ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
             GetPrefs(), GetApplicationContext()->GetLocalState());
   }
   return pref_proxy_config_tracker_.get();
diff --git a/ios/chrome/browser/ios_chrome_io_thread.mm b/ios/chrome/browser/ios_chrome_io_thread.mm
index 9e5e73b..9508c67 100644
--- a/ios/chrome/browser/ios_chrome_io_thread.mm
+++ b/ios/chrome/browser/ios_chrome_io_thread.mm
@@ -31,13 +31,13 @@
 #include "components/net_log/chrome_net_log.h"
 #include "components/network_session_configurator/network_session_configurator.h"
 #include "components/prefs/pref_service.h"
+#include "components/proxy_config/ios/proxy_service_factory.h"
 #include "components/proxy_config/pref_proxy_config_tracker.h"
 #include "components/variations/variations_associated_data.h"
 #include "components/version_info/version_info.h"
 #include "ios/chrome/browser/chrome_switches.h"
 #include "ios/chrome/browser/net/cookie_util.h"
 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h"
-#include "ios/chrome/browser/net/proxy_service_factory.h"
 #include "ios/chrome/common/channel_info.h"
 #include "ios/web/public/user_agent.h"
 #include "ios/web/public/web_client.h"
@@ -278,7 +278,7 @@
       creation_time_(base::TimeTicks::Now()),
       weak_factory_(this) {
   pref_proxy_config_tracker_ =
-      ios::ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
+      ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
           local_state);
   IOSChromeNetworkDelegate::InitializePrefsOnUIThread(nullptr, local_state);
   ssl_config_service_manager_.reset(
@@ -499,9 +499,8 @@
   // If we're in unit_tests, IOSChromeIOThread may not be run.
   if (!web::WebThread::IsMessageLoopValid(web::WebThread::IO))
     return;
-  system_proxy_config_service_ =
-      ios::ProxyServiceFactory::CreateProxyConfigService(
-          pref_proxy_config_tracker_.get());
+  system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService(
+      pref_proxy_config_tracker_.get());
 
   system_url_request_context_getter_ = new SystemURLRequestContextGetter(this);
   // Safe to post an unretained this pointer, since IOSChromeIOThread is
@@ -517,7 +516,7 @@
   DCHECK(!globals_->system_proxy_service.get());
   DCHECK(system_proxy_config_service_.get());
 
-  globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService(
+  globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService(
       net_log_, nullptr, globals_->system_network_delegate.get(),
       std::move(system_proxy_config_service_), true /* quick_check_enabled */);
 
diff --git a/ios/chrome/browser/net/BUILD.gn b/ios/chrome/browser/net/BUILD.gn
index 1a696d70..94b7fe0 100644
--- a/ios/chrome/browser/net/BUILD.gn
+++ b/ios/chrome/browser/net/BUILD.gn
@@ -21,8 +21,6 @@
     "ios_chrome_network_delegate.h",
     "ios_chrome_url_request_context_getter.cc",
     "ios_chrome_url_request_context_getter.h",
-    "proxy_service_factory.cc",
-    "proxy_service_factory.h",
     "retryable_url_fetcher.h",
     "retryable_url_fetcher.mm",
   ]
@@ -32,7 +30,6 @@
     "//components/content_settings/core/browser",
     "//components/pref_registry",
     "//components/prefs",
-    "//components/proxy_config",
     "//components/update_client",
     "//ios/chrome/browser",
     "//ios/chrome/browser/browser_state",