Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/autofill/autofill_agent.h" | 5 #include "chrome/renderer/autofill/autofill_agent.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/time.h" | |
| 8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/common/autofill_messages.h" | 10 #include "chrome/common/autofill_messages.h" |
| 10 #include "chrome/common/chrome_constants.h" | 11 #include "chrome/common/chrome_constants.h" |
| 11 #include "chrome/renderer/autofill/password_autofill_manager.h" | 12 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 12 #include "content/renderer/render_view.h" | 13 #include "content/renderer/render_view.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 94 |
| 94 void AutofillAgent::WillSubmitForm(WebFrame* frame, | 95 void AutofillAgent::WillSubmitForm(WebFrame* frame, |
| 95 const WebFormElement& form) { | 96 const WebFormElement& form) { |
| 96 FormData form_data; | 97 FormData form_data; |
| 97 if (FormManager::WebFormElementToFormData( | 98 if (FormManager::WebFormElementToFormData( |
| 98 form, | 99 form, |
| 99 FormManager::REQUIRE_AUTOCOMPLETE, | 100 FormManager::REQUIRE_AUTOCOMPLETE, |
| 100 static_cast<FormManager::ExtractMask>( | 101 static_cast<FormManager::ExtractMask>( |
| 101 FormManager::EXTRACT_VALUE | FormManager::EXTRACT_OPTION_TEXT), | 102 FormManager::EXTRACT_VALUE | FormManager::EXTRACT_OPTION_TEXT), |
| 102 &form_data)) { | 103 &form_data)) { |
| 103 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data)); | 104 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, |
| 105 base::TimeTicks::Now())); | |
|
dhollowa
2011/08/31 22:40:52
Wouldn't it be simpler to just track the time on t
Ilya Sherman
2011/08/31 23:21:32
Yes, but it would be somewhat less accurate, since
dhollowa
2011/08/31 23:42:20
We're measuring user-time at a many-seconds possib
| |
| 104 } | 106 } |
| 105 } | 107 } |
| 106 | 108 |
| 107 void AutofillAgent::FrameTranslated(WebFrame* frame) { | 109 void AutofillAgent::FrameTranslated(WebFrame* frame) { |
| 108 // The page is translated, so try to extract the form data again. | 110 // The page is translated, so try to extract the form data again. |
| 109 DidFinishDocumentLoad(frame); | 111 DidFinishDocumentLoad(frame); |
| 110 } | 112 } |
| 111 | 113 |
| 112 bool AutofillAgent::InputElementClicked(const WebInputElement& element, | 114 bool AutofillAgent::InputElementClicked(const WebInputElement& element, |
| 113 bool was_focused, | 115 bool was_focused, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 } | 196 } |
| 195 | 197 |
| 196 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { | 198 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { |
| 197 if (password_autofill_manager_->TextDidChangeInTextField(element)) | 199 if (password_autofill_manager_->TextDidChangeInTextField(element)) |
| 198 return; | 200 return; |
| 199 | 201 |
| 200 ShowSuggestions(element, false, true, false); | 202 ShowSuggestions(element, false, true, false); |
| 201 | 203 |
| 202 webkit_glue::FormData form; | 204 webkit_glue::FormData form; |
| 203 webkit_glue::FormField field; | 205 webkit_glue::FormField field; |
| 204 if (FindFormAndFieldForNode(element, &form, &field)) | 206 if (FindFormAndFieldForNode(element, &form, &field)) { |
| 205 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field)); | 207 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, |
|
dhollowa
2011/08/31 22:40:52
I would think it is just as telling to track the d
Ilya Sherman
2011/08/31 23:21:32
I considered that, but a <form> element being load
dhollowa
2011/08/31 23:42:20
But for the dynamic case, we don't flag it as fill
| |
| 208 base::TimeTicks::Now())); | |
| 209 } | |
| 206 } | 210 } |
| 207 | 211 |
| 208 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, | 212 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, |
| 209 const WebKeyboardEvent& event) { | 213 const WebKeyboardEvent& event) { |
| 210 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) | 214 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) |
| 211 return; | 215 return; |
| 212 | 216 |
| 213 if (event.windowsKeyCode == ui::VKEY_DOWN || | 217 if (event.windowsKeyCode == ui::VKEY_DOWN || |
| 214 event.windowsKeyCode == ui::VKEY_UP) | 218 event.windowsKeyCode == ui::VKEY_UP) |
| 215 ShowSuggestions(element, true, true, true); | 219 ShowSuggestions(element, true, true, true); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 } | 308 } |
| 305 | 309 |
| 306 void AutofillAgent::OnFormDataFilled(int query_id, | 310 void AutofillAgent::OnFormDataFilled(int query_id, |
| 307 const webkit_glue::FormData& form) { | 311 const webkit_glue::FormData& form) { |
| 308 if (!render_view()->webview() || query_id != autofill_query_id_) | 312 if (!render_view()->webview() || query_id != autofill_query_id_) |
| 309 return; | 313 return; |
| 310 | 314 |
| 311 switch (autofill_action_) { | 315 switch (autofill_action_) { |
| 312 case AUTOFILL_FILL: | 316 case AUTOFILL_FILL: |
| 313 form_manager_.FillForm(form, autofill_query_element_); | 317 form_manager_.FillForm(form, autofill_query_element_); |
| 314 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id())); | 318 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(), |
| 319 base::TimeTicks::Now())); | |
| 315 break; | 320 break; |
| 316 case AUTOFILL_PREVIEW: | 321 case AUTOFILL_PREVIEW: |
| 317 form_manager_.PreviewForm(form, autofill_query_element_); | 322 form_manager_.PreviewForm(form, autofill_query_element_); |
| 318 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); | 323 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); |
| 319 break; | 324 break; |
| 320 default: | 325 default: |
| 321 NOTREACHED(); | 326 NOTREACHED(); |
| 322 } | 327 } |
| 323 autofill_action_ = AUTOFILL_NONE; | 328 autofill_action_ = AUTOFILL_NONE; |
| 324 } | 329 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 // WebFormControlElementToFormField does not scrape the DOM for the field | 423 // WebFormControlElementToFormField does not scrape the DOM for the field |
| 419 // label, so find the label here. | 424 // label, so find the label here. |
| 420 // TODO(isherman): Add form and field identities so we can use the cached form | 425 // TODO(isherman): Add form and field identities so we can use the cached form |
| 421 // data in FormManager. | 426 // data in FormManager. |
| 422 field->label = FormManager::LabelForElement(element); | 427 field->label = FormManager::LabelForElement(element); |
| 423 | 428 |
| 424 return true; | 429 return true; |
| 425 } | 430 } |
| 426 | 431 |
| 427 } // namespace autofill | 432 } // namespace autofill |
| OLD | NEW |