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

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: Fixes compile error. 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 autofill_field->Type().GetStorableType() == CREDIT_CARD_NAME_FULL && 300 autofill_field->Type().GetStorableType() == CREDIT_CARD_NAME_FULL &&
301 base::FeatureList::IsEnabled(kAutofillScanCardholderName); 301 base::FeatureList::IsEnabled(kAutofillScanCardholderName);
302 302
303 if (!is_card_number_field && !is_scannable_name_on_card_field) 303 if (!is_card_number_field && !is_scannable_name_on_card_field)
304 return false; 304 return false;
305 305
306 static const int kShowScanCreditCardMaxValueLength = 6; 306 static const int kShowScanCreditCardMaxValueLength = 6;
307 return field.value.size() <= kShowScanCreditCardMaxValueLength; 307 return field.value.size() <= kShowScanCreditCardMaxValueLength;
308 } 308 }
309 309
310 bool AutofillManager::IsCreditCardPopup(const FormData& form,
311 const FormFieldData& field) {
312 AutofillField* autofill_field = GetAutofillField(form, field);
313 return autofill_field && autofill_field->Type().group() == CREDIT_CARD;
314 }
315
310 bool AutofillManager::ShouldShowCreditCardSigninPromo( 316 bool AutofillManager::ShouldShowCreditCardSigninPromo(
311 const FormData& form, 317 const FormData& form,
312 const FormFieldData& field) { 318 const FormFieldData& field) {
313 if (!IsAutofillCreditCardSigninPromoEnabled()) 319 if (!IsAutofillCreditCardSigninPromoEnabled())
314 return false; 320 return false;
315 321
316 // Check whether we are dealing with a credit card field and whether it's 322 // Check whether we are dealing with a credit card field and whether it's
317 // appropriate to show the promo (e.g. the platform is supported). 323 // appropriate to show the promo (e.g. the platform is supported).
318 AutofillField* autofill_field = GetAutofillField(form, field); 324 AutofillField* autofill_field = GetAutofillField(form, field);
319 if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD || 325 if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD ||
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 UpdateInitialInteractionTimestamp(timestamp); 526 UpdateInitialInteractionTimestamp(timestamp);
521 } 527 }
522 528
523 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 529 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
524 const FormData& form, 530 const FormData& form,
525 const FormFieldData& field, 531 const FormFieldData& field,
526 const gfx::RectF& bounding_box) { 532 const gfx::RectF& bounding_box) {
527 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 533 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
528 return; 534 return;
529 535
530 std::vector<Suggestion> suggestions;
531
532 gfx::RectF transformed_box = 536 gfx::RectF transformed_box =
533 driver_->TransformBoundingBoxToViewportCoordinates(bounding_box); 537 driver_->TransformBoundingBoxToViewportCoordinates(bounding_box);
534 external_delegate_->OnQuery(query_id, form, field, transformed_box); 538 external_delegate_->OnQuery(query_id, form, field, transformed_box);
535 539
536 // Need to refresh models before using the form_event_loggers. 540 // Need to refresh models before using the form_event_loggers.
537 bool is_autofill_possible = RefreshDataModels(); 541 bool is_autofill_possible = RefreshDataModels();
538 542
539 FormStructure* form_structure = NULL; 543 FormStructure* form_structure = NULL;
540 AutofillField* autofill_field = NULL; 544 AutofillField* autofill_field = NULL;
541 bool got_autofillable_form = 545 bool got_autofillable_form =
542 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 546 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
543 // Don't send suggestions or track forms that should not be parsed. 547 // Don't send suggestions or track forms that should not be parsed.
544 form_structure->ShouldBeParsed(); 548 form_structure->ShouldBeParsed();
545 549
546 // Logging interactions of forms that are autofillable. 550 // Logging interactions of forms that are autofillable.
547 if (got_autofillable_form) { 551 if (got_autofillable_form) {
548 if (autofill_field->Type().group() == CREDIT_CARD) { 552 if (autofill_field->Type().group() == CREDIT_CARD) {
549 driver_->DidInteractWithCreditCardForm(); 553 driver_->DidInteractWithCreditCardForm();
550 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); 554 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm();
551 } else { 555 } else {
552 address_form_event_logger_->OnDidInteractWithAutofillableForm(); 556 address_form_event_logger_->OnDidInteractWithAutofillableForm();
553 } 557 }
554 } 558 }
555 559
560 std::vector<Suggestion> suggestions;
561
556 if (is_autofill_possible && 562 if (is_autofill_possible &&
557 driver_->RendererIsAvailable() && 563 driver_->RendererIsAvailable() &&
558 got_autofillable_form) { 564 got_autofillable_form) {
559 AutofillType type = autofill_field->Type(); 565 AutofillType type = autofill_field->Type();
560 bool is_filling_credit_card = (type.group() == CREDIT_CARD); 566 bool is_filling_credit_card = (type.group() == CREDIT_CARD);
561 // On desktop, don't return non credit card related suggestions for forms or 567 // On desktop, don't return non credit card related suggestions for forms or
562 // fields that have the "autocomplete" attribute set to off. 568 // fields that have the "autocomplete" attribute set to off.
563 if (IsDesktopPlatform() && !is_filling_credit_card && 569 if (IsDesktopPlatform() && !is_filling_credit_card &&
564 !field.should_autocomplete) { 570 !field.should_autocomplete) {
565 return; 571 return;
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 credit_card_form_event_logger_->OnDidPollSuggestions(field); 1787 credit_card_form_event_logger_->OnDidPollSuggestions(field);
1782 1788
1783 // The field value is sanitized before attempting to match it to the user's 1789 // The field value is sanitized before attempting to match it to the user's
1784 // data. 1790 // data.
1785 std::vector<Suggestion> suggestions = 1791 std::vector<Suggestion> suggestions =
1786 personal_data_->GetCreditCardSuggestions( 1792 personal_data_->GetCreditCardSuggestions(
1787 type, SanitizeCreditCardFieldValue(field.value)); 1793 type, SanitizeCreditCardFieldValue(field.value));
1788 for (size_t i = 0; i < suggestions.size(); i++) { 1794 for (size_t i = 0; i < suggestions.size(); i++) {
1789 suggestions[i].frontend_id = 1795 suggestions[i].frontend_id =
1790 MakeFrontendID(suggestions[i].backend_id, std::string()); 1796 MakeFrontendID(suggestions[i].backend_id, std::string());
1797 suggestions[i].is_value_bold = IsCreditCardPopupValueBold();
1791 } 1798 }
1792 return suggestions; 1799 return suggestions;
1793 } 1800 }
1794 1801
1795 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1802 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1796 if (forms.empty()) 1803 if (forms.empty())
1797 return; 1804 return;
1798 1805
1799 std::vector<FormStructure*> non_queryable_forms; 1806 std::vector<FormStructure*> non_queryable_forms;
1800 std::vector<FormStructure*> queryable_forms; 1807 std::vector<FormStructure*> queryable_forms;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 if (i > 0) 2129 if (i > 0)
2123 fputs("Next oldest form:\n", file); 2130 fputs("Next oldest form:\n", file);
2124 } 2131 }
2125 fputs("\n", file); 2132 fputs("\n", file);
2126 2133
2127 fclose(file); 2134 fclose(file);
2128 } 2135 }
2129 #endif // ENABLE_FORM_DEBUG_DUMP 2136 #endif // ENABLE_FORM_DEBUG_DUMP
2130 2137
2131 } // namespace autofill 2138 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_popup_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698