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

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

Issue 308933002: Fix PassphraseTextfield::OnFocus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/ime/input_method.h"
8 9
9 namespace chromeos { 10 namespace chromeos {
10 11
11 PassphraseTextfield::PassphraseTextfield() 12 PassphraseTextfield::PassphraseTextfield()
12 : Textfield(), 13 : Textfield(),
13 show_fake_(false), 14 show_fake_(false),
14 changed_(true) { 15 changed_(true) {
15 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 16 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
16 } 17 }
17 18
18 void PassphraseTextfield::SetShowFake(bool show_fake) { 19 void PassphraseTextfield::SetShowFake(bool show_fake) {
19 show_fake_ = show_fake; 20 show_fake_ = show_fake;
20 if (show_fake_) 21 if (show_fake_)
21 SetFakePassphrase(); 22 SetFakePassphrase();
22 else 23 else
23 ClearFakePassphrase(); 24 ClearFakePassphrase();
24 } 25 }
25 26
26 void PassphraseTextfield::OnFocus() { 27 void PassphraseTextfield::OnFocus() {
27 // If showing the fake password, then clear it when focused. 28 // If showing the fake password, then clear it when focused.
28 if (show_fake_ && !changed_) 29 if (show_fake_ && !changed_)
29 ClearFakePassphrase(); 30 ClearFakePassphrase();
30 Textfield::OnFocus(); 31 Textfield::OnFocus();
32 GetInputMethod()->OnFocus();
31 } 33 }
32 34
33 void PassphraseTextfield::OnBlur() { 35 void PassphraseTextfield::OnBlur() {
34 // If password is not changed, then show the fake password when blurred. 36 // If password is not changed, then show the fake password when blurred.
35 if (show_fake_ && text().empty()) 37 if (show_fake_ && text().empty())
36 SetFakePassphrase(); 38 SetFakePassphrase();
37 Textfield::OnBlur(); 39 Textfield::OnBlur();
40 GetInputMethod()->OnFocus();
38 } 41 }
39 42
40 std::string PassphraseTextfield::GetPassphrase() { 43 std::string PassphraseTextfield::GetPassphrase() {
41 return changed_ ? base::UTF16ToUTF8(text()) : std::string(); 44 return changed_ ? base::UTF16ToUTF8(text()) : std::string();
42 } 45 }
43 46
44 void PassphraseTextfield::SetFakePassphrase() { 47 void PassphraseTextfield::SetFakePassphrase() {
45 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase, 48 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase,
46 (base::ASCIIToUTF16("********"))); 49 (base::ASCIIToUTF16("********")));
47 SetText(fake_passphrase); 50 SetText(fake_passphrase);
48 changed_ = false; 51 changed_ = false;
49 } 52 }
50 53
51 void PassphraseTextfield::ClearFakePassphrase() { 54 void PassphraseTextfield::ClearFakePassphrase() {
52 SetText(base::string16()); 55 SetText(base::string16());
53 changed_ = true; 56 changed_ = true;
54 } 57 }
55 58
56 } // namespace chromeos 59 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698