Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: chrome/browser/autofill/autofill_external_delegate.cc

Issue 9600038: Add Password Autofill Manager to New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding password popup Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/autofill_external_delegate.cc
diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc
index 4105709df4993045f92069ceaa3933924acb55fc..7ca007160d406560254c54eee6cdb382e8656d92 100644
--- a/chrome/browser/autofill/autofill_external_delegate.cc
+++ b/chrome/browser/autofill/autofill_external_delegate.cc
@@ -24,6 +24,8 @@ AutofillExternalDelegate::AutofillExternalDelegate(
AutofillManager* autofill_manager)
: tab_contents_wrapper_(tab_contents_wrapper),
autofill_manager_(autofill_manager),
+ password_autofill_manager_(
+ tab_contents_wrapper->web_contents()->GetRenderViewHost()),
autofill_query_id_(0),
display_warning_if_disabled_(false),
has_shown_autofill_popup_for_current_edit_(false),
@@ -33,6 +35,9 @@ AutofillExternalDelegate::AutofillExternalDelegate(
void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
int list_index) {
+ if (unique_id == kPasswordEntryIds)
+ return;
+
if (list_index == suggestions_options_index_ ||
list_index == suggestions_clear_index_ ||
unique_id == -1)
@@ -136,6 +141,22 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
}
+void AutofillExternalDelegate::ShowPasswordSuggestions(
+ const std::vector<string16>& suggestions) {
+ if (suggestions.empty()) {
+ HideAutofillPopup();
+ }
Ilya Sherman 2012/03/20 00:58:55 nit: No need for curly braces.
csharp 2012/03/21 14:10:31 Done.
+
+ std::vector<string16> empty;
+ std::vector<int> password_ids;
+ for (size_t i = 0; i < suggestions.size(); ++i) {
+ empty.push_back(string16());
Ilya Sherman 2012/03/20 00:58:55 Hmm, why are the suggestions all empty?
csharp 2012/03/21 14:10:31 The suggestions still have values, it just the lab
Ilya Sherman 2012/03/22 01:20:06 Ah, sorry, misread the code. You could write this
+ password_ids.push_back(kPasswordEntryIds);
+ }
+
+ ApplyAutofillSuggestions(suggestions, empty, empty, password_ids, -1);
+}
+
void AutofillExternalDelegate::DidEndTextFieldEditing() {
has_shown_autofill_popup_for_current_edit_ = false;
}
@@ -145,12 +166,16 @@ void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
int unique_id,
unsigned index) {
// If the selected element is a warning we don't want to do anything.
- if (unique_id < 0)
+ if (unique_id < 0 && unique_id != kPasswordEntryIds)
return;
- // TODO(csharp): Add the password autofill manager.
- // if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
- // return;
+ HideAutofillPopup();
+
+ // TODO(csharp) Fix how password are handled so that FindLoginInfo works.
csharp 2012/03/16 20:21:12 I think this will work in mostly cases right now.
Ilya Sherman 2012/03/20 00:58:55 It seems like this should work in all cases, but y
+ if (unique_id == kPasswordEntryIds) {
+ // Accepting has been handled by the password manager.
+ return;
+ }
if (suggestions_options_index_ != -1 &&
index == static_cast<unsigned>(suggestions_options_index_)) {
@@ -172,11 +197,13 @@ void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
} else {
FillAutofillFormData(unique_id, false);
}
-
- HideAutofillPopup();
}
void AutofillExternalDelegate::ClearPreviewedForm() {
+ if (password_autofill_manager_.DidClearAutofillSelection(
+ autofill_query_field_))
+ return;
+
RenderViewHost* host =
tab_contents_wrapper_->web_contents()->GetRenderViewHost();
host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
@@ -189,6 +216,18 @@ void AutofillExternalDelegate::HideAutofillPopup() {
HideAutofillPopupInternal();
}
+void AutofillExternalDelegate::Reset() {
+ HideAutofillPopup();
+
+ password_autofill_manager_.Reset();
+}
+
+void AutofillExternalDelegate::AddPasswordFormMapping(
+ const webkit::forms::FormField& form,
+ const webkit::forms::PasswordFormFillData& fill_data) {
+ password_autofill_manager_.AddPasswordFormMapping(form, fill_data);
+}
+
void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
bool is_preview) {
RenderViewHost* host =

Powered by Google App Engine
This is Rietveld 408576698