Index: components/autofill/browser/autofill_manager.cc |
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc |
index e7b2171746ce9158104609e205bb0d90653e458a..6ecf9e934fd1580ccae0724bb6c855f80c97de97 100644 |
--- a/components/autofill/browser/autofill_manager.cc |
+++ b/components/autofill/browser/autofill_manager.cc |
@@ -329,19 +329,20 @@ bool AutofillManager::OnMessageReceived(const IPC::Message& message) { |
bool AutofillManager::OnFormSubmitted(const FormData& form, |
const TimeTicks& timestamp) { |
- // Let AutoComplete know as well. |
- autocomplete_history_manager_.OnFormSubmitted(form); |
- |
if (!IsAutofillEnabled()) |
return false; |
- if (web_contents()->GetBrowserContext()->IsOffTheRecord()) |
- return false; |
Ilya Sherman
2013/06/15 00:28:09
I think this check is still needed.
sgurun-gerrit only
2013/06/17 21:20:32
Done.
|
+ // Let AutoComplete know as well. |
+ autocomplete_history_manager_.OnFormSubmitted(form); |
Ilya Sherman
2013/06/15 00:28:09
Does this re-ordering still make sense given the u
sgurun-gerrit only
2013/06/17 21:20:32
There seems multiple issues with enabling/disablin
|
// Don't save data that was submitted through JavaScript. |
if (!form.user_submitted) |
return false; |
+ // If there is no personal_data_, nothing to do. |
+ if (!personal_data_) |
+ return false; |
+ |
// Grab a copy of the form data. |
scoped_ptr<FormStructure> submitted_form( |
new FormStructure(form, GetAutocheckoutURLPrefix())); |
@@ -494,6 +495,27 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
display_warning); |
} |
+ GetAutofillSuggestions(form, |
+ field, |
+ &values, |
+ &labels, |
+ &icons, |
+ &unique_ids); |
Ilya Sherman
2013/06/15 00:28:09
nit: This all fits on a single line.
Ilya Sherman
2013/06/15 00:28:09
What's the purpose of decomposing out this method?
sgurun-gerrit only
2013/06/17 21:20:32
Done.
sgurun-gerrit only
2013/06/17 21:20:32
Done.
|
+ |
+ // Add the results from AutoComplete. They come back asynchronously, so we |
+ // hand off what we generated and they will send the results back to the |
+ // renderer. |
+ autocomplete_history_manager_.OnGetAutocompleteSuggestions( |
+ query_id, field.name, field.value, values, labels, icons, unique_ids); |
+} |
+ |
+void AutofillManager::GetAutofillSuggestions( |
+ const FormData& form, |
+ const FormFieldData& field, |
+ std::vector<base::string16>* values, |
+ std::vector<base::string16>* labels, |
+ std::vector<string16>* icons, |
+ std::vector<int>* unique_ids) { |
RenderViewHost* host = NULL; |
FormStructure* form_structure = NULL; |
AutofillField* autofill_field = NULL; |
@@ -506,17 +528,17 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
(AutofillType(type).group() == AutofillType::CREDIT_CARD); |
if (is_filling_credit_card) { |
GetCreditCardSuggestions( |
- field, type, &values, &labels, &icons, &unique_ids); |
+ field, type, values, labels, icons, unique_ids); |
} else { |
GetProfileSuggestions( |
- form_structure, field, type, &values, &labels, &icons, &unique_ids); |
+ form_structure, field, type, values, labels, icons, unique_ids); |
} |
- DCHECK_EQ(values.size(), labels.size()); |
- DCHECK_EQ(values.size(), icons.size()); |
- DCHECK_EQ(values.size(), unique_ids.size()); |
+ DCHECK_EQ(values->size(), labels->size()); |
+ DCHECK_EQ(values->size(), icons->size()); |
+ DCHECK_EQ(values->size(), unique_ids->size()); |
- if (!values.empty()) { |
+ if (!values->empty()) { |
// Don't provide Autofill suggestions when Autofill is disabled, and don't |
// provide credit card suggestions for non-HTTPS pages. However, provide a |
// warning to the user in these cases. |
@@ -526,11 +548,11 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
else if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) |
warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; |
if (warning) { |
- values.assign(1, l10n_util::GetStringUTF16(warning)); |
- labels.assign(1, base::string16()); |
- icons.assign(1, base::string16()); |
- unique_ids.assign(1, |
- WebKit::WebAutofillClient::MenuItemIDWarningMessage); |
+ values->assign(1, l10n_util::GetStringUTF16(warning)); |
+ labels->assign(1, base::string16()); |
+ icons->assign(1, base::string16()); |
+ unique_ids->assign(1, |
+ WebKit::WebAutofillClient::MenuItemIDWarningMessage); |
} else { |
bool section_is_autofilled = |
SectionIsAutofilled(*form_structure, form, |
@@ -540,8 +562,8 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
// for suggestions, then the user is editing the value of a field. |
// In this case, mimic autocomplete: don't display labels or icons, |
// as that information is redundant. |
- labels.assign(labels.size(), base::string16()); |
- icons.assign(icons.size(), base::string16()); |
+ labels->assign(labels->size(), base::string16()); |
+ icons->assign(icons->size(), base::string16()); |
} |
// When filling credit card suggestions, the values and labels are |
@@ -549,23 +571,17 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
// duplicates only tend to be a problem when filling address forms |
// anyway, only don't de-dup credit card suggestions. |
if (!is_filling_credit_card) |
- RemoveDuplicateSuggestions(&values, &labels, &icons, &unique_ids); |
+ RemoveDuplicateSuggestions(values, labels, icons, unique_ids); |
// The first time we show suggestions on this page, log the number of |
// suggestions shown. |
if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { |
- metric_logger_->LogAddressSuggestionsCount(values.size()); |
+ metric_logger_->LogAddressSuggestionsCount(values->size()); |
has_logged_address_suggestions_count_ = true; |
} |
} |
} |
} |
- |
- // Add the results from AutoComplete. They come back asynchronously, so we |
- // hand off what we generated and they will send the results back to the |
- // renderer. |
- autocomplete_history_manager_.OnGetAutocompleteSuggestions( |
- query_id, field.name, field.value, values, labels, icons, unique_ids); |
} |
void AutofillManager::OnFillAutofillFormData(int query_id, |
@@ -864,11 +880,14 @@ std::string AutofillManager::GetAutocheckoutURLPrefix() const { |
autofill::autocheckout::WhitelistManager* whitelist_manager = |
manager_delegate_->GetAutocheckoutWhitelistManager(); |
- return whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()); |
+ return whitelist_manager ? |
+ whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()) : |
+ std::string(); |
} |
bool AutofillManager::IsAutofillEnabled() const { |
- return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
+ return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled) |
+ && !manager_delegate_->ShouldIgnoreFormData() ; |
Ilya Sherman
2013/06/15 00:28:09
nit: The "&&" should go on the previous line.
sgurun-gerrit only
2013/06/17 21:20:32
Done.
|
} |
void AutofillManager::SendAutofillTypePredictions( |
@@ -890,6 +909,7 @@ void AutofillManager::SendAutofillTypePredictions( |
void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
const CreditCard* imported_credit_card; |
+ |
Ilya Sherman
2013/06/15 00:28:09
nit: Spurious diff.
sgurun-gerrit only
2013/06/17 21:20:32
Done.
|
if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) |
return; |
@@ -1010,9 +1030,13 @@ void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { |
} |
bool AutofillManager::GetHost(RenderViewHost** host) const { |
+ |
Ilya Sherman
2013/06/15 00:28:09
nit: Spurious diff.
sgurun-gerrit only
2013/06/17 21:20:32
Done.
|
if (!IsAutofillEnabled()) |
return false; |
+ if (!personal_data_) |
+ return false; |
+ |
// No autofill data to return if the profiles are empty. |
if (personal_data_->GetProfiles().empty() && |
personal_data_->GetCreditCards().empty()) { |