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

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

Issue 15097004: Enable Autocomplete feature for chromium webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setSaveFormData2
Patch Set: address Ben's comments Created 7 years, 7 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/autofill_manager.h" 5 #include "components/autofill/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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 316 }
317 317
318 bool AutofillManager::OnFormSubmitted(const FormData& form, 318 bool AutofillManager::OnFormSubmitted(const FormData& form,
319 const TimeTicks& timestamp) { 319 const TimeTicks& timestamp) {
320 // Let AutoComplete know as well. 320 // Let AutoComplete know as well.
321 autocomplete_history_manager_.OnFormSubmitted(form); 321 autocomplete_history_manager_.OnFormSubmitted(form);
322 322
323 if (!IsAutofillEnabled()) 323 if (!IsAutofillEnabled())
324 return false; 324 return false;
325 325
326 if (web_contents()->GetBrowserContext()->IsOffTheRecord()) 326 if (external_delegate_ && external_delegate_->ShouldIgnoreFormData())
Ilya Sherman 2013/06/03 23:22:19 Should this check just be part of the IsAutofillEn
sgurun-gerrit only 2013/06/13 01:13:31 Agreed. much less error prone. On 2013/06/03 23:2
327 return false; 327 return false;
328 328
329 // Don't save data that was submitted through JavaScript. 329 // Don't save data that was submitted through JavaScript.
330 if (!form.user_submitted) 330 if (!form.user_submitted)
331 return false; 331 return false;
332 332
333 // If there is no personal_data_, nothing to do.
334 if (!personal_data_)
335 return false;
336
333 // Grab a copy of the form data. 337 // Grab a copy of the form data.
334 scoped_ptr<FormStructure> submitted_form( 338 scoped_ptr<FormStructure> submitted_form(
335 new FormStructure(form, GetAutocheckoutURLPrefix())); 339 new FormStructure(form, GetAutocheckoutURLPrefix()));
336 340
337 // Disregard forms that we wouldn't ever autofill in the first place. 341 // Disregard forms that we wouldn't ever autofill in the first place.
338 if (!submitted_form->ShouldBeParsed(true)) 342 if (!submitted_form->ShouldBeParsed(true))
339 return false; 343 return false;
340 344
341 // Ignore forms not present in our cache. These are typically forms with 345 // Ignore forms not present in our cache. These are typically forms with
342 // wonky JavaScript that also makes them not auto-fillable. 346 // wonky JavaScript that also makes them not auto-fillable.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (has_more_forms) 422 if (has_more_forms)
419 return; 423 return;
420 } 424 }
421 425
422 autocheckout_manager_.OnFormsSeen(); 426 autocheckout_manager_.OnFormsSeen();
423 bool enabled = IsAutofillEnabled(); 427 bool enabled = IsAutofillEnabled();
424 if (!has_logged_autofill_enabled_) { 428 if (!has_logged_autofill_enabled_) {
425 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); 429 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled);
426 has_logged_autofill_enabled_ = true; 430 has_logged_autofill_enabled_ = true;
427 } 431 }
428
Ilya Sherman 2013/06/03 23:22:19 nit: Spurious diff.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
429 if (!enabled) 432 if (!enabled)
430 return; 433 return;
431 434
432 forms_loaded_timestamp_ = timestamp; 435 forms_loaded_timestamp_ = timestamp;
433 ParseForms(forms); 436 ParseForms(forms);
434 } 437 }
435 438
436 void AutofillManager::OnTextFieldDidChange(const FormData& form, 439 void AutofillManager::OnTextFieldDidChange(const FormData& form,
437 const FormFieldData& field, 440 const FormFieldData& field,
438 const TimeTicks& timestamp) { 441 const TimeTicks& timestamp) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 std::vector<int> unique_ids; 478 std::vector<int> unique_ids;
476 479
477 if (external_delegate_) { 480 if (external_delegate_) {
478 external_delegate_->OnQuery(query_id, 481 external_delegate_->OnQuery(query_id,
479 form, 482 form,
480 field, 483 field,
481 bounding_box, 484 bounding_box,
482 display_warning); 485 display_warning);
483 } 486 }
484 487
488 if (personal_data_) {
Ilya Sherman 2013/06/03 23:22:19 Please move this check into the wrapped method.
sgurun-gerrit only 2013/06/13 01:13:31 Done. Actually this seems redundant since wrapped
489 OnQueryFormFieldAutofillPersonalData(query_id,
490 form,
491 field,
492 &values,
493 &labels,
494 &icons,
495 &unique_ids);
496 }
Ilya Sherman 2013/06/03 23:22:19 nit: Please add a newline after this one.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
497 // Add the results from AutoComplete. They come back asynchronously, so we
498 // hand off what we generated and they will send the results back to the
499 // renderer.
500 autocomplete_history_manager_.OnGetAutocompleteSuggestions(
501 query_id, field.name, field.value, values, labels, icons, unique_ids);
502 }
503
504 void AutofillManager::OnQueryFormFieldAutofillPersonalData(
505 int query_id,
Ilya Sherman 2013/06/03 23:22:19 This parameter doesn't seem to be used.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
506 const FormData& form,
507 const FormFieldData& field,
508 std::vector<base::string16>* values,
509 std::vector<base::string16>* labels,
510 std::vector<string16>* icons,
511 std::vector<int>* unique_ids) {
485 RenderViewHost* host = NULL; 512 RenderViewHost* host = NULL;
486 FormStructure* form_structure = NULL; 513 FormStructure* form_structure = NULL;
487 AutofillField* autofill_field = NULL; 514 AutofillField* autofill_field = NULL;
488 if (GetHost(&host) && 515 if (GetHost(&host) &&
489 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 516 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
490 // Don't send suggestions for forms that aren't auto-fillable. 517 // Don't send suggestions for forms that aren't auto-fillable.
491 form_structure->IsAutofillable(false)) { 518 form_structure->IsAutofillable(false)) {
492 AutofillFieldType type = autofill_field->type(); 519 AutofillFieldType type = autofill_field->type();
493 bool is_filling_credit_card = 520 bool is_filling_credit_card =
494 (AutofillType(type).group() == AutofillType::CREDIT_CARD); 521 (AutofillType(type).group() == AutofillType::CREDIT_CARD);
495 if (is_filling_credit_card) { 522 if (is_filling_credit_card) {
496 GetCreditCardSuggestions( 523 GetCreditCardSuggestions(
497 field, type, &values, &labels, &icons, &unique_ids); 524 field, type, values, labels, icons, unique_ids);
498 } else { 525 } else {
499 GetProfileSuggestions( 526 GetProfileSuggestions(
500 form_structure, field, type, &values, &labels, &icons, &unique_ids); 527 form_structure, field, type, values, labels, icons, unique_ids);
501 } 528 }
502 529
503 DCHECK_EQ(values.size(), labels.size()); 530 DCHECK_EQ(values->size(), labels->size());
504 DCHECK_EQ(values.size(), icons.size()); 531 DCHECK_EQ(values->size(), icons->size());
505 DCHECK_EQ(values.size(), unique_ids.size()); 532 DCHECK_EQ(values->size(), unique_ids->size());
506 533
507 if (!values.empty()) { 534 if (!values->empty()) {
508 // Don't provide Autofill suggestions when Autofill is disabled, and don't 535 // Don't provide Autofill suggestions when Autofill is disabled, and don't
509 // provide credit card suggestions for non-HTTPS pages. However, provide a 536 // provide credit card suggestions for non-HTTPS pages. However, provide a
510 // warning to the user in these cases. 537 // warning to the user in these cases.
511 int warning = 0; 538 int warning = 0;
512 if (!form_structure->IsAutofillable(true)) 539 if (!form_structure->IsAutofillable(true))
513 warning = IDS_AUTOFILL_WARNING_FORM_DISABLED; 540 warning = IDS_AUTOFILL_WARNING_FORM_DISABLED;
514 else if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) 541 else if (is_filling_credit_card && !FormIsHTTPS(*form_structure))
515 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; 542 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION;
516 if (warning) { 543 if (warning) {
517 values.assign(1, l10n_util::GetStringUTF16(warning)); 544 values->assign(1, l10n_util::GetStringUTF16(warning));
518 labels.assign(1, base::string16()); 545 labels->assign(1, base::string16());
519 icons.assign(1, base::string16()); 546 icons->assign(1, base::string16());
520 unique_ids.assign(1, 547 unique_ids->assign(1,
521 WebKit::WebAutofillClient::MenuItemIDWarningMessage); 548 WebKit::WebAutofillClient::MenuItemIDWarningMessage);
522 } else { 549 } else {
523 bool section_is_autofilled = 550 bool section_is_autofilled =
524 SectionIsAutofilled(*form_structure, form, 551 SectionIsAutofilled(*form_structure, form,
525 autofill_field->section()); 552 autofill_field->section());
526 if (section_is_autofilled) { 553 if (section_is_autofilled) {
527 // If the relevant section is auto-filled and the renderer is querying 554 // If the relevant section is auto-filled and the renderer is querying
528 // for suggestions, then the user is editing the value of a field. 555 // for suggestions, then the user is editing the value of a field.
529 // In this case, mimic autocomplete: don't display labels or icons, 556 // In this case, mimic autocomplete: don't display labels or icons,
530 // as that information is redundant. 557 // as that information is redundant.
531 labels.assign(labels.size(), base::string16()); 558 labels->assign(labels->size(), base::string16());
532 icons.assign(icons.size(), base::string16()); 559 icons->assign(icons->size(), base::string16());
533 } 560 }
534 561
535 // When filling credit card suggestions, the values and labels are 562 // When filling credit card suggestions, the values and labels are
536 // typically obfuscated, which makes detecting duplicates hard. Since 563 // typically obfuscated, which makes detecting duplicates hard. Since
537 // duplicates only tend to be a problem when filling address forms 564 // duplicates only tend to be a problem when filling address forms
538 // anyway, only don't de-dup credit card suggestions. 565 // anyway, only don't de-dup credit card suggestions.
539 if (!is_filling_credit_card) 566 if (!is_filling_credit_card)
540 RemoveDuplicateSuggestions(&values, &labels, &icons, &unique_ids); 567 RemoveDuplicateSuggestions(values, labels, icons, unique_ids);
541 568
542 // The first time we show suggestions on this page, log the number of 569 // The first time we show suggestions on this page, log the number of
543 // suggestions shown. 570 // suggestions shown.
544 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { 571 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) {
545 metric_logger_->LogAddressSuggestionsCount(values.size()); 572 metric_logger_->LogAddressSuggestionsCount(values->size());
546 has_logged_address_suggestions_count_ = true; 573 has_logged_address_suggestions_count_ = true;
547 } 574 }
548 } 575 }
549 } 576 }
550 } 577 }
551
552 // Add the results from AutoComplete. They come back asynchronously, so we
553 // hand off what we generated and they will send the results back to the
554 // renderer.
555 autocomplete_history_manager_.OnGetAutocompleteSuggestions(
556 query_id, field.name, field.value, values, labels, icons, unique_ids);
557 } 578 }
558 579
559 void AutofillManager::OnFillAutofillFormData(int query_id, 580 void AutofillManager::OnFillAutofillFormData(int query_id,
560 const FormData& form, 581 const FormData& form,
561 const FormFieldData& field, 582 const FormFieldData& field,
562 int unique_id) { 583 int unique_id) {
563 RenderViewHost* host = NULL; 584 RenderViewHost* host = NULL;
564 const AutofillDataModel* data_model = NULL; 585 const AutofillDataModel* data_model = NULL;
565 size_t variant = 0; 586 size_t variant = 0;
566 FormStructure* form_structure = NULL; 587 FormStructure* form_structure = NULL;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 702 }
682 } 703 }
683 704
684 void AutofillManager::OnHideAutofillUi() { 705 void AutofillManager::OnHideAutofillUi() {
685 if (IsNativeUiEnabled()) 706 if (IsNativeUiEnabled())
686 manager_delegate_->HideAutofillPopup(); 707 manager_delegate_->HideAutofillPopup();
687 manager_delegate_->HideAutocheckoutBubble(); 708 manager_delegate_->HideAutocheckoutBubble();
688 } 709 }
689 710
690 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { 711 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) {
712
Ilya Sherman 2013/06/03 23:22:19 nit: Spurious newline.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
713 if (!personal_data_)
714 return;
Ilya Sherman 2013/06/03 23:22:19 Why is this code reachable?
sgurun-gerrit only 2013/06/13 01:13:31 should not be reachable. removing.
715
691 const AutofillDataModel* data_model = NULL; 716 const AutofillDataModel* data_model = NULL;
692 size_t variant = 0; 717 size_t variant = 0;
693 if (!GetProfileOrCreditCard(unique_id, &data_model, &variant)) { 718 if (!GetProfileOrCreditCard(unique_id, &data_model, &variant)) {
694 NOTREACHED(); 719 NOTREACHED();
695 return; 720 return;
696 } 721 }
697 722
698 // TODO(csharp): If we are dealing with a variant only the variant should 723 // TODO(csharp): If we are dealing with a variant only the variant should
699 // be deleted, instead of doing nothing. 724 // be deleted, instead of doing nothing.
700 // http://crbug.com/124211 725 // http://crbug.com/124211
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 bounding_box); 883 bounding_box);
859 } 884 }
860 885
861 std::string AutofillManager::GetAutocheckoutURLPrefix() const { 886 std::string AutofillManager::GetAutocheckoutURLPrefix() const {
862 if (!web_contents()) 887 if (!web_contents())
863 return std::string(); 888 return std::string();
864 889
865 autofill::autocheckout::WhitelistManager* whitelist_manager = 890 autofill::autocheckout::WhitelistManager* whitelist_manager =
866 manager_delegate_->GetAutocheckoutWhitelistManager(); 891 manager_delegate_->GetAutocheckoutWhitelistManager();
867 892
868 return whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()); 893 return whitelist_manager ?
894 whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()) :
895 std::string();
869 } 896 }
870 897
871 bool AutofillManager::IsAutofillEnabled() const { 898 bool AutofillManager::IsAutofillEnabled() const {
872 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); 899 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
873 } 900 }
874 901
875 void AutofillManager::SendAutofillTypePredictions( 902 void AutofillManager::SendAutofillTypePredictions(
876 const std::vector<FormStructure*>& forms) const { 903 const std::vector<FormStructure*>& forms) const {
877 if (!CommandLine::ForCurrentProcess()->HasSwitch( 904 if (!CommandLine::ForCurrentProcess()->HasSwitch(
878 switches::kShowAutofillTypePredictions)) 905 switches::kShowAutofillTypePredictions))
879 return; 906 return;
880 907
881 RenderViewHost* host = web_contents()->GetRenderViewHost(); 908 RenderViewHost* host = web_contents()->GetRenderViewHost();
882 if (!host) 909 if (!host)
883 return; 910 return;
884 911
885 std::vector<FormDataPredictions> type_predictions; 912 std::vector<FormDataPredictions> type_predictions;
886 FormStructure::GetFieldTypePredictions(forms, &type_predictions); 913 FormStructure::GetFieldTypePredictions(forms, &type_predictions);
887 host->Send( 914 host->Send(
888 new AutofillMsg_FieldTypePredictionsAvailable(host->GetRoutingID(), 915 new AutofillMsg_FieldTypePredictionsAvailable(host->GetRoutingID(),
889 type_predictions)); 916 type_predictions));
890 } 917 }
891 918
892 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { 919 void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
893 const CreditCard* imported_credit_card; 920 const CreditCard* imported_credit_card;
Ilya Sherman 2013/06/03 23:22:19 nit: Please keep this just above line 925.
sgurun-gerrit only 2013/06/13 01:13:31 I think this code should also be unreachable?
921
922 if (!personal_data_)
923 return;
924
894 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) 925 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card))
895 return; 926 return;
896 927
897 // If credit card information was submitted, we need to confirm whether to 928 // If credit card information was submitted, we need to confirm whether to
898 // save it. 929 // save it.
899 if (imported_credit_card) { 930 if (imported_credit_card) {
900 manager_delegate_->ConfirmSaveCreditCard( 931 manager_delegate_->ConfirmSaveCreditCard(
901 *metric_logger_, 932 *metric_logger_,
902 *imported_credit_card, 933 *imported_credit_card,
903 base::Bind(&PersonalDataManager::SaveImportedCreditCard, 934 base::Bind(&PersonalDataManager::SaveImportedCreditCard,
(...skipping 13 matching lines...) Expand all
917 submitted_form->LogQualityMetrics(*metric_logger_, 948 submitted_form->LogQualityMetrics(*metric_logger_,
918 load_time, 949 load_time,
919 interaction_time, 950 interaction_time,
920 submission_time); 951 submission_time);
921 952
922 if (submitted_form->ShouldBeCrowdsourced()) 953 if (submitted_form->ShouldBeCrowdsourced())
923 UploadFormData(*submitted_form); 954 UploadFormData(*submitted_form);
924 } 955 }
925 956
926 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { 957 void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
927 if (!download_manager_) 958 if (!download_manager_ || !personal_data_)
928 return; 959 return;
929 960
930 // Check if the form is among the forms that were recently auto-filled. 961 // Check if the form is among the forms that were recently auto-filled.
931 bool was_autofilled = false; 962 bool was_autofilled = false;
932 std::string form_signature = submitted_form.FormSignature(); 963 std::string form_signature = submitted_form.FormSignature();
933 for (std::list<std::string>::const_iterator it = 964 for (std::list<std::string>::const_iterator it =
934 autofilled_form_signatures_.begin(); 965 autofilled_form_signatures_.begin();
935 it != autofilled_form_signatures_.end() && !was_autofilled; 966 it != autofilled_form_signatures_.end() && !was_autofilled;
936 ++it) { 967 ++it) {
937 if (*it == form_signature) 968 if (*it == form_signature)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 } 1015 }
985 1016
986 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { 1017 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) {
987 metric_logger_.reset(metric_logger); 1018 metric_logger_.reset(metric_logger);
988 } 1019 }
989 1020
990 bool AutofillManager::GetHost(RenderViewHost** host) const { 1021 bool AutofillManager::GetHost(RenderViewHost** host) const {
991 if (!IsAutofillEnabled()) 1022 if (!IsAutofillEnabled())
992 return false; 1023 return false;
993 1024
1025 if (!personal_data_)
1026 return false;
Ilya Sherman 2013/06/03 23:22:19 Why is this code reachable?
sgurun-gerrit only 2013/06/13 01:13:31 it is eventually reachable via OnQueryFormFieldAut
1027
994 // No autofill data to return if the profiles are empty. 1028 // No autofill data to return if the profiles are empty.
995 if (personal_data_->GetProfiles().empty() && 1029 if (personal_data_->GetProfiles().empty() &&
996 personal_data_->GetCreditCards().empty()) { 1030 personal_data_->GetCreditCards().empty()) {
997 return false; 1031 return false;
998 } 1032 }
999 1033
1000 *host = web_contents()->GetRenderViewHost(); 1034 *host = web_contents()->GetRenderViewHost();
1001 if (!*host) 1035 if (!*host)
1002 return false; 1036 return false;
1003 1037
1004 return true; 1038 return true;
1005 } 1039 }
1006 1040
1007 bool AutofillManager::GetProfileOrCreditCard( 1041 bool AutofillManager::GetProfileOrCreditCard(
1008 int unique_id, 1042 int unique_id,
1009 const AutofillDataModel** data_model, 1043 const AutofillDataModel** data_model,
1010 size_t* variant) const { 1044 size_t* variant) const {
1045 if (!personal_data_)
1046 return false;
Ilya Sherman 2013/06/03 23:22:19 Why is this code reachable?
sgurun-gerrit only 2013/06/13 01:13:31 Done.
1047
1011 // Unpack the |unique_id| into component parts. 1048 // Unpack the |unique_id| into component parts.
1012 GUIDPair credit_card_guid; 1049 GUIDPair credit_card_guid;
1013 GUIDPair profile_guid; 1050 GUIDPair profile_guid;
1014 UnpackGUIDs(unique_id, &credit_card_guid, &profile_guid); 1051 UnpackGUIDs(unique_id, &credit_card_guid, &profile_guid);
1015 DCHECK(!base::IsValidGUID(credit_card_guid.first) || 1052 DCHECK(!base::IsValidGUID(credit_card_guid.first) ||
1016 !base::IsValidGUID(profile_guid.first)); 1053 !base::IsValidGUID(profile_guid.first));
1017 1054
1018 // Find the profile that matches the |profile_guid|, if one is specified. 1055 // Find the profile that matches the |profile_guid|, if one is specified.
1019 // Otherwise find the credit card that matches the |credit_card_guid|, 1056 // Otherwise find the credit card that matches the |credit_card_guid|,
1020 // if specified. 1057 // if specified.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 } 1187 }
1151 1188
1152 void AutofillManager::GetProfileSuggestions( 1189 void AutofillManager::GetProfileSuggestions(
1153 FormStructure* form, 1190 FormStructure* form,
1154 const FormFieldData& field, 1191 const FormFieldData& field,
1155 AutofillFieldType type, 1192 AutofillFieldType type,
1156 std::vector<base::string16>* values, 1193 std::vector<base::string16>* values,
1157 std::vector<base::string16>* labels, 1194 std::vector<base::string16>* labels,
1158 std::vector<base::string16>* icons, 1195 std::vector<base::string16>* icons,
1159 std::vector<int>* unique_ids) const { 1196 std::vector<int>* unique_ids) const {
1197
Ilya Sherman 2013/06/03 23:22:19 nit: Spurious newline.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
1198 if (!personal_data_)
1199 return;
Ilya Sherman 2013/06/03 23:22:19 nit: Please add a newline after this line.
Ilya Sherman 2013/06/03 23:22:19 Why is this code reachable?
sgurun-gerrit only 2013/06/13 01:13:31 Done.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
1160 std::vector<AutofillFieldType> field_types(form->field_count()); 1200 std::vector<AutofillFieldType> field_types(form->field_count());
1161 for (size_t i = 0; i < form->field_count(); ++i) { 1201 for (size_t i = 0; i < form->field_count(); ++i) {
1162 field_types[i] = form->field(i)->type(); 1202 field_types[i] = form->field(i)->type();
1163 } 1203 }
1164 std::vector<GUIDPair> guid_pairs; 1204 std::vector<GUIDPair> guid_pairs;
1165 1205
1166 personal_data_->GetProfileSuggestions( 1206 personal_data_->GetProfileSuggestions(
1167 type, field.value, field.is_autofilled, field_types, 1207 type, field.value, field.is_autofilled, field_types,
1168 values, labels, icons, &guid_pairs); 1208 values, labels, icons, &guid_pairs);
1169 1209
1170 for (size_t i = 0; i < guid_pairs.size(); ++i) { 1210 for (size_t i = 0; i < guid_pairs.size(); ++i) {
1171 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0), 1211 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0),
1172 guid_pairs[i])); 1212 guid_pairs[i]));
1173 } 1213 }
1174 } 1214 }
1175 1215
1176 void AutofillManager::GetCreditCardSuggestions( 1216 void AutofillManager::GetCreditCardSuggestions(
1177 const FormFieldData& field, 1217 const FormFieldData& field,
1178 AutofillFieldType type, 1218 AutofillFieldType type,
1179 std::vector<base::string16>* values, 1219 std::vector<base::string16>* values,
1180 std::vector<base::string16>* labels, 1220 std::vector<base::string16>* labels,
1181 std::vector<base::string16>* icons, 1221 std::vector<base::string16>* icons,
1182 std::vector<int>* unique_ids) const { 1222 std::vector<int>* unique_ids) const {
1223
Ilya Sherman 2013/06/03 23:22:19 nit: Spurious newline.
sgurun-gerrit only 2013/06/13 01:13:31 Done.
1224 if (!personal_data_)
1225 return;
Ilya Sherman 2013/06/03 23:22:19 Why is this code reachable?
sgurun-gerrit only 2013/06/13 01:13:31 removed. On 2013/06/03 23:22:19, Ilya Sherman wro
1226
1183 std::vector<GUIDPair> guid_pairs; 1227 std::vector<GUIDPair> guid_pairs;
1184 personal_data_->GetCreditCardSuggestions( 1228 personal_data_->GetCreditCardSuggestions(
1185 type, field.value, values, labels, icons, &guid_pairs); 1229 type, field.value, values, labels, icons, &guid_pairs);
1186 1230
1187 for (size_t i = 0; i < guid_pairs.size(); ++i) { 1231 for (size_t i = 0; i < guid_pairs.size(); ++i) {
1188 unique_ids->push_back(PackGUIDs(guid_pairs[i], GUIDPair(std::string(), 0))); 1232 unique_ids->push_back(PackGUIDs(guid_pairs[i], GUIDPair(std::string(), 0)));
1189 } 1233 }
1190 } 1234 }
1191 1235
1192 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1236 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 1338
1295 void AutofillManager::UpdateInitialInteractionTimestamp( 1339 void AutofillManager::UpdateInitialInteractionTimestamp(
1296 const TimeTicks& interaction_timestamp) { 1340 const TimeTicks& interaction_timestamp) {
1297 if (initial_interaction_timestamp_.is_null() || 1341 if (initial_interaction_timestamp_.is_null() ||
1298 interaction_timestamp < initial_interaction_timestamp_) { 1342 interaction_timestamp < initial_interaction_timestamp_) {
1299 initial_interaction_timestamp_ = interaction_timestamp; 1343 initial_interaction_timestamp_ = interaction_timestamp;
1300 } 1344 }
1301 } 1345 }
1302 1346
1303 } // namespace autofill 1347 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698