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 8f17ef13be9c2e335dcf9d22452d704c7396d730..aee6d521fd8ef04a56b8989ab7edec11ba85168a 100644 |
| --- a/chrome/browser/autofill/autofill_manager.cc |
| +++ b/chrome/browser/autofill/autofill_manager.cc |
| @@ -23,6 +23,7 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/api/infobars/infobar_service.h" |
| #include "chrome/browser/api/sync/profile_sync_service_base.h" |
| +#include "chrome/browser/autofill/autocheckout/whitelist_manager.h" |
| #include "chrome/browser/autofill/autocheckout_manager.h" |
| #include "chrome/browser/autofill/autocheckout_infobar_delegate.h" |
| #include "chrome/browser/autofill/autocomplete_history_manager.h" |
| @@ -80,7 +81,7 @@ const char* kAutofillManagerWebContentsUserDataKey = "web_contents_autofill"; |
| const double kAutofillPositiveUploadRateDefaultValue = 0.20; |
| const double kAutofillNegativeUploadRateDefaultValue = 0.20; |
| -const size_t kMaxRecentFormSignaturesToRemember = 3; |
| +const size_t kMaxRecentFormSignaturesToRemember = 0; |
|
Ilya Sherman
2013/01/24 06:36:48
Why did you change this variable?
benquan
2013/01/24 18:30:42
ah, this change was for testing, reverted.
|
| // Set a conservative upper bound on the number of forms we are willing to |
| // cache, simply to prevent unbounded memory consumption. |
| @@ -394,7 +395,8 @@ bool AutofillManager::OnFormSubmitted(const FormData& form, |
| return false; |
| // Grab a copy of the form data. |
| - scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); |
| + scoped_ptr<FormStructure> submitted_form( |
| + new FormStructure(form, IsAutocheckoutEnabled())); |
| // Disregard forms that we wouldn't ever autofill in the first place. |
| if (!submitted_form->ShouldBeParsed(true)) |
| @@ -454,6 +456,9 @@ bool AutofillManager::OnFormSubmitted(const FormData& form, |
| void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms, |
| const TimeTicks& timestamp) { |
| + DVLOG(1) << "Autocheckout is " |
| + << (IsAutocheckoutEnabled() ? "enabled" : "disabled") |
| + << " for " << web_contents()->GetURL(); |
| bool enabled = IsAutofillEnabled(); |
| if (!has_logged_autofill_enabled_) { |
| metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); |
| @@ -887,8 +892,19 @@ void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) { |
| // TODO(ahutter): Plug into WalletClient. |
| } |
| +bool AutofillManager::IsAutocheckoutEnabled() const { |
| + if (!web_contents()) |
| + return false; |
| + |
| + autocheckout::WhitelistManager* wm = |
| + autocheckout::WhitelistManager::GetForBrowserContext( |
| + web_contents()->GetBrowserContext()); |
| + return wm->IsAutocheckoutEnabled(web_contents()->GetURL()); |
| +} |
| + |
| bool AutofillManager::IsAutofillEnabled() const { |
| - return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
| + return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled) || |
| + IsAutocheckoutEnabled(); |
| } |
| void AutofillManager::SendAutofillTypePredictions( |
| @@ -1087,7 +1103,7 @@ bool AutofillManager::GetCachedFormAndField(const FormData& form, |
| // If we do not have this form in our cache but it is parseable, we'll add it |
| // in the call to |UpdateCachedForm()|. |
| if (!FindCachedForm(form, form_structure) && |
| - !FormStructure(form).ShouldBeParsed(false)) { |
| + !FormStructure(form, IsAutocheckoutEnabled()).ShouldBeParsed(false)) { |
| return false; |
| } |
| @@ -1134,7 +1150,8 @@ bool AutofillManager::UpdateCachedForm(const FormData& live_form, |
| return false; |
| // Add the new or updated form to our cache. |
| - form_structures_.push_back(new FormStructure(live_form)); |
| + form_structures_.push_back( |
| + new FormStructure(live_form, IsAutocheckoutEnabled())); |
| *updated_form = *form_structures_.rbegin(); |
| (*updated_form)->DetermineHeuristicTypes(*metric_logger_); |
| @@ -1210,9 +1227,11 @@ void AutofillManager::GetCreditCardSuggestions( |
| void AutofillManager::ParseForms(const std::vector<FormData>& forms) { |
| std::vector<FormStructure*> non_queryable_forms; |
| + bool autocheckout_enabled = IsAutocheckoutEnabled(); |
| for (std::vector<FormData>::const_iterator iter = forms.begin(); |
| iter != forms.end(); ++iter) { |
| - scoped_ptr<FormStructure> form_structure(new FormStructure(*iter)); |
| + scoped_ptr<FormStructure> form_structure( |
| + new FormStructure(*iter, autocheckout_enabled)); |
| if (!form_structure->ShouldBeParsed(false)) |
| continue; |