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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 DCHECK_EQ(values.size(), labels.size()); | 487 DCHECK_EQ(values.size(), labels.size()); |
488 DCHECK_EQ(values.size(), icons.size()); | 488 DCHECK_EQ(values.size(), icons.size()); |
489 DCHECK_EQ(values.size(), unique_ids.size()); | 489 DCHECK_EQ(values.size(), unique_ids.size()); |
490 | 490 |
491 if (!values.empty()) { | 491 if (!values.empty()) { |
492 // Don't provide Autofill suggestions when Autofill is disabled, and don't | 492 // Don't provide Autofill suggestions when Autofill is disabled, and don't |
493 // provide credit card suggestions for non-HTTPS pages. However, provide a | 493 // provide credit card suggestions for non-HTTPS pages. However, provide a |
494 // warning to the user in these cases. | 494 // warning to the user in these cases. |
495 int warning = 0; | 495 int warning = 0; |
496 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) | 496 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) { |
497 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; | 497 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; |
| 498 } |
498 if (warning) { | 499 if (warning) { |
499 values.assign(1, l10n_util::GetStringUTF16(warning)); | 500 values.assign(1, l10n_util::GetStringUTF16(warning)); |
500 labels.assign(1, base::string16()); | 501 labels.assign(1, base::string16()); |
501 icons.assign(1, base::string16()); | 502 icons.assign(1, base::string16()); |
502 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE); | 503 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE); |
503 } else { | 504 } else { |
504 bool section_is_autofilled = | 505 bool section_is_autofilled = |
505 SectionIsAutofilled(*form_structure, form, | 506 SectionIsAutofilled(*form_structure, form, |
506 autofill_field->section()); | 507 autofill_field->section()); |
507 if (section_is_autofilled) { | 508 if (section_is_autofilled) { |
(...skipping 15 matching lines...) Expand all Loading... |
523 // The first time we show suggestions on this page, log the number of | 524 // The first time we show suggestions on this page, log the number of |
524 // suggestions shown. | 525 // suggestions shown. |
525 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { | 526 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { |
526 metric_logger_->LogAddressSuggestionsCount(values.size()); | 527 metric_logger_->LogAddressSuggestionsCount(values.size()); |
527 has_logged_address_suggestions_count_ = true; | 528 has_logged_address_suggestions_count_ = true; |
528 } | 529 } |
529 } | 530 } |
530 } | 531 } |
531 } | 532 } |
532 | 533 |
533 // Add the results from AutoComplete. They come back asynchronously, so we | 534 if (field.should_autocomplete) { |
534 // hand off what we generated and they will send the results back to the | 535 // Add the results from AutoComplete. They come back asynchronously, so we |
535 // renderer. | 536 // hand off what we generated and they will send the results back to the |
536 autocomplete_history_manager_->OnGetAutocompleteSuggestions( | 537 // renderer. |
537 query_id, field.name, field.value, field.form_control_type, values, | 538 autocomplete_history_manager_->OnGetAutocompleteSuggestions( |
538 labels, icons, unique_ids); | 539 query_id, field.name, field.value, field.form_control_type, values, |
| 540 labels, icons, unique_ids); |
| 541 } else { |
| 542 // Autocomplete is disabled for this field; only pass back Autofill |
| 543 // suggestions. |
| 544 autocomplete_history_manager_->CancelPendingQuery(); |
| 545 external_delegate_->OnSuggestionsReturned( |
| 546 query_id, values, labels, icons, unique_ids); |
| 547 } |
539 } | 548 } |
540 | 549 |
541 void AutofillManager::FillOrPreviewForm( | 550 void AutofillManager::FillOrPreviewForm( |
542 AutofillDriver::RendererFormDataAction action, | 551 AutofillDriver::RendererFormDataAction action, |
543 int query_id, | 552 int query_id, |
544 const FormData& form, | 553 const FormData& form, |
545 const FormFieldData& field, | 554 const FormFieldData& field, |
546 int unique_id) { | 555 int unique_id) { |
547 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) | 556 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) |
548 return; | 557 return; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 return false; | 1251 return false; |
1243 | 1252 |
1244 // Disregard forms that we wouldn't ever autofill in the first place. | 1253 // Disregard forms that we wouldn't ever autofill in the first place. |
1245 if (!form.ShouldBeParsed()) | 1254 if (!form.ShouldBeParsed()) |
1246 return false; | 1255 return false; |
1247 | 1256 |
1248 return true; | 1257 return true; |
1249 } | 1258 } |
1250 | 1259 |
1251 } // namespace autofill | 1260 } // namespace autofill |
OLD | NEW |