From acca2a1fc734142de039f65405ef259737d7a8fc Mon Sep 17 00:00:00 2001 From: "darin@chromium.org" Date: Fri, 16 Oct 2009 03:53:39 +0000 Subject: Move autofill related WebView{Delegate} methods into the WebKit API. This CL also changes a bunch of autofill related wstring values to string16. R=jcampan BUG=24595 TEST=none Review URL: http://codereview.chromium.org/279001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29244 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/print_web_view_helper.h | 10 +++++-- chrome/renderer/render_view.cc | 51 ++++++++++++++++----------------- chrome/renderer/render_view.h | 21 +++++++------- 3 files changed, 44 insertions(+), 38 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index fee75f8..80b309f 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -205,13 +205,19 @@ class PrintWebViewHelper : public WebViewDelegate { virtual int historyBackListCount() { return 0; } virtual int historyForwardListCount() { return 0; } virtual void didAddHistoryItem() {} - virtual void didUpdateInspectorSettings() {} virtual void focusAccessibilityObject( const WebKit::WebAccessibilityObject& object) {} + virtual void didUpdateInspectorSettings() {} + virtual void queryAutofillSuggestions( + const WebKit::WebNode& node, const WebKit::WebString& name, + const WebKit::WebString& value) {} + virtual void removeAutofillSuggestions( + const WebKit::WebString& name, const WebKit::WebString& value) {} // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect&) {} - virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect) {} + virtual void didScrollRect( + int dx, int dy, const WebKit::WebRect& clipRect) {} virtual void didFocus() {} virtual void didBlur() {} virtual void didChangeCursor(const WebKit::WebCursorInfo&) {} diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 5691a84..734605a 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -223,8 +223,7 @@ RenderView::RenderView(RenderThreadBase* render_thread, history_forward_list_count_(0), has_unload_listener_(false), decrement_shared_popup_at_destruction_(false), - form_field_autofill_request_id_(0), - form_field_autofill_node_id_(0), + autofill_query_id_(0), popup_notification_visible_(false), spelling_panel_visible_(false), delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), @@ -1233,30 +1232,15 @@ void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) { autodetected)); } -void RenderView::QueryFormFieldAutofill(const std::wstring& field_name, - const std::wstring& text, - int64 node_id) { - static int message_id_counter = 0; - form_field_autofill_request_id_ = message_id_counter++; - form_field_autofill_node_id_ = node_id; - Send(new ViewHostMsg_QueryFormFieldAutofill( - routing_id_, form_field_autofill_request_id_, field_name, text)); -} - -void RenderView::RemoveStoredAutofillEntry(const std::wstring& name, - const std::wstring& value) { - Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value)); -} - void RenderView::OnQueryFormFieldAutofillAck( - int request_id, - const std::vector& suggestions, + int query_id, + const std::vector& suggestions, int default_suggestion_index) { - if (!webview() || request_id != form_field_autofill_request_id_) - return; - - webview()->AutofillSuggestionsForNode( - form_field_autofill_node_id_, suggestions, default_suggestion_index); + if (webview() && query_id == autofill_query_id_ && !suggestions.empty()) { + webview()->applyAutofillSuggestions( + autofill_query_node_, suggestions, default_suggestion_index); + } + autofill_query_node_.reset(); } void RenderView::OnPopupNotificationVisibilityChanged(bool visible) { @@ -1716,6 +1700,21 @@ void RenderView::didUpdateInspectorSettings() { routing_id_, webview()->inspectorSettings().utf8())); } +void RenderView::queryAutofillSuggestions(const WebNode& node, + const WebString& name, + const WebString& value) { + static int query_counter = 0; + autofill_query_id_ = query_counter++; + autofill_query_node_ = node; + Send(new ViewHostMsg_QueryFormFieldAutofill( + routing_id_, autofill_query_id_, name, value)); +} + +void RenderView::removeAutofillSuggestions(const WebString& name, + const WebString& value) { + Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value)); +} + // WebKit::WebWidgetClient ---------------------------------------------------- // We are supposed to get a single call to Show for a newly created RenderView @@ -3286,13 +3285,13 @@ void RenderView::AltErrorPageFinished(WebFrame* frame, void RenderView::OnMoveOrResizeStarted() { if (webview()) - webview()->HideAutofillPopup(); + webview()->hideAutofillPopup(); } void RenderView::OnResize(const gfx::Size& new_size, const gfx::Rect& resizer_rect) { if (webview()) - webview()->HideAutofillPopup(); + webview()->hideAutofillPopup(); RenderWidget::OnResize(new_size, resizer_rect); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 16b4fe0..f100778 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -38,6 +38,7 @@ #include "webkit/api/public/WebConsoleMessage.h" #include "webkit/api/public/WebContextMenuData.h" #include "webkit/api/public/WebFrameClient.h" +#include "webkit/api/public/WebNode.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/glue/dom_serializer_delegate.h" #include "webkit/glue/form_data.h" @@ -164,11 +165,6 @@ class RenderView : public RenderWidget, virtual void OnMessageReceived(const IPC::Message& msg); // WebViewDelegate - virtual void QueryFormFieldAutofill(const std::wstring& field_name, - const std::wstring& text, - int64 node_id); - virtual void RemoveStoredAutofillEntry(const std::wstring& field_name, - const std::wstring& text); virtual void LoadNavigationErrorPage( WebKit::WebFrame* frame, const WebKit::WebURLRequest& failed_request, @@ -258,9 +254,14 @@ class RenderView : public RenderWidget, virtual int historyBackListCount(); virtual int historyForwardListCount(); virtual void didAddHistoryItem(); - virtual void didUpdateInspectorSettings(); virtual void focusAccessibilityObject( const WebKit::WebAccessibilityObject& acc_obj); + virtual void didUpdateInspectorSettings(); + virtual void queryAutofillSuggestions( + const WebKit::WebNode& node, const WebKit::WebString& name, + const WebKit::WebString& value); + virtual void removeAutofillSuggestions( + const WebKit::WebString& name, const WebKit::WebString& value); virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() { return notification_provider_.get(); @@ -636,8 +637,8 @@ class RenderView : public RenderWidget, // Notification that we have received autofill suggestion. void OnQueryFormFieldAutofillAck( - int request_id, - const std::vector& suggestions, + int query_id, + const std::vector& suggestions, int default_suggestions_index); // Message that the popup notification has been shown or hidden. @@ -871,11 +872,11 @@ class RenderView : public RenderWidget, // The id of the last request sent for form field autofill. Used to ignore // out of date responses. - int form_field_autofill_request_id_; + int autofill_query_id_; // The id of the node corresponding to the last request sent for form field // autofill. - int64 form_field_autofill_node_id_; + WebKit::WebNode autofill_query_node_; // We need to prevent windows from closing themselves with a window.close() // call while a blocked popup notification is being displayed. We cannot -- cgit v1.1