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

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

Issue 2358463002: Views::Textfield: Prevent revealing password text. (Closed)
Patch Set: Address review comments. 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
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a89c3cc99aa9ae0d48a321b85faef35ef54e74a0 100644
--- a/ui/views/controls/textfield/textfield_model.cc
+++ b/ui/views/controls/textfield/textfield_model.cc
@@ -344,11 +344,15 @@ void TextfieldModel::Append(const base::string16& new_text) {
}
bool TextfieldModel::Delete(bool add_to_kill_buffer) {
+ // |add_to_kill_buffer| should never be true for an obscured textfield.
+ DCHECK(!add_to_kill_buffer || !render_text_->obscured());
+
if (HasCompositionText()) {
// No undo/redo for composition text.
CancelCompositionText();
return true;
}
+
if (HasSelection()) {
if (add_to_kill_buffer)
SetKillBuffer(GetSelectedText());
@@ -369,11 +373,15 @@ bool TextfieldModel::Delete(bool add_to_kill_buffer) {
}
bool TextfieldModel::Backspace(bool add_to_kill_buffer) {
+ // |add_to_kill_buffer| should never be true for an obscured textfield.
+ DCHECK(!add_to_kill_buffer || !render_text_->obscured());
+
if (HasCompositionText()) {
// No undo/redo for composition text.
CancelCompositionText();
return true;
}
+
if (HasSelection()) {
if (add_to_kill_buffer)
SetKillBuffer(GetSelectedText());
@@ -430,8 +438,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) {
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698