| 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..ab24a9e0b8b793e9238f2142ae7927dec4dec963 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))
|
| return;
|
|
|
| // Determine the possible field types and upload the form structure to the
|
| @@ -148,9 +150,9 @@ void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) {
|
| ParseForms(forms);
|
| }
|
|
|
| -bool AutoFillManager::GetAutoFillSuggestions(int query_id,
|
| - bool field_autofilled,
|
| - const FormField& field) {
|
| +bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled,
|
| + const FormField& field,
|
| + bool autofill_disabled) {
|
| if (!IsAutoFillEnabled())
|
| return false;
|
|
|
| @@ -172,7 +174,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))
|
| continue;
|
|
|
| for (std::vector<AutoFillField*>::const_iterator iter = form->begin();
|
| @@ -214,6 +216,30 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id,
|
| if (values.empty())
|
| return false;
|
|
|
| + // Don't provide autofill suggestions when autofill is disabled, but provide a
|
| + // warning to the user.
|
| + if (autofill_disabled || !form->IsAutoFillable(true)) {
|
| + values.assign(
|
| + 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_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 +257,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 +550,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 +622,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,
|
| + // 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());
|
|
|