Chromium Code Reviews| Index: chrome/renderer/autofill/autofill_agent.cc |
| diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc |
| index f293635e2f12f19b1138d00a1f81ae2c817d37e4..c84843b07e09c0dcb0814550b65e91fd7bd68288 100644 |
| --- a/chrome/renderer/autofill/autofill_agent.cc |
| +++ b/chrome/renderer/autofill/autofill_agent.cc |
| @@ -19,6 +19,7 @@ |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| #include "ui/base/keycodes/keyboard_codes.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -59,6 +60,7 @@ AutofillAgent::AutofillAgent( |
| suggestions_clear_index_(-1), |
| suggestions_options_index_(-1), |
| has_shown_autofill_popup_for_current_edit_(false), |
| + has_external_delegate_(false), |
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| render_view->GetWebView()->setAutofillClient(this); |
| } |
| @@ -74,6 +76,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| OnFieldTypePredictionsAvailable) |
| IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex, |
| OnSelectAutofillSuggestionAtIndex) |
| + IPC_MESSAGE_HANDLER(AutofillMsg_SetHasExternalDelegate, |
| + OnSetHasExternalDelegate) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -124,6 +128,9 @@ bool AutofillAgent::InputElementClicked(const WebInputElement& element, |
| } |
| bool AutofillAgent::InputElementLostFocus() { |
| + if (has_external_delegate_) |
|
John Grabowski
2011/11/08 20:46:02
Can you confirm this is called when, for example,
csharp
2011/11/09 16:18:37
This function is not called in both of these cases
Ilya Sherman
2011/11/09 20:34:19
My hunch is that we'll want to add something along
|
| + Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); |
| + |
| return false; |
| } |
| @@ -315,11 +322,24 @@ void AutofillAgent::OnSuggestionsReturned(int query_id, |
| separator_index = values.size(); |
| } |
| - // Send to WebKit for display. |
| if (!v.empty() && !autofill_query_element_.isNull() && |
| autofill_query_element_.isFocusable()) { |
| - web_view->applyAutofillSuggestions( |
| - autofill_query_element_, v, l, i, ids, separator_index); |
| + if (has_external_delegate_) { |
| + // Send to an external delegate for display. |
| + WebKit::WebRect autofill_element_rect = |
| + autofill_query_element_.getRect(); |
| + |
| + Send(new AutofillHostMsg_AutofillElementBounds( |
| + routing_id(), |
| + autofill_element_rect.x, |
| + autofill_element_rect.y, |
| + autofill_element_rect.width, |
| + autofill_element_rect.height)); |
| + } else { |
| + // Send to WebKit for display. |
| + web_view->applyAutofillSuggestions( |
| + autofill_query_element_, v, l, i, ids, separator_index); |
| + } |
| } |
| Send(new AutofillHostMsg_DidShowAutofillSuggestions( |
| @@ -362,6 +382,10 @@ void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) { |
| // render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex); |
| } |
| +void AutofillAgent::OnSetHasExternalDelegate(bool has_external_delegate) { |
| + has_external_delegate_ = has_external_delegate; |
| +} |
| + |
| void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
| bool autofill_on_empty_values, |
| bool requires_caret_at_end, |