OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/networking_private/networking_private_chromeos. h" | 5 #include "extensions/browser/api/networking_private/networking_private_chromeos. h" |
6 | 6 |
7 #include <memory> | |
8 | |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | |
11 #include "base/values.h" | 14 #include "base/values.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/dbus/shill_manager_client.h" | 16 #include "chromeos/dbus/shill_manager_client.h" |
14 #include "chromeos/login/login_state.h" | 17 #include "chromeos/login/login_state.h" |
15 #include "chromeos/network/device_state.h" | 18 #include "chromeos/network/device_state.h" |
16 #include "chromeos/network/managed_network_configuration_handler.h" | 19 #include "chromeos/network/managed_network_configuration_handler.h" |
17 #include "chromeos/network/network_activation_handler.h" | 20 #include "chromeos/network/network_activation_handler.h" |
18 #include "chromeos/network/network_connection_handler.h" | 21 #include "chromeos/network/network_connection_handler.h" |
19 #include "chromeos/network/network_device_handler.h" | 22 #include "chromeos/network/network_device_handler.h" |
20 #include "chromeos/network/network_event_log.h" | 23 #include "chromeos/network/network_event_log.h" |
21 #include "chromeos/network/network_state.h" | 24 #include "chromeos/network/network_state.h" |
22 #include "chromeos/network/network_state_handler.h" | 25 #include "chromeos/network/network_state_handler.h" |
23 #include "chromeos/network/network_util.h" | 26 #include "chromeos/network/network_util.h" |
24 #include "chromeos/network/onc/onc_signature.h" | 27 #include "chromeos/network/onc/onc_signature.h" |
25 #include "chromeos/network/onc/onc_translator.h" | 28 #include "chromeos/network/onc/onc_translator.h" |
26 #include "chromeos/network/onc/onc_utils.h" | 29 #include "chromeos/network/onc/onc_utils.h" |
27 #include "chromeos/network/portal_detector/network_portal_detector.h" | 30 #include "chromeos/network/portal_detector/network_portal_detector.h" |
31 #include "chromeos/network/proxy/ui_proxy_config.h" | |
32 #include "chromeos/network/proxy/ui_proxy_config_service.h" | |
28 #include "components/onc/onc_constants.h" | 33 #include "components/onc/onc_constants.h" |
34 #include "components/proxy_config/proxy_prefs.h" | |
29 #include "content/public/browser/browser_context.h" | 35 #include "content/public/browser/browser_context.h" |
30 #include "extensions/browser/api/networking_private/networking_private_api.h" | 36 #include "extensions/browser/api/networking_private/networking_private_api.h" |
31 #include "extensions/browser/extension_registry.h" | 37 #include "extensions/browser/extension_registry.h" |
32 #include "extensions/browser/extensions_browser_client.h" | 38 #include "extensions/browser/extensions_browser_client.h" |
33 #include "extensions/common/extension.h" | 39 #include "extensions/common/extension.h" |
34 #include "extensions/common/extension_set.h" | 40 #include "extensions/common/extension_set.h" |
35 #include "extensions/common/permissions/api_permission.h" | 41 #include "extensions/common/permissions/api_permission.h" |
36 #include "extensions/common/permissions/permissions_data.h" | 42 #include "extensions/common/permissions/permissions_data.h" |
37 #include "third_party/cros_system_api/dbus/service_constants.h" | 43 #include "third_party/cros_system_api/dbus/service_constants.h" |
38 | 44 |
39 using chromeos::NetworkHandler; | 45 using chromeos::NetworkHandler; |
40 using chromeos::NetworkStateHandler; | 46 using chromeos::NetworkStateHandler; |
41 using chromeos::NetworkTypePattern; | 47 using chromeos::NetworkTypePattern; |
42 using chromeos::ShillManagerClient; | 48 using chromeos::ShillManagerClient; |
49 using chromeos::UIProxyConfig; | |
43 using extensions::NetworkingPrivateDelegate; | 50 using extensions::NetworkingPrivateDelegate; |
44 | 51 |
45 namespace private_api = extensions::api::networking_private; | 52 namespace private_api = extensions::api::networking_private; |
46 | 53 |
47 namespace { | 54 namespace { |
48 | 55 |
49 chromeos::NetworkStateHandler* GetStateHandler() { | 56 chromeos::NetworkStateHandler* GetStateHandler() { |
50 return NetworkHandler::Get()->network_state_handler(); | 57 return NetworkHandler::Get()->network_state_handler(); |
51 } | 58 } |
52 | 59 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 device_state = | 214 device_state = |
208 GetStateHandler()->GetDeviceState(network_state->device_path()); | 215 GetStateHandler()->GetDeviceState(network_state->device_path()); |
209 } | 216 } |
210 if (!device_state) { | 217 if (!device_state) { |
211 device_state = | 218 device_state = |
212 GetStateHandler()->GetDeviceStateByType(NetworkTypePattern::Cellular()); | 219 GetStateHandler()->GetDeviceStateByType(NetworkTypePattern::Cellular()); |
213 } | 220 } |
214 return device_state; | 221 return device_state; |
215 } | 222 } |
216 | 223 |
224 // Ensures that |container| has a DictionaryValue for |key| and returns it. | |
225 base::DictionaryValue* EnsureDictionaryValue(const std::string& key, | |
226 base::DictionaryValue* container) { | |
227 base::DictionaryValue* dict; | |
228 if (!container->GetDictionary(key, &dict)) { | |
229 container->SetWithoutPathExpansion( | |
230 key, base::MakeUnique<base::DictionaryValue>()); | |
231 container->GetDictionary(key, &dict); | |
232 } | |
233 return dict; | |
234 } | |
235 | |
236 // Sets the active and effective ONC dictionary values of |dict| based on | |
237 // |state|. Also sets the UserEditable property to false. | |
238 void SetProxyEffectiveValue(base::DictionaryValue* dict, | |
239 ProxyPrefs::ConfigState state, | |
240 std::unique_ptr<base::Value> value) { | |
241 // NOTE: ProxyPrefs::ConfigState only exposes 'CONFIG_POLICY' so just use | |
242 // 'UserPolicy' here for the effective type. The existing UI does not | |
243 // differentiate between policy types. TODO(stevenjb): Eliminate UIProxyConfig | |
244 // and instead generate a proper ONC dictionary with the correct policy source | |
245 // preserved. crbug.com/662529. | |
246 dict->SetStringWithoutPathExpansion(::onc::kAugmentationEffectiveSetting, | |
247 state == ProxyPrefs::CONFIG_EXTENSION | |
248 ? ::onc::kAugmentationActiveExtension | |
249 : ::onc::kAugmentationUserPolicy); | |
250 if (state != ProxyPrefs::CONFIG_EXTENSION) { | |
251 std::unique_ptr<base::Value> value_copy(value->CreateDeepCopy()); | |
252 dict->SetWithoutPathExpansion(::onc::kAugmentationUserPolicy, | |
253 std::move(value_copy)); | |
254 } | |
255 dict->SetWithoutPathExpansion(::onc::kAugmentationActiveSetting, | |
256 std::move(value)); | |
257 dict->SetBooleanWithoutPathExpansion(::onc::kAugmentationUserEditable, false); | |
258 } | |
259 | |
260 std::string GetProxySettingsType(const UIProxyConfig::Mode& mode) { | |
261 switch (mode) { | |
262 case UIProxyConfig::MODE_DIRECT: | |
263 return ::onc::proxy::kDirect; | |
264 case UIProxyConfig::MODE_AUTO_DETECT: | |
265 return ::onc::proxy::kWPAD; | |
266 case UIProxyConfig::MODE_PAC_SCRIPT: | |
267 return ::onc::proxy::kPAC; | |
268 case UIProxyConfig::MODE_SINGLE_PROXY: | |
269 case UIProxyConfig::MODE_PROXY_PER_SCHEME: | |
270 return ::onc::proxy::kManual; | |
271 } | |
272 NOTREACHED(); | |
273 return ::onc::proxy::kDirect; | |
274 } | |
275 | |
276 void SetManualProxy(base::DictionaryValue* manual, | |
277 ProxyPrefs::ConfigState state, | |
278 const std::string& key, | |
279 const UIProxyConfig::ManualProxy& proxy) { | |
280 base::DictionaryValue* dict = EnsureDictionaryValue(key, manual); | |
281 base::DictionaryValue* host_dict = | |
282 EnsureDictionaryValue(::onc::proxy::kHost, dict); | |
283 SetProxyEffectiveValue(host_dict, state, | |
284 base::WrapUnique<base::Value>(new base::StringValue( | |
michaelpg
2016/11/14 21:19:23
can WrapUnique become MakeUnique without the `new`
stevenjb
2016/11/15 00:04:23
MakeUnique<Value>(string) doesn't work because Val
| |
285 proxy.server.host_port_pair().host()))); | |
286 uint16_t port = proxy.server.host_port_pair().port(); | |
287 base::DictionaryValue* port_dict = | |
288 EnsureDictionaryValue(::onc::proxy::kPort, dict); | |
289 SetProxyEffectiveValue( | |
290 port_dict, state, | |
291 base::WrapUnique<base::Value>( | |
292 new base::FundamentalValue(static_cast<int>(port)))); | |
michaelpg
2016/11/14 21:19:23
dumb noob question: is a static cast necessary?
michaelpg
2016/11/14 21:19:23
same question
stevenjb
2016/11/15 00:04:23
No, I think it's OK, since u16 -> int isn't lossy,
| |
293 } | |
294 | |
217 } // namespace | 295 } // namespace |
218 | 296 |
219 //////////////////////////////////////////////////////////////////////////////// | 297 //////////////////////////////////////////////////////////////////////////////// |
220 | 298 |
221 namespace extensions { | 299 namespace extensions { |
222 | 300 |
223 NetworkingPrivateChromeOS::NetworkingPrivateChromeOS( | 301 NetworkingPrivateChromeOS::NetworkingPrivateChromeOS( |
224 content::BrowserContext* browser_context, | 302 content::BrowserContext* browser_context, |
225 std::unique_ptr<VerifyDelegate> verify_delegate) | 303 std::unique_ptr<VerifyDelegate> verify_delegate) |
226 : NetworkingPrivateDelegate(std::move(verify_delegate)), | 304 : NetworkingPrivateDelegate(std::move(verify_delegate)), |
227 browser_context_(browser_context), | 305 browser_context_(browser_context), |
228 weak_ptr_factory_(this) {} | 306 weak_ptr_factory_(this) {} |
229 | 307 |
230 NetworkingPrivateChromeOS::~NetworkingPrivateChromeOS() { | 308 NetworkingPrivateChromeOS::~NetworkingPrivateChromeOS() {} |
231 } | |
232 | 309 |
233 void NetworkingPrivateChromeOS::GetProperties( | 310 void NetworkingPrivateChromeOS::GetProperties( |
234 const std::string& guid, | 311 const std::string& guid, |
235 const DictionaryCallback& success_callback, | 312 const DictionaryCallback& success_callback, |
236 const FailureCallback& failure_callback) { | 313 const FailureCallback& failure_callback) { |
237 std::string service_path, error; | 314 std::string service_path, error; |
238 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 315 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
239 failure_callback.Run(error); | 316 failure_callback.Run(error); |
240 return; | 317 return; |
241 } | 318 } |
242 | 319 |
243 std::string user_id_hash; | 320 std::string user_id_hash; |
244 if (!GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { | 321 if (!GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { |
245 failure_callback.Run(error); | 322 failure_callback.Run(error); |
246 return; | 323 return; |
247 } | 324 } |
248 | 325 |
249 GetManagedConfigurationHandler()->GetProperties( | 326 GetManagedConfigurationHandler()->GetProperties( |
250 user_id_hash, service_path, | 327 user_id_hash, service_path, |
251 base::Bind(&NetworkingPrivateChromeOS::GetPropertiesCallback, | 328 base::Bind(&NetworkingPrivateChromeOS::GetPropertiesCallback, |
252 weak_ptr_factory_.GetWeakPtr(), success_callback), | 329 weak_ptr_factory_.GetWeakPtr(), guid, false /* managed */, |
330 success_callback), | |
253 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); | 331 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); |
254 } | 332 } |
255 | 333 |
256 void NetworkingPrivateChromeOS::GetManagedProperties( | 334 void NetworkingPrivateChromeOS::GetManagedProperties( |
257 const std::string& guid, | 335 const std::string& guid, |
258 const DictionaryCallback& success_callback, | 336 const DictionaryCallback& success_callback, |
259 const FailureCallback& failure_callback) { | 337 const FailureCallback& failure_callback) { |
260 std::string service_path, error; | 338 std::string service_path, error; |
261 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 339 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
262 failure_callback.Run(error); | 340 failure_callback.Run(error); |
263 return; | 341 return; |
264 } | 342 } |
265 | 343 |
266 std::string user_id_hash; | 344 std::string user_id_hash; |
267 if (!GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { | 345 if (!GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { |
268 failure_callback.Run(error); | 346 failure_callback.Run(error); |
269 return; | 347 return; |
270 } | 348 } |
271 | 349 |
272 GetManagedConfigurationHandler()->GetManagedProperties( | 350 GetManagedConfigurationHandler()->GetManagedProperties( |
273 user_id_hash, service_path, | 351 user_id_hash, service_path, |
274 base::Bind(&NetworkingPrivateChromeOS::GetPropertiesCallback, | 352 base::Bind(&NetworkingPrivateChromeOS::GetPropertiesCallback, |
275 weak_ptr_factory_.GetWeakPtr(), success_callback), | 353 weak_ptr_factory_.GetWeakPtr(), guid, true /* managed */, |
354 success_callback), | |
276 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); | 355 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); |
277 } | 356 } |
278 | 357 |
279 void NetworkingPrivateChromeOS::GetState( | 358 void NetworkingPrivateChromeOS::GetState( |
280 const std::string& guid, | 359 const std::string& guid, |
281 const DictionaryCallback& success_callback, | 360 const DictionaryCallback& success_callback, |
282 const FailureCallback& failure_callback) { | 361 const FailureCallback& failure_callback) { |
283 std::string service_path, error; | 362 std::string service_path, error; |
284 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 363 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
285 failure_callback.Run(error); | 364 failure_callback.Run(error); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 655 |
577 std::unique_ptr<DeviceStateList> device_state_list(new DeviceStateList); | 656 std::unique_ptr<DeviceStateList> device_state_list(new DeviceStateList); |
578 for (const chromeos::DeviceState* device : devices) { | 657 for (const chromeos::DeviceState* device : devices) { |
579 std::string onc_type = | 658 std::string onc_type = |
580 chromeos::network_util::TranslateShillTypeToONC(device->type()); | 659 chromeos::network_util::TranslateShillTypeToONC(device->type()); |
581 AppendDeviceState(onc_type, device, device_state_list.get()); | 660 AppendDeviceState(onc_type, device, device_state_list.get()); |
582 technologies_found.insert(onc_type); | 661 technologies_found.insert(onc_type); |
583 } | 662 } |
584 | 663 |
585 // For any technologies that we do not have a DeviceState entry for, append | 664 // For any technologies that we do not have a DeviceState entry for, append |
586 // an entry if the technolog is available. | 665 // an entry if the technology is available. |
587 const char* technology_types[] = {::onc::network_type::kEthernet, | 666 const char* technology_types[] = { |
588 ::onc::network_type::kWiFi, | 667 ::onc::network_type::kEthernet, ::onc::network_type::kWiFi, |
589 ::onc::network_type::kWimax, | 668 ::onc::network_type::kWimax, ::onc::network_type::kCellular}; |
590 ::onc::network_type::kCellular}; | |
591 for (const char* technology : technology_types) { | 669 for (const char* technology : technology_types) { |
592 if (base::ContainsValue(technologies_found, technology)) | 670 if (base::ContainsValue(technologies_found, technology)) |
593 continue; | 671 continue; |
594 AppendDeviceState(technology, nullptr /* device */, | 672 AppendDeviceState(technology, nullptr /* device */, |
595 device_state_list.get()); | 673 device_state_list.get()); |
596 } | 674 } |
597 return device_state_list; | 675 return device_state_list; |
598 } | 676 } |
599 | 677 |
600 bool NetworkingPrivateChromeOS::EnableNetworkType(const std::string& type) { | 678 bool NetworkingPrivateChromeOS::EnableNetworkType(const std::string& type) { |
(...skipping 17 matching lines...) Expand all Loading... | |
618 } | 696 } |
619 | 697 |
620 bool NetworkingPrivateChromeOS::RequestScan() { | 698 bool NetworkingPrivateChromeOS::RequestScan() { |
621 GetStateHandler()->RequestScan(); | 699 GetStateHandler()->RequestScan(); |
622 return true; | 700 return true; |
623 } | 701 } |
624 | 702 |
625 // Private methods | 703 // Private methods |
626 | 704 |
627 void NetworkingPrivateChromeOS::GetPropertiesCallback( | 705 void NetworkingPrivateChromeOS::GetPropertiesCallback( |
706 const std::string& guid, | |
707 bool managed, | |
628 const DictionaryCallback& callback, | 708 const DictionaryCallback& callback, |
629 const std::string& service_path, | 709 const std::string& service_path, |
630 const base::DictionaryValue& dictionary) { | 710 const base::DictionaryValue& dictionary) { |
631 std::unique_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy()); | 711 std::unique_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy()); |
632 AppendThirdPartyProviderName(dictionary_copy.get()); | 712 AppendThirdPartyProviderName(dictionary_copy.get()); |
713 if (managed) | |
714 SetManagedActiveProxyValues(guid, dictionary_copy.get()); | |
633 callback.Run(std::move(dictionary_copy)); | 715 callback.Run(std::move(dictionary_copy)); |
634 } | 716 } |
635 | 717 |
636 // Populate ThirdPartyVPN.kProviderName for third-party VPNs. | |
637 void NetworkingPrivateChromeOS::AppendThirdPartyProviderName( | 718 void NetworkingPrivateChromeOS::AppendThirdPartyProviderName( |
638 base::DictionaryValue* dictionary) { | 719 base::DictionaryValue* dictionary) { |
639 base::DictionaryValue* third_party_vpn = | 720 base::DictionaryValue* third_party_vpn = |
640 GetThirdPartyVPNDictionary(dictionary); | 721 GetThirdPartyVPNDictionary(dictionary); |
641 if (!third_party_vpn) | 722 if (!third_party_vpn) |
642 return; | 723 return; |
643 | 724 |
644 const std::string extension_id = GetStringFromDictionary( | 725 const std::string extension_id = GetStringFromDictionary( |
645 *third_party_vpn, ::onc::third_party_vpn::kExtensionID); | 726 *third_party_vpn, ::onc::third_party_vpn::kExtensionID); |
646 const ExtensionSet& extensions = | 727 const ExtensionSet& extensions = |
647 ExtensionRegistry::Get(browser_context_)->enabled_extensions(); | 728 ExtensionRegistry::Get(browser_context_)->enabled_extensions(); |
648 for (const auto& extension : extensions) { | 729 for (const auto& extension : extensions) { |
649 if (extension->permissions_data()->HasAPIPermission( | 730 if (extension->permissions_data()->HasAPIPermission( |
650 APIPermission::kVpnProvider) && | 731 APIPermission::kVpnProvider) && |
651 extension->id() == extension_id) { | 732 extension->id() == extension_id) { |
652 third_party_vpn->SetStringWithoutPathExpansion( | 733 third_party_vpn->SetStringWithoutPathExpansion( |
653 ::onc::third_party_vpn::kProviderName, extension->name()); | 734 ::onc::third_party_vpn::kProviderName, extension->name()); |
654 break; | 735 break; |
655 } | 736 } |
656 } | 737 } |
657 } | 738 } |
658 | 739 |
740 void NetworkingPrivateChromeOS::SetManagedActiveProxyValues( | |
741 const std::string& guid, | |
742 base::DictionaryValue* dictionary) { | |
743 // NOTE: We use UIProxyConfigService and UIProxyConfig for historical | |
744 // reasons. The model and service were written for a much older UI but | |
745 // contain a fair amount of subtle logic which is why we use them. | |
746 // TODO(stevenjb): Re-factor this code and eliminate UIProxyConfig once | |
747 // the old options UI is abandoned. crbug.com/662529. | |
748 chromeos::UIProxyConfigService* ui_proxy_config_service = | |
749 NetworkHandler::Get()->ui_proxy_config_service(); | |
750 ui_proxy_config_service->UpdateFromPrefs(guid); | |
751 UIProxyConfig config; | |
752 ui_proxy_config_service->GetProxyConfig(guid, &config); | |
753 ProxyPrefs::ConfigState state = config.state; | |
754 | |
755 VLOG(1) << "CONFIG STATE FOR: " << guid << ": " << state | |
michaelpg
2016/11/14 21:19:23
intentionally left in?
stevenjb
2016/11/15 00:04:23
Yeah. I'm not convinced I'm done debugging this.
| |
756 << " MODE: " << config.mode; | |
757 | |
758 if (state != ProxyPrefs::CONFIG_POLICY && | |
759 state != ProxyPrefs::CONFIG_EXTENSION && | |
760 state != ProxyPrefs::CONFIG_OTHER_PRECEDE) { | |
761 return; | |
762 } | |
763 | |
764 // Ensure that the ProxySettings dictionary exists. | |
765 base::DictionaryValue* proxy_settings = | |
766 EnsureDictionaryValue(::onc::network_config::kProxySettings, dictionary); | |
767 VLOG(2) << " PROXY: " << *proxy_settings; | |
768 | |
769 // Ensure that the ProxySettings.Type dictionary exists and set the Type | |
770 // value to the value from |ui_proxy_config_service|. | |
771 base::DictionaryValue* proxy_type_dict = | |
772 EnsureDictionaryValue(::onc::network_config::kType, proxy_settings); | |
773 SetProxyEffectiveValue(proxy_type_dict, state, | |
774 base::WrapUnique<base::Value>(new base::StringValue( | |
775 GetProxySettingsType(config.mode)))); | |
776 | |
777 // Update any appropriate sub dictionary based on the new type. | |
778 switch (config.mode) { | |
779 case UIProxyConfig::MODE_SINGLE_PROXY: { | |
780 // Use the same proxy value (config.single_proxy) for all proxies. | |
781 base::DictionaryValue* manual = | |
782 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); | |
783 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.single_proxy); | |
784 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.single_proxy); | |
785 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.single_proxy); | |
786 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.single_proxy); | |
787 break; | |
788 } | |
789 case UIProxyConfig::MODE_PROXY_PER_SCHEME: { | |
790 base::DictionaryValue* manual = | |
791 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); | |
792 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.http_proxy); | |
793 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.https_proxy); | |
794 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.ftp_proxy); | |
795 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.socks_proxy); | |
796 break; | |
797 } | |
798 case UIProxyConfig::MODE_PAC_SCRIPT: { | |
799 base::DictionaryValue* pac = | |
800 EnsureDictionaryValue(::onc::proxy::kPAC, proxy_settings); | |
801 SetProxyEffectiveValue( | |
802 pac, state, base::WrapUnique<base::Value>(new base::StringValue( | |
803 config.automatic_proxy.pac_url.spec()))); | |
804 break; | |
805 } | |
806 case UIProxyConfig::MODE_DIRECT: | |
807 case UIProxyConfig::MODE_AUTO_DETECT: | |
808 break; | |
809 } | |
810 | |
811 VLOG(2) << " NEW PROXY: " << *proxy_settings; | |
812 } | |
813 | |
659 void NetworkingPrivateChromeOS::ConnectFailureCallback( | 814 void NetworkingPrivateChromeOS::ConnectFailureCallback( |
660 const std::string& guid, | 815 const std::string& guid, |
661 const VoidCallback& success_callback, | 816 const VoidCallback& success_callback, |
662 const FailureCallback& failure_callback, | 817 const FailureCallback& failure_callback, |
663 const std::string& error_name, | 818 const std::string& error_name, |
664 std::unique_ptr<base::DictionaryValue> error_data) { | 819 std::unique_ptr<base::DictionaryValue> error_data) { |
665 // TODO(stevenjb): Temporary workaround to show the configuration UI. | 820 // TODO(stevenjb): Temporary workaround to show the configuration UI. |
666 // Eventually the caller (e.g. Settings) should handle any failures and | 821 // Eventually the caller (e.g. Settings) should handle any failures and |
667 // show its own configuration UI. crbug.com/380937. | 822 // show its own configuration UI. crbug.com/380937. |
668 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { | 823 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { |
669 success_callback.Run(); | 824 success_callback.Run(); |
670 return; | 825 return; |
671 } | 826 } |
672 failure_callback.Run(error_name); | 827 failure_callback.Run(error_name); |
673 } | 828 } |
674 | 829 |
675 } // namespace extensions | 830 } // namespace extensions |
OLD | NEW |