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

Side by Side Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 231283003: Password manager: introduce logging for the internals page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further comments addressed + unrelated style changes split off to a different CL Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/content/common/autofill_messages.h" 12 #include "components/autofill/content/common/autofill_messages.h"
13 #include "components/autofill/content/renderer/form_autofill_util.h" 13 #include "components/autofill/content/renderer/form_autofill_util.h"
14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" 14 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
15 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h"
15 #include "components/autofill/core/common/form_field_data.h" 16 #include "components/autofill/core/common/form_field_data.h"
16 #include "components/autofill/core/common/password_autofill_util.h" 17 #include "components/autofill/core/common/password_autofill_util.h"
17 #include "components/autofill/core/common/password_form.h" 18 #include "components/autofill/core/common/password_form.h"
18 #include "components/autofill/core/common/password_form_fill_data.h" 19 #include "components/autofill/core/common/password_form_fill_data.h"
19 #include "content/public/renderer/render_view.h" 20 #include "content/public/renderer/render_view.h"
20 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
21 #include "third_party/WebKit/public/web/WebAutofillClient.h" 22 #include "third_party/WebKit/public/web/WebAutofillClient.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebElement.h" 24 #include "third_party/WebKit/public/web/WebElement.h"
24 #include "third_party/WebKit/public/web/WebFormElement.h" 25 #include "third_party/WebKit/public/web/WebFormElement.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h" 26 #include "third_party/WebKit/public/web/WebInputEvent.h"
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" 27 #include "third_party/WebKit/public/web/WebLocalFrame.h"
27 #include "third_party/WebKit/public/web/WebNode.h" 28 #include "third_party/WebKit/public/web/WebNode.h"
28 #include "third_party/WebKit/public/web/WebNodeList.h" 29 #include "third_party/WebKit/public/web/WebNodeList.h"
29 #include "third_party/WebKit/public/web/WebPasswordFormData.h" 30 #include "third_party/WebKit/public/web/WebPasswordFormData.h"
30 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
31 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 32 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
32 #include "third_party/WebKit/public/web/WebView.h" 33 #include "third_party/WebKit/public/web/WebView.h"
33 #include "ui/events/keycodes/keyboard_codes.h" 34 #include "ui/events/keycodes/keyboard_codes.h"
35 #include "url/gurl.h"
34 36
35 namespace autofill { 37 namespace autofill {
36 namespace { 38 namespace {
37 39
38 // The size above which we stop triggering autocomplete. 40 // The size above which we stop triggering autocomplete.
39 static const size_t kMaximumTextSizeForAutocomplete = 1000; 41 static const size_t kMaximumTextSizeForAutocomplete = 1000;
40 42
41 // Maps element names to the actual elements to simplify form filling. 43 // Maps element names to the actual elements to simplify form filling.
42 typedef std::map<base::string16, blink::WebInputElement> FormInputElementMap; 44 typedef std::map<base::string16, blink::WebInputElement> FormInputElementMap;
43 45
46 // Use the shorter name when referencing SavePasswordProgressLogger::StringID
47 // values to spare line breaks. The code provides enough context for that
48 // already.
49 typedef SavePasswordProgressLogger Logger;
50
44 // Utility struct for form lookup and autofill. When we parse the DOM to look up 51 // Utility struct for form lookup and autofill. When we parse the DOM to look up
45 // a form, in addition to action and origin URL's we have to compare all 52 // a form, in addition to action and origin URL's we have to compare all
46 // necessary form elements. To avoid having to look these up again when we want 53 // necessary form elements. To avoid having to look these up again when we want
47 // to fill the form, the FindFormElements function stores the pointers 54 // to fill the form, the FindFormElements function stores the pointers
48 // in a FormElements* result, referenced to ensure they are safe to use. 55 // in a FormElements* result, referenced to ensure they are safe to use.
49 struct FormElements { 56 struct FormElements {
50 blink::WebFormElement form_element; 57 blink::WebFormElement form_element;
51 FormInputElementMap input_elements; 58 FormInputElementMap input_elements;
52 }; 59 };
53 60
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // appropriately named elements match the element to be saved. Currently 200 // appropriately named elements match the element to be saved. Currently
194 // we ignore filling passwords where naming is ambigious anyway. 201 // we ignore filling passwords where naming is ambigious anyway.
195 for (size_t i = 0; i < temp_elements.size(); ++i) { 202 for (size_t i = 0; i < temp_elements.size(); ++i) {
196 if (temp_elements[i].to<blink::WebElement>().getAttribute("value") == 203 if (temp_elements[i].to<blink::WebElement>().getAttribute("value") ==
197 form.password_value) 204 form.password_value)
198 return true; 205 return true;
199 } 206 }
200 return false; 207 return false;
201 } 208 }
202 209
210 // Log a message including the name, method and action of |form|.
211 void LogHTMLForm(SavePasswordProgressLogger* logger,
212 SavePasswordProgressLogger::StringID message_id,
213 const blink::WebFormElement& form) {
214 logger->LogHTMLForm(message_id,
215 form.name().utf8(),
216 form.method().utf8(),
217 GURL(form.action().utf8()));
218 }
219
203 } // namespace 220 } // namespace
204 221
205 //////////////////////////////////////////////////////////////////////////////// 222 ////////////////////////////////////////////////////////////////////////////////
206 // PasswordAutofillAgent, public: 223 // PasswordAutofillAgent, public:
207 224
208 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) 225 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view)
209 : content::RenderViewObserver(render_view), 226 : content::RenderViewObserver(render_view),
210 usernames_usage_(NOTHING_TO_AUTOFILL), 227 usernames_usage_(NOTHING_TO_AUTOFILL),
211 web_view_(render_view->GetWebView()), 228 web_view_(render_view->GetWebView()),
229 logging_state_active_(false),
212 weak_ptr_factory_(this) { 230 weak_ptr_factory_(this) {
213 } 231 }
214 232
215 PasswordAutofillAgent::~PasswordAutofillAgent() { 233 PasswordAutofillAgent::~PasswordAutofillAgent() {
216 } 234 }
217 235
218 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() 236 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper()
219 : was_user_gesture_seen_(false) { 237 : was_user_gesture_seen_(false) {
220 } 238 }
221 239
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) { 416 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) {
399 SendPasswordForms(frame, false /* only_visible */); 417 SendPasswordForms(frame, false /* only_visible */);
400 } 418 }
401 419
402 void PasswordAutofillAgent::FirstUserGestureObserved() { 420 void PasswordAutofillAgent::FirstUserGestureObserved() {
403 gatekeeper_.OnUserGesture(); 421 gatekeeper_.OnUserGesture();
404 } 422 }
405 423
406 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame, 424 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame,
407 bool only_visible) { 425 bool only_visible) {
426 scoped_ptr<RendererSavePasswordProgressLogger> logger;
427 // From the perspective of saving passwords, only calls with |only_visible|
428 // being true are important -- the decision whether to save the password is
429 // only made after visible forms are known, for failed login detection. Calls
430 // with |only_visible| false are important for password form autofill, which
431 // is currently not part of the logging.
432 if (only_visible && logging_state_active_) {
433 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
434 logger->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD);
435 }
436
408 // Make sure that this security origin is allowed to use password manager. 437 // Make sure that this security origin is allowed to use password manager.
409 blink::WebSecurityOrigin origin = frame->document().securityOrigin(); 438 blink::WebSecurityOrigin origin = frame->document().securityOrigin();
410 if (!OriginCanAccessPasswordManager(origin)) 439 if (logger) {
440 logger->LogURL(Logger::STRING_SECURITY_ORIGIN,
441 GURL(origin.toString().utf8()));
442 }
443 if (!OriginCanAccessPasswordManager(origin)) {
444 if (logger) {
445 logger->LogMessage(Logger::STRING_SECURITY_ORIGIN_FAILURE);
446 logger->LogMessage(Logger::STRING_DECISION_DROP);
447 }
411 return; 448 return;
449 }
412 450
413 // Checks whether the webpage is a redirect page or an empty page. 451 // Checks whether the webpage is a redirect page or an empty page.
414 if (IsWebpageEmpty(frame)) 452 if (IsWebpageEmpty(frame)) {
453 if (logger) {
454 logger->LogMessage(Logger::STRING_WEBPAGE_EMPTY);
455 logger->LogMessage(Logger::STRING_DECISION_DROP);
456 }
415 return; 457 return;
458 }
416 459
417 blink::WebVector<blink::WebFormElement> forms; 460 blink::WebVector<blink::WebFormElement> forms;
418 frame->document().forms(forms); 461 frame->document().forms(forms);
462 if (logger)
463 logger->LogNumber(Logger::STRING_NUMBER_OF_ALL_FORMS, forms.size());
419 464
420 std::vector<PasswordForm> password_forms; 465 std::vector<PasswordForm> password_forms;
421 for (size_t i = 0; i < forms.size(); ++i) { 466 for (size_t i = 0; i < forms.size(); ++i) {
422 const blink::WebFormElement& form = forms[i]; 467 const blink::WebFormElement& form = forms[i];
468 bool is_form_visible = IsWebNodeVisible(form);
469 if (logger) {
470 LogHTMLForm(logger.get(), Logger::STRING_FORM_FOUND_ON_PAGE, form);
471 logger->LogBoolean(Logger::STRING_FORM_IS_VISIBLE, is_form_visible);
472 }
423 473
424 // If requested, ignore non-rendered forms, e.g. those styled with 474 // If requested, ignore non-rendered forms, e.g. those styled with
425 // display:none. 475 // display:none.
426 if (only_visible && !IsWebNodeVisible(form)) 476 if (only_visible && !is_form_visible)
427 continue; 477 continue;
428 478
429 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); 479 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form));
430 if (password_form.get()) 480 if (password_form.get()) {
481 if (logger) {
482 logger->LogPasswordForm(Logger::STRING_FORM_IS_PASSWORD,
483 *password_form);
484 }
431 password_forms.push_back(*password_form); 485 password_forms.push_back(*password_form);
486 }
432 } 487 }
433 488
434 if (password_forms.empty() && !only_visible) { 489 if (password_forms.empty() && !only_visible) {
435 // We need to send the PasswordFormsRendered message regardless of whether 490 // We need to send the PasswordFormsRendered message regardless of whether
436 // there are any forms visible, as this is also the code path that triggers 491 // there are any forms visible, as this is also the code path that triggers
437 // showing the infobar. 492 // showing the infobar.
438 return; 493 return;
439 } 494 }
440 495
441 if (only_visible) { 496 if (only_visible) {
442 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), 497 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(),
443 password_forms)); 498 password_forms));
444 } else { 499 } else {
445 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); 500 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms));
446 } 501 }
447 } 502 }
448 503
449 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { 504 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) {
450 bool handled = true; 505 bool handled = true;
451 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) 506 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message)
452 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) 507 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm)
508 IPC_MESSAGE_HANDLER(AutofillMsg_ChangeLoggingState, OnChangeLoggingState)
453 IPC_MESSAGE_UNHANDLED(handled = false) 509 IPC_MESSAGE_UNHANDLED(handled = false)
454 IPC_END_MESSAGE_MAP() 510 IPC_END_MESSAGE_MAP()
455 return handled; 511 return handled;
456 } 512 }
457 513
458 void PasswordAutofillAgent::DidStartLoading() { 514 void PasswordAutofillAgent::DidStartLoading() {
459 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { 515 if (usernames_usage_ != NOTHING_TO_AUTOFILL) {
460 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", 516 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage",
461 usernames_usage_, 517 usernames_usage_,
462 OTHER_POSSIBLE_USERNAMES_MAX); 518 OTHER_POSSIBLE_USERNAMES_MAX);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // into a hidden field and then clear the password (http://crbug.com/28910). 550 // into a hidden field and then clear the password (http://crbug.com/28910).
495 // This method gets called before any of those handlers run, so save away 551 // This method gets called before any of those handlers run, so save away
496 // a copy of the password in case it gets lost. 552 // a copy of the password in case it gets lost.
497 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); 553 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form));
498 if (password_form) 554 if (password_form)
499 provisionally_saved_forms_[frame].reset(password_form.release()); 555 provisionally_saved_forms_[frame].reset(password_form.release());
500 } 556 }
501 557
502 void PasswordAutofillAgent::WillSubmitForm(blink::WebLocalFrame* frame, 558 void PasswordAutofillAgent::WillSubmitForm(blink::WebLocalFrame* frame,
503 const blink::WebFormElement& form) { 559 const blink::WebFormElement& form) {
560 scoped_ptr<RendererSavePasswordProgressLogger> logger;
561 if (logging_state_active_) {
562 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
563 logger->LogMessage(Logger::STRING_WILL_SUBMIT_FORM_METHOD);
564 LogHTMLForm(logger.get(), Logger::STRING_HTML_FORM_FOR_SUBMIT, form);
565 }
566
504 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); 567 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form);
505 568
506 // If there is a provisionally saved password, copy over the previous 569 // If there is a provisionally saved password, copy over the previous
507 // password value so we get the user's typed password, not the value that 570 // password value so we get the user's typed password, not the value that
508 // may have been transformed for submit. 571 // may have been transformed for submit.
509 // TODO(gcasto): Do we need to have this action equality check? Is it trying 572 // TODO(gcasto): Do we need to have this action equality check? Is it trying
510 // to prevent accidentally copying over passwords from a different form? 573 // to prevent accidentally copying over passwords from a different form?
511 if (submitted_form) { 574 if (submitted_form) {
575 if (logger) {
576 logger->LogPasswordForm(Logger::STRING_CREATED_PASSWORD_FORM,
577 *submitted_form);
578 }
512 if (provisionally_saved_forms_[frame].get() && 579 if (provisionally_saved_forms_[frame].get() &&
513 submitted_form->action == provisionally_saved_forms_[frame]->action) { 580 submitted_form->action == provisionally_saved_forms_[frame]->action) {
581 if (logger)
582 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED);
514 submitted_form->password_value = 583 submitted_form->password_value =
515 provisionally_saved_forms_[frame]->password_value; 584 provisionally_saved_forms_[frame]->password_value;
516 } 585 }
517 586
518 // Some observers depend on sending this information now instead of when 587 // Some observers depend on sending this information now instead of when
519 // the frame starts loading. If there are redirects that cause a new 588 // the frame starts loading. If there are redirects that cause a new
520 // RenderView to be instantiated (such as redirects to the WebStore) 589 // RenderView to be instantiated (such as redirects to the WebStore)
521 // we will never get to finish the load. 590 // we will never get to finish the load.
522 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(), 591 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
523 *submitted_form)); 592 *submitted_form));
524 // Remove reference since we have already submitted this form. 593 // Remove reference since we have already submitted this form.
525 provisionally_saved_forms_.erase(frame); 594 provisionally_saved_forms_.erase(frame);
595 } else if (logger) {
596 logger->LogMessage(Logger::STRING_DECISION_DROP);
526 } 597 }
527 } 598 }
528 599
529 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms( 600 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms(
530 const blink::WebFrame* current_frame) { 601 const blink::WebFrame* current_frame) {
531 for (FrameToPasswordFormMap::const_iterator it = 602 for (FrameToPasswordFormMap::const_iterator it =
532 provisionally_saved_forms_.begin(); 603 provisionally_saved_forms_.begin();
533 it != provisionally_saved_forms_.end(); 604 it != provisionally_saved_forms_.end();
534 ++it) { 605 ++it) {
535 blink::WebFrame* form_frame = it->first; 606 blink::WebFrame* form_frame = it->first;
536 // The check that the returned frame is related to |current_frame| is mainly 607 // The check that the returned frame is related to |current_frame| is mainly
537 // for double-checking. There should not be any unrelated frames in 608 // for double-checking. There should not be any unrelated frames in
538 // |provisionally_saved_forms_|, because the map is cleared after 609 // |provisionally_saved_forms_|, because the map is cleared after
539 // navigation. If there are reasons to remove this check in the future and 610 // navigation. If there are reasons to remove this check in the future and
540 // keep just the first frame found, it might be a good idea to add a UMA 611 // keep just the first frame found, it might be a good idea to add a UMA
541 // statistic or a similar check on how many frames are here to choose from. 612 // statistic or a similar check on how many frames are here to choose from.
542 if (current_frame == form_frame || 613 if (current_frame == form_frame ||
543 current_frame->findChildByName(form_frame->assignedName())) { 614 current_frame->findChildByName(form_frame->assignedName())) {
544 return form_frame; 615 return form_frame;
545 } 616 }
546 } 617 }
547 return NULL; 618 return NULL;
548 } 619 }
549 620
550 void PasswordAutofillAgent::DidStartProvisionalLoad( 621 void PasswordAutofillAgent::DidStartProvisionalLoad(
551 blink::WebLocalFrame* frame) { 622 blink::WebLocalFrame* frame) {
623 scoped_ptr<RendererSavePasswordProgressLogger> logger;
624 if (logging_state_active_) {
625 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
626 logger->LogMessage(Logger::STRING_DID_START_PROVISIONAL_LOAD_METHOD);
627 }
628
552 if (!frame->parent()) { 629 if (!frame->parent()) {
553 // If the navigation is not triggered by a user gesture, e.g. by some ajax 630 // If the navigation is not triggered by a user gesture, e.g. by some ajax
554 // callback, then inherit the submitted password form from the previous 631 // callback, then inherit the submitted password form from the previous
555 // state. This fixes the no password save issue for ajax login, tracked in 632 // state. This fixes the no password save issue for ajax login, tracked in
556 // [http://crbug/43219]. Note that this still fails for sites that use 633 // [http://crbug/43219]. Note that this still fails for sites that use
557 // synchonous XHR as isProcessingUserGesture() will return true. 634 // synchonous XHR as isProcessingUserGesture() will return true.
558 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); 635 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame);
636 if (logger) {
637 logger->LogBoolean(Logger::STRING_FORM_FRAME_EQ_FRAME,
638 form_frame == frame);
639 }
559 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) { 640 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) {
560 // If onsubmit has been called, try and save that form. 641 // If onsubmit has been called, try and save that form.
561 if (provisionally_saved_forms_[form_frame].get()) { 642 if (provisionally_saved_forms_[form_frame].get()) {
643 if (logger) {
644 logger->LogPasswordForm(
645 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME,
646 *provisionally_saved_forms_[form_frame]);
647 }
562 Send(new AutofillHostMsg_PasswordFormSubmitted( 648 Send(new AutofillHostMsg_PasswordFormSubmitted(
563 routing_id(), *provisionally_saved_forms_[form_frame])); 649 routing_id(), *provisionally_saved_forms_[form_frame]));
564 provisionally_saved_forms_.erase(form_frame); 650 provisionally_saved_forms_.erase(form_frame);
565 } else { 651 } else {
566 // Loop through the forms on the page looking for one that has been 652 // Loop through the forms on the page looking for one that has been
567 // filled out. If one exists, try and save the credentials. 653 // filled out. If one exists, try and save the credentials.
568 blink::WebVector<blink::WebFormElement> forms; 654 blink::WebVector<blink::WebFormElement> forms;
569 frame->document().forms(forms); 655 frame->document().forms(forms);
570 656
657 bool password_forms_found = false;
571 for (size_t i = 0; i < forms.size(); ++i) { 658 for (size_t i = 0; i < forms.size(); ++i) {
572 blink::WebFormElement form_element = forms[i]; 659 blink::WebFormElement form_element = forms[i];
660 if (logger) {
661 LogHTMLForm(
662 logger.get(), Logger::STRING_FORM_FOUND_ON_PAGE, form_element);
663 }
573 scoped_ptr<PasswordForm> password_form( 664 scoped_ptr<PasswordForm> password_form(
574 CreatePasswordForm(form_element)); 665 CreatePasswordForm(form_element));
575 if (password_form.get() && !password_form->username_value.empty() && 666 if (password_form.get() && !password_form->username_value.empty() &&
576 !password_form->password_value.empty() && 667 !password_form->password_value.empty() &&
577 !PasswordValueIsDefault(*password_form, form_element)) { 668 !PasswordValueIsDefault(*password_form, form_element)) {
669 password_forms_found = true;
670 if (logger) {
671 logger->LogPasswordForm(
672 Logger::STRING_PASSWORD_FORM_FOUND_ON_PAGE, *password_form);
673 }
578 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(), 674 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
579 *password_form)); 675 *password_form));
580 } 676 }
581 } 677 }
678 if (!password_forms_found && logger) {
679 logger->LogMessage(Logger::STRING_DECISION_DROP);
680 }
582 } 681 }
583 } 682 }
584 // Clear the whole map during main frame navigation. 683 // Clear the whole map during main frame navigation.
585 provisionally_saved_forms_.clear(); 684 provisionally_saved_forms_.clear();
586 685
587 // This is a new navigation, so require a new user gesture before filling in 686 // This is a new navigation, so require a new user gesture before filling in
588 // passwords. 687 // passwords.
589 gatekeeper_.Reset(); 688 gatekeeper_.Reset();
689 } else {
690 if (logger)
691 logger->LogMessage(Logger::STRING_DECISION_DROP);
590 } 692 }
591 } 693 }
592 694
593 void PasswordAutofillAgent::OnFillPasswordForm( 695 void PasswordAutofillAgent::OnFillPasswordForm(
594 const PasswordFormFillData& form_data) { 696 const PasswordFormFillData& form_data) {
595 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { 697 if (usernames_usage_ == NOTHING_TO_AUTOFILL) {
596 if (form_data.other_possible_usernames.size()) 698 if (form_data.other_possible_usernames.size())
597 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; 699 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT;
598 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) 700 else if (usernames_usage_ == NOTHING_TO_AUTOFILL)
599 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; 701 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 736
635 FormData form; 737 FormData form;
636 FormFieldData field; 738 FormFieldData field;
637 FindFormAndFieldForFormControlElement( 739 FindFormAndFieldForFormControlElement(
638 username_element, &form, &field, REQUIRE_NONE); 740 username_element, &form, &field, REQUIRE_NONE);
639 Send(new AutofillHostMsg_AddPasswordFormMapping( 741 Send(new AutofillHostMsg_AddPasswordFormMapping(
640 routing_id(), field, form_data)); 742 routing_id(), field, form_data));
641 } 743 }
642 } 744 }
643 745
746 void PasswordAutofillAgent::OnChangeLoggingState(bool active) {
747 logging_state_active_ = active;
748 }
749
644 //////////////////////////////////////////////////////////////////////////////// 750 ////////////////////////////////////////////////////////////////////////////////
645 // PasswordAutofillAgent, private: 751 // PasswordAutofillAgent, private:
646 752
647 void PasswordAutofillAgent::GetSuggestions( 753 void PasswordAutofillAgent::GetSuggestions(
648 const PasswordFormFillData& fill_data, 754 const PasswordFormFillData& fill_data,
649 const base::string16& input, 755 const base::string16& input,
650 std::vector<base::string16>* suggestions, 756 std::vector<base::string16>* suggestions,
651 std::vector<base::string16>* realms) { 757 std::vector<base::string16>* realms) {
652 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { 758 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) {
653 suggestions->push_back(fill_data.basic_data.fields[0].value); 759 suggestions->push_back(fill_data.basic_data.fields[0].value);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 1002 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
897 if (iter == login_to_password_info_.end()) 1003 if (iter == login_to_password_info_.end())
898 return false; 1004 return false;
899 1005
900 *found_input = input; 1006 *found_input = input;
901 *found_password = iter->second; 1007 *found_password = iter->second;
902 return true; 1008 return true;
903 } 1009 }
904 1010
905 } // namespace autofill 1011 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698