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

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

Issue 1136473006: Don't autofill credit cards on non-secure pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add period Created 5 years, 5 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 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 for (size_t i = 0; i < form_structure.field_count(); ++i) { 80 for (size_t i = 0; i < form_structure.field_count(); ++i) {
81 if (form_structure.field(i)->section() == section && 81 if (form_structure.field(i)->section() == section &&
82 form.fields[i].is_autofilled) { 82 form.fields[i].is_autofilled) {
83 return true; 83 return true;
84 } 84 }
85 } 85 }
86 86
87 return false; 87 return false;
88 } 88 }
89 89
90 bool FormIsHTTPS(const FormStructure& form) {
91 return form.source_url().SchemeIs(url::kHttpsScheme);
92 }
93
94 // Uses the existing personal data in |profiles| and |credit_cards| to determine 90 // Uses the existing personal data in |profiles| and |credit_cards| to determine
95 // possible field types for the |submitted_form|. This is potentially 91 // possible field types for the |submitted_form|. This is potentially
96 // expensive -- on the order of 50ms even for a small set of |stored_data|. 92 // expensive -- on the order of 50ms even for a small set of |stored_data|.
97 // Hence, it should not run on the UI thread -- to avoid locking up the UI -- 93 // Hence, it should not run on the UI thread -- to avoid locking up the UI --
98 // nor on the IO thread -- to avoid blocking IPC calls. 94 // nor on the IO thread -- to avoid blocking IPC calls.
99 void DeterminePossibleFieldTypesForUpload( 95 void DeterminePossibleFieldTypesForUpload(
100 const std::vector<AutofillProfile>& profiles, 96 const std::vector<AutofillProfile>& profiles,
101 const std::vector<CreditCard>& credit_cards, 97 const std::vector<CreditCard>& credit_cards,
102 const std::string& app_locale, 98 const std::string& app_locale,
103 FormStructure* submitted_form) { 99 FormStructure* submitted_form) {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 got_autofillable_form) { 481 got_autofillable_form) {
486 AutofillType type = autofill_field->Type(); 482 AutofillType type = autofill_field->Type();
487 bool is_filling_credit_card = (type.group() == CREDIT_CARD); 483 bool is_filling_credit_card = (type.group() == CREDIT_CARD);
488 if (is_filling_credit_card) { 484 if (is_filling_credit_card) {
489 suggestions = GetCreditCardSuggestions(field, type); 485 suggestions = GetCreditCardSuggestions(field, type);
490 } else { 486 } else {
491 suggestions = 487 suggestions =
492 GetProfileSuggestions(*form_structure, field, *autofill_field); 488 GetProfileSuggestions(*form_structure, field, *autofill_field);
493 } 489 }
494 if (!suggestions.empty()) { 490 if (!suggestions.empty()) {
495 // Don't provide credit card suggestions for non-HTTPS pages. However, 491 // Don't provide credit card suggestions for non-secure pages. However,
496 // do provide a warning to the user. 492 // do provide a warning to the user. This will generate warnings on pages
497 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) { 493 // with mixed content (which includes forms with an http target).
494 if (is_filling_credit_card &&
495 !client_->IsContextSecure(form_structure->source_url())) {
498 Suggestion warning_suggestion(l10n_util::GetStringUTF16( 496 Suggestion warning_suggestion(l10n_util::GetStringUTF16(
499 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); 497 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION));
500 warning_suggestion.frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 498 warning_suggestion.frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE;
501 suggestions.assign(1, warning_suggestion); 499 suggestions.assign(1, warning_suggestion);
502 } else { 500 } else {
503 bool section_is_autofilled = 501 bool section_is_autofilled =
504 SectionIsAutofilled(*form_structure, form, 502 SectionIsAutofilled(*form_structure, form,
505 autofill_field->section()); 503 autofill_field->section());
506 if (section_is_autofilled) { 504 if (section_is_autofilled) {
507 // If the relevant section is auto-filled and the renderer is querying 505 // If the relevant section is auto-filled and the renderer is querying
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 1561
1564 bool is_from_address_book = 1562 bool is_from_address_book =
1565 profile->record_type() == AutofillProfile::AUXILIARY_PROFILE; 1563 profile->record_type() == AutofillProfile::AUXILIARY_PROFILE;
1566 UMA_HISTOGRAM_BOOLEAN( 1564 UMA_HISTOGRAM_BOOLEAN(
1567 "Autofill.MacAddressBook.AcceptedSuggestionIsFromAddressBook", 1565 "Autofill.MacAddressBook.AcceptedSuggestionIsFromAddressBook",
1568 is_from_address_book); 1566 is_from_address_book);
1569 } 1567 }
1570 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 1568 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
1571 1569
1572 } // namespace autofill 1570 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_client.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698