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..925bf9cca60b24b17ff190172cb4d1803bb4a939 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -261,12 +261,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 +1285,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 +1979,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)); |
} |
@@ -2031,4 +2025,11 @@ void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) { |
OnAfterUserAction(); |
} |
+base::TimeDelta Textfield::GetPasswordRevealDuration() { |
sky
2016/08/26 19:02:52
Make this an anonymous function and move to namesp
xiyuan
2016/08/26 19:45:40
Done.
|
+ return ViewsDelegate::GetInstance() |
+ ? ViewsDelegate::GetInstance() |
+ ->GetTextfieldPasswordRevealDuration() |
+ : base::TimeDelta(); |
+} |
+ |
} // namespace views |