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

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

Issue 2358463002: Views::Textfield: Prevent revealing password text. (Closed)
Patch Set: Created 4 years, 3 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
Index: ui/views/controls/textfield/textfield_model.cc
diff --git a/ui/views/controls/textfield/textfield_model.cc b/ui/views/controls/textfield/textfield_model.cc
index 5738887b7256d5c84e2aa333472fae50bc42ec25..30e67443fd964a5e55936e4360d73861410f3b19 100644
--- a/ui/views/controls/textfield/textfield_model.cc
+++ b/ui/views/controls/textfield/textfield_model.cc
@@ -349,6 +349,9 @@ bool TextfieldModel::Delete(bool add_to_kill_buffer) {
CancelCompositionText();
return true;
}
+ // |add_to_kill_buffer| should never be true for an obscured textfield.
Peter Kasting 2016/09/20 17:29:30 Nit: Why not DCHECK this atop the function instead
karandeepb 2016/09/21 03:36:12 Done.
+ DCHECK(!(add_to_kill_buffer && render_text_->obscured()));
Peter Kasting 2016/09/20 17:29:30 Nit: Distribute "!" through and eliminate parens
karandeepb 2016/09/21 03:36:12 Done.
+
if (HasSelection()) {
if (add_to_kill_buffer)
SetKillBuffer(GetSelectedText());
@@ -374,6 +377,9 @@ bool TextfieldModel::Backspace(bool add_to_kill_buffer) {
CancelCompositionText();
return true;
}
+ // |add_to_kill_buffer| should never be true for an obscured textfield.
+ DCHECK(!(add_to_kill_buffer && render_text_->obscured()));
Peter Kasting 2016/09/20 17:29:30 Same comments
karandeepb 2016/09/21 03:36:12 Done.
+
if (HasSelection()) {
if (add_to_kill_buffer)
SetKillBuffer(GetSelectedText());
@@ -430,8 +436,7 @@ bool TextfieldModel::MoveCursorTo(const gfx::Point& point, bool select) {
}
base::string16 TextfieldModel::GetSelectedText() const {
- return text().substr(render_text_->selection().GetMin(),
- render_text_->selection().length());
+ return GetTextFromRange(render_text_->selection());
}
void TextfieldModel::SelectRange(const gfx::Range& range) {

Powered by Google App Engine
This is Rietveld 408576698