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; | |
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|. | |
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(); |
Evan Stade
2015/03/23 21:40:41
+walter --- the meaning of this is changing slight
Walter Cacau
2015/03/23 21:53:07
Maybe we should create a new histogram value for t
Evan Stade
2015/03/23 22:09:06
I don't think it's very common or very interesting
Evan Stade
2015/03/23 22:34:02
Done.
| |
571 return; | 599 return; |
572 } | 600 } |
573 credit_card_form_event_logger_->OnDidFillSuggestion(credit_card); | 601 credit_card_form_event_logger_->OnDidFillSuggestion(credit_card); |
574 } | 602 } |
575 | 603 |
576 FillOrPreviewDataModelForm(action, query_id, form, field, credit_card, | 604 FillOrPreviewDataModelForm(action, query_id, form, field, credit_card, |
577 variant, true /* is_credit_card */); | 605 variant, true /* is_credit_card */); |
578 } | 606 } |
579 | 607 |
580 void AutofillManager::FillOrPreviewProfileForm( | 608 void AutofillManager::FillOrPreviewProfileForm( |
(...skipping 881 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 |