OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/browser/proxy_policy_handler.h" | 5 #include "components/policy/core/browser/proxy_policy_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 proxy_mode = ProxyPrefs::MODE_DIRECT; | 168 proxy_mode = ProxyPrefs::MODE_DIRECT; |
169 NOTREACHED(); | 169 NOTREACHED(); |
170 } | 170 } |
171 } else { | 171 } else { |
172 return; | 172 return; |
173 } | 173 } |
174 | 174 |
175 switch (proxy_mode) { | 175 switch (proxy_mode) { |
176 case ProxyPrefs::MODE_DIRECT: | 176 case ProxyPrefs::MODE_DIRECT: |
177 prefs->SetValue(proxy_config::prefs::kProxy, | 177 prefs->SetValue(proxy_config::prefs::kProxy, |
178 base::WrapUnique(ProxyConfigDictionary::CreateDirect())); | 178 ProxyConfigDictionary::CreateDirect()); |
179 break; | 179 break; |
180 case ProxyPrefs::MODE_AUTO_DETECT: | 180 case ProxyPrefs::MODE_AUTO_DETECT: |
181 prefs->SetValue( | 181 prefs->SetValue(proxy_config::prefs::kProxy, |
182 proxy_config::prefs::kProxy, | 182 ProxyConfigDictionary::CreateAutoDetect()); |
183 base::WrapUnique(ProxyConfigDictionary::CreateAutoDetect())); | |
184 break; | 183 break; |
185 case ProxyPrefs::MODE_PAC_SCRIPT: { | 184 case ProxyPrefs::MODE_PAC_SCRIPT: { |
186 std::string pac_url_string; | 185 std::string pac_url_string; |
187 if (pac_url && pac_url->GetAsString(&pac_url_string)) { | 186 if (pac_url && pac_url->GetAsString(&pac_url_string)) { |
188 prefs->SetValue(proxy_config::prefs::kProxy, | 187 prefs->SetValue( |
189 base::WrapUnique(ProxyConfigDictionary::CreatePacScript( | 188 proxy_config::prefs::kProxy, |
190 pac_url_string, false))); | 189 ProxyConfigDictionary::CreatePacScript(pac_url_string, false)); |
191 } else { | 190 } else { |
192 NOTREACHED(); | 191 NOTREACHED(); |
193 } | 192 } |
194 break; | 193 break; |
195 } | 194 } |
196 case ProxyPrefs::MODE_FIXED_SERVERS: { | 195 case ProxyPrefs::MODE_FIXED_SERVERS: { |
197 std::string proxy_server; | 196 std::string proxy_server; |
198 std::string bypass_list_string; | 197 std::string bypass_list_string; |
199 if (server->GetAsString(&proxy_server)) { | 198 if (server->GetAsString(&proxy_server)) { |
200 if (bypass_list) | 199 if (bypass_list) |
201 bypass_list->GetAsString(&bypass_list_string); | 200 bypass_list->GetAsString(&bypass_list_string); |
202 prefs->SetValue( | 201 prefs->SetValue(proxy_config::prefs::kProxy, |
203 proxy_config::prefs::kProxy, | 202 ProxyConfigDictionary::CreateFixedServers( |
204 base::WrapUnique(ProxyConfigDictionary::CreateFixedServers( | 203 proxy_server, bypass_list_string)); |
205 proxy_server, bypass_list_string))); | |
206 } | 204 } |
207 break; | 205 break; |
208 } | 206 } |
209 case ProxyPrefs::MODE_SYSTEM: | 207 case ProxyPrefs::MODE_SYSTEM: |
210 prefs->SetValue(proxy_config::prefs::kProxy, | 208 prefs->SetValue(proxy_config::prefs::kProxy, |
211 base::WrapUnique(ProxyConfigDictionary::CreateSystem())); | 209 ProxyConfigDictionary::CreateSystem()); |
212 break; | 210 break; |
213 case ProxyPrefs::kModeCount: | 211 case ProxyPrefs::kModeCount: |
214 NOTREACHED(); | 212 NOTREACHED(); |
215 } | 213 } |
216 } | 214 } |
217 | 215 |
218 const base::Value* ProxyPolicyHandler::GetProxyPolicyValue( | 216 const base::Value* ProxyPolicyHandler::GetProxyPolicyValue( |
219 const PolicyMap& policies, const char* policy_name) { | 217 const PolicyMap& policies, const char* policy_name) { |
220 // See note on the ProxyPolicyHandler implementation above. | 218 // See note on the ProxyPolicyHandler implementation above. |
221 const base::Value* value = policies.GetValue(key::kProxySettings); | 219 const base::Value* value = policies.GetValue(key::kProxySettings); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 key::kProxyServerMode, | 326 key::kProxyServerMode, |
329 IDS_POLICY_OUT_OF_RANGE_ERROR, | 327 IDS_POLICY_OUT_OF_RANGE_ERROR, |
330 base::IntToString(server_mode_value)); | 328 base::IntToString(server_mode_value)); |
331 return false; | 329 return false; |
332 } | 330 } |
333 } | 331 } |
334 return true; | 332 return true; |
335 } | 333 } |
336 | 334 |
337 } // namespace policy | 335 } // namespace policy |
OLD | NEW |