OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/common/autofill_messages.h" | 7 #include "chrome/common/autofill_messages.h" |
8 #include "chrome/common/form_data.h" | 8 #include "chrome/common/form_data.h" |
9 #include "chrome/common/form_field_data.h" | 9 #include "chrome/common/form_field_data.h" |
10 #include "chrome/renderer/autofill/autofill_agent.h" | 10 #include "chrome/renderer/autofill/autofill_agent.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 void SimulateUsernameChange(const std::string& username, | 120 void SimulateUsernameChange(const std::string& username, |
121 bool move_caret_to_end) { | 121 bool move_caret_to_end) { |
122 username_element_.setValue(WebString::fromUTF8(username)); | 122 username_element_.setValue(WebString::fromUTF8(username)); |
123 if (move_caret_to_end) | 123 if (move_caret_to_end) |
124 username_element_.setSelectionRange(username.length(), username.length()); | 124 username_element_.setSelectionRange(username.length(), username.length()); |
125 autofill_agent_->textFieldDidChange(username_element_); | 125 autofill_agent_->textFieldDidChange(username_element_); |
126 // Processing is delayed because of a WebKit bug, see | 126 // Processing is delayed because of a WebKit bug, see |
127 // PasswordAutocompleteManager::TextDidChangeInTextField() for details. | 127 // PasswordAutocompleteManager::TextDidChangeInTextField() for details. |
128 MessageLoop::current()->RunAllPending(); | 128 MessageLoop::current()->RunUntilIdle(); |
129 } | 129 } |
130 | 130 |
131 void SimulateKeyDownEvent(const WebInputElement& element, | 131 void SimulateKeyDownEvent(const WebInputElement& element, |
132 ui::KeyboardCode key_code) { | 132 ui::KeyboardCode key_code) { |
133 WebKit::WebKeyboardEvent key_event; | 133 WebKit::WebKeyboardEvent key_event; |
134 key_event.windowsKeyCode = key_code; | 134 key_event.windowsKeyCode = key_code; |
135 autofill_agent_->textFieldDidReceiveKeyDown(element, key_event); | 135 autofill_agent_->textFieldDidReceiveKeyDown(element, key_event); |
136 } | 136 } |
137 | 137 |
138 void CheckTextFieldsState(const std::string& username, | 138 void CheckTextFieldsState(const std::string& username, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 // didSelectAutofillSuggestion on the renderer. | 410 // didSelectAutofillSuggestion on the renderer. |
411 autofill_agent_->didSelectAutofillSuggestion(username_element_, | 411 autofill_agent_->didSelectAutofillSuggestion(username_element_, |
412 ASCIIToUTF16(kAliceUsername), | 412 ASCIIToUTF16(kAliceUsername), |
413 WebKit::WebString(), | 413 WebKit::WebString(), |
414 0); | 414 0); |
415 // Autocomplete should not have kicked in. | 415 // Autocomplete should not have kicked in. |
416 CheckTextFieldsState("", false, "", false); | 416 CheckTextFieldsState("", false, "", false); |
417 } | 417 } |
418 | 418 |
419 } // namespace autofill | 419 } // namespace autofill |
OLD | NEW |