Chromium Code Reviews| 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 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool IsCreditCardExpirationType(ServerFieldType type) { | 178 bool IsCreditCardExpirationType(ServerFieldType type) { |
| 179 return type == CREDIT_CARD_EXP_MONTH || | 179 return type == CREDIT_CARD_EXP_MONTH || |
| 180 type == CREDIT_CARD_EXP_2_DIGIT_YEAR || | 180 type == CREDIT_CARD_EXP_2_DIGIT_YEAR || |
| 181 type == CREDIT_CARD_EXP_4_DIGIT_YEAR || | 181 type == CREDIT_CARD_EXP_4_DIGIT_YEAR || |
| 182 type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR || | 182 type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR || |
| 183 type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR; | 183 type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Create http bad warning message at the top of autofill popup list showing | |
| 187 // "Payment not secure" when users are on http sites or broken https sites. | |
| 188 Suggestion CreateHttpWarningMessageSuggestionItem(const GURL& source_url) { | |
| 189 std::string icon_str; | |
| 190 | |
| 191 // Show http warning icon for http sites. | |
| 192 if (source_url.is_valid() && source_url.SchemeIs("http")) { | |
| 193 icon_str = "httpWarning"; | |
| 194 } else { | |
| 195 // Show https_invalid icon for broken https sites. | |
| 196 icon_str = "httpsInvalid"; | |
| 197 } | |
| 198 | |
| 199 Suggestion cc_field_http_warning_suggestion( | |
| 200 l10n_util::GetStringUTF16(IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE)); | |
| 201 cc_field_http_warning_suggestion.frontend_id = | |
| 202 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; | |
| 203 cc_field_http_warning_suggestion.icon = base::UTF8ToUTF16(icon_str); | |
|
Evan Stade
2016/11/29 15:23:32
nit: I would rearrange this so that you don't need
lshang
2016/11/29 23:48:30
Done.
| |
| 204 | |
| 205 return cc_field_http_warning_suggestion; | |
| 206 } | |
| 207 | |
| 186 } // namespace | 208 } // namespace |
| 187 | 209 |
| 188 AutofillManager::AutofillManager( | 210 AutofillManager::AutofillManager( |
| 189 AutofillDriver* driver, | 211 AutofillDriver* driver, |
| 190 AutofillClient* client, | 212 AutofillClient* client, |
| 191 const std::string& app_locale, | 213 const std::string& app_locale, |
| 192 AutofillDownloadManagerState enable_download_manager) | 214 AutofillDownloadManagerState enable_download_manager) |
| 193 : driver_(driver), | 215 : driver_(driver), |
| 194 client_(client), | 216 client_(client), |
| 195 payments_client_( | 217 payments_client_( |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 // Autofill is disabled for a website. | 591 // Autofill is disabled for a website. |
| 570 Suggestion warning_suggestion(l10n_util::GetStringUTF16( | 592 Suggestion warning_suggestion(l10n_util::GetStringUTF16( |
| 571 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); | 593 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); |
| 572 warning_suggestion.frontend_id = | 594 warning_suggestion.frontend_id = |
| 573 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; | 595 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; |
| 574 suggestions.assign(1, warning_suggestion); | 596 suggestions.assign(1, warning_suggestion); |
| 575 | 597 |
| 576 // On top of the explanation message, first show a "Payment not secure" | 598 // On top of the explanation message, first show a "Payment not secure" |
| 577 // message. | 599 // message. |
| 578 if (IsCreditCardAutofillHttpWarningEnabled()) { | 600 if (IsCreditCardAutofillHttpWarningEnabled()) { |
| 579 Suggestion cc_field_http_warning_suggestion(l10n_util::GetStringUTF16( | |
| 580 IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE)); | |
| 581 cc_field_http_warning_suggestion.frontend_id = | |
| 582 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; | |
| 583 suggestions.insert(suggestions.begin(), | 601 suggestions.insert(suggestions.begin(), |
| 584 cc_field_http_warning_suggestion); | 602 CreateHttpWarningMessageSuggestionItem( |
| 603 form_structure->source_url())); | |
| 585 } | 604 } |
| 586 } else { | 605 } else { |
| 587 bool section_is_autofilled = | 606 bool section_is_autofilled = |
| 588 SectionIsAutofilled(*form_structure, form, | 607 SectionIsAutofilled(*form_structure, form, |
| 589 autofill_field->section()); | 608 autofill_field->section()); |
| 590 if (section_is_autofilled) { | 609 if (section_is_autofilled) { |
| 591 // If the relevant section is auto-filled and the renderer is querying | 610 // If the relevant section is auto-filled and the renderer is querying |
| 592 // for suggestions, then the user is editing the value of a field. | 611 // for suggestions, then the user is editing the value of a field. |
| 593 // In this case, mimic autocomplete: don't display labels or icons, | 612 // In this case, mimic autocomplete: don't display labels or icons, |
| 594 // as that information is redundant. Moreover, filter out duplicate | 613 // as that information is redundant. Moreover, filter out duplicate |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2104 if (i > 0) | 2123 if (i > 0) |
| 2105 fputs("Next oldest form:\n", file); | 2124 fputs("Next oldest form:\n", file); |
| 2106 } | 2125 } |
| 2107 fputs("\n", file); | 2126 fputs("\n", file); |
| 2108 | 2127 |
| 2109 fclose(file); | 2128 fclose(file); |
| 2110 } | 2129 } |
| 2111 #endif // ENABLE_FORM_DEBUG_DUMP | 2130 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2112 | 2131 |
| 2113 } // namespace autofill | 2132 } // namespace autofill |
| OLD | NEW |