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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2286433002: views: Textfield gets password reveal duration from ViewsDelegate (Closed)
Patch Set: move GetPasswordRevealDuration to cc and revert TextfieldTestApi change Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/views_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index ea2a29aa89fec7a4c5d5b8aa545a4bfca1126253..952bc5a20de4e78497bb0c522c33a210a18a4bba 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -212,6 +212,13 @@ ui::TextEditCommand GetTextEditCommandFromMenuCommand(int command_id,
return ui::TextEditCommand::INVALID_COMMAND;
}
+base::TimeDelta GetPasswordRevealDuration() {
+ return ViewsDelegate::GetInstance()
+ ? ViewsDelegate::GetInstance()
+ ->GetTextfieldPasswordRevealDuration()
+ : base::TimeDelta();
+}
+
} // namespace
// static
@@ -261,12 +268,6 @@ Textfield::Textfield()
SetBorder(std::unique_ptr<Border>(new FocusableBorder()));
SetFocusBehavior(FocusBehavior::ALWAYS);
- if (ViewsDelegate::GetInstance()) {
- password_reveal_duration_ =
- ViewsDelegate::GetInstance()
- ->GetDefaultTextfieldObscuredRevealDuration();
- }
-
// These allow BrowserView to pass edit commands from the Chrome menu to us
// when we're focused by simply asking the FocusManager to
// ProcessAccelerator() with the relevant accelerators.
@@ -1291,7 +1292,7 @@ void Textfield::InsertChar(const ui::KeyEvent& event) {
DoInsertChar(ch);
if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD &&
- !password_reveal_duration_.is_zero()) {
+ !GetPasswordRevealDuration().is_zero()) {
const size_t change_offset = model_->GetCursorPosition();
DCHECK_GT(change_offset, 0u);
RevealPasswordChar(change_offset - 1);
@@ -1985,7 +1986,7 @@ void Textfield::RevealPasswordChar(int index) {
SchedulePaint();
if (index != -1) {
- password_reveal_timer_.Start(FROM_HERE, password_reveal_duration_,
+ password_reveal_timer_.Start(FROM_HERE, GetPasswordRevealDuration(),
base::Bind(&Textfield::RevealPasswordChar,
weak_ptr_factory_.GetWeakPtr(), -1));
}
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698