| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // fields. | 496 // fields. |
| 497 | 497 |
| 498 // Input matches the username, fill in required values. | 498 // Input matches the username, fill in required values. |
| 499 if (!username_element->isNull() && | 499 if (!username_element->isNull() && |
| 500 IsElementAutocompletable(*username_element)) { | 500 IsElementAutocompletable(*username_element)) { |
| 501 // TODO(crbug.com/507714): Why not setSuggestedValue? | 501 // TODO(crbug.com/507714): Why not setSuggestedValue? |
| 502 username_element->setValue(username, true); | 502 username_element->setValue(username, true); |
| 503 (*nonscript_modified_values)[*username_element] = username; | 503 (*nonscript_modified_values)[*username_element] = username; |
| 504 username_element->setAutofilled(true); | 504 username_element->setAutofilled(true); |
| 505 if (logger) | 505 if (logger) |
| 506 logger->LogMessage(Logger::STRING_USERNAME_FILLED); | 506 logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element); |
| 507 if (set_selection) { | 507 if (set_selection) { |
| 508 form_util::PreviewSuggestion(username, current_username, | 508 form_util::PreviewSuggestion(username, current_username, |
| 509 username_element); | 509 username_element); |
| 510 } | 510 } |
| 511 } else if (current_username != username) { | 511 } else if (current_username != username) { |
| 512 // If the username can't be filled and it doesn't match a saved password | 512 // If the username can't be filled and it doesn't match a saved password |
| 513 // as is, don't autofill a password. | 513 // as is, don't autofill a password. |
| 514 return false; | 514 return false; |
| 515 } | 515 } |
| 516 | 516 |
| 517 // Wait to fill in the password until a user gesture occurs. This is to make | 517 // Wait to fill in the password until a user gesture occurs. This is to make |
| 518 // sure that we do not fill in the DOM with a password until we believe the | 518 // sure that we do not fill in the DOM with a password until we believe the |
| 519 // user is intentionally interacting with the page. | 519 // user is intentionally interacting with the page. |
| 520 password_element->setSuggestedValue(password); | 520 password_element->setSuggestedValue(password); |
| 521 (*nonscript_modified_values)[*password_element] = password; | 521 (*nonscript_modified_values)[*password_element] = password; |
| 522 registration_callback.Run(password_element); | 522 registration_callback.Run(password_element); |
| 523 | 523 |
| 524 password_element->setAutofilled(true); | 524 password_element->setAutofilled(true); |
| 525 if (logger) | 525 if (logger) |
| 526 logger->LogMessage(Logger::STRING_PASSWORD_FILLED); | 526 logger->LogElementName(Logger::STRING_PASSWORD_FILLED, *password_element); |
| 527 return true; | 527 return true; |
| 528 } | 528 } |
| 529 | 529 |
| 530 // Attempts to fill |username_element| and |password_element| with the | 530 // Attempts to fill |username_element| and |password_element| with the |
| 531 // |fill_data|. Will use the data corresponding to the preferred username, | 531 // |fill_data|. Will use the data corresponding to the preferred username, |
| 532 // unless the |username_element| already has a value set. In that case, | 532 // unless the |username_element| already has a value set. In that case, |
| 533 // attempts to fill the password matching the already filled username, if | 533 // attempts to fill the password matching the already filled username, if |
| 534 // such a password exists. The |password_element| will have the | 534 // such a password exists. The |password_element| will have the |
| 535 // |suggestedValue| set, and |suggestedValue| will be registered for copying to | 535 // |suggestedValue| set, and |suggestedValue| will be registered for copying to |
| 536 // the real value through |registration_callback|. Returns true if the password | 536 // the real value through |registration_callback|. Returns true if the password |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { | 1537 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { |
| 1538 return provisionally_saved_form_ && | 1538 return provisionally_saved_form_ && |
| 1539 !provisionally_saved_form_->username_value.empty() && | 1539 !provisionally_saved_form_->username_value.empty() && |
| 1540 !(provisionally_saved_form_->password_value.empty() && | 1540 !(provisionally_saved_form_->password_value.empty() && |
| 1541 provisionally_saved_form_->new_password_value.empty()); | 1541 provisionally_saved_form_->new_password_value.empty()); |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 } // namespace autofill | 1544 } // namespace autofill |
| OLD | NEW |