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

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

Issue 19705013: [password autofill] Remove references to PasswordForm from RenderViewImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/renderer/form_autofill_util.h" 12 #include "components/autofill/content/renderer/form_autofill_util.h"
13 #include "components/autofill/core/common/autofill_messages.h" 13 #include "components/autofill/core/common/autofill_messages.h"
14 #include "components/autofill/core/common/form_field_data.h" 14 #include "components/autofill/core/common/form_field_data.h"
15 #include "components/autofill/core/common/password_form_fill_data.h" 15 #include "components/autofill/core/common/password_form_fill_data.h"
16 #include "content/public/common/password_form.h" 16 #include "content/public/common/password_form.h"
17 #include "content/public/renderer/password_form_conversion_utils.h" 17 #include "content/public/renderer/password_form_conversion_utils.h"
18 #include "content/public/renderer/render_view.h" 18 #include "content/public/renderer/render_view.h"
19 #include "third_party/WebKit/public/platform/WebVector.h" 19 #include "third_party/WebKit/public/platform/WebVector.h"
20 #include "third_party/WebKit/public/web/WebAutofillClient.h" 20 #include "third_party/WebKit/public/web/WebAutofillClient.h"
21 #include "third_party/WebKit/public/web/WebDocument.h" 21 #include "third_party/WebKit/public/web/WebDocument.h"
22 #include "third_party/WebKit/public/web/WebElement.h" 22 #include "third_party/WebKit/public/web/WebElement.h"
23 #include "third_party/WebKit/public/web/WebFormElement.h" 23 #include "third_party/WebKit/public/web/WebFormElement.h"
24 #include "third_party/WebKit/public/web/WebFrame.h" 24 #include "third_party/WebKit/public/web/WebFrame.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h" 25 #include "third_party/WebKit/public/web/WebInputEvent.h"
26 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 26 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
27 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
27 #include "third_party/WebKit/public/web/WebView.h" 28 #include "third_party/WebKit/public/web/WebView.h"
28 #include "ui/base/keycodes/keyboard_codes.h" 29 #include "ui/base/keycodes/keyboard_codes.h"
29 30
30 namespace autofill { 31 namespace autofill {
31 namespace { 32 namespace {
32 33
33 // The size above which we stop triggering autocomplete. 34 // The size above which we stop triggering autocomplete.
34 static const size_t kMaximumTextSizeForAutocomplete = 1000; 35 static const size_t kMaximumTextSizeForAutocomplete = 1000;
35 36
36 // Maps element names to the actual elements to simplify form filling. 37 // Maps element names to the actual elements to simplify form filling.
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 422 }
422 423
423 void PasswordAutofillAgent::FrameDetached(WebKit::WebFrame* frame) { 424 void PasswordAutofillAgent::FrameDetached(WebKit::WebFrame* frame) {
424 FrameClosing(frame); 425 FrameClosing(frame);
425 } 426 }
426 427
427 void PasswordAutofillAgent::FrameWillClose(WebKit::WebFrame* frame) { 428 void PasswordAutofillAgent::FrameWillClose(WebKit::WebFrame* frame) {
428 FrameClosing(frame); 429 FrameClosing(frame);
429 } 430 }
430 431
432 void PasswordAutofillAgent::WillSendSubmitEvent(
433 WebKit::WebFrame* frame,
434 const WebKit::WebFormElement& form) {
435 // Some login forms have onSubmit handlers that put a hash of the password
436 // into a hidden field and then clear the password (http://crbug.com/28910).
437 // This method gets called before any of those handlers run, so save away
438 // a copy of the password in case it gets lost.
439 provisionally_saved_forms_[frame].reset(
440 content::CreatePasswordForm(form).release());
441 }
442
443 void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame,
444 const WebKit::WebFormElement& form) {
445 scoped_ptr<content::PasswordForm> submitted_form =
446 content::CreatePasswordForm(form);
447
448 // If there is a provisionally saved password, copy over the previous
449 // password value so we get the user's typed password, not the value that
450 // may have been transformed for submit.
451 // TODO(gcasto): Do we need to have this action equality check? Is it trying
452 // to prevent accidentally copying over passwords from a different form?
453 if (submitted_form) {
454 if (provisionally_saved_forms_[frame].get() &&
455 submitted_form->action == provisionally_saved_forms_[frame]->action) {
456 submitted_form->password_value =
457 provisionally_saved_forms_[frame]->password_value;
458 }
459
460 // Some observers depend on sending this information now instead of when
461 // the frame starts loading. If there are redirects that cause a new
462 // RenderView to be instantiated (such as redirects to the WebStore)
463 // we will never get to finish the load.
464 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
465 *submitted_form));
466 // Remove reference since we have already submitted this form.
467 provisionally_saved_forms_.erase(frame);
468 }
469 }
470
471 void PasswordAutofillAgent::DidStartProvisionalLoad(WebKit::WebFrame* frame) {
472 if (!frame->parent()) {
473 // If the navigation is not triggered by a user gesture, e.g. by some ajax
474 // callback, then inherit the submitted password form from the previous
475 // state. This fixes the no password save issue for ajax login, tracked in
476 // [http://crbug/43219]. Note that there are still some sites that this
477 // fails for because they use some element other than a submit button to
478 // trigger submission (which means WillSendSubmitEvent will not be called).
479 if (!WebKit::WebUserGestureIndicator::isProcessingUserGesture() &&
480 provisionally_saved_forms_[frame].get()) {
481 Send(new AutofillHostMsg_PasswordFormSubmitted(
482 routing_id(),
483 *provisionally_saved_forms_[frame]));
484 provisionally_saved_forms_.erase(frame);
485 }
486 // Clear the whole map during main frame navigation.
487 provisionally_saved_forms_.clear();
488 }
489 }
490
431 void PasswordAutofillAgent::OnFillPasswordForm( 491 void PasswordAutofillAgent::OnFillPasswordForm(
432 const PasswordFormFillData& form_data) { 492 const PasswordFormFillData& form_data) {
433 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { 493 if (usernames_usage_ == NOTHING_TO_AUTOFILL) {
434 if (form_data.other_possible_usernames.size()) 494 if (form_data.other_possible_usernames.size())
435 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; 495 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT;
436 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) 496 else if (usernames_usage_ == NOTHING_TO_AUTOFILL)
437 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; 497 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT;
438 } 498 }
439 499
440 FormElementsList forms; 500 FormElementsList forms;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 731 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
672 if (iter == login_to_password_info_.end()) 732 if (iter == login_to_password_info_.end())
673 return false; 733 return false;
674 734
675 *found_input = input; 735 *found_input = input;
676 *found_password = iter->second; 736 *found_password = iter->second;
677 return true; 737 return true;
678 } 738 }
679 739
680 } // namespace autofill 740 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | components/autofill/core/common/autofill_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698