1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/options/passphrase_textfield.h"
7 #include "base/strings/utf_string_conversions.h"
11 PassphraseTextfield::PassphraseTextfield()
15 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD
);
18 void PassphraseTextfield::SetShowFake(bool show_fake
) {
19 show_fake_
= show_fake
;
23 ClearFakePassphrase();
26 void PassphraseTextfield::OnFocus() {
27 // If showing the fake password, then clear it when focused.
28 if (show_fake_
&& !changed_
)
29 ClearFakePassphrase();
33 void PassphraseTextfield::OnBlur() {
34 // If password is not changed, then show the fake password when blurred.
35 if (show_fake_
&& text().empty())
40 std::string
PassphraseTextfield::GetPassphrase() {
41 return changed_
? base::UTF16ToUTF8(text()) : std::string();
44 void PassphraseTextfield::SetFakePassphrase() {
45 CR_DEFINE_STATIC_LOCAL(base::string16
, fake_passphrase
,
46 (base::ASCIIToUTF16("********")));
47 SetText(fake_passphrase
);
51 void PassphraseTextfield::ClearFakePassphrase() {
52 SetText(base::string16());
56 } // namespace chromeos