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

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

Issue 2286433002: views: Textfield gets password reveal duration from ViewsDelegate (Closed)
Patch Set: no setter 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/controls/textfield/textfield_test_api.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..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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698