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 return Suggestion( | |
| 200 l10n_util::GetStringUTF8(IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE), | |
|
Evan Stade
2016/11/28 16:12:02
nit: the documentation for Suggestion says this co
lshang
2016/11/29 10:07:35
Done.
| |
| 201 std::string(), icon_str, POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); | |
| 202 } | |
| 203 | |
| 186 } // namespace | 204 } // namespace |
| 187 | 205 |
| 188 AutofillManager::AutofillManager( | 206 AutofillManager::AutofillManager( |
| 189 AutofillDriver* driver, | 207 AutofillDriver* driver, |
| 190 AutofillClient* client, | 208 AutofillClient* client, |
| 191 const std::string& app_locale, | 209 const std::string& app_locale, |
| 192 AutofillDownloadManagerState enable_download_manager) | 210 AutofillDownloadManagerState enable_download_manager) |
| 193 : driver_(driver), | 211 : driver_(driver), |
| 194 client_(client), | 212 client_(client), |
| 195 payments_client_( | 213 payments_client_( |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 // Autofill is disabled for a website. | 587 // Autofill is disabled for a website. |
| 570 Suggestion warning_suggestion(l10n_util::GetStringUTF16( | 588 Suggestion warning_suggestion(l10n_util::GetStringUTF16( |
| 571 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); | 589 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); |
| 572 warning_suggestion.frontend_id = | 590 warning_suggestion.frontend_id = |
| 573 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; | 591 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; |
| 574 suggestions.assign(1, warning_suggestion); | 592 suggestions.assign(1, warning_suggestion); |
| 575 | 593 |
| 576 // On top of the explanation message, first show a "Payment not secure" | 594 // On top of the explanation message, first show a "Payment not secure" |
| 577 // message. | 595 // message. |
| 578 if (IsCreditCardAutofillHttpWarningEnabled()) { | 596 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(), | 597 suggestions.insert(suggestions.begin(), |
| 584 cc_field_http_warning_suggestion); | 598 CreateHttpWarningMessageSuggestionItem( |
| 599 form_structure->source_url())); | |
| 585 } | 600 } |
| 586 } else { | 601 } else { |
| 587 bool section_is_autofilled = | 602 bool section_is_autofilled = |
| 588 SectionIsAutofilled(*form_structure, form, | 603 SectionIsAutofilled(*form_structure, form, |
| 589 autofill_field->section()); | 604 autofill_field->section()); |
| 590 if (section_is_autofilled) { | 605 if (section_is_autofilled) { |
| 591 // If the relevant section is auto-filled and the renderer is querying | 606 // 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. | 607 // for suggestions, then the user is editing the value of a field. |
| 593 // In this case, mimic autocomplete: don't display labels or icons, | 608 // In this case, mimic autocomplete: don't display labels or icons, |
| 594 // as that information is redundant. Moreover, filter out duplicate | 609 // 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) | 2119 if (i > 0) |
| 2105 fputs("Next oldest form:\n", file); | 2120 fputs("Next oldest form:\n", file); |
| 2106 } | 2121 } |
| 2107 fputs("\n", file); | 2122 fputs("\n", file); |
| 2108 | 2123 |
| 2109 fclose(file); | 2124 fclose(file); |
| 2110 } | 2125 } |
| 2111 #endif // ENABLE_FORM_DEBUG_DUMP | 2126 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2112 | 2127 |
| 2113 } // namespace autofill | 2128 } // namespace autofill |
| OLD | NEW |