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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Uses format string for expiration date label. Consistently returns 0 as default (non-experiment) va… Created 4 years 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/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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 autofill_field->Type().GetStorableType() == CREDIT_CARD_NAME_FULL && 283 autofill_field->Type().GetStorableType() == CREDIT_CARD_NAME_FULL &&
284 base::FeatureList::IsEnabled(kAutofillScanCardholderName); 284 base::FeatureList::IsEnabled(kAutofillScanCardholderName);
285 285
286 if (!is_card_number_field && !is_scannable_name_on_card_field) 286 if (!is_card_number_field && !is_scannable_name_on_card_field)
287 return false; 287 return false;
288 288
289 static const int kShowScanCreditCardMaxValueLength = 6; 289 static const int kShowScanCreditCardMaxValueLength = 6;
290 return field.value.size() <= kShowScanCreditCardMaxValueLength; 290 return field.value.size() <= kShowScanCreditCardMaxValueLength;
291 } 291 }
292 292
293 bool AutofillManager::IsCreditCardField(const FormData& form,
294 const FormFieldData& field) {
295 AutofillField* autofill_field = GetAutofillField(form, field);
296 return autofill_field && autofill_field->Type().group() == CREDIT_CARD;
297 }
298
293 bool AutofillManager::ShouldShowCreditCardSigninPromo( 299 bool AutofillManager::ShouldShowCreditCardSigninPromo(
294 const FormData& form, 300 const FormData& form,
295 const FormFieldData& field) { 301 const FormFieldData& field) {
296 if (!IsAutofillCreditCardSigninPromoEnabled()) 302 if (!IsAutofillCreditCardSigninPromoEnabled())
297 return false; 303 return false;
298 304
299 // Check whether we are dealing with a credit card field and whether it's 305 // Check whether we are dealing with a credit card field and whether it's
300 // appropriate to show the promo (e.g. the platform is supported). 306 // appropriate to show the promo (e.g. the platform is supported).
301 AutofillField* autofill_field = GetAutofillField(form, field); 307 AutofillField* autofill_field = GetAutofillField(form, field);
302 if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD || 308 if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD ||
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 UpdateInitialInteractionTimestamp(timestamp); 509 UpdateInitialInteractionTimestamp(timestamp);
504 } 510 }
505 511
506 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 512 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
507 const FormData& form, 513 const FormData& form,
508 const FormFieldData& field, 514 const FormFieldData& field,
509 const gfx::RectF& bounding_box) { 515 const gfx::RectF& bounding_box) {
510 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 516 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
511 return; 517 return;
512 518
513 std::vector<Suggestion> suggestions;
514
515 gfx::RectF transformed_box = 519 gfx::RectF transformed_box =
516 driver_->TransformBoundingBoxToViewportCoordinates(bounding_box); 520 driver_->TransformBoundingBoxToViewportCoordinates(bounding_box);
517 external_delegate_->OnQuery(query_id, form, field, transformed_box); 521 external_delegate_->OnQuery(query_id, form, field, transformed_box);
518 522
519 // Need to refresh models before using the form_event_loggers. 523 // Need to refresh models before using the form_event_loggers.
520 bool is_autofill_possible = RefreshDataModels(); 524 bool is_autofill_possible = RefreshDataModels();
521 525
522 FormStructure* form_structure = NULL; 526 FormStructure* form_structure = NULL;
523 AutofillField* autofill_field = NULL; 527 AutofillField* autofill_field = NULL;
524 bool got_autofillable_form = 528 bool got_autofillable_form =
525 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 529 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
526 // Don't send suggestions or track forms that should not be parsed. 530 // Don't send suggestions or track forms that should not be parsed.
527 form_structure->ShouldBeParsed(); 531 form_structure->ShouldBeParsed();
528 532
529 // Logging interactions of forms that are autofillable. 533 // Logging interactions of forms that are autofillable.
530 if (got_autofillable_form) { 534 if (got_autofillable_form) {
531 if (autofill_field->Type().group() == CREDIT_CARD) { 535 if (autofill_field->Type().group() == CREDIT_CARD) {
532 driver_->DidInteractWithCreditCardForm(); 536 driver_->DidInteractWithCreditCardForm();
533 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); 537 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm();
534 } else { 538 } else {
535 address_form_event_logger_->OnDidInteractWithAutofillableForm(); 539 address_form_event_logger_->OnDidInteractWithAutofillableForm();
536 } 540 }
537 } 541 }
538 542
543 std::vector<Suggestion> suggestions;
544
539 if (is_autofill_possible && 545 if (is_autofill_possible &&
540 driver_->RendererIsAvailable() && 546 driver_->RendererIsAvailable() &&
541 got_autofillable_form) { 547 got_autofillable_form) {
542 AutofillType type = autofill_field->Type(); 548 AutofillType type = autofill_field->Type();
543 bool is_filling_credit_card = (type.group() == CREDIT_CARD); 549 bool is_filling_credit_card = (type.group() == CREDIT_CARD);
544 // On desktop, don't return non credit card related suggestions for forms or 550 // On desktop, don't return non credit card related suggestions for forms or
545 // fields that have the "autocomplete" attribute set to off. 551 // fields that have the "autocomplete" attribute set to off.
546 if (IsDesktopPlatform() && !is_filling_credit_card && 552 if (IsDesktopPlatform() && !is_filling_credit_card &&
547 !field.should_autocomplete) { 553 !field.should_autocomplete) {
548 return; 554 return;
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 credit_card_form_event_logger_->OnDidPollSuggestions(field); 1769 credit_card_form_event_logger_->OnDidPollSuggestions(field);
1764 1770
1765 // The field value is sanitized before attempting to match it to the user's 1771 // The field value is sanitized before attempting to match it to the user's
1766 // data. 1772 // data.
1767 std::vector<Suggestion> suggestions = 1773 std::vector<Suggestion> suggestions =
1768 personal_data_->GetCreditCardSuggestions( 1774 personal_data_->GetCreditCardSuggestions(
1769 type, SanitizeCreditCardFieldValue(field.value)); 1775 type, SanitizeCreditCardFieldValue(field.value));
1770 for (size_t i = 0; i < suggestions.size(); i++) { 1776 for (size_t i = 0; i < suggestions.size(); i++) {
1771 suggestions[i].frontend_id = 1777 suggestions[i].frontend_id =
1772 MakeFrontendID(suggestions[i].backend_id, std::string()); 1778 MakeFrontendID(suggestions[i].backend_id, std::string());
1779 suggestions[i].is_value_bold = IsCreditCardPopupValueBold();
1773 } 1780 }
1774 return suggestions; 1781 return suggestions;
1775 } 1782 }
1776 1783
1777 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1784 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1778 if (forms.empty()) 1785 if (forms.empty())
1779 return; 1786 return;
1780 1787
1781 std::vector<FormStructure*> non_queryable_forms; 1788 std::vector<FormStructure*> non_queryable_forms;
1782 std::vector<FormStructure*> queryable_forms; 1789 std::vector<FormStructure*> queryable_forms;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 if (i > 0) 2111 if (i > 0)
2105 fputs("Next oldest form:\n", file); 2112 fputs("Next oldest form:\n", file);
2106 } 2113 }
2107 fputs("\n", file); 2114 fputs("\n", file);
2108 2115
2109 fclose(file); 2116 fclose(file);
2110 } 2117 }
2111 #endif // ENABLE_FORM_DEBUG_DUMP 2118 #endif // ENABLE_FORM_DEBUG_DUMP
2112 2119
2113 } // namespace autofill 2120 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698