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

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

Issue 8909002: views: Convert IsEnabled() to just enabled() since it's just a simple accessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
OLDNEW
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/common/net/x509_certificate_model.h" 10 #include "chrome/common/net/x509_certificate_model.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 void VPNConfigView::InitFocus() { 292 void VPNConfigView::InitFocus() {
293 // Put focus in the first editable field. 293 // Put focus in the first editable field.
294 if (server_textfield_) 294 if (server_textfield_)
295 server_textfield_->RequestFocus(); 295 server_textfield_->RequestFocus();
296 else if (service_textfield_) 296 else if (service_textfield_)
297 service_textfield_->RequestFocus(); 297 service_textfield_->RequestFocus();
298 else if (provider_type_combobox_) 298 else if (provider_type_combobox_)
299 provider_type_combobox_->RequestFocus(); 299 provider_type_combobox_->RequestFocus();
300 else if (psk_passphrase_textfield_ && psk_passphrase_textfield_->IsEnabled()) 300 else if (psk_passphrase_textfield_ && psk_passphrase_textfield_->enabled())
301 psk_passphrase_textfield_->RequestFocus(); 301 psk_passphrase_textfield_->RequestFocus();
302 else if (user_cert_combobox_ && user_cert_combobox_->IsEnabled()) 302 else if (user_cert_combobox_ && user_cert_combobox_->enabled())
303 user_cert_combobox_->RequestFocus(); 303 user_cert_combobox_->RequestFocus();
304 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->IsEnabled()) 304 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->enabled())
305 server_ca_cert_combobox_->RequestFocus(); 305 server_ca_cert_combobox_->RequestFocus();
306 } 306 }
307 307
308 const std::string VPNConfigView::GetService() const { 308 const std::string VPNConfigView::GetService() const {
309 if (service_textfield_ != NULL) 309 if (service_textfield_ != NULL)
310 return GetTextFromField(service_textfield_, true); 310 return GetTextFromField(service_textfield_, true);
311 return service_path_; 311 return service_path_;
312 } 312 }
313 313
314 const std::string VPNConfigView::GetServer() const { 314 const std::string VPNConfigView::GetServer() const {
315 if (server_textfield_ != NULL) 315 if (server_textfield_ != NULL)
316 return GetTextFromField(server_textfield_, true); 316 return GetTextFromField(server_textfield_, true);
317 return server_hostname_; 317 return server_hostname_;
318 } 318 }
319 319
320 const std::string VPNConfigView::GetPSKPassphrase() const { 320 const std::string VPNConfigView::GetPSKPassphrase() const {
321 if (psk_passphrase_textfield_ && 321 if (psk_passphrase_textfield_ &&
322 psk_passphrase_textfield_->IsEnabled() && 322 psk_passphrase_textfield_->enabled() &&
323 psk_passphrase_textfield_->IsVisible()) 323 psk_passphrase_textfield_->IsVisible())
324 return GetTextFromField(psk_passphrase_textfield_, false); 324 return GetTextFromField(psk_passphrase_textfield_, false);
325 return std::string(); 325 return std::string();
326 } 326 }
327 327
328 const std::string VPNConfigView::GetUsername() const { 328 const std::string VPNConfigView::GetUsername() const {
329 return GetTextFromField(username_textfield_, true); 329 return GetTextFromField(username_textfield_, true);
330 } 330 }
331 331
332 const std::string VPNConfigView::GetUserPassphrase() const { 332 const std::string VPNConfigView::GetUserPassphrase() const {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 614
615 void VPNConfigView::Refresh() { 615 void VPNConfigView::Refresh() {
616 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 616 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
617 617
618 UpdateControls(); 618 UpdateControls();
619 619
620 // Set certificate combo boxes. 620 // Set certificate combo boxes.
621 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); 621 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_);
622 if (server_ca_cert_combobox_) { 622 if (server_ca_cert_combobox_) {
623 server_ca_cert_combobox_->ModelChanged(); 623 server_ca_cert_combobox_->ModelChanged();
624 if (server_ca_cert_combobox_->IsEnabled() && 624 if (server_ca_cert_combobox_->enabled() &&
625 (vpn && !vpn->ca_cert_nss().empty())) { 625 (vpn && !vpn->ca_cert_nss().empty())) {
626 // Select the current server CA certificate in the combobox. 626 // Select the current server CA certificate in the combobox.
627 int cert_index = cert_library_->GetCACertificates().FindCertByNickname( 627 int cert_index = cert_library_->GetCACertificates().FindCertByNickname(
628 vpn->ca_cert_nss()); 628 vpn->ca_cert_nss());
629 if (cert_index >= 0) { 629 if (cert_index >= 0) {
630 // Skip item for "Default" 630 // Skip item for "Default"
631 server_ca_cert_combobox_->SetSelectedItem(1 + cert_index); 631 server_ca_cert_combobox_->SetSelectedItem(1 + cert_index);
632 } else { 632 } else {
633 server_ca_cert_combobox_->SetSelectedItem(0); 633 server_ca_cert_combobox_->SetSelectedItem(0);
634 } 634 }
635 } else { 635 } else {
636 server_ca_cert_combobox_->SetSelectedItem(0); 636 server_ca_cert_combobox_->SetSelectedItem(0);
637 } 637 }
638 } 638 }
639 639
640 if (user_cert_combobox_) { 640 if (user_cert_combobox_) {
641 user_cert_combobox_->ModelChanged(); 641 user_cert_combobox_->ModelChanged();
642 if (user_cert_combobox_->IsEnabled() && 642 if (user_cert_combobox_->enabled() &&
643 (vpn && !vpn->client_cert_id().empty())) { 643 (vpn && !vpn->client_cert_id().empty())) {
644 int cert_index = cert_library_->GetUserCertificates().FindCertByPkcs11Id( 644 int cert_index = cert_library_->GetUserCertificates().FindCertByPkcs11Id(
645 vpn->client_cert_id()); 645 vpn->client_cert_id());
646 if (cert_index >= 0) 646 if (cert_index >= 0)
647 user_cert_combobox_->SetSelectedItem(cert_index); 647 user_cert_combobox_->SetSelectedItem(cert_index);
648 else 648 else
649 user_cert_combobox_->SetSelectedItem(0); 649 user_cert_combobox_->SetSelectedItem(0);
650 } else { 650 } else {
651 user_cert_combobox_->SetSelectedItem(0); 651 user_cert_combobox_->SetSelectedItem(0);
652 } 652 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 bool VPNConfigView::UserCertRequired() const { 757 bool VPNConfigView::UserCertRequired() const {
758 return provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_USER_CERT 758 return provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_USER_CERT
759 || provider_type_ == PROVIDER_TYPE_OPEN_VPN; 759 || provider_type_ == PROVIDER_TYPE_OPEN_VPN;
760 } 760 }
761 761
762 bool VPNConfigView::HaveUserCerts() const { 762 bool VPNConfigView::HaveUserCerts() const {
763 return cert_library_->GetUserCertificates().Size() > 0; 763 return cert_library_->GetUserCertificates().Size() > 0;
764 } 764 }
765 765
766 bool VPNConfigView::IsUserCertValid() const { 766 bool VPNConfigView::IsUserCertValid() const {
767 if (!user_cert_combobox_ || !user_cert_combobox_->IsEnabled()) 767 if (!user_cert_combobox_ || !user_cert_combobox_->enabled())
768 return false; 768 return false;
769 int selected = user_cert_combobox_->selected_item(); 769 int selected = user_cert_combobox_->selected_item();
770 if (selected < 0) 770 if (selected < 0)
771 return false; 771 return false;
772 // Currently only hardware-backed user certificates are valid. 772 // Currently only hardware-backed user certificates are valid.
773 if (cert_library_->IsHardwareBacked() && 773 if (cert_library_->IsHardwareBacked() &&
774 !cert_library_->GetUserCertificates().IsHardwareBackedAt(selected)) 774 !cert_library_->GetUserCertificates().IsHardwareBackedAt(selected))
775 return false; 775 return false;
776 return true; 776 return true;
777 } 777 }
778 778
779 const std::string VPNConfigView::GetTextFromField( 779 const std::string VPNConfigView::GetTextFromField(
780 views::Textfield* textfield, bool trim_whitespace) const { 780 views::Textfield* textfield, bool trim_whitespace) const {
781 if (!textfield) 781 if (!textfield)
782 return std::string(); 782 return std::string();
783 std::string untrimmed = UTF16ToUTF8(textfield->text()); 783 std::string untrimmed = UTF16ToUTF8(textfield->text());
784 if (!trim_whitespace) 784 if (!trim_whitespace)
785 return untrimmed; 785 return untrimmed;
786 std::string result; 786 std::string result;
787 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); 787 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result);
788 return result; 788 return result;
789 } 789 }
790 790
791 } // namespace chromeos 791 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/username_view.cc ('k') | chrome/browser/chromeos/options/wifi_config_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698