OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/proxy_service_factory.h" | 5 #include "chrome/browser/net/proxy_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return false; | 50 return false; |
51 if (command_line.HasSwitch(switches::kV8PacMojoOutOfProcess)) | 51 if (command_line.HasSwitch(switches::kV8PacMojoOutOfProcess)) |
52 return true; | 52 return true; |
53 return group_name == "Enabled"; | 53 return group_name == "Enabled"; |
54 } | 54 } |
55 #endif // !defined(OS_ANDROID) | 55 #endif // !defined(OS_ANDROID) |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 // static | 59 // static |
60 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( | 60 scoped_ptr<net::ProxyConfigService> |
61 PrefProxyConfigTracker* tracker) { | 61 ProxyServiceFactory::CreateProxyConfigService(PrefProxyConfigTracker* tracker) { |
62 // The linux gconf-based proxy settings getter relies on being initialized | 62 // The linux gconf-based proxy settings getter relies on being initialized |
63 // from the UI thread. | 63 // from the UI thread. |
64 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 64 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
65 | 65 |
66 scoped_ptr<net::ProxyConfigService> base_service; | 66 scoped_ptr<net::ProxyConfigService> base_service; |
67 | 67 |
68 #if !defined(OS_CHROMEOS) | 68 #if !defined(OS_CHROMEOS) |
69 // On ChromeOS, base service is NULL; chromeos::ProxyConfigServiceImpl | 69 // On ChromeOS, base service is NULL; chromeos::ProxyConfigServiceImpl |
70 // determines the effective proxy config to take effect in the network layer, | 70 // determines the effective proxy config to take effect in the network layer, |
71 // be it from prefs or system (which is network shill on chromeos). | 71 // be it from prefs or system (which is network shill on chromeos). |
72 | 72 |
73 // For other platforms, create a baseline service that provides proxy | 73 // For other platforms, create a baseline service that provides proxy |
74 // configuration in case nothing is configured through prefs (Note: prefs | 74 // configuration in case nothing is configured through prefs (Note: prefs |
75 // include command line and configuration policy). | 75 // include command line and configuration policy). |
76 | 76 |
77 // TODO(port): the IO and FILE message loops are only used by Linux. Can | 77 // TODO(port): the IO and FILE message loops are only used by Linux. Can |
78 // that code be moved to chrome/browser instead of being in net, so that it | 78 // that code be moved to chrome/browser instead of being in net, so that it |
79 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. | 79 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. |
80 base_service.reset(net::ProxyService::CreateSystemProxyConfigService( | 80 base_service = net::ProxyService::CreateSystemProxyConfigService( |
81 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 81 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
82 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 82 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
83 #endif // !defined(OS_CHROMEOS) | 83 #endif // !defined(OS_CHROMEOS) |
84 | 84 |
85 return tracker->CreateTrackingProxyConfigService(base_service.Pass()) | 85 return tracker->CreateTrackingProxyConfigService(base_service.Pass()); |
86 .release(); | |
87 } | 86 } |
88 | 87 |
89 // static | 88 // static |
90 PrefProxyConfigTracker* | 89 PrefProxyConfigTracker* |
91 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 90 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
92 PrefService* profile_prefs, | 91 PrefService* profile_prefs, |
93 PrefService* local_state_prefs) { | 92 PrefService* local_state_prefs) { |
94 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
95 return new chromeos::ProxyConfigServiceImpl(profile_prefs, local_state_prefs); | 94 return new chromeos::ProxyConfigServiceImpl(profile_prefs, local_state_prefs); |
96 #else | 95 #else |
(...skipping 14 matching lines...) Expand all Loading... |
111 local_state_prefs, | 110 local_state_prefs, |
112 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 111 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
113 #endif // defined(OS_CHROMEOS) | 112 #endif // defined(OS_CHROMEOS) |
114 } | 113 } |
115 | 114 |
116 // static | 115 // static |
117 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( | 116 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( |
118 net::NetLog* net_log, | 117 net::NetLog* net_log, |
119 net::URLRequestContext* context, | 118 net::URLRequestContext* context, |
120 net::NetworkDelegate* network_delegate, | 119 net::NetworkDelegate* network_delegate, |
121 net::ProxyConfigService* proxy_config_service, | 120 scoped_ptr<net::ProxyConfigService> proxy_config_service, |
122 const base::CommandLine& command_line, | 121 const base::CommandLine& command_line, |
123 bool quick_check_enabled) { | 122 bool quick_check_enabled) { |
124 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 123 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
125 #if defined(OS_IOS) | 124 #if defined(OS_IOS) |
126 bool use_v8 = false; | 125 bool use_v8 = false; |
127 #else | 126 #else |
128 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 127 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
129 // TODO(eroman): Figure out why this doesn't work in single-process mode. | 128 // TODO(eroman): Figure out why this doesn't work in single-process mode. |
130 // Should be possible now that a private isolate is used. | 129 // Should be possible now that a private isolate is used. |
131 // http://crbug.com/474654 | 130 // http://crbug.com/474654 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 #else | 162 #else |
164 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 163 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
165 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 164 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
166 #endif | 165 #endif |
167 | 166 |
168 #if !defined(OS_ANDROID) | 167 #if !defined(OS_ANDROID) |
169 // In-process Mojo PAC can only be set on the command line, so its presence | 168 // In-process Mojo PAC can only be set on the command line, so its presence |
170 // should override other options. | 169 // should override other options. |
171 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { | 170 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { |
172 proxy_service = net::CreateProxyServiceUsingMojoInProcess( | 171 proxy_service = net::CreateProxyServiceUsingMojoInProcess( |
173 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 172 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
174 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 173 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
175 network_delegate); | 174 network_delegate); |
176 } else if (EnableOutOfProcessV8Pac(command_line)) { | 175 } else if (EnableOutOfProcessV8Pac(command_line)) { |
177 proxy_service = net::CreateProxyServiceUsingMojoFactory( | 176 proxy_service = net::CreateProxyServiceUsingMojoFactory( |
178 UtilityProcessMojoProxyResolverFactory::GetInstance(), | 177 UtilityProcessMojoProxyResolverFactory::GetInstance(), |
179 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 178 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
180 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 179 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
181 network_delegate); | 180 network_delegate); |
182 } | 181 } |
183 #endif // !defined(OS_ANDROID) | 182 #endif // !defined(OS_ANDROID) |
184 | 183 |
185 if (!proxy_service) { | 184 if (!proxy_service) { |
186 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 185 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
187 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 186 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
188 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 187 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
189 network_delegate); | 188 network_delegate); |
190 } | 189 } |
191 #endif // defined(OS_IOS) | 190 #endif // defined(OS_IOS) |
192 } else { | 191 } else { |
193 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 192 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
194 proxy_config_service, | 193 proxy_config_service.Pass(), num_pac_threads, net_log); |
195 num_pac_threads, | |
196 net_log); | |
197 } | 194 } |
198 | 195 |
199 proxy_service->set_quick_check_enabled(quick_check_enabled); | 196 proxy_service->set_quick_check_enabled(quick_check_enabled); |
200 | 197 |
201 return proxy_service; | 198 return proxy_service; |
202 } | 199 } |
OLD | NEW |