Chromium Code Reviews| 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_generation_agent.h" | 5 #include "components/autofill/content/renderer/password_generation_agent.h" |
| 6 | 6 |
| 7 #include <memory> | |
|
Mathieu
2016/04/04 13:36:17
and here too, in most other cc files it's omitted
vabr (Chromium)
2016/04/04 14:29:04
Here, on the other hand, line 207, for example, se
| |
| 8 | |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "components/autofill/content/common/autofill_messages.h" | 11 #include "components/autofill/content/common/autofill_messages.h" |
| 11 #include "components/autofill/content/renderer/form_autofill_util.h" | 12 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 12 #include "components/autofill/content/renderer/password_autofill_agent.h" | 13 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 13 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 14 #include "components/autofill/core/common/autofill_switches.h" | 15 #include "components/autofill/core/common/autofill_switches.h" |
| 15 #include "components/autofill/core/common/form_data.h" | 16 #include "components/autofill/core/common/form_data.h" |
| 16 #include "components/autofill/core/common/password_form.h" | 17 #include "components/autofill/core/common/password_form.h" |
| 17 #include "components/autofill/core/common/password_form_generation_data.h" | 18 #include "components/autofill/core/common/password_form_generation_data.h" |
| 18 #include "components/autofill/core/common/password_generation_util.h" | 19 #include "components/autofill/core/common/password_generation_util.h" |
| 19 #include "content/public/renderer/render_frame.h" | 20 #include "content/public/renderer/render_frame.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 return; | 197 return; |
| 197 | 198 |
| 198 blink::WebVector<blink::WebFormElement> forms; | 199 blink::WebVector<blink::WebFormElement> forms; |
| 199 render_frame()->GetWebFrame()->document().forms(forms); | 200 render_frame()->GetWebFrame()->document().forms(forms); |
| 200 for (size_t i = 0; i < forms.size(); ++i) { | 201 for (size_t i = 0; i < forms.size(); ++i) { |
| 201 if (forms[i].isNull()) | 202 if (forms[i].isNull()) |
| 202 continue; | 203 continue; |
| 203 | 204 |
| 204 // If we can't get a valid PasswordForm, we skip this form because the | 205 // If we can't get a valid PasswordForm, we skip this form because the |
| 205 // the password won't get saved even if we generate it. | 206 // the password won't get saved even if we generate it. |
| 206 scoped_ptr<PasswordForm> password_form( | 207 std::unique_ptr<PasswordForm> password_form( |
| 207 CreatePasswordFormFromWebForm(forms[i], nullptr, nullptr)); | 208 CreatePasswordFormFromWebForm(forms[i], nullptr, nullptr)); |
| 208 if (!password_form.get()) { | 209 if (!password_form.get()) { |
| 209 VLOG(2) << "Skipping form as it would not be saved"; | 210 VLOG(2) << "Skipping form as it would not be saved"; |
| 210 continue; | 211 continue; |
| 211 } | 212 } |
| 212 | 213 |
| 213 // Do not generate password for GAIA since it is used to retrieve the | 214 // Do not generate password for GAIA since it is used to retrieve the |
| 214 // generated paswords. | 215 // generated paswords. |
| 215 GURL realm(password_form->signon_realm); | 216 GURL realm(password_form->signon_realm); |
| 216 if (realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) | 217 if (realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 blink::WebDocument doc = render_frame()->GetWebFrame()->document(); | 469 blink::WebDocument doc = render_frame()->GetWebFrame()->document(); |
| 469 if (doc.isNull()) | 470 if (doc.isNull()) |
| 470 return; | 471 return; |
| 471 | 472 |
| 472 blink::WebElement focused_element = doc.focusedElement(); | 473 blink::WebElement focused_element = doc.focusedElement(); |
| 473 const blink::WebInputElement* element = toWebInputElement(&focused_element); | 474 const blink::WebInputElement* element = toWebInputElement(&focused_element); |
| 474 if (!element || !element->isPasswordField()) | 475 if (!element || !element->isPasswordField()) |
| 475 return; | 476 return; |
| 476 | 477 |
| 477 blink::WebFormElement form = element->form(); | 478 blink::WebFormElement form = element->form(); |
| 478 scoped_ptr<PasswordForm> password_form; | 479 std::unique_ptr<PasswordForm> password_form; |
| 479 std::vector<blink::WebFormControlElement> control_elements; | 480 std::vector<blink::WebFormControlElement> control_elements; |
| 480 if (!form.isNull()) { | 481 if (!form.isNull()) { |
| 481 password_form = CreatePasswordFormFromWebForm(form, nullptr, nullptr); | 482 password_form = CreatePasswordFormFromWebForm(form, nullptr, nullptr); |
| 482 control_elements = form_util::ExtractAutofillableElementsInForm(form); | 483 control_elements = form_util::ExtractAutofillableElementsInForm(form); |
| 483 } else { | 484 } else { |
| 484 const blink::WebFrame& frame = *render_frame()->GetWebFrame(); | 485 const blink::WebFrame& frame = *render_frame()->GetWebFrame(); |
| 485 password_form = | 486 password_form = |
| 486 CreatePasswordFormFromUnownedInputElements(frame, nullptr, nullptr); | 487 CreatePasswordFormFromUnownedInputElements(frame, nullptr, nullptr); |
| 487 control_elements = | 488 control_elements = |
| 488 form_util::GetUnownedFormFieldElements(frame.document().all(), nullptr); | 489 form_util::GetUnownedFormFieldElements(frame.document().all(), nullptr); |
| 489 } | 490 } |
| 490 | 491 |
| 491 if (!password_form) | 492 if (!password_form) |
| 492 return; | 493 return; |
| 493 | 494 |
| 494 generation_element_ = *element; | 495 generation_element_ = *element; |
| 495 std::vector<blink::WebInputElement> password_elements; | 496 std::vector<blink::WebInputElement> password_elements; |
| 496 GetAccountCreationPasswordFields(control_elements, &password_elements); | 497 GetAccountCreationPasswordFields(control_elements, &password_elements); |
| 497 password_elements = FindPasswordElementsForGeneration( | 498 password_elements = FindPasswordElementsForGeneration( |
| 498 password_elements, element->nameForAutofill()); | 499 password_elements, element->nameForAutofill()); |
| 499 generation_form_data_.reset(new AccountCreationFormData( | 500 generation_form_data_.reset(new AccountCreationFormData( |
| 500 make_linked_ptr(password_form.release()), password_elements)); | 501 make_linked_ptr(password_form.release()), password_elements)); |
| 501 is_manually_triggered_ = true; | 502 is_manually_triggered_ = true; |
| 502 ShowGenerationPopup(); | 503 ShowGenerationPopup(); |
| 503 } | 504 } |
| 504 | 505 |
| 505 } // namespace autofill | 506 } // namespace autofill |
| OLD | NEW |