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

Unified Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 8490017: Setting up external delegate calls to allow a future delegate to handle autofill (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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/renderer/autofill/autofill_agent.cc
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc
index f293635e2f12f19b1138d00a1f81ae2c817d37e4..fb609503e0d37e42db12cb3c621ee7af18a8beac 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_HasExternalDelegate,
+ HasExternalDelegate)
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_)
+ Send(new AutofillDelegateMsg_HideAutofillPopup(routing_id()));
+
return false;
}
@@ -252,6 +259,8 @@ void AutofillAgent::OnSuggestionsReturned(int query_id,
if (values.empty()) {
// No suggestions, any popup currently showing is obsolete.
web_view->hidePopups();
+ if (has_external_delegate_)
+ Send(new AutofillDelegateMsg_HideAutofillPopup(routing_id()));
Ilya Sherman 2011/11/07 21:48:49 This call shouldn't be necessary -- all the releva
csharp1 2011/11/08 19:59:00 Done.
return;
}
@@ -315,11 +324,30 @@ 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 AutofillDelegateMsg_AutofillElementBounds(
+ routing_id(),
+ autofill_element_rect.x,
+ autofill_element_rect.y,
+ autofill_element_rect.width,
+ autofill_element_rect.height));
+
+ Send(new AutofillDelegateMsg_ShowAutofillSuggestions(
+ routing_id(), query_id, v, l, i, ids));
Ilya Sherman 2011/11/07 21:48:49 We'll need to rework how warnings are handled; but
csharp1 2011/11/08 19:59:00 So if I understand correctly, you are suggesting t
Ilya Sherman 2011/11/08 21:06:16 Right. Once the transition to the browser-side UI
csharp 2011/11/09 16:18:37 Ok, I've added a todo to copy the logic over. I qu
+ } else {
+ // Send to WebKit for display.
+ web_view->applyAutofillSuggestions(
+ autofill_query_element_, v, l, i, ids, separator_index);
+ }
+ } else {
+ if (has_external_delegate_)
+ Send(new AutofillDelegateMsg_HideAutofillPopup(routing_id()));
}
Send(new AutofillHostMsg_DidShowAutofillSuggestions(
@@ -362,6 +390,10 @@ void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) {
// render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex);
}
+void AutofillAgent::HasExternalDelegate(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,
« chrome/renderer/autofill/autofill_agent.h ('K') | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698