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

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

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Rebase 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/content/renderer/password_form_conversion_utils.h"
14 #include "components/autofill/core/common/autofill_messages.h" 14 #include "components/autofill/core/common/autofill_messages.h"
15 #include "components/autofill/core/common/form_field_data.h" 15 #include "components/autofill/core/common/form_field_data.h"
16 #include "components/autofill/core/common/password_form.h"
16 #include "components/autofill/core/common/password_form_fill_data.h" 17 #include "components/autofill/core/common/password_form_fill_data.h"
17 #include "content/public/common/password_form.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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 void PasswordAutofillAgent::SendPasswordForms(WebKit::WebFrame* frame, 357 void PasswordAutofillAgent::SendPasswordForms(WebKit::WebFrame* frame,
358 bool only_visible) { 358 bool only_visible) {
359 // Make sure that this security origin is allowed to use password manager. 359 // Make sure that this security origin is allowed to use password manager.
360 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); 360 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin();
361 if (!OriginCanAccessPasswordManager(origin)) 361 if (!OriginCanAccessPasswordManager(origin))
362 return; 362 return;
363 363
364 WebKit::WebVector<WebKit::WebFormElement> forms; 364 WebKit::WebVector<WebKit::WebFormElement> forms;
365 frame->document().forms(forms); 365 frame->document().forms(forms);
366 366
367 std::vector<content::PasswordForm> password_forms; 367 std::vector<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(CreatePasswordForm(form)); 376 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form));
377 if (password_form.get()) 377 if (password_form.get())
378 password_forms.push_back(*password_form); 378 password_forms.push_back(*password_form);
379 } 379 }
380 380
381 if (password_forms.empty() && !only_visible) { 381 if (password_forms.empty() && !only_visible) {
382 // We need to send the PasswordFormsRendered message regardless of whether 382 // We need to send the PasswordFormsRendered message regardless of whether
383 // 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
384 // showing the infobar. 384 // showing the infobar.
385 return; 385 return;
386 } 386 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 const WebKit::WebFormElement& form) { 438 const WebKit::WebFormElement& form) {
439 // 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
440 // 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).
441 // 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
442 // a copy of the password in case it gets lost. 442 // a copy of the password in case it gets lost.
443 provisionally_saved_forms_[frame].reset(CreatePasswordForm(form).release()); 443 provisionally_saved_forms_[frame].reset(CreatePasswordForm(form).release());
444 } 444 }
445 445
446 void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame, 446 void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame,
447 const WebKit::WebFormElement& form) { 447 const WebKit::WebFormElement& form) {
448 scoped_ptr<content::PasswordForm> submitted_form = CreatePasswordForm(form); 448 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form);
449 449
450 // If there is a provisionally saved password, copy over the previous 450 // If there is a provisionally saved password, copy over the previous
451 // 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
452 // may have been transformed for submit. 452 // may have been transformed for submit.
453 // 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
454 // to prevent accidentally copying over passwords from a different form? 454 // to prevent accidentally copying over passwords from a different form?
455 if (submitted_form) { 455 if (submitted_form) {
456 if (provisionally_saved_forms_[frame].get() && 456 if (provisionally_saved_forms_[frame].get() &&
457 submitted_form->action == provisionally_saved_forms_[frame]->action) { 457 submitted_form->action == provisionally_saved_forms_[frame]->action) {
458 submitted_form->password_value = 458 submitted_form->password_value =
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 733 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
734 if (iter == login_to_password_info_.end()) 734 if (iter == login_to_password_info_.end())
735 return false; 735 return false;
736 736
737 *found_input = input; 737 *found_input = input;
738 *found_password = iter->second; 738 *found_password = iter->second;
739 return true; 739 return true;
740 } 740 }
741 741
742 } // namespace autofill 742 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698