Index: chrome/browser/autofill/autofill_manager.cc |
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc |
index 4bba52b11c8e1af5f42633f5bb9ab7d10c2b1047..11e75199c5b9b7dbdb99c88aff96d3766ca0949b 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/autocomplete_history_manager.h" |
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
#include "chrome/browser/autofill/autofill_country.h" |
@@ -391,7 +392,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)) |
@@ -839,8 +841,17 @@ void AutofillManager::OnDidEndTextFieldEditing() { |
external_delegate_->DidEndTextFieldEditing(); |
} |
+bool AutofillManager::IsAutocheckoutEnabled() const{ |
ahutter
2013/01/19 02:07:16
missing space
benquan
2013/01/23 23:50:53
Done.
|
+ if (!web_contents()) return false; |
ahutter
2013/01/19 02:07:16
newline
benquan
2013/01/23 23:50:53
Done.
|
+ autocheckout::WhitelistManager* wm = |
+ autocheckout::WhitelistManager::GetForBrowserContext( |
+ web_contents()->GetBrowserContext()); |
+ return wm->IsAutocheckoutEnabled(web_contents()->GetURL()); |
ahutter
2013/01/19 02:07:16
does web_contents() always refer to url in the nav
benquan
2013/01/23 23:50:53
it refers to the tab the AutofillManager associate
|
+} |
+ |
bool AutofillManager::IsAutofillEnabled() const { |
- return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
+ return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled) || |
+ IsAutocheckoutEnabled(); |
} |
void AutofillManager::SendAutofillTypePredictions( |
@@ -1038,7 +1049,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; |
} |
@@ -1085,7 +1096,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_); |
@@ -1184,9 +1196,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; |