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

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

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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 8c0bcddd2684b5f6e19602e47d431a514968369b..e99fb98454dfc64647d25c68e6617e0749d65783 100644
--- a/chrome/browser/autofill/autofill_external_delegate.cc
+++ b/chrome/browser/autofill/autofill_external_delegate.cc
@@ -26,12 +26,22 @@ AutofillExternalDelegate::AutofillExternalDelegate(
has_shown_autofill_popup_for_current_edit_(false) {
}
-void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int listIndex) {
+void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
+ int list_index) {
+ if (suggestions_options_index_ == list_index ||
+ suggestions_clear_index_ == list_index)
+ return;
+
RenderViewHost* host =
tab_contents_wrapper_->web_contents()->GetRenderViewHost();
- host->Send(new AutofillMsg_SelectAutofillSuggestionAtIndex(
- host->routing_id(),
- listIndex));
+ host->Send(new AutofillMsg_SetAutofillActionPreview(
+ host->routing_id()));
+
+ // Fill the values for the whole form.
+ autofill_manager_->OnFillAutofillFormData(autofill_query_id_,
+ autofill_query_form_,
+ autofill_query_field_,
+ unique_id);
}
void AutofillExternalDelegate::OnQuery(int query_id,
@@ -39,6 +49,7 @@ void AutofillExternalDelegate::OnQuery(int query_id,
const webkit::forms::FormField& field,
const gfx::Rect& bounds,
bool display_warning_if_disabled) {
+ autofill_query_form_ = form;
autofill_query_field_ = field;
display_warning_if_disabled_ = display_warning_if_disabled;
autofill_query_id_ = query_id;
@@ -50,6 +61,50 @@ void AutofillExternalDelegate::DidEndTextFieldEditing() {
has_shown_autofill_popup_for_current_edit_ = false;
}
+void AutofillExternalDelegate::didAcceptAutofillSuggestions(string16 value,
+ int unique_id,
+ unsigned index) {
+ HideAutofillPopup();
+
+ // TODO(csharp): Add the password autofill manager.
+ //if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
+ // return;
+
+ if (suggestions_options_index_ != -1 &&
+ index == static_cast<unsigned>(suggestions_options_index_)) {
+ // User selected 'Autofill Options'.
+ autofill_manager_->OnShowAutofillDialog();
+ } else if (suggestions_clear_index_ != -1 &&
+ index == static_cast<unsigned>(suggestions_clear_index_)) {
+ // User selected 'Clear form'.
+ RenderViewHost* host =
+ tab_contents_wrapper_->web_contents()->GetRenderViewHost();
+ host->Send(new AutofillMsg_ClearForm(host->routing_id()));
+
+ } else if (!unique_id) {
+ // User selected an Autocomplete entry, so we fill directly.
+ RenderViewHost* host =
+ tab_contents_wrapper_->web_contents()->GetRenderViewHost();
+ host->Send(new AutofillMsg_SetNodeText(
+ host->routing_id(),
+ value));
+ } else {
+ RenderViewHost* host =
+ tab_contents_wrapper_->web_contents()->GetRenderViewHost();
+ host->Send(new AutofillMsg_SetAutofillActionFill(
+ host->routing_id()));
+
+ // Fill the values for the whole form.
+ autofill_manager_->OnFillAutofillFormData(autofill_query_id_,
+ autofill_query_form_,
+ autofill_query_field_,
+ unique_id);
+ }
+
+ suggestions_clear_index_ = -1;
+ suggestions_options_index_ = -1;
+}
+
void AutofillExternalDelegate::OnSuggestionsReturned(
int query_id,
const std::vector<string16>& values,
@@ -109,6 +164,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
l.push_back(string16());
i.push_back(string16());
ids.push_back(0);
+ suggestions_clear_index_ = v.size() - 1;
separator_index = v.size() - 1;
}
@@ -119,6 +175,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
l.push_back(string16());
i.push_back(string16());
ids.push_back(0);
+ suggestions_options_index_ = v.size() - 1;
separator_index = values.size();
}

Powered by Google App Engine
This is Rietveld 408576698