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/chromeos/options/vpn_config_view.h" | 5 #include "chrome/browser/chromeos/options/vpn_config_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 VPNConfigView::VPNConfigView(NetworkConfigView* parent, | 222 VPNConfigView::VPNConfigView(NetworkConfigView* parent, |
223 const std::string& service_path) | 223 const std::string& service_path) |
224 : ChildNetworkConfigView(parent, service_path), | 224 : ChildNetworkConfigView(parent, service_path), |
225 service_text_modified_(false), | 225 service_text_modified_(false), |
226 enable_psk_passphrase_(false), | 226 enable_psk_passphrase_(false), |
227 enable_user_cert_(false), | 227 enable_user_cert_(false), |
228 enable_server_ca_cert_(false), | 228 enable_server_ca_cert_(false), |
229 enable_otp_(false), | 229 enable_otp_(false), |
230 enable_group_name_(false), | 230 enable_group_name_(false), |
| 231 user_passphrase_required_(false), |
231 title_(0), | 232 title_(0), |
232 layout_(NULL), | 233 layout_(NULL), |
233 server_textfield_(NULL), | 234 server_textfield_(NULL), |
234 service_text_(NULL), | 235 service_text_(NULL), |
235 service_textfield_(NULL), | 236 service_textfield_(NULL), |
236 provider_type_combobox_(NULL), | 237 provider_type_combobox_(NULL), |
237 provider_type_text_label_(NULL), | 238 provider_type_text_label_(NULL), |
238 psk_passphrase_label_(NULL), | 239 psk_passphrase_label_(NULL), |
239 psk_passphrase_textfield_(NULL), | 240 psk_passphrase_textfield_(NULL), |
240 user_cert_label_(NULL), | 241 user_cert_label_(NULL), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return service_textfield_; | 274 return service_textfield_; |
274 else if (provider_type_combobox_) | 275 else if (provider_type_combobox_) |
275 return provider_type_combobox_; | 276 return provider_type_combobox_; |
276 else if (psk_passphrase_textfield_ && psk_passphrase_textfield_->enabled()) | 277 else if (psk_passphrase_textfield_ && psk_passphrase_textfield_->enabled()) |
277 return psk_passphrase_textfield_; | 278 return psk_passphrase_textfield_; |
278 else if (user_cert_combobox_ && user_cert_combobox_->enabled()) | 279 else if (user_cert_combobox_ && user_cert_combobox_->enabled()) |
279 return user_cert_combobox_; | 280 return user_cert_combobox_; |
280 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->enabled()) | 281 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->enabled()) |
281 return server_ca_cert_combobox_; | 282 return server_ca_cert_combobox_; |
282 } | 283 } |
283 if (user_passphrase_textfield_) | 284 if (user_passphrase_textfield_ && user_passphrase_required_) |
284 return user_passphrase_textfield_; | 285 return user_passphrase_textfield_; |
285 else if (otp_textfield_) | 286 else if (otp_textfield_) |
286 return otp_textfield_; | 287 return otp_textfield_; |
287 return NULL; | 288 return NULL; |
288 } | 289 } |
289 | 290 |
290 bool VPNConfigView::CanLogin() { | 291 bool VPNConfigView::CanLogin() { |
291 // Username is always required. | 292 // Username is always required. |
292 if (GetUsername().empty()) | 293 if (GetUsername().empty()) |
293 return false; | 294 return false; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 const base::DictionaryValue& service_properties) { | 707 const base::DictionaryValue& service_properties) { |
707 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> | 708 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
708 GetNetworkState(service_path); | 709 GetNetworkState(service_path); |
709 if (!vpn) { | 710 if (!vpn) { |
710 NET_LOG_ERROR("Shill Error getting properties VpnConfigView", service_path); | 711 NET_LOG_ERROR("Shill Error getting properties VpnConfigView", service_path); |
711 return; | 712 return; |
712 } | 713 } |
713 | 714 |
714 std::string provider_type, server_hostname, username, group_name; | 715 std::string provider_type, server_hostname, username, group_name; |
715 bool psk_passphrase_required = false; | 716 bool psk_passphrase_required = false; |
716 bool user_passphrase_required = true; | 717 user_passphrase_required_ = true; |
717 const base::DictionaryValue* provider_properties; | 718 const base::DictionaryValue* provider_properties; |
718 if (service_properties.GetDictionaryWithoutPathExpansion( | 719 if (service_properties.GetDictionaryWithoutPathExpansion( |
719 shill::kProviderProperty, &provider_properties)) { | 720 shill::kProviderProperty, &provider_properties)) { |
720 provider_properties->GetStringWithoutPathExpansion( | 721 provider_properties->GetStringWithoutPathExpansion( |
721 shill::kTypeProperty, &provider_type); | 722 shill::kTypeProperty, &provider_type); |
722 provider_properties->GetStringWithoutPathExpansion( | 723 provider_properties->GetStringWithoutPathExpansion( |
723 shill::kHostProperty, &server_hostname); | 724 shill::kHostProperty, &server_hostname); |
724 if (provider_type == shill::kProviderL2tpIpsec) { | 725 if (provider_type == shill::kProviderL2tpIpsec) { |
725 provider_properties->GetStringWithoutPathExpansion( | 726 provider_properties->GetStringWithoutPathExpansion( |
726 shill::kL2tpIpsecClientCertIdProperty, &client_cert_id_); | 727 shill::kL2tpIpsecClientCertIdProperty, &client_cert_id_); |
727 ca_cert_pem_ = GetPemFromDictionary( | 728 ca_cert_pem_ = GetPemFromDictionary( |
728 provider_properties, shill::kL2tpIpsecCaCertPemProperty); | 729 provider_properties, shill::kL2tpIpsecCaCertPemProperty); |
729 provider_properties->GetBooleanWithoutPathExpansion( | 730 provider_properties->GetBooleanWithoutPathExpansion( |
730 shill::kL2tpIpsecPskRequiredProperty, &psk_passphrase_required); | 731 shill::kL2tpIpsecPskRequiredProperty, &psk_passphrase_required); |
731 provider_properties->GetStringWithoutPathExpansion( | 732 provider_properties->GetStringWithoutPathExpansion( |
732 shill::kL2tpIpsecUserProperty, &username); | 733 shill::kL2tpIpsecUserProperty, &username); |
733 provider_properties->GetStringWithoutPathExpansion( | 734 provider_properties->GetStringWithoutPathExpansion( |
734 shill::kL2tpIpsecTunnelGroupProperty, &group_name); | 735 shill::kL2tpIpsecTunnelGroupProperty, &group_name); |
735 } else if (provider_type == shill::kProviderOpenVpn) { | 736 } else if (provider_type == shill::kProviderOpenVpn) { |
736 provider_properties->GetStringWithoutPathExpansion( | 737 provider_properties->GetStringWithoutPathExpansion( |
737 shill::kOpenVPNClientCertIdProperty, &client_cert_id_); | 738 shill::kOpenVPNClientCertIdProperty, &client_cert_id_); |
738 ca_cert_pem_ = GetPemFromDictionary( | 739 ca_cert_pem_ = GetPemFromDictionary( |
739 provider_properties, shill::kOpenVPNCaCertPemProperty); | 740 provider_properties, shill::kOpenVPNCaCertPemProperty); |
740 provider_properties->GetStringWithoutPathExpansion( | 741 provider_properties->GetStringWithoutPathExpansion( |
741 shill::kOpenVPNUserProperty, &username); | 742 shill::kOpenVPNUserProperty, &username); |
742 provider_properties->GetBooleanWithoutPathExpansion( | 743 provider_properties->GetBooleanWithoutPathExpansion( |
743 shill::kPassphraseRequiredProperty, &user_passphrase_required); | 744 shill::kPassphraseRequiredProperty, &user_passphrase_required_); |
744 } | 745 } |
745 } | 746 } |
746 bool save_credentials = false; | 747 bool save_credentials = false; |
747 service_properties.GetBooleanWithoutPathExpansion( | 748 service_properties.GetBooleanWithoutPathExpansion( |
748 shill::kSaveCredentialsProperty, &save_credentials); | 749 shill::kSaveCredentialsProperty, &save_credentials); |
749 | 750 |
750 provider_type_index_ = ProviderTypeToIndex(provider_type, client_cert_id_); | 751 provider_type_index_ = ProviderTypeToIndex(provider_type, client_cert_id_); |
751 | 752 |
752 if (service_text_) | 753 if (service_text_) |
753 service_text_->SetText(base::ASCIIToUTF16(vpn->name())); | 754 service_text_->SetText(base::ASCIIToUTF16(vpn->name())); |
754 if (provider_type_text_label_) | 755 if (provider_type_text_label_) |
755 provider_type_text_label_->SetText( | 756 provider_type_text_label_->SetText( |
756 ProviderTypeIndexToString(provider_type_index_)); | 757 ProviderTypeIndexToString(provider_type_index_)); |
757 | 758 |
758 if (server_textfield_ && !server_hostname.empty()) | 759 if (server_textfield_ && !server_hostname.empty()) |
759 server_textfield_->SetText(base::UTF8ToUTF16(server_hostname)); | 760 server_textfield_->SetText(base::UTF8ToUTF16(server_hostname)); |
760 if (username_textfield_ && !username.empty()) | 761 if (username_textfield_ && !username.empty()) |
761 username_textfield_->SetText(base::UTF8ToUTF16(username)); | 762 username_textfield_->SetText(base::UTF8ToUTF16(username)); |
762 if (group_name_textfield_ && !group_name.empty()) | 763 if (group_name_textfield_ && !group_name.empty()) |
763 group_name_textfield_->SetText(base::UTF8ToUTF16(group_name)); | 764 group_name_textfield_->SetText(base::UTF8ToUTF16(group_name)); |
764 if (psk_passphrase_textfield_) | 765 if (psk_passphrase_textfield_) |
765 psk_passphrase_textfield_->SetShowFake(!psk_passphrase_required); | 766 psk_passphrase_textfield_->SetShowFake(!psk_passphrase_required); |
766 if (user_passphrase_textfield_) | 767 if (user_passphrase_textfield_) |
767 user_passphrase_textfield_->SetShowFake(!user_passphrase_required); | 768 user_passphrase_textfield_->SetShowFake(!user_passphrase_required_); |
768 if (save_credentials_checkbox_) | 769 if (save_credentials_checkbox_) |
769 save_credentials_checkbox_->SetChecked(save_credentials); | 770 save_credentials_checkbox_->SetChecked(save_credentials); |
770 | 771 |
771 Refresh(); | 772 Refresh(); |
772 UpdateCanLogin(); | 773 UpdateCanLogin(); |
773 } | 774 } |
774 | 775 |
775 void VPNConfigView::ParseUIProperties(const NetworkState* vpn) { | 776 void VPNConfigView::ParseUIProperties(const NetworkState* vpn) { |
776 std::string type_dict_name = | 777 std::string type_dict_name = |
777 ProviderTypeIndexToONCDictKey(provider_type_index_); | 778 ProviderTypeIndexToONCDictKey(provider_type_index_); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 property_ui_data->ParseOncProperty( | 1065 property_ui_data->ParseOncProperty( |
1065 onc_source, | 1066 onc_source, |
1066 onc, | 1067 onc, |
1067 base::StringPrintf("%s.%s.%s", | 1068 base::StringPrintf("%s.%s.%s", |
1068 ::onc::network_config::kVPN, | 1069 ::onc::network_config::kVPN, |
1069 dict_key.c_str(), | 1070 dict_key.c_str(), |
1070 key.c_str())); | 1071 key.c_str())); |
1071 } | 1072 } |
1072 | 1073 |
1073 } // namespace chromeos | 1074 } // namespace chromeos |
OLD | NEW |