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/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 suggestions); | 544 suggestions); |
| 545 } else { | 545 } else { |
| 546 // Autocomplete is disabled for this field; only pass back Autofill | 546 // Autocomplete is disabled for this field; only pass back Autofill |
| 547 // suggestions. | 547 // suggestions. |
| 548 autocomplete_history_manager_->CancelPendingQuery(); | 548 autocomplete_history_manager_->CancelPendingQuery(); |
| 549 external_delegate_->OnSuggestionsReturned( | 549 external_delegate_->OnSuggestionsReturned( |
| 550 query_id, suggestions); | 550 query_id, suggestions); |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 bool AutofillManager::WillFillCreditCardNumber(const FormData& form, | |
| 555 const FormFieldData& field) { | |
| 556 FormStructure* form_structure = NULL; | |
|
brettw
2015/03/24 22:30:47
I thought we were preferring nullptr for new code.
Evan Stade
2015/03/24 22:34:01
old habits die hard
| |
| 557 AutofillField* autofill_field = NULL; | |
| 558 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field)) | |
| 559 return false; | |
| 560 | |
| 561 if (autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER) | |
| 562 return true; | |
| 563 | |
| 564 // If the relevant section is autofilled, we'll only fill |autofill_field|. | |
|
brettw
2015/03/24 22:30:47
Everything here makes sense to me except these thr
Evan Stade
2015/03/24 22:34:01
your understanding is correct, I'll apply your new
| |
| 565 if (SectionIsAutofilled(*form_structure, form, autofill_field->section())) | |
| 566 return false; | |
| 567 | |
| 568 DCHECK_EQ(form_structure->field_count(), form.fields.size()); | |
| 569 for (size_t i = 0; i < form_structure->field_count(); ++i) { | |
| 570 if (form_structure->field(i)->section() == autofill_field->section() && | |
| 571 form_structure->field(i)->Type().GetStorableType() == | |
| 572 CREDIT_CARD_NUMBER && | |
| 573 form.fields[i].value.empty()) { | |
| 574 return true; | |
| 575 } | |
| 576 } | |
| 577 | |
| 578 return false; | |
| 579 } | |
| 580 | |
| 554 void AutofillManager::FillOrPreviewCreditCardForm( | 581 void AutofillManager::FillOrPreviewCreditCardForm( |
| 555 AutofillDriver::RendererFormDataAction action, | 582 AutofillDriver::RendererFormDataAction action, |
| 556 int query_id, | 583 int query_id, |
| 557 const FormData& form, | 584 const FormData& form, |
| 558 const FormFieldData& field, | 585 const FormFieldData& field, |
| 559 const CreditCard& credit_card, | 586 const CreditCard& credit_card, |
| 560 size_t variant) { | 587 size_t variant) { |
| 561 if (action == AutofillDriver::FORM_DATA_ACTION_FILL) { | 588 if (action == AutofillDriver::FORM_DATA_ACTION_FILL) { |
| 562 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { | 589 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD && |
| 590 WillFillCreditCardNumber(form, field)) { | |
| 563 unmasking_card_ = credit_card; | 591 unmasking_card_ = credit_card; |
| 564 unmasking_query_id_ = query_id; | 592 unmasking_query_id_ = query_id; |
| 565 unmasking_form_ = form; | 593 unmasking_form_ = form; |
| 566 unmasking_field_ = field; | 594 unmasking_field_ = field; |
| 567 real_pan_client_.Prepare(); | 595 real_pan_client_.Prepare(); |
| 568 client()->ShowUnmaskPrompt(unmasking_card_, | 596 client()->ShowUnmaskPrompt(unmasking_card_, |
| 569 weak_ptr_factory_.GetWeakPtr()); | 597 weak_ptr_factory_.GetWeakPtr()); |
| 570 credit_card_form_event_logger_->OnDidSelectMaskedServerCardSuggestion(); | 598 credit_card_form_event_logger_->OnDidSelectMaskedServerCardSuggestion(); |
| 571 return; | 599 return; |
| 572 } | 600 } |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1462 return false; | 1490 return false; |
| 1463 | 1491 |
| 1464 // Disregard forms that we wouldn't ever autofill in the first place. | 1492 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1465 if (!form.ShouldBeParsed()) | 1493 if (!form.ShouldBeParsed()) |
| 1466 return false; | 1494 return false; |
| 1467 | 1495 |
| 1468 return true; | 1496 return true; |
| 1469 } | 1497 } |
| 1470 | 1498 |
| 1471 } // namespace autofill | 1499 } // namespace autofill |
| OLD | NEW |