Index: ui/views/controls/textfield/textfield.cc |
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
index 14736697771bda755ab2e7e08f2ad70cc1fee919..4182263222aba3ec8fd5dc9075f732cc05da16af 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -685,6 +685,9 @@ bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { |
ExecuteTextEditCommand(edit_command); |
handled = true; |
} |
+ |
+ if (!handled) |
+ OnEditFailed(); |
return handled; |
} |
@@ -1275,6 +1278,11 @@ void Textfield::InsertText(const base::string16& new_text) { |
} |
void Textfield::InsertChar(const ui::KeyEvent& event) { |
+ if (read_only()) { |
+ OnEditFailed(); |
+ return; |
+ } |
+ |
// Filter out all control characters, including tab and new line characters, |
// and all characters with Alt modifier (and Search on ChromeOS). But allow |
// characters with the AltGr modifier. On Windows AltGr is represented by |
@@ -2033,4 +2041,8 @@ void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) { |
OnAfterUserAction(); |
} |
+void Textfield::OnEditFailed() { |
+ PlatformStyle::OnTextfieldEditFailed(); |
+} |
+ |
} // namespace views |