OLD | NEW |
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" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 } | 448 } |
449 | 449 |
450 void PasswordAutofillAgent::DidStartLoading() { | 450 void PasswordAutofillAgent::DidStartLoading() { |
451 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 451 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
452 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 452 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
453 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 453 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
454 usernames_usage_ = NOTHING_TO_AUTOFILL; | 454 usernames_usage_ = NOTHING_TO_AUTOFILL; |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebFrame* frame) { | 458 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { |
459 // The |frame| contents have been parsed, but not yet rendered. Let the | 459 // The |frame| contents have been parsed, but not yet rendered. Let the |
460 // PasswordManager know that forms are loaded, even though we can't yet tell | 460 // PasswordManager know that forms are loaded, even though we can't yet tell |
461 // whether they're visible. | 461 // whether they're visible. |
462 SendPasswordForms(frame, false); | 462 SendPasswordForms(frame, false); |
463 } | 463 } |
464 | 464 |
465 void PasswordAutofillAgent::DidFinishLoad(blink::WebFrame* frame) { | 465 void PasswordAutofillAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
466 // The |frame| contents have been rendered. Let the PasswordManager know | 466 // The |frame| contents have been rendered. Let the PasswordManager know |
467 // which of the loaded frames are actually visible to the user. This also | 467 // which of the loaded frames are actually visible to the user. This also |
468 // triggers the "Save password?" infobar if the user just submitted a password | 468 // triggers the "Save password?" infobar if the user just submitted a password |
469 // form. | 469 // form. |
470 SendPasswordForms(frame, true); | 470 SendPasswordForms(frame, true); |
471 } | 471 } |
472 | 472 |
473 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) { | 473 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) { |
474 FrameClosing(frame); | 474 FrameClosing(frame); |
475 } | 475 } |
476 | 476 |
477 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) { | 477 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) { |
478 FrameClosing(frame); | 478 FrameClosing(frame); |
479 } | 479 } |
480 | 480 |
481 void PasswordAutofillAgent::WillSendSubmitEvent( | 481 void PasswordAutofillAgent::WillSendSubmitEvent( |
482 blink::WebFrame* frame, | 482 blink::WebLocalFrame* frame, |
483 const blink::WebFormElement& form) { | 483 const blink::WebFormElement& form) { |
484 // Some login forms have onSubmit handlers that put a hash of the password | 484 // Some login forms have onSubmit handlers that put a hash of the password |
485 // into a hidden field and then clear the password (http://crbug.com/28910). | 485 // into a hidden field and then clear the password (http://crbug.com/28910). |
486 // This method gets called before any of those handlers run, so save away | 486 // This method gets called before any of those handlers run, so save away |
487 // a copy of the password in case it gets lost. | 487 // a copy of the password in case it gets lost. |
488 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); | 488 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); |
489 if (password_form) | 489 if (password_form) |
490 provisionally_saved_forms_[frame].reset(password_form.release()); | 490 provisionally_saved_forms_[frame].reset(password_form.release()); |
491 } | 491 } |
492 | 492 |
493 void PasswordAutofillAgent::WillSubmitForm(blink::WebFrame* frame, | 493 void PasswordAutofillAgent::WillSubmitForm(blink::WebLocalFrame* frame, |
494 const blink::WebFormElement& form) { | 494 const blink::WebFormElement& form) { |
495 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); | 495 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); |
496 | 496 |
497 // If there is a provisionally saved password, copy over the previous | 497 // If there is a provisionally saved password, copy over the previous |
498 // password value so we get the user's typed password, not the value that | 498 // password value so we get the user's typed password, not the value that |
499 // may have been transformed for submit. | 499 // may have been transformed for submit. |
500 // TODO(gcasto): Do we need to have this action equality check? Is it trying | 500 // TODO(gcasto): Do we need to have this action equality check? Is it trying |
501 // to prevent accidentally copying over passwords from a different form? | 501 // to prevent accidentally copying over passwords from a different form? |
502 if (submitted_form) { | 502 if (submitted_form) { |
503 if (provisionally_saved_forms_[frame].get() && | 503 if (provisionally_saved_forms_[frame].get() && |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // keep just the first frame found, it might be a good idea to add a UMA | 535 // keep just the first frame found, it might be a good idea to add a UMA |
536 // statistic or a similar check on how many frames are here to choose from. | 536 // statistic or a similar check on how many frames are here to choose from. |
537 if (current_frame == form_frame || | 537 if (current_frame == form_frame || |
538 current_frame->findChildByName(form_frame->assignedName())) { | 538 current_frame->findChildByName(form_frame->assignedName())) { |
539 return form_frame; | 539 return form_frame; |
540 } | 540 } |
541 } | 541 } |
542 return NULL; | 542 return NULL; |
543 } | 543 } |
544 | 544 |
545 void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) { | 545 void PasswordAutofillAgent::DidStartProvisionalLoad( |
| 546 blink::WebLocalFrame* frame) { |
546 if (!frame->parent()) { | 547 if (!frame->parent()) { |
547 // If the navigation is not triggered by a user gesture, e.g. by some ajax | 548 // If the navigation is not triggered by a user gesture, e.g. by some ajax |
548 // callback, then inherit the submitted password form from the previous | 549 // callback, then inherit the submitted password form from the previous |
549 // state. This fixes the no password save issue for ajax login, tracked in | 550 // state. This fixes the no password save issue for ajax login, tracked in |
550 // [http://crbug/43219]. Note that this still fails for sites that use | 551 // [http://crbug/43219]. Note that this still fails for sites that use |
551 // synchonous XHR as isProcessingUserGesture() will return true. | 552 // synchonous XHR as isProcessingUserGesture() will return true. |
552 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); | 553 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); |
553 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) { | 554 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) { |
554 // If onsubmit has been called, try and save that form. | 555 // If onsubmit has been called, try and save that form. |
555 if (provisionally_saved_forms_[form_frame].get()) { | 556 if (provisionally_saved_forms_[form_frame].get()) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 896 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
896 if (iter == login_to_password_info_.end()) | 897 if (iter == login_to_password_info_.end()) |
897 return false; | 898 return false; |
898 | 899 |
899 *found_input = input; | 900 *found_input = input; |
900 *found_password = iter->second; | 901 *found_password = iter->second; |
901 return true; | 902 return true; |
902 } | 903 } |
903 | 904 |
904 } // namespace autofill | 905 } // namespace autofill |
OLD | NEW |