This source file includes following definitions.
- changed_
- SetShowFake
- OnFocus
- OnBlur
- GetPassphrase
- SetFakePassphrase
- ClearFakePassphrase
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "base/strings/utf_string_conversions.h"
namespace chromeos {
PassphraseTextfield::PassphraseTextfield()
: Textfield(),
show_fake_(false),
changed_(true) {
SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
}
void PassphraseTextfield::SetShowFake(bool show_fake) {
show_fake_ = show_fake;
if (show_fake_)
SetFakePassphrase();
else
ClearFakePassphrase();
}
void PassphraseTextfield::OnFocus() {
if (show_fake_ && !changed_)
ClearFakePassphrase();
Textfield::OnFocus();
}
void PassphraseTextfield::OnBlur() {
if (show_fake_ && text().empty())
SetFakePassphrase();
Textfield::OnBlur();
}
std::string PassphraseTextfield::GetPassphrase() {
return changed_ ? base::UTF16ToUTF8(text()) : std::string();
}
void PassphraseTextfield::SetFakePassphrase() {
CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase,
(base::ASCIIToUTF16("********")));
SetText(fake_passphrase);
changed_ = false;
}
void PassphraseTextfield::ClearFakePassphrase() {
SetText(base::string16());
changed_ = true;
}
}