Chromium Code Reviews| Index: chrome/browser/autofill/autofill_manager.cc |
| diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc |
| index 6f89173cb7f7b0162df38565f7c05f23797ec344..7a8481ddb693eefbf6c2e68e7399076f5283fa6a 100644 |
| --- a/chrome/browser/autofill/autofill_manager.cc |
| +++ b/chrome/browser/autofill/autofill_manager.cc |
| @@ -7,6 +7,7 @@ |
| #include <limits> |
| #include <string> |
| +#include "app/l10n_util.h" |
| #include "base/basictypes.h" |
| #include "base/string16.h" |
| #include "base/utf_string_conversions.h" |
| @@ -22,6 +23,7 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| +#include "grit/generated_resources.h" |
| #include "webkit/glue/form_data.h" |
| #include "webkit/glue/form_field.h" |
| @@ -132,7 +134,7 @@ void AutoFillManager::FormSubmitted(const FormData& form) { |
| // Grab a copy of the form data. |
| upload_form_structure_.reset(new FormStructure(form)); |
| - if (!upload_form_structure_->IsAutoFillable()) |
| + if (!upload_form_structure_->IsAutoFillable(false)) |
|
dhollowa
2010/11/15 18:47:57
These changes should not alter the types of form d
Ilya Sherman
2010/11/15 22:53:32
Done.
|
| return; |
| // Determine the possible field types and upload the form structure to the |
| @@ -148,8 +150,7 @@ void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) { |
| ParseForms(forms); |
| } |
| -bool AutoFillManager::GetAutoFillSuggestions(int query_id, |
| - bool field_autofilled, |
| +bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled, |
| const FormField& field) { |
| if (!IsAutoFillEnabled()) |
| return false; |
| @@ -172,7 +173,7 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id, |
| form = *form_iter; |
| // Don't send suggestions for forms that aren't auto-fillable. |
| - if (!form->IsAutoFillable()) |
| + if (!form->IsAutoFillable(false)) |
|
dhollowa
2010/11/15 18:47:57
Instead of changing the |IsAutoFillable| and |Shou
Ilya Sherman
2010/11/15 22:53:32
As discussed offline, we only want to show the war
|
| continue; |
| for (std::vector<AutoFillField*>::const_iterator iter = form->begin(); |
| @@ -214,6 +215,30 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id, |
| if (values.empty()) |
| return false; |
| + // Don't provide autofill suggestions when autofill is disabled, but provide a |
|
dhollowa
2010/11/15 18:47:57
nit: The convention in comments is to use "AutoFil
Ilya Sherman
2010/11/15 22:53:32
Done.
|
| + // warning to the user. |
| + if (!form->IsAutoFillable(true)) { |
| + values.assign( |
| + 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED)); |
| + labels.assign(1, string16()); |
| + icons.assign(1, string16()); |
| + unique_ids.assign(1, -1); |
| + host->AutoFillSuggestionsReturned(values, labels, icons, unique_ids); |
| + return true; |
| + } |
| + |
| + // Don't provide credit card suggestions for non-HTTPS pages, but provide a |
| + // warning to the user. |
| + if (!FormIsHTTPS(form) && type.group() == AutoFillType::CREDIT_CARD) { |
| + values.assign( |
| + 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)); |
| + labels.assign(1, string16()); |
| + icons.assign(1, string16()); |
| + unique_ids.assign(1, -1); |
| + host->AutoFillSuggestionsReturned(values, labels, icons, unique_ids); |
| + return true; |
| + } |
| + |
| // If the form is auto-filled and the renderer is querying for suggestions, |
| // then the user is editing the value of a field. In this case, mimick |
| // autocomplete. In particular, don't display labels, as that information is |
| @@ -231,8 +256,7 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id, |
| } |
| } |
| - host->AutoFillSuggestionsReturned( |
| - query_id, values, labels, icons, unique_ids); |
| + host->AutoFillSuggestionsReturned(values, labels, icons, unique_ids); |
| return true; |
| } |
| @@ -525,10 +549,6 @@ void AutoFillManager::GetCreditCardSuggestions(FormStructure* form, |
| std::vector<string16>* labels, |
| std::vector<string16>* icons, |
| std::vector<int>* unique_ids) { |
| - // Don't return CC suggestions for non-HTTPS pages. |
| - if (!FormIsHTTPS(form)) |
| - return; |
| - |
| for (std::vector<CreditCard*>::const_iterator iter = |
| personal_data_->credit_cards().begin(); |
| iter != personal_data_->credit_cards().end(); ++iter) { |
| @@ -601,11 +621,13 @@ void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile, |
| void AutoFillManager::ParseForms( |
| const std::vector<webkit_glue::FormData>& forms) { |
| - for (std::vector<FormData>::const_iterator iter = |
| - forms.begin(); |
| + for (std::vector<FormData>::const_iterator iter = forms.begin(); |
| iter != forms.end(); ++iter) { |
| scoped_ptr<FormStructure> form_structure(new FormStructure(*iter)); |
| - if (!form_structure->ShouldBeParsed()) |
| + // TODO(isherman): Might want to set aside forms that have method != POST, |
|
dhollowa
2010/11/15 18:47:57
As mentioned above, we can keep |ShouldBeParsed| a
Ilya Sherman
2010/11/15 22:53:32
As mentioned in the reply above, keeping the seman
|
| + // and not send those to the server. It seems like that might not work |
| + // though. |
| + if (!form_structure->ShouldBeParsed(false)) |
| continue; |
| DeterminePossibleFieldTypes(form_structure.get()); |