Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/chromeos/options/passphrase_textfield.cc

Issue 120503005: Merge NativeTextfieldViews into views::Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix touch drag and drop unit test. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/options/passphrase_textfield.h" 5 #include "chrome/browser/chromeos/options/passphrase_textfield.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 8
9 namespace chromeos { 9 namespace chromeos {
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 void PassphraseTextfield::OnFocus() { 25 void PassphraseTextfield::OnFocus() {
26 // If showing the fake password, then clear it when focused. 26 // If showing the fake password, then clear it when focused.
27 if (show_fake_ && !changed_) 27 if (show_fake_ && !changed_)
28 ClearFakePassphrase(); 28 ClearFakePassphrase();
29 Textfield::OnFocus(); 29 Textfield::OnFocus();
30 } 30 }
31 31
32 void PassphraseTextfield::OnBlur() { 32 void PassphraseTextfield::OnBlur() {
33 // If password is not changed, then show the fake password when blurred. 33 // If password is not changed, then show the fake password when blurred.
34 if (show_fake_ && text().empty()) 34 if (show_fake_ && GetText().empty())
35 SetFakePassphrase(); 35 SetFakePassphrase();
36 Textfield::OnBlur(); 36 Textfield::OnBlur();
37 } 37 }
38 38
39 std::string PassphraseTextfield::GetPassphrase() { 39 std::string PassphraseTextfield::GetPassphrase() {
40 return changed_ ? base::UTF16ToUTF8(text()) : std::string(); 40 return changed_ ? base::UTF16ToUTF8(GetText()) : std::string();
41 } 41 }
42 42
43 void PassphraseTextfield::SetFakePassphrase() { 43 void PassphraseTextfield::SetFakePassphrase() {
44 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase, 44 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase,
45 (base::ASCIIToUTF16("********"))); 45 (base::ASCIIToUTF16("********")));
46 SetText(fake_passphrase); 46 SetText(fake_passphrase);
47 changed_ = false; 47 changed_ = false;
48 } 48 }
49 49
50 void PassphraseTextfield::ClearFakePassphrase() { 50 void PassphraseTextfield::ClearFakePassphrase() {
51 SetText(base::string16()); 51 SetText(base::string16());
52 changed_ = true; 52 changed_ = true;
53 } 53 }
54 54
55 } // namespace chromeos 55 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698