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

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

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 5 years, 5 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
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"
9 8
10 namespace chromeos { 9 namespace chromeos {
11 10
12 PassphraseTextfield::PassphraseTextfield() 11 PassphraseTextfield::PassphraseTextfield()
13 : Textfield(), 12 : Textfield(),
14 show_fake_(false), 13 show_fake_(false),
15 changed_(true) { 14 changed_(true) {
16 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 15 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
17 } 16 }
18 17
19 void PassphraseTextfield::SetShowFake(bool show_fake) { 18 void PassphraseTextfield::SetShowFake(bool show_fake) {
20 show_fake_ = show_fake; 19 show_fake_ = show_fake;
21 if (show_fake_) 20 if (show_fake_)
22 SetFakePassphrase(); 21 SetFakePassphrase();
23 else 22 else
24 ClearFakePassphrase(); 23 ClearFakePassphrase();
25 } 24 }
26 25
27 void PassphraseTextfield::OnFocus() { 26 void PassphraseTextfield::OnFocus() {
28 // If showing the fake password, then clear it when focused. 27 // If showing the fake password, then clear it when focused.
29 if (show_fake_ && !changed_) 28 if (show_fake_ && !changed_)
30 ClearFakePassphrase(); 29 ClearFakePassphrase();
31 Textfield::OnFocus(); 30 Textfield::OnFocus();
32 GetInputMethod()->OnFocus();
33 } 31 }
34 32
35 void PassphraseTextfield::OnBlur() { 33 void PassphraseTextfield::OnBlur() {
36 // If password is not changed, then show the fake password when blurred. 34 // If password is not changed, then show the fake password when blurred.
37 if (show_fake_ && text().empty()) 35 if (show_fake_ && text().empty())
38 SetFakePassphrase(); 36 SetFakePassphrase();
39 Textfield::OnBlur(); 37 Textfield::OnBlur();
40 GetInputMethod()->OnFocus();
41 } 38 }
42 39
43 std::string PassphraseTextfield::GetPassphrase() { 40 std::string PassphraseTextfield::GetPassphrase() {
44 return changed_ ? base::UTF16ToUTF8(text()) : std::string(); 41 return changed_ ? base::UTF16ToUTF8(text()) : std::string();
45 } 42 }
46 43
47 void PassphraseTextfield::SetFakePassphrase() { 44 void PassphraseTextfield::SetFakePassphrase() {
48 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase, 45 CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase,
49 (base::ASCIIToUTF16("********"))); 46 (base::ASCIIToUTF16("********")));
50 SetText(fake_passphrase); 47 SetText(fake_passphrase);
51 changed_ = false; 48 changed_ = false;
52 } 49 }
53 50
54 void PassphraseTextfield::ClearFakePassphrase() { 51 void PassphraseTextfield::ClearFakePassphrase() {
55 SetText(base::string16()); 52 SetText(base::string16());
56 changed_ = true; 53 changed_ = true;
57 } 54 }
58 55
59 } // namespace chromeos 56 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/magnifier/magnification_controller_unittest.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698