Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: chrome/browser/chromeos/options/vpn_config_view.cc

Issue 10377168: cros vpn config: Read UI data from the correct VPN dictionaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/options/vpn_config_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 case chromeos::PROVIDER_TYPE_OPEN_VPN: 44 case chromeos::PROVIDER_TYPE_OPEN_VPN:
45 return l10n_util::GetStringUTF16( 45 return l10n_util::GetStringUTF16(
46 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN); 46 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN);
47 case chromeos::PROVIDER_TYPE_MAX: 47 case chromeos::PROVIDER_TYPE_MAX:
48 break; 48 break;
49 } 49 }
50 NOTREACHED(); 50 NOTREACHED();
51 return string16(); 51 return string16();
52 } 52 }
53 53
54 // Translates the provider type to the name of the respective ONC dictionary
55 // containing configuration data for the type.
56 std::string ProviderTypeToONCDictKey(chromeos::ProviderType type) {
57 switch (type) {
58 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK:
59 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT:
60 return chromeos::onc::vpn::kIPsec;
61 case chromeos::PROVIDER_TYPE_OPEN_VPN:
62 return chromeos::onc::vpn::kOpenVPN;
63 case chromeos::PROVIDER_TYPE_MAX:
64 break;
65 }
66
67 NOTREACHED() << "Unhandled provider type " << type;
68 return std::string();
69 }
70
54 } // namespace 71 } // namespace
55 72
56 namespace chromeos { 73 namespace chromeos {
57 74
58 namespace internal { 75 namespace internal {
59 76
60 class ProviderTypeComboboxModel : public ui::ComboboxModel { 77 class ProviderTypeComboboxModel : public ui::ComboboxModel {
61 public: 78 public:
62 ProviderTypeComboboxModel(); 79 ProviderTypeComboboxModel();
63 virtual ~ProviderTypeComboboxModel(); 80 virtual ~ProviderTypeComboboxModel();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return std::string(); // "None installed" 444 return std::string(); // "None installed"
428 } else { 445 } else {
429 // Certificates are listed in the order they appear in the model. 446 // Certificates are listed in the order they appear in the model.
430 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; 447 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0;
431 return cert_library_->GetUserCertificates().GetPkcs11IdAt(index); 448 return cert_library_->GetUserCertificates().GetPkcs11IdAt(index);
432 } 449 }
433 } 450 }
434 451
435 void VPNConfigView::Init(VirtualNetwork* vpn) { 452 void VPNConfigView::Init(VirtualNetwork* vpn) {
436 if (vpn) { 453 if (vpn) {
437 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, onc::vpn::kServerCARef); 454 ProviderType type = vpn->provider_type();
438 ParseVPNUIProperty(&psk_passphrase_ui_data_, vpn, onc::vpn::kPSK); 455 std::string type_dict_name = ProviderTypeToONCDictKey(type);
439 ParseVPNUIProperty(&user_cert_ui_data_, vpn, onc::vpn::kClientCertRef); 456 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name,
440 ParseVPNUIProperty(&username_ui_data_, vpn, onc::vpn::kUsername); 457 onc::vpn::kServerCARef);
441 ParseVPNUIProperty(&user_passphrase_ui_data_, vpn, onc::vpn::kPassword); 458 ParseVPNUIProperty(&psk_passphrase_ui_data_, vpn, type_dict_name,
442 ParseVPNUIProperty(&group_name_ui_data_, vpn, onc::vpn::kGroup); 459 onc::vpn::kPSK);
460 ParseVPNUIProperty(&user_cert_ui_data_, vpn, type_dict_name,
461 onc::vpn::kClientCertRef);
462 ParseVPNUIProperty(&group_name_ui_data_, vpn, type_dict_name,
463 onc::vpn::kGroup);
464
465 const std::string credentials_dict_name(
466 type == PROVIDER_TYPE_L2TP_IPSEC_PSK ?
467 onc::vpn::kL2TP : type_dict_name);
468 ParseVPNUIProperty(&username_ui_data_, vpn, credentials_dict_name,
469 onc::vpn::kUsername);
470 ParseVPNUIProperty(&user_passphrase_ui_data_, vpn, credentials_dict_name,
471 onc::vpn::kPassword);
443 } 472 }
444 473
445 views::GridLayout* layout = views::GridLayout::CreatePanel(this); 474 views::GridLayout* layout = views::GridLayout::CreatePanel(this);
446 SetLayoutManager(layout); 475 SetLayoutManager(layout);
447 476
448 // VPN may require certificates, so always set the library and observe. 477 // VPN may require certificates, so always set the library and observe.
449 cert_library_ = CrosLibrary::Get()->GetCertLibrary(); 478 cert_library_ = CrosLibrary::Get()->GetCertLibrary();
450 479
451 // Setup a callback if certificates are yet to be loaded. 480 // Setup a callback if certificates are yet to be loaded.
452 if (!cert_library_->CertificatesLoaded()) 481 if (!cert_library_->CertificatesLoaded())
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 875
847 const std::string VPNConfigView::GetPassphraseFromField( 876 const std::string VPNConfigView::GetPassphraseFromField(
848 PassphraseTextfield* textfield) const { 877 PassphraseTextfield* textfield) const {
849 if (!textfield) 878 if (!textfield)
850 return std::string(); 879 return std::string();
851 return textfield->GetPassphrase(); 880 return textfield->GetPassphrase();
852 } 881 }
853 882
854 void VPNConfigView::ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data, 883 void VPNConfigView::ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data,
855 Network* network, 884 Network* network,
885 const std::string& dict_key,
856 const std::string& key) { 886 const std::string& key) {
857 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); 887 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
858 const base::DictionaryValue* onc = 888 const base::DictionaryValue* onc =
859 network_library->FindOncForNetwork(network->unique_id()); 889 network_library->FindOncForNetwork(network->unique_id());
860 890
861 base::DictionaryValue* vpn_dict = NULL;
862 if (!onc || !onc->GetDictionary(onc::kVPN, &vpn_dict))
863 return;
864
865 std::string vpn_type;
866 if (!vpn_dict || !vpn_dict->GetString(onc::kType, &vpn_type))
867 return;
868
869 property_ui_data->ParseOncProperty( 891 property_ui_data->ParseOncProperty(
870 network->ui_data(), onc, 892 network->ui_data(), onc,
871 base::StringPrintf("%s.%s.%s", onc::kVPN, vpn_type.c_str(), key.c_str())); 893 base::StringPrintf("%s.%s.%s", onc::kVPN, dict_key.c_str(), key.c_str()));
872 } 894 }
873 895
874 } // namespace chromeos 896 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/vpn_config_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698