From e1df9eab568c6c03733c4e6889099c5afa643f26 Mon Sep 17 00:00:00 2001 From: "stevenjb@chromium.org" Date: Thu, 5 Sep 2013 19:17:43 +0000 Subject: [PATCH] Show ****** in wifi passphrase field Shill does not send the passphrase to Chrome for security reasons, so show ****** in the passphrase field when configuring wifi if the service is Connectable. (Sometimes when a connection fails we do not know why it failed and so we show the configure dialog in case it is an error in the configuration). BUG=264819 Review URL: https://chromiumcodereview.appspot.com/23522013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221491 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chromeos/options/passphrase_textfield.h | 2 ++ .../browser/chromeos/options/wifi_config_view.cc | 31 +++++++++++++--------- chrome/browser/chromeos/options/wifi_config_view.h | 3 ++- chromeos/dbus/shill_service_client_stub.cc | 1 + 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/chrome/browser/chromeos/options/passphrase_textfield.h b/chrome/browser/chromeos/options/passphrase_textfield.h index 1f1b59066865..3a2113dea0cc 100644 --- a/chrome/browser/chromeos/options/passphrase_textfield.h +++ b/chrome/browser/chromeos/options/passphrase_textfield.h @@ -27,6 +27,8 @@ class PassphraseTextfield : public views::Textfield { // Returns the passphrase. If it's unchanged, then returns an empty string. std::string GetPassphrase(); + bool show_fake() const { return show_fake_; } + private: void SetFakePassphrase(); void ClearFakePassphrase(); diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index 1f57adc35b03..e8193d7dcb09 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -10,6 +10,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/chromeos/enrollment_dialog_view.h" #include "chrome/browser/chromeos/net/onc_utils.h" +#include "chrome/browser/chromeos/options/passphrase_textfield.h" #include "chrome/browser/profiles/profile_manager.h" #include "chromeos/login/login_state.h" #include "chromeos/network/network_configuration_handler.h" @@ -401,9 +402,10 @@ bool WifiConfigView::CanLogin() { return false; // If the network requires a passphrase, make sure it is the right length. - if (passphrase_textfield_ != NULL - && passphrase_textfield_->enabled() - && passphrase_textfield_->text().length() < kMinWirelessPasswordLen) + if (passphrase_textfield_ != NULL && + passphrase_textfield_->enabled() && + !passphrase_textfield_->show_fake() && + passphrase_textfield_->text().length() < kMinWirelessPasswordLen) return false; // If we're using EAP, we must have a method. @@ -1054,11 +1056,10 @@ void WifiConfigView::Init(bool show_8021x) { string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); passphrase_label_ = new views::Label(passphrase_label_text); layout->AddView(passphrase_label_); - passphrase_textfield_ = new views::Textfield( - views::Textfield::STYLE_OBSCURED); + passphrase_textfield_ = new PassphraseTextfield(); passphrase_textfield_->SetController(this); // Disable passphrase input initially for other network. - passphrase_label_->SetEnabled(wifi != NULL); + passphrase_label_->SetEnabled(wifi); passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); passphrase_textfield_->SetAccessibleName(passphrase_label_text); layout->AddView(passphrase_textfield_); @@ -1172,13 +1173,13 @@ void WifiConfigView::InitFromProperties( bool show_8021x, const std::string& service_path, const base::DictionaryValue& properties) { - std::string passphrase; - properties.GetStringWithoutPathExpansion( - flimflam::kPassphraseProperty, &passphrase); - passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); - - if (!show_8021x) + if (!show_8021x) { + std::string passphrase; + properties.GetStringWithoutPathExpansion( + flimflam::kPassphraseProperty, &passphrase); + passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); return; + } // EAP Method std::string eap_method; @@ -1277,6 +1278,12 @@ void WifiConfigView::InitFromProperties( properties.GetStringWithoutPathExpansion( flimflam::kEapPasswordProperty, &eap_password); passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); + // If 'Connectable' is True, show a fake passphrase to indicate that it + // has already been set. + bool connectable = false; + properties.GetBooleanWithoutPathExpansion( + flimflam::kConnectableProperty, &connectable); + passphrase_textfield_->SetShowFake(connectable); } // Save credentials diff --git a/chrome/browser/chromeos/options/wifi_config_view.h b/chrome/browser/chromeos/options/wifi_config_view.h index 983e3595c2ed..8cafd3a75060 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.h +++ b/chrome/browser/chromeos/options/wifi_config_view.h @@ -32,6 +32,7 @@ class ToggleImageButton; namespace chromeos { class NetworkState; +class PassphraseTextfield; namespace internal { class EAPMethodComboboxModel; @@ -190,7 +191,7 @@ class WifiConfigView : public ChildNetworkConfigView, scoped_ptr security_combobox_model_; views::Combobox* security_combobox_; views::Label* passphrase_label_; - views::Textfield* passphrase_textfield_; + PassphraseTextfield* passphrase_textfield_; views::ToggleImageButton* passphrase_visible_button_; views::Label* error_label_; diff --git a/chromeos/dbus/shill_service_client_stub.cc b/chromeos/dbus/shill_service_client_stub.cc index d7c28da19542..3e7659703ac1 100644 --- a/chromeos/dbus/shill_service_client_stub.cc +++ b/chromeos/dbus/shill_service_client_stub.cc @@ -96,6 +96,7 @@ void ShillServiceClientStub::GetProperties( NULL); call_status = DBUS_METHOD_CALL_SUCCESS; } else { + LOG(ERROR) << "Properties not found for: " << service_path.value(); result_properties.reset(new base::DictionaryValue); call_status = DBUS_METHOD_CALL_FAILURE; } -- 2.11.4.GIT