| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual string16 GetItemAt(int combo_index) { | 80 virtual string16 GetItemAt(int combo_index) { |
| 81 if (!cert_library_->CertificatesLoaded()) | 81 if (!cert_library_->CertificatesLoaded()) |
| 82 return l10n_util::GetStringUTF16( | 82 return l10n_util::GetStringUTF16( |
| 83 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 83 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
| 84 if (combo_index == 0) | 84 if (combo_index == 0) |
| 85 return l10n_util::GetStringUTF16( | 85 return l10n_util::GetStringUTF16( |
| 86 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); | 86 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); |
| 87 int cert_index = combo_index - 1; | 87 int cert_index = combo_index - 1; |
| 88 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); | 88 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); |
| 89 } | 89 } |
| 90 |
| 90 private: | 91 private: |
| 91 CertLibrary* cert_library_; | 92 CertLibrary* cert_library_; |
| 92 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); | 93 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 class UserCertComboboxModel : public ui::ComboboxModel { | 96 class UserCertComboboxModel : public ui::ComboboxModel { |
| 96 public: | 97 public: |
| 97 explicit UserCertComboboxModel(CertLibrary* cert_library) | 98 explicit UserCertComboboxModel(CertLibrary* cert_library) |
| 98 : cert_library_(cert_library) { | 99 : cert_library_(cert_library) { |
| 99 } | 100 } |
| 100 virtual ~UserCertComboboxModel() {} | 101 virtual ~UserCertComboboxModel() {} |
| 101 virtual int GetItemCount() { | 102 virtual int GetItemCount() { |
| 102 if (!cert_library_->CertificatesLoaded()) | 103 if (!cert_library_->CertificatesLoaded()) |
| 103 return 1; // "Loading" | 104 return 1; // "Loading" |
| 104 int num_certs = cert_library_->GetUserCertificates().Size(); | 105 int num_certs = cert_library_->GetUserCertificates().Size(); |
| 105 if (num_certs == 0) | 106 if (num_certs == 0) |
| 106 return 1; // "None installed" | 107 return 1; // "None installed" |
| 107 return num_certs; | 108 return num_certs; |
| 108 } | 109 } |
| 109 virtual string16 GetItemAt(int combo_index) { | 110 virtual string16 GetItemAt(int combo_index) { |
| 110 if (!cert_library_->CertificatesLoaded()) | 111 if (!cert_library_->CertificatesLoaded()) |
| 111 return l10n_util::GetStringUTF16( | 112 return l10n_util::GetStringUTF16( |
| 112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 113 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
| 113 if (cert_library_->GetUserCertificates().Size() == 0) | 114 if (cert_library_->GetUserCertificates().Size() == 0) |
| 114 return l10n_util::GetStringUTF16( | 115 return l10n_util::GetStringUTF16( |
| 115 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 116 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
| 116 return cert_library_->GetUserCertificates().GetDisplayStringAt(combo_index); | 117 return cert_library_->GetUserCertificates().GetDisplayStringAt(combo_index); |
| 117 } | 118 } |
| 119 |
| 118 private: | 120 private: |
| 119 CertLibrary* cert_library_; | 121 CertLibrary* cert_library_; |
| 120 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel); | 122 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel); |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) | 125 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) |
| 124 : ChildNetworkConfigView(parent, vpn), | 126 : ChildNetworkConfigView(parent, vpn), |
| 125 cert_library_(NULL) { | 127 cert_library_(NULL) { |
| 126 Init(vpn); | 128 Init(vpn); |
| 127 } | 129 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 339 |
| 338 const std::string VPNConfigView::GetServerCACertNssNickname() const { | 340 const std::string VPNConfigView::GetServerCACertNssNickname() const { |
| 339 DCHECK(server_ca_cert_combobox_); | 341 DCHECK(server_ca_cert_combobox_); |
| 340 DCHECK(cert_library_); | 342 DCHECK(cert_library_); |
| 341 int selected = server_ca_cert_combobox_->selected_item(); | 343 int selected = server_ca_cert_combobox_->selected_item(); |
| 342 if (selected == 0) { | 344 if (selected == 0) { |
| 343 // First item is "Default". | 345 // First item is "Default". |
| 344 return std::string(); | 346 return std::string(); |
| 345 } else { | 347 } else { |
| 346 DCHECK(cert_library_); | 348 DCHECK(cert_library_); |
| 347 DCHECK(cert_library_->GetCACertificates().Size() > 0); | 349 DCHECK_GT(cert_library_->GetCACertificates().Size(), 0); |
| 348 int cert_index = selected - 1; | 350 int cert_index = selected - 1; |
| 349 return cert_library_->GetCACertificates().GetNicknameAt(cert_index); | 351 return cert_library_->GetCACertificates().GetNicknameAt(cert_index); |
| 350 } | 352 } |
| 351 } | 353 } |
| 352 | 354 |
| 353 const std::string VPNConfigView::GetUserCertID() const { | 355 const std::string VPNConfigView::GetUserCertID() const { |
| 354 DCHECK(user_cert_combobox_); | 356 DCHECK(user_cert_combobox_); |
| 355 DCHECK(cert_library_); | 357 DCHECK(cert_library_); |
| 356 if (!HaveUserCerts()) { | 358 if (!HaveUserCerts()) { |
| 357 return std::string(); // "None installed" | 359 return std::string(); // "None installed" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 384 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); | 386 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); |
| 385 | 387 |
| 386 // Initialize members. | 388 // Initialize members. |
| 387 service_text_modified_ = false; | 389 service_text_modified_ = false; |
| 388 provider_type_ = vpn ? | 390 provider_type_ = vpn ? |
| 389 vpn->provider_type() : | 391 vpn->provider_type() : |
| 390 chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK; | 392 chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK; |
| 391 | 393 |
| 392 // Server label and input. | 394 // Server label and input. |
| 393 layout->StartRow(0, column_view_set_id); | 395 layout->StartRow(0, column_view_set_id); |
| 394 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 396 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 395 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME)))); | 397 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME))); |
| 396 if (!vpn) { | 398 if (!vpn) { |
| 397 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 399 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
| 398 server_textfield_->SetController(this); | 400 server_textfield_->SetController(this); |
| 399 layout->AddView(server_textfield_); | 401 layout->AddView(server_textfield_); |
| 400 server_text_ = NULL; | 402 server_text_ = NULL; |
| 401 } else { | 403 } else { |
| 402 server_hostname_ = vpn->server_hostname(); | 404 server_hostname_ = vpn->server_hostname(); |
| 403 server_text_ = new views::Label(UTF8ToWide(server_hostname_)); | 405 server_text_ = new views::Label(UTF8ToUTF16(server_hostname_)); |
| 404 server_text_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 406 server_text_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 405 layout->AddView(server_text_); | 407 layout->AddView(server_text_); |
| 406 server_textfield_ = NULL; | 408 server_textfield_ = NULL; |
| 407 } | 409 } |
| 408 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 410 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 409 | 411 |
| 410 // Service label and name or input. | 412 // Service label and name or input. |
| 411 layout->StartRow(0, column_view_set_id); | 413 layout->StartRow(0, column_view_set_id); |
| 412 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 414 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 413 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME)))); | 415 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME))); |
| 414 if (!vpn) { | 416 if (!vpn) { |
| 415 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 417 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
| 416 service_textfield_->SetController(this); | 418 service_textfield_->SetController(this); |
| 417 layout->AddView(service_textfield_); | 419 layout->AddView(service_textfield_); |
| 418 service_text_ = NULL; | 420 service_text_ = NULL; |
| 419 } else { | 421 } else { |
| 420 service_text_ = new views::Label(ASCIIToWide(vpn->name())); | 422 service_text_ = new views::Label(ASCIIToUTF16(vpn->name())); |
| 421 service_text_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 423 service_text_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 422 layout->AddView(service_text_); | 424 layout->AddView(service_text_); |
| 423 service_textfield_ = NULL; | 425 service_textfield_ = NULL; |
| 424 } | 426 } |
| 425 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 427 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 426 | 428 |
| 427 // Provider type label and select. | 429 // Provider type label and select. |
| 428 layout->StartRow(0, column_view_set_id); | 430 layout->StartRow(0, column_view_set_id); |
| 429 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 431 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 430 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE)))); | 432 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE))); |
| 431 if (!vpn) { | 433 if (!vpn) { |
| 432 provider_type_combobox_ = | 434 provider_type_combobox_ = |
| 433 new views::Combobox(new ProviderTypeComboboxModel()); | 435 new views::Combobox(new ProviderTypeComboboxModel()); |
| 434 provider_type_combobox_->set_listener(this); | 436 provider_type_combobox_->set_listener(this); |
| 435 layout->AddView(provider_type_combobox_); | 437 layout->AddView(provider_type_combobox_); |
| 436 provider_type_text_label_ = NULL; | 438 provider_type_text_label_ = NULL; |
| 437 } else { | 439 } else { |
| 438 provider_type_text_label_ = | 440 provider_type_text_label_ = |
| 439 new views::Label(UTF16ToWide(ProviderTypeToString(provider_type_))); | 441 new views::Label(ProviderTypeToString(provider_type_)); |
| 440 provider_type_text_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 442 provider_type_text_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 441 layout->AddView(provider_type_text_label_); | 443 layout->AddView(provider_type_text_label_); |
| 442 provider_type_combobox_ = NULL; | 444 provider_type_combobox_ = NULL; |
| 443 } | 445 } |
| 444 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 446 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 445 | 447 |
| 446 // PSK passphrase label, input and visible button. | 448 // PSK passphrase label, input and visible button. |
| 447 layout->StartRow(0, column_view_set_id); | 449 layout->StartRow(0, column_view_set_id); |
| 448 psk_passphrase_label_ = new views::Label(UTF16ToWide( | 450 psk_passphrase_label_ = new views::Label(l10n_util::GetStringUTF16( |
| 449 l10n_util::GetStringUTF16( | 451 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE)); |
| 450 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE))); | |
| 451 layout->AddView(psk_passphrase_label_); | 452 layout->AddView(psk_passphrase_label_); |
| 452 psk_passphrase_textfield_ = new views::Textfield( | 453 psk_passphrase_textfield_ = new views::Textfield( |
| 453 views::Textfield::STYLE_PASSWORD); | 454 views::Textfield::STYLE_PASSWORD); |
| 454 psk_passphrase_textfield_->SetController(this); | 455 psk_passphrase_textfield_->SetController(this); |
| 455 if (vpn && !vpn->psk_passphrase().empty()) | 456 if (vpn && !vpn->psk_passphrase().empty()) |
| 456 psk_passphrase_textfield_->SetText(UTF8ToUTF16(vpn->psk_passphrase())); | 457 psk_passphrase_textfield_->SetText(UTF8ToUTF16(vpn->psk_passphrase())); |
| 457 layout->AddView(psk_passphrase_textfield_); | 458 layout->AddView(psk_passphrase_textfield_); |
| 458 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 459 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 459 | 460 |
| 460 // Server CA certificate | 461 // Server CA certificate |
| 461 layout->StartRow(0, column_view_set_id); | 462 layout->StartRow(0, column_view_set_id); |
| 462 server_ca_cert_label_ = | 463 server_ca_cert_label_ = |
| 463 new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 464 new views::Label(l10n_util::GetStringUTF16( |
| 464 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA))); | 465 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA)); |
| 465 layout->AddView(server_ca_cert_label_); | 466 layout->AddView(server_ca_cert_label_); |
| 466 ServerCACertComboboxModel* server_ca_cert_model = | 467 ServerCACertComboboxModel* server_ca_cert_model = |
| 467 new ServerCACertComboboxModel(cert_library_); | 468 new ServerCACertComboboxModel(cert_library_); |
| 468 server_ca_cert_combobox_ = new views::Combobox(server_ca_cert_model); | 469 server_ca_cert_combobox_ = new views::Combobox(server_ca_cert_model); |
| 469 layout->AddView(server_ca_cert_combobox_); | 470 layout->AddView(server_ca_cert_combobox_); |
| 470 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 471 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 471 | 472 |
| 472 // User certificate label and input. | 473 // User certificate label and input. |
| 473 layout->StartRow(0, column_view_set_id); | 474 layout->StartRow(0, column_view_set_id); |
| 474 user_cert_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 475 user_cert_label_ = new views::Label(l10n_util::GetStringUTF16( |
| 475 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT))); | 476 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT)); |
| 476 layout->AddView(user_cert_label_); | 477 layout->AddView(user_cert_label_); |
| 477 UserCertComboboxModel* user_cert_model = | 478 UserCertComboboxModel* user_cert_model = |
| 478 new UserCertComboboxModel(cert_library_); | 479 new UserCertComboboxModel(cert_library_); |
| 479 user_cert_combobox_ = new views::Combobox(user_cert_model); | 480 user_cert_combobox_ = new views::Combobox(user_cert_model); |
| 480 user_cert_combobox_->set_listener(this); | 481 user_cert_combobox_->set_listener(this); |
| 481 layout->AddView(user_cert_combobox_); | 482 layout->AddView(user_cert_combobox_); |
| 482 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 483 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 483 | 484 |
| 484 // Username label and input. | 485 // Username label and input. |
| 485 layout->StartRow(0, column_view_set_id); | 486 layout->StartRow(0, column_view_set_id); |
| 486 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 487 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 487 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME)))); | 488 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME))); |
| 488 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 489 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
| 489 username_textfield_->SetController(this); | 490 username_textfield_->SetController(this); |
| 490 if (vpn && !vpn->username().empty()) | 491 if (vpn && !vpn->username().empty()) |
| 491 username_textfield_->SetText(UTF8ToUTF16(vpn->username())); | 492 username_textfield_->SetText(UTF8ToUTF16(vpn->username())); |
| 492 layout->AddView(username_textfield_); | 493 layout->AddView(username_textfield_); |
| 493 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 494 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 494 | 495 |
| 495 // User passphrase label, input and visble button. | 496 // User passphrase label, input and visble button. |
| 496 layout->StartRow(0, column_view_set_id); | 497 layout->StartRow(0, column_view_set_id); |
| 497 layout->AddView(new views::Label(UTF16ToWide( | 498 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 498 l10n_util::GetStringUTF16( | 499 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE))); |
| 499 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE)))); | |
| 500 user_passphrase_textfield_ = new views::Textfield( | 500 user_passphrase_textfield_ = new views::Textfield( |
| 501 views::Textfield::STYLE_PASSWORD); | 501 views::Textfield::STYLE_PASSWORD); |
| 502 user_passphrase_textfield_->SetController(this); | 502 user_passphrase_textfield_->SetController(this); |
| 503 if (vpn && !vpn->user_passphrase().empty()) | 503 if (vpn && !vpn->user_passphrase().empty()) |
| 504 user_passphrase_textfield_->SetText(UTF8ToUTF16(vpn->user_passphrase())); | 504 user_passphrase_textfield_->SetText(UTF8ToUTF16(vpn->user_passphrase())); |
| 505 layout->AddView(user_passphrase_textfield_); | 505 layout->AddView(user_passphrase_textfield_); |
| 506 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 506 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 507 | 507 |
| 508 // OTP label and input. | 508 // OTP label and input. |
| 509 layout->StartRow(0, column_view_set_id); | 509 layout->StartRow(0, column_view_set_id); |
| 510 otp_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 510 otp_label_ = new views::Label(l10n_util::GetStringUTF16( |
| 511 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP))); | 511 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP)); |
| 512 layout->AddView(otp_label_); | 512 layout->AddView(otp_label_); |
| 513 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 513 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
| 514 otp_textfield_->SetController(this); | 514 otp_textfield_->SetController(this); |
| 515 layout->AddView(otp_textfield_); | 515 layout->AddView(otp_textfield_); |
| 516 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 516 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 517 | 517 |
| 518 // This is not currently implemented with no immediate plans to do so. | 518 // This is not currently implemented with no immediate plans to do so. |
| 519 // TODO(stevenjb,kmixter): Set true if we implement this. | 519 // TODO(stevenjb,kmixter): Set true if we implement this. |
| 520 // See http://crosbug.com/19252. | 520 // See http://crosbug.com/19252. |
| 521 const bool show_group_name = false; | 521 const bool show_group_name = false; |
| 522 | 522 |
| 523 // Group Name label and input. | 523 // Group Name label and input. |
| 524 if (show_group_name) { | 524 if (show_group_name) { |
| 525 layout->StartRow(0, column_view_set_id); | 525 layout->StartRow(0, column_view_set_id); |
| 526 group_name_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 526 group_name_label_ = new views::Label(l10n_util::GetStringUTF16( |
| 527 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME))); | 527 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME)); |
| 528 layout->AddView(group_name_label_); | 528 layout->AddView(group_name_label_); |
| 529 group_name_textfield_ = | 529 group_name_textfield_ = |
| 530 new views::Textfield(views::Textfield::STYLE_DEFAULT); | 530 new views::Textfield(views::Textfield::STYLE_DEFAULT); |
| 531 group_name_textfield_->SetController(this); | 531 group_name_textfield_->SetController(this); |
| 532 if (vpn && !vpn->group_name().empty()) | 532 if (vpn && !vpn->group_name().empty()) |
| 533 group_name_textfield_->SetText(UTF8ToUTF16(vpn->group_name())); | 533 group_name_textfield_->SetText(UTF8ToUTF16(vpn->group_name())); |
| 534 layout->AddView(group_name_textfield_); | 534 layout->AddView(group_name_textfield_); |
| 535 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 535 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 536 } else { | 536 } else { |
| 537 group_name_label_ = NULL; | 537 group_name_label_ = NULL; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 632 |
| 633 if (otp_label_) | 633 if (otp_label_) |
| 634 otp_label_->SetEnabled(enable_otp); | 634 otp_label_->SetEnabled(enable_otp); |
| 635 if (otp_textfield_) | 635 if (otp_textfield_) |
| 636 otp_textfield_->SetEnabled(enable_otp); | 636 otp_textfield_->SetEnabled(enable_otp); |
| 637 | 637 |
| 638 if (group_name_label_) | 638 if (group_name_label_) |
| 639 group_name_label_->SetEnabled(enable_group_name); | 639 group_name_label_->SetEnabled(enable_group_name); |
| 640 if (group_name_textfield_) | 640 if (group_name_textfield_) |
| 641 group_name_textfield_->SetEnabled(enable_group_name); | 641 group_name_textfield_->SetEnabled(enable_group_name); |
| 642 | |
| 643 } | 642 } |
| 644 | 643 |
| 645 void VPNConfigView::UpdateErrorLabel() { | 644 void VPNConfigView::UpdateErrorLabel() { |
| 646 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 645 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 647 | 646 |
| 648 // Error message. | 647 // Error message. |
| 649 std::string error_msg; | 648 std::string error_msg; |
| 650 if (UserCertRequired() && cert_library_->CertificatesLoaded()) { | 649 if (UserCertRequired() && cert_library_->CertificatesLoaded()) { |
| 651 if (!HaveUserCerts()) { | 650 if (!HaveUserCerts()) { |
| 652 error_msg = l10n_util::GetStringUTF8( | 651 error_msg = l10n_util::GetStringUTF8( |
| 653 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); | 652 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); |
| 654 } else if (!IsUserCertValid()) { | 653 } else if (!IsUserCertValid()) { |
| 655 error_msg = l10n_util::GetStringUTF8( | 654 error_msg = l10n_util::GetStringUTF8( |
| 656 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 655 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
| 657 } | 656 } |
| 658 } | 657 } |
| 659 if (error_msg.empty() && !service_path_.empty()) { | 658 if (error_msg.empty() && !service_path_.empty()) { |
| 660 // TODO(kuan): differentiate between bad psk and user passphrases. | 659 // TODO(kuan): differentiate between bad psk and user passphrases. |
| 661 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | 660 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); |
| 662 if (vpn && vpn->failed()) { | 661 if (vpn && vpn->failed()) { |
| 663 if (vpn->error() == ERROR_BAD_PASSPHRASE) { | 662 if (vpn->error() == ERROR_BAD_PASSPHRASE) { |
| 664 error_msg = l10n_util::GetStringUTF8( | 663 error_msg = l10n_util::GetStringUTF8( |
| 665 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); | 664 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); |
| 666 } else { | 665 } else { |
| 667 error_msg = vpn->GetErrorString(); | 666 error_msg = vpn->GetErrorString(); |
| 668 } | 667 } |
| 669 } | 668 } |
| 670 } | 669 } |
| 671 if (!error_msg.empty()) { | 670 if (!error_msg.empty()) { |
| 672 error_label_->SetText(UTF8ToWide(error_msg)); | 671 error_label_->SetText(UTF8ToUTF16(error_msg)); |
| 673 error_label_->SetVisible(true); | 672 error_label_->SetVisible(true); |
| 674 } else { | 673 } else { |
| 675 error_label_->SetVisible(false); | 674 error_label_->SetVisible(false); |
| 676 } | 675 } |
| 677 } | 676 } |
| 678 | 677 |
| 679 void VPNConfigView::UpdateCanLogin() { | 678 void VPNConfigView::UpdateCanLogin() { |
| 680 parent_->GetDialogClientView()->UpdateDialogButtons(); | 679 parent_->GetDialogClientView()->UpdateDialogButtons(); |
| 681 } | 680 } |
| 682 | 681 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 708 return std::string(); | 707 return std::string(); |
| 709 std::string untrimmed = UTF16ToUTF8(textfield->text()); | 708 std::string untrimmed = UTF16ToUTF8(textfield->text()); |
| 710 if (!trim_whitespace) | 709 if (!trim_whitespace) |
| 711 return untrimmed; | 710 return untrimmed; |
| 712 std::string result; | 711 std::string result; |
| 713 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); | 712 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); |
| 714 return result; | 713 return result; |
| 715 } | 714 } |
| 716 | 715 |
| 717 } // namespace chromeos | 716 } // namespace chromeos |
| OLD | NEW |