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

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

Issue 512993002: Remove dead code in Autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also switch non-const point to const ref Created 6 years, 3 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
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 454 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
455 // Don't send suggestions for forms that aren't auto-fillable. 455 // Don't send suggestions for forms that aren't auto-fillable.
456 form_structure->IsAutofillable()) { 456 form_structure->IsAutofillable()) {
457 AutofillType type = autofill_field->Type(); 457 AutofillType type = autofill_field->Type();
458 bool is_filling_credit_card = (type.group() == CREDIT_CARD); 458 bool is_filling_credit_card = (type.group() == CREDIT_CARD);
459 if (is_filling_credit_card) { 459 if (is_filling_credit_card) {
460 GetCreditCardSuggestions( 460 GetCreditCardSuggestions(
461 field, type, &values, &labels, &icons, &unique_ids); 461 field, type, &values, &labels, &icons, &unique_ids);
462 } else { 462 } else {
463 GetProfileSuggestions( 463 GetProfileSuggestions(
464 form_structure, field, type, &values, &labels, &icons, &unique_ids); 464 *form_structure, field, type, &values, &labels, &icons, &unique_ids);
465 } 465 }
466 466
467 DCHECK_EQ(values.size(), labels.size()); 467 DCHECK_EQ(values.size(), labels.size());
468 DCHECK_EQ(values.size(), icons.size()); 468 DCHECK_EQ(values.size(), icons.size());
469 DCHECK_EQ(values.size(), unique_ids.size()); 469 DCHECK_EQ(values.size(), unique_ids.size());
470 470
471 if (!values.empty()) { 471 if (!values.empty()) {
472 // Don't provide Autofill suggestions when Autofill is disabled, and don't 472 // Don't provide Autofill suggestions when Autofill is disabled, and don't
473 // provide credit card suggestions for non-HTTPS pages. However, provide a 473 // provide credit card suggestions for non-HTTPS pages. However, provide a
474 // warning to the user in these cases. 474 // warning to the user in these cases.
475 int warning = 0; 475 int warning = 0;
476 if (!form_structure->IsAutofillable()) 476 if (is_filling_credit_card && !FormIsHTTPS(*form_structure))
477 warning = IDS_AUTOFILL_WARNING_FORM_DISABLED;
478 else if (is_filling_credit_card && !FormIsHTTPS(*form_structure))
479 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; 477 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION;
480 if (warning) { 478 if (warning) {
481 values.assign(1, l10n_util::GetStringUTF16(warning)); 479 values.assign(1, l10n_util::GetStringUTF16(warning));
482 labels.assign(1, base::string16()); 480 labels.assign(1, base::string16());
483 icons.assign(1, base::string16()); 481 icons.assign(1, base::string16());
484 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE); 482 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE);
485 } else { 483 } else {
486 bool section_is_autofilled = 484 bool section_is_autofilled =
487 SectionIsAutofilled(*form_structure, form, 485 SectionIsAutofilled(*form_structure, form,
488 autofill_field->section()); 486 autofill_field->section());
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } 1061 }
1064 1062
1065 // Annotate the updated form with its predicted types. 1063 // Annotate the updated form with its predicted types.
1066 std::vector<FormStructure*> forms(1, *updated_form); 1064 std::vector<FormStructure*> forms(1, *updated_form);
1067 driver_->SendAutofillTypePredictionsToRenderer(forms); 1065 driver_->SendAutofillTypePredictionsToRenderer(forms);
1068 1066
1069 return true; 1067 return true;
1070 } 1068 }
1071 1069
1072 void AutofillManager::GetProfileSuggestions( 1070 void AutofillManager::GetProfileSuggestions(
1073 FormStructure* form, 1071 const FormStructure& form,
1074 const FormFieldData& field, 1072 const FormFieldData& field,
1075 const AutofillType& type, 1073 const AutofillType& type,
1076 std::vector<base::string16>* values, 1074 std::vector<base::string16>* values,
1077 std::vector<base::string16>* labels, 1075 std::vector<base::string16>* labels,
1078 std::vector<base::string16>* icons, 1076 std::vector<base::string16>* icons,
1079 std::vector<int>* unique_ids) const { 1077 std::vector<int>* unique_ids) const {
1080 std::vector<ServerFieldType> field_types(form->field_count()); 1078 std::vector<ServerFieldType> field_types(form.field_count());
1081 for (size_t i = 0; i < form->field_count(); ++i) { 1079 for (size_t i = 0; i < form.field_count(); ++i) {
1082 field_types.push_back(form->field(i)->Type().GetStorableType()); 1080 field_types.push_back(form.field(i)->Type().GetStorableType());
1083 } 1081 }
1084 std::vector<GUIDPair> guid_pairs; 1082 std::vector<GUIDPair> guid_pairs;
1085 1083
1086 personal_data_->GetProfileSuggestions( 1084 personal_data_->GetProfileSuggestions(
1087 type, field.value, field.is_autofilled, field_types, 1085 type, field.value, field.is_autofilled, field_types,
1088 base::Callback<bool(const AutofillProfile&)>(), 1086 base::Callback<bool(const AutofillProfile&)>(),
1089 values, labels, icons, &guid_pairs); 1087 values, labels, icons, &guid_pairs);
1090 1088
1091 for (size_t i = 0; i < guid_pairs.size(); ++i) { 1089 for (size_t i = 0; i < guid_pairs.size(); ++i) {
1092 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0), 1090 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0),
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 return false; 1219 return false;
1222 1220
1223 // Disregard forms that we wouldn't ever autofill in the first place. 1221 // Disregard forms that we wouldn't ever autofill in the first place.
1224 if (!form.ShouldBeParsed()) 1222 if (!form.ShouldBeParsed())
1225 return false; 1223 return false;
1226 1224
1227 return true; 1225 return true;
1228 } 1226 }
1229 1227
1230 } // namespace autofill 1228 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698