Commit e1df9eab authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

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
parent 8a451b90
......@@ -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();
......
......@@ -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
......
......@@ -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<internal::SecurityComboboxModel> 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_;
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment