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> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return ::onc::proxy::kDirect; | 273 return ::onc::proxy::kDirect; |
274 } | 274 } |
275 | 275 |
276 void SetManualProxy(base::DictionaryValue* manual, | 276 void SetManualProxy(base::DictionaryValue* manual, |
277 ProxyPrefs::ConfigState state, | 277 ProxyPrefs::ConfigState state, |
278 const std::string& key, | 278 const std::string& key, |
279 const UIProxyConfig::ManualProxy& proxy) { | 279 const UIProxyConfig::ManualProxy& proxy) { |
280 base::DictionaryValue* dict = EnsureDictionaryValue(key, manual); | 280 base::DictionaryValue* dict = EnsureDictionaryValue(key, manual); |
281 base::DictionaryValue* host_dict = | 281 base::DictionaryValue* host_dict = |
282 EnsureDictionaryValue(::onc::proxy::kHost, dict); | 282 EnsureDictionaryValue(::onc::proxy::kHost, dict); |
283 SetProxyEffectiveValue(host_dict, state, | 283 SetProxyEffectiveValue( |
284 base::MakeUnique<base::StringValue>( | 284 host_dict, state, |
285 proxy.server.host_port_pair().host())); | 285 base::MakeUnique<base::Value>(proxy.server.host_port_pair().host())); |
286 uint16_t port = proxy.server.host_port_pair().port(); | 286 uint16_t port = proxy.server.host_port_pair().port(); |
287 base::DictionaryValue* port_dict = | 287 base::DictionaryValue* port_dict = |
288 EnsureDictionaryValue(::onc::proxy::kPort, dict); | 288 EnsureDictionaryValue(::onc::proxy::kPort, dict); |
289 SetProxyEffectiveValue(port_dict, state, base::MakeUnique<base::Value>(port)); | 289 SetProxyEffectiveValue(port_dict, state, base::MakeUnique<base::Value>(port)); |
290 } | 290 } |
291 | 291 |
292 } // namespace | 292 } // namespace |
293 | 293 |
294 //////////////////////////////////////////////////////////////////////////////// | 294 //////////////////////////////////////////////////////////////////////////////// |
295 | 295 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 // Ensure that the ProxySettings dictionary exists. | 772 // Ensure that the ProxySettings dictionary exists. |
773 base::DictionaryValue* proxy_settings = | 773 base::DictionaryValue* proxy_settings = |
774 EnsureDictionaryValue(::onc::network_config::kProxySettings, dictionary); | 774 EnsureDictionaryValue(::onc::network_config::kProxySettings, dictionary); |
775 VLOG(2) << " PROXY: " << *proxy_settings; | 775 VLOG(2) << " PROXY: " << *proxy_settings; |
776 | 776 |
777 // Ensure that the ProxySettings.Type dictionary exists and set the Type | 777 // Ensure that the ProxySettings.Type dictionary exists and set the Type |
778 // value to the value from |ui_proxy_config_service|. | 778 // value to the value from |ui_proxy_config_service|. |
779 base::DictionaryValue* proxy_type_dict = | 779 base::DictionaryValue* proxy_type_dict = |
780 EnsureDictionaryValue(::onc::network_config::kType, proxy_settings); | 780 EnsureDictionaryValue(::onc::network_config::kType, proxy_settings); |
781 SetProxyEffectiveValue(proxy_type_dict, state, | 781 SetProxyEffectiveValue(proxy_type_dict, state, |
782 base::WrapUnique<base::Value>(new base::StringValue( | 782 base::WrapUnique<base::Value>(new base::Value( |
783 GetProxySettingsType(config.mode)))); | 783 GetProxySettingsType(config.mode)))); |
784 | 784 |
785 // Update any appropriate sub dictionary based on the new type. | 785 // Update any appropriate sub dictionary based on the new type. |
786 switch (config.mode) { | 786 switch (config.mode) { |
787 case UIProxyConfig::MODE_SINGLE_PROXY: { | 787 case UIProxyConfig::MODE_SINGLE_PROXY: { |
788 // Use the same proxy value (config.single_proxy) for all proxies. | 788 // Use the same proxy value (config.single_proxy) for all proxies. |
789 base::DictionaryValue* manual = | 789 base::DictionaryValue* manual = |
790 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); | 790 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); |
791 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.single_proxy); | 791 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.single_proxy); |
792 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.single_proxy); | 792 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.single_proxy); |
793 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.single_proxy); | 793 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.single_proxy); |
794 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.single_proxy); | 794 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.single_proxy); |
795 break; | 795 break; |
796 } | 796 } |
797 case UIProxyConfig::MODE_PROXY_PER_SCHEME: { | 797 case UIProxyConfig::MODE_PROXY_PER_SCHEME: { |
798 base::DictionaryValue* manual = | 798 base::DictionaryValue* manual = |
799 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); | 799 EnsureDictionaryValue(::onc::proxy::kManual, proxy_settings); |
800 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.http_proxy); | 800 SetManualProxy(manual, state, ::onc::proxy::kHttp, config.http_proxy); |
801 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.https_proxy); | 801 SetManualProxy(manual, state, ::onc::proxy::kHttps, config.https_proxy); |
802 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.ftp_proxy); | 802 SetManualProxy(manual, state, ::onc::proxy::kFtp, config.ftp_proxy); |
803 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.socks_proxy); | 803 SetManualProxy(manual, state, ::onc::proxy::kSocks, config.socks_proxy); |
804 break; | 804 break; |
805 } | 805 } |
806 case UIProxyConfig::MODE_PAC_SCRIPT: { | 806 case UIProxyConfig::MODE_PAC_SCRIPT: { |
807 base::DictionaryValue* pac = | 807 base::DictionaryValue* pac = |
808 EnsureDictionaryValue(::onc::proxy::kPAC, proxy_settings); | 808 EnsureDictionaryValue(::onc::proxy::kPAC, proxy_settings); |
809 SetProxyEffectiveValue( | 809 SetProxyEffectiveValue(pac, state, |
810 pac, state, base::WrapUnique<base::Value>(new base::StringValue( | 810 base::WrapUnique<base::Value>(new base::Value( |
811 config.automatic_proxy.pac_url.spec()))); | 811 config.automatic_proxy.pac_url.spec()))); |
812 break; | 812 break; |
813 } | 813 } |
814 case UIProxyConfig::MODE_DIRECT: | 814 case UIProxyConfig::MODE_DIRECT: |
815 case UIProxyConfig::MODE_AUTO_DETECT: | 815 case UIProxyConfig::MODE_AUTO_DETECT: |
816 break; | 816 break; |
817 } | 817 } |
818 | 818 |
819 VLOG(2) << " NEW PROXY: " << *proxy_settings; | 819 VLOG(2) << " NEW PROXY: " << *proxy_settings; |
820 } | 820 } |
821 | 821 |
822 void NetworkingPrivateChromeOS::ConnectFailureCallback( | 822 void NetworkingPrivateChromeOS::ConnectFailureCallback( |
823 const std::string& guid, | 823 const std::string& guid, |
824 const VoidCallback& success_callback, | 824 const VoidCallback& success_callback, |
825 const FailureCallback& failure_callback, | 825 const FailureCallback& failure_callback, |
826 const std::string& error_name, | 826 const std::string& error_name, |
827 std::unique_ptr<base::DictionaryValue> error_data) { | 827 std::unique_ptr<base::DictionaryValue> error_data) { |
828 // TODO(stevenjb): Temporary workaround to show the configuration UI. | 828 // TODO(stevenjb): Temporary workaround to show the configuration UI. |
829 // Eventually the caller (e.g. Settings) should handle any failures and | 829 // Eventually the caller (e.g. Settings) should handle any failures and |
830 // show its own configuration UI. crbug.com/380937. | 830 // show its own configuration UI. crbug.com/380937. |
831 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { | 831 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { |
832 success_callback.Run(); | 832 success_callback.Run(); |
833 return; | 833 return; |
834 } | 834 } |
835 failure_callback.Run(error_name); | 835 failure_callback.Run(error_name); |
836 } | 836 } |
837 | 837 |
838 } // namespace extensions | 838 } // namespace extensions |
OLD | NEW |