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

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

Issue 23622013: Move password_form_conversion_utils out of //content into //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@password_form_includes_removal
Patch Set: Created 7 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
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/content/renderer/password_form_conversion_utils.h"
13 #include "components/autofill/core/common/autofill_messages.h" 14 #include "components/autofill/core/common/autofill_messages.h"
14 #include "components/autofill/core/common/form_field_data.h" 15 #include "components/autofill/core/common/form_field_data.h"
15 #include "components/autofill/core/common/password_form_fill_data.h" 16 #include "components/autofill/core/common/password_form_fill_data.h"
16 #include "content/public/common/password_form.h" 17 #include "content/public/common/password_form.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/WebUserGestureIndicator.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 366
367 std::vector<content::PasswordForm> password_forms; 367 std::vector<content::PasswordForm> password_forms;
368 for (size_t i = 0; i < forms.size(); ++i) { 368 for (size_t i = 0; i < forms.size(); ++i) {
369 const WebKit::WebFormElement& form = forms[i]; 369 const WebKit::WebFormElement& form = forms[i];
370 370
371 // If requested, ignore non-rendered forms, e.g. those styled with 371 // If requested, ignore non-rendered forms, e.g. those styled with
372 // display:none. 372 // display:none.
373 if (only_visible && !IsWebNodeVisible(form)) 373 if (only_visible && !IsWebNodeVisible(form))
374 continue; 374 continue;
375 375
376 scoped_ptr<content::PasswordForm> password_form( 376 scoped_ptr<content::PasswordForm> password_form(CreatePasswordForm(form));
377 content::CreatePasswordForm(form));
378 if (password_form.get()) 377 if (password_form.get())
379 password_forms.push_back(*password_form); 378 password_forms.push_back(*password_form);
380 } 379 }
381 380
382 if (password_forms.empty() && !only_visible) { 381 if (password_forms.empty() && !only_visible) {
383 // We need to send the PasswordFormsRendered message regardless of whether 382 // We need to send the PasswordFormsRendered message regardless of whether
384 // there are any forms visible, as this is also the code path that triggers 383 // there are any forms visible, as this is also the code path that triggers
385 // showing the infobar. 384 // showing the infobar.
386 return; 385 return;
387 } 386 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 FrameClosing(frame); 433 FrameClosing(frame);
435 } 434 }
436 435
437 void PasswordAutofillAgent::WillSendSubmitEvent( 436 void PasswordAutofillAgent::WillSendSubmitEvent(
438 WebKit::WebFrame* frame, 437 WebKit::WebFrame* frame,
439 const WebKit::WebFormElement& form) { 438 const WebKit::WebFormElement& form) {
440 // Some login forms have onSubmit handlers that put a hash of the password 439 // Some login forms have onSubmit handlers that put a hash of the password
441 // into a hidden field and then clear the password (http://crbug.com/28910). 440 // into a hidden field and then clear the password (http://crbug.com/28910).
442 // This method gets called before any of those handlers run, so save away 441 // This method gets called before any of those handlers run, so save away
443 // a copy of the password in case it gets lost. 442 // a copy of the password in case it gets lost.
444 provisionally_saved_forms_[frame].reset( 443 provisionally_saved_forms_[frame].reset(CreatePasswordForm(form).release());
445 content::CreatePasswordForm(form).release());
446 } 444 }
447 445
448 void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame, 446 void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame,
449 const WebKit::WebFormElement& form) { 447 const WebKit::WebFormElement& form) {
450 scoped_ptr<content::PasswordForm> submitted_form = 448 scoped_ptr<content::PasswordForm> submitted_form = CreatePasswordForm(form);
451 content::CreatePasswordForm(form);
452 449
453 // If there is a provisionally saved password, copy over the previous 450 // If there is a provisionally saved password, copy over the previous
454 // password value so we get the user's typed password, not the value that 451 // password value so we get the user's typed password, not the value that
455 // may have been transformed for submit. 452 // may have been transformed for submit.
456 // TODO(gcasto): Do we need to have this action equality check? Is it trying 453 // TODO(gcasto): Do we need to have this action equality check? Is it trying
457 // to prevent accidentally copying over passwords from a different form? 454 // to prevent accidentally copying over passwords from a different form?
458 if (submitted_form) { 455 if (submitted_form) {
459 if (provisionally_saved_forms_[frame].get() && 456 if (provisionally_saved_forms_[frame].get() &&
460 submitted_form->action == provisionally_saved_forms_[frame]->action) { 457 submitted_form->action == provisionally_saved_forms_[frame]->action) {
461 submitted_form->password_value = 458 submitted_form->password_value =
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 733 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
737 if (iter == login_to_password_info_.end()) 734 if (iter == login_to_password_info_.end())
738 return false; 735 return false;
739 736
740 *found_input = input; 737 *found_input = input;
741 *found_password = iter->second; 738 *found_password = iter->second;
742 return true; 739 return true;
743 } 740 }
744 741
745 } // namespace autofill 742 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698