diff options
author | chocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 19:21:16 +0000 |
---|---|---|
committer | chocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 19:21:16 +0000 |
commit | d76bbe9ad18f01d5731d17ec73336709a224fdf1 (patch) | |
tree | 37f7128f819c64e3c388d0142aa40f2267d059f3 /chrome/browser/chromeos/options/passphrase_textfield.cc | |
parent | 2027bd2c2668f5e3524270ad0aa9ccc9bb4d2e1e (diff) | |
download | chromium_src-d76bbe9ad18f01d5731d17ec73336709a224fdf1.zip chromium_src-d76bbe9ad18f01d5731d17ec73336709a224fdf1.tar.gz chromium_src-d76bbe9ad18f01d5731d17ec73336709a224fdf1.tar.bz2 |
For VPN passwords that are not passed back to the UI from flimflam, we show a fake password ******** in the UI. When user focuses on the textfield, we clear it out and replace it when the textfield loses focus and the user has not changed the password.
BUG=chromium-os:24685
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/9406003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/options/passphrase_textfield.cc')
-rw-r--r-- | chrome/browser/chromeos/options/passphrase_textfield.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/options/passphrase_textfield.cc b/chrome/browser/chromeos/options/passphrase_textfield.cc new file mode 100644 index 0000000..e7b3614 --- /dev/null +++ b/chrome/browser/chromeos/options/passphrase_textfield.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/options/passphrase_textfield.h" + +#include "base/utf_string_conversions.h" + +namespace chromeos { + +// String to use as password if the password is set but not available in the UI. +// User will see this as ******** +const string16 kFakePassphrase = ASCIIToUTF16("********"); + +PassphraseTextfield::PassphraseTextfield(bool show_fake) + : Textfield(views::Textfield::STYLE_OBSCURED), + show_fake_(show_fake), + changed_(true) { + if (show_fake_) { + SetText(kFakePassphrase); + changed_ = false; + } +} + +void PassphraseTextfield::OnFocus() { + // If showing the fake password, then clear it when focused. + if (show_fake_ && !changed_) { + SetText(string16()); + changed_ = true; + } +} + +void PassphraseTextfield::OnBlur() { + // If passowrd is not changed, then show the fake password when blurred. + if (show_fake_ && text().empty()) { + SetText(kFakePassphrase); + changed_ = false; + } +} + +std::string PassphraseTextfield::GetPassphrase() { + return changed_ ? UTF16ToUTF8(text()) : std::string(); +} + +} // namespace chromeos |