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

Side by Side Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 7740070: Add metrics to measure time elapsed between form load and form submission with or without Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Once more, with feeling Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 IPC_END_MESSAGE_MAP() 73 IPC_END_MESSAGE_MAP()
73 return handled; 74 return handled;
74 } 75 }
75 76
76 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 77 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
77 // The document has now been fully loaded. Scan for forms to be sent up to 78 // The document has now been fully loaded. Scan for forms to be sent up to
78 // the browser. 79 // the browser.
79 std::vector<webkit_glue::FormData> forms; 80 std::vector<webkit_glue::FormData> forms;
80 form_manager_.ExtractForms(frame, &forms); 81 form_manager_.ExtractForms(frame, &forms);
81 82
82 if (!forms.empty()) 83 if (!forms.empty()) {
83 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms)); 84 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
85 base::TimeTicks::Now()));
86 }
84 } 87 }
85 88
86 void AutofillAgent::FrameDetached(WebFrame* frame) { 89 void AutofillAgent::FrameDetached(WebFrame* frame) {
87 form_manager_.ResetFrame(frame); 90 form_manager_.ResetFrame(frame);
88 } 91 }
89 92
90 void AutofillAgent::FrameWillClose(WebFrame* frame) { 93 void AutofillAgent::FrameWillClose(WebFrame* frame) {
91 form_manager_.ResetFrame(frame); 94 form_manager_.ResetFrame(frame);
92 } 95 }
93 96
94 void AutofillAgent::WillSubmitForm(WebFrame* frame, 97 void AutofillAgent::WillSubmitForm(WebFrame* frame,
95 const WebFormElement& form) { 98 const WebFormElement& form) {
96 FormData form_data; 99 FormData form_data;
97 if (FormManager::WebFormElementToFormData( 100 if (FormManager::WebFormElementToFormData(
98 form, 101 form,
99 FormManager::REQUIRE_AUTOCOMPLETE, 102 FormManager::REQUIRE_AUTOCOMPLETE,
100 static_cast<FormManager::ExtractMask>( 103 static_cast<FormManager::ExtractMask>(
101 FormManager::EXTRACT_VALUE | FormManager::EXTRACT_OPTION_TEXT), 104 FormManager::EXTRACT_VALUE | FormManager::EXTRACT_OPTION_TEXT),
102 &form_data)) { 105 &form_data)) {
103 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data)); 106 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
107 base::TimeTicks::Now()));
104 } 108 }
105 } 109 }
106 110
107 void AutofillAgent::FrameTranslated(WebFrame* frame) { 111 void AutofillAgent::FrameTranslated(WebFrame* frame) {
108 // The page is translated, so try to extract the form data again. 112 // The page is translated, so try to extract the form data again.
109 DidFinishDocumentLoad(frame); 113 DidFinishDocumentLoad(frame);
110 } 114 }
111 115
112 bool AutofillAgent::InputElementClicked(const WebInputElement& element, 116 bool AutofillAgent::InputElementClicked(const WebInputElement& element,
113 bool was_focused, 117 bool was_focused,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 198 }
195 199
196 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { 200 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) {
197 if (password_autofill_manager_->TextDidChangeInTextField(element)) 201 if (password_autofill_manager_->TextDidChangeInTextField(element))
198 return; 202 return;
199 203
200 ShowSuggestions(element, false, true, false); 204 ShowSuggestions(element, false, true, false);
201 205
202 webkit_glue::FormData form; 206 webkit_glue::FormData form;
203 webkit_glue::FormField field; 207 webkit_glue::FormField field;
204 if (FindFormAndFieldForNode(element, &form, &field)) 208 if (FindFormAndFieldForNode(element, &form, &field)) {
205 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field)); 209 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field,
210 base::TimeTicks::Now()));
211 }
206 } 212 }
207 213
208 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, 214 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
209 const WebKeyboardEvent& event) { 215 const WebKeyboardEvent& event) {
210 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) 216 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event))
211 return; 217 return;
212 218
213 if (event.windowsKeyCode == ui::VKEY_DOWN || 219 if (event.windowsKeyCode == ui::VKEY_DOWN ||
214 event.windowsKeyCode == ui::VKEY_UP) 220 event.windowsKeyCode == ui::VKEY_UP)
215 ShowSuggestions(element, true, true, true); 221 ShowSuggestions(element, true, true, true);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 310 }
305 311
306 void AutofillAgent::OnFormDataFilled(int query_id, 312 void AutofillAgent::OnFormDataFilled(int query_id,
307 const webkit_glue::FormData& form) { 313 const webkit_glue::FormData& form) {
308 if (!render_view()->webview() || query_id != autofill_query_id_) 314 if (!render_view()->webview() || query_id != autofill_query_id_)
309 return; 315 return;
310 316
311 switch (autofill_action_) { 317 switch (autofill_action_) {
312 case AUTOFILL_FILL: 318 case AUTOFILL_FILL:
313 form_manager_.FillForm(form, autofill_query_element_); 319 form_manager_.FillForm(form, autofill_query_element_);
314 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id())); 320 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(),
321 base::TimeTicks::Now()));
315 break; 322 break;
316 case AUTOFILL_PREVIEW: 323 case AUTOFILL_PREVIEW:
317 form_manager_.PreviewForm(form, autofill_query_element_); 324 form_manager_.PreviewForm(form, autofill_query_element_);
318 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); 325 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
319 break; 326 break;
320 default: 327 default:
321 NOTREACHED(); 328 NOTREACHED();
322 } 329 }
323 autofill_action_ = AUTOFILL_NONE; 330 autofill_action_ = AUTOFILL_NONE;
324 } 331 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 // WebFormControlElementToFormField does not scrape the DOM for the field 425 // WebFormControlElementToFormField does not scrape the DOM for the field
419 // label, so find the label here. 426 // label, so find the label here.
420 // TODO(isherman): Add form and field identities so we can use the cached form 427 // TODO(isherman): Add form and field identities so we can use the cached form
421 // data in FormManager. 428 // data in FormManager.
422 field->label = FormManager::LabelForElement(element); 429 field->label = FormManager::LabelForElement(element);
423 430
424 return true; 431 return true;
425 } 432 }
426 433
427 } // namespace autofill 434 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/common/autofill_messages.h ('k') | chrome/renderer/autofill/form_autocomplete_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698