summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 19:28:08 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 19:28:08 +0000
commit89ac46c97e6a3b2f2726bd11d52824d27ee26a24 (patch)
treec976f9689ff7fabd3c3e54e06ed051d1bd4544c7 /chrome
parent9ac105a1023bc696e619e5714c524e1a3ffdc2ef (diff)
downloadchromium_src-89ac46c97e6a3b2f2726bd11d52824d27ee26a24.zip
chromium_src-89ac46c97e6a3b2f2726bd11d52824d27ee26a24.tar.gz
chromium_src-89ac46c97e6a3b2f2726bd11d52824d27ee26a24.tar.bz2
This CL adds the autofill UI in forms.
When the user types text in a text field in a form, the renderer queries the browser for suggestion based on the entered text and displays the suggestions in a popup. Listeners are set on the form text field in a similar fashion than for password save. The popup showing the suggestion uses the same mechanism as the select popup. Note that a difference between the select and the autofill popup is that the autofill should not take focus, so the page still has focus and the user can still type in while it shows. The creation of the render widget was modified for that purpose so we can specify the popup should not be focused when shown. Review URL: http://codereview.chromium.org/8885 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4804 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/render_view_host.cc44
-rw-r--r--chrome/browser/render_view_host.h7
-rw-r--r--chrome/browser/render_view_host_delegate.h5
-rw-r--r--chrome/browser/render_widget_helper.cc6
-rw-r--r--chrome/browser/render_widget_helper.h2
-rw-r--r--chrome/browser/render_widget_host_view_win.cc9
-rw-r--r--chrome/browser/render_widget_host_view_win.h8
-rw-r--r--chrome/browser/resource_message_filter.cc6
-rw-r--r--chrome/browser/resource_message_filter.h2
-rw-r--r--chrome/browser/web_contents_view.cc6
-rw-r--r--chrome/browser/web_contents_view.h6
-rw-r--r--chrome/browser/web_contents_view_win.cc7
-rw-r--r--chrome/browser/web_contents_view_win.h3
-rw-r--r--chrome/common/render_messages_internal.h23
-rw-r--r--chrome/renderer/render_view.cc36
-rw-r--r--chrome/renderer/render_view.h17
-rw-r--r--chrome/renderer/render_widget.cc14
-rw-r--r--chrome/renderer/render_widget.h9
-rw-r--r--chrome/renderer/render_widget_unittest.cc6
19 files changed, 176 insertions, 40 deletions
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index 08addb5..963acc9 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -680,6 +680,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK);
IPC_MESSAGE_HANDLER(ViewHostMsg_UnloadListenerChanged,
OnUnloadListenerChanged);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_QueryFormFieldAutofill,
+ OnQueryFormFieldAutofill)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP_EX()
@@ -709,10 +711,11 @@ void RenderViewHost::OnMsgCreateWindow(int route_id,
view->CreateNewWindow(route_id, modal_dialog_event);
}
-void RenderViewHost::OnMsgCreateWidget(int route_id) {
+void RenderViewHost::OnMsgCreateWidget(int route_id,
+ bool focus_on_show) {
RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
if (view)
- view->CreateNewWidget(route_id);
+ view->CreateNewWidget(route_id, focus_on_show);
}
void RenderViewHost::OnMsgShowView(int route_id,
@@ -1203,6 +1206,43 @@ void RenderViewHost::OnUnloadListenerChanged(bool has_listener) {
has_unload_listener_ = has_listener;
}
+void RenderViewHost::OnQueryFormFieldAutofill(const std::wstring& field_name,
+ const std::wstring& user_text,
+ int64 node_id,
+ int request_id) {
+ // TODO(jcampan): this is where the suggestions should be queried from the
+ // database. The sample code commented below is left here in the meantime for
+ // testing purpose.
+#ifndef TEST_AUTOFILL
+ static std::vector<std::wstring>* suggestions = NULL;
+ if (!suggestions) {
+ suggestions = new std::vector<std::wstring>();
+ suggestions->push_back(L"Alice");
+ suggestions->push_back(L"Jay");
+ suggestions->push_back(L"Jason");
+ suggestions->push_back(L"Jasmine");
+ suggestions->push_back(L"Jamel");
+ suggestions->push_back(L"Jamelo");
+ suggestions->push_back(L"Volvo");
+ suggestions->push_back(L"Volswagen");
+ }
+
+
+ std::vector<std::wstring> result;
+ for (std::vector<std::wstring>::iterator iter = suggestions->begin();
+ iter != suggestions->end(); ++iter) {
+ if (StartsWith(*iter, user_text, false))
+ result.push_back(*iter);
+ }
+ Send(new ViewMsg_AutofillSuggestions(routing_id_,
+ node_id, request_id, result, 0));
+#else
+ Send(new ViewMsg_AutofillSuggestions(routing_id_,
+ node_id, request_id,
+ std::vector<std::wstring>(), 0));
+#endif
+}
+
void RenderViewHost::NotifyRendererUnresponsive() {
if (is_waiting_for_unload_ack_ &&
!Singleton<CrossSiteRequestManager>()->HasPendingCrossSiteRequest(
diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h
index e387171..551c5b8 100644
--- a/chrome/browser/render_view_host.h
+++ b/chrome/browser/render_view_host.h
@@ -393,7 +393,7 @@ class RenderViewHost : public RenderWidgetHost {
// IPC message handlers:
void OnMsgCreateWindow(int route_id, HANDLE modal_dialog_event);
- void OnMsgCreateWidget(int route_id);
+ void OnMsgCreateWidget(int route_id, bool focus_on_show);
void OnMsgShowView(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
@@ -491,7 +491,10 @@ class RenderViewHost : public RenderWidgetHost {
const webkit_glue::WebApplicationInfo& info);
void OnMsgShouldCloseACK(bool proceed);
void OnUnloadListenerChanged(bool has_handler);
-
+ void OnQueryFormFieldAutofill(const std::wstring& field_name,
+ const std::wstring& user_text,
+ int64 node_id,
+ int request_id);
virtual void NotifyRendererUnresponsive();
virtual void NotifyRendererResponsive();
diff --git a/chrome/browser/render_view_host_delegate.h b/chrome/browser/render_view_host_delegate.h
index 44aa1c99..eea3113 100644
--- a/chrome/browser/render_view_host_delegate.h
+++ b/chrome/browser/render_view_host_delegate.h
@@ -60,7 +60,10 @@ class RenderViewHostDelegate {
// The page is trying to open a new widget (e.g. a select popup). The
// widget should be created associated with the given route, but it should
// not be shown yet. That should happen in response to ShowCreatedWidget.
- virtual void CreateNewWidget(int route_id) = 0;
+ // If |focus_on_show| is true, the focus is given to the widget when shown,
+ // otherwise the focus is not changed.
+ virtual void CreateNewWidget(int route_id,
+ bool focus_on_show) = 0;
// Show a previously created page with the specified disposition and bounds.
// The window is identified by the route_id passed to CreateNewWindow.
diff --git a/chrome/browser/render_widget_helper.cc b/chrome/browser/render_widget_helper.cc
index d6e2bd7..4b87080 100644
--- a/chrome/browser/render_widget_helper.cc
+++ b/chrome/browser/render_widget_helper.cc
@@ -218,9 +218,11 @@ void RenderWidgetHelper::CreateNewWindow(int opener_id,
this, &RenderWidgetHelper::OnSimulateReceivedMessage, msg));
}
-void RenderWidgetHelper::CreateNewWidget(int opener_id, int* route_id) {
+void RenderWidgetHelper::CreateNewWidget(int opener_id,
+ bool focus_on_show,
+ int* route_id) {
*route_id = GetNextRoutingID();
- ViewHostMsg_CreateWidgetWithRoute msg(opener_id, *route_id);
+ ViewHostMsg_CreateWidgetWithRoute msg(opener_id, *route_id, focus_on_show);
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &RenderWidgetHelper::OnSimulateReceivedMessage, msg));
}
diff --git a/chrome/browser/render_widget_helper.h b/chrome/browser/render_widget_helper.h
index 7b6295f..c09462a 100644
--- a/chrome/browser/render_widget_helper.h
+++ b/chrome/browser/render_widget_helper.h
@@ -113,7 +113,7 @@ class RenderWidgetHelper :
void CreateNewWindow(int opener_id, bool user_gesture, int* route_id,
HANDLE* modal_dialog_event, HANDLE render_process);
- void CreateNewWidget(int opener_id, int* route_id);
+ void CreateNewWidget(int opener_id, bool focus_on_show, int* route_id);
private:
// A class used to proxy a paint message. PaintMsgProxy objects are created
diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc
index 05eb2a2..ab9275a 100644
--- a/chrome/browser/render_widget_host_view_win.cc
+++ b/chrome/browser/render_widget_host_view_win.cc
@@ -65,10 +65,8 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
///////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostViewWin, public:
-RenderWidgetHostViewWin::RenderWidgetHostViewWin(
- RenderWidgetHost* widget)
- : RenderWidgetHostView(),
- render_widget_host_(widget),
+RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
+ : render_widget_host_(widget),
real_cursor_(LoadCursor(NULL, IDC_ARROW)),
real_cursor_type_(WebCursor::ARROW),
track_mouse_leave_(false),
@@ -79,7 +77,8 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(
tooltip_showing_(false),
shutdown_factory_(this),
parent_hwnd_(NULL),
- is_loading_(false) {
+ is_loading_(false),
+ focus_on_show_(true) {
render_widget_host_->set_view(this);
renderer_accessible_ =
CommandLine().HasSwitch(switches::kEnableRendererAccessibility);
diff --git a/chrome/browser/render_widget_host_view_win.h b/chrome/browser/render_widget_host_view_win.h
index 348e21c..1d15674 100644
--- a/chrome/browser/render_widget_host_view_win.h
+++ b/chrome/browser/render_widget_host_view_win.h
@@ -65,6 +65,11 @@ class RenderWidgetHostViewWin :
close_on_deactivate_ = close_on_deactivate;
}
+ void set_focus_on_show(bool focus) {
+ focus_on_show_ = focus;
+ }
+ bool focus_on_show() const { return focus_on_show_; }
+
void set_parent_hwnd(HWND parent) { parent_hwnd_ = parent; }
DECLARE_WND_CLASS_EX(kRenderWidgetHostHWNDClass, CS_DBLCLKS, 0);
@@ -259,6 +264,9 @@ class RenderWidgetHostViewWin :
// value returns true for is_null() if we are not recording whiteout times.
base::TimeTicks whiteout_start_time_;
+ // Whether the window should get focus when shown. Default is true.
+ bool focus_on_show_;
+
// Whether the renderer is made accessible.
// TODO(jcampan): http://b/issue?id=1432077 This is a temporary work-around
// until that bug is fixed.
diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc
index 2e25e92..24eb964 100644
--- a/chrome/browser/resource_message_filter.cc
+++ b/chrome/browser/resource_message_filter.cc
@@ -234,8 +234,10 @@ void ResourceMessageFilter::OnMsgCreateWindow(int opener_id,
modal_dialog_event, render_handle_);
}
-void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, int* route_id) {
- render_widget_helper_->CreateNewWidget(opener_id, route_id);
+void ResourceMessageFilter::OnMsgCreateWidget(int opener_id,
+ bool focus_on_show,
+ int* route_id) {
+ render_widget_helper_->CreateNewWidget(opener_id, focus_on_show, route_id);
}
void ResourceMessageFilter::OnRequestResource(
diff --git a/chrome/browser/resource_message_filter.h b/chrome/browser/resource_message_filter.h
index 7dd3513..1b068e4 100644
--- a/chrome/browser/resource_message_filter.h
+++ b/chrome/browser/resource_message_filter.h
@@ -77,7 +77,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
private:
void OnMsgCreateWindow(int opener_id, bool user_gesture, int* route_id,
HANDLE* modal_dialog_event);
- void OnMsgCreateWidget(int opener_id, int* route_id);
+ void OnMsgCreateWidget(int opener_id, bool focus_on_show, int* route_id);
void OnRequestResource(const IPC::Message& msg, int request_id,
const ViewHostMsg_Resource_Request& request);
void OnCancelRequest(int request_id);
diff --git a/chrome/browser/web_contents_view.cc b/chrome/browser/web_contents_view.cc
index 28dd88b..931e36c 100644
--- a/chrome/browser/web_contents_view.cc
+++ b/chrome/browser/web_contents_view.cc
@@ -10,9 +10,11 @@ void WebContentsView::CreateNewWindow(int route_id, HANDLE modal_dialog_event) {
modal_dialog_event);
}
-void WebContentsView::CreateNewWidget(int route_id) {
+void WebContentsView::CreateNewWidget(int route_id,
+ bool focus_on_show) {
// Save the created widget associated with the route so we can show it later.
- pending_widget_views_[route_id] = CreateNewWidgetInternal(route_id);
+ pending_widget_views_[route_id] = CreateNewWidgetInternal(route_id,
+ focus_on_show);
}
void WebContentsView::ShowCreatedWindow(int route_id,
diff --git a/chrome/browser/web_contents_view.h b/chrome/browser/web_contents_view.h
index 6ebf84c..e6b24c2 100644
--- a/chrome/browser/web_contents_view.h
+++ b/chrome/browser/web_contents_view.h
@@ -172,7 +172,8 @@ class WebContentsView : public RenderViewHostDelegate::View {
// the Show functions rather than the route ID.
virtual WebContents* CreateNewWindowInternal(int route_id,
HANDLE modal_dialog_event) = 0;
- virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id) = 0;
+ virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id,
+ bool focus_on_show) = 0;
virtual void ShowCreatedWindowInternal(WebContents* new_web_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
@@ -185,7 +186,8 @@ class WebContentsView : public RenderViewHostDelegate::View {
// do some book-keeping associated with the request. The request is then
// forwarded to *Internal which does platform-specific work.
virtual void CreateNewWindow(int route_id, HANDLE modal_dialog_event);
- virtual void CreateNewWidget(int route_id);
+ virtual void CreateNewWidget(int route_id,
+ bool focus_on_show);
virtual void ShowCreatedWindow(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc
index 082fb89..3ba7173 100644
--- a/chrome/browser/web_contents_view_win.cc
+++ b/chrome/browser/web_contents_view_win.cc
@@ -378,7 +378,8 @@ WebContents* WebContentsViewWin::CreateNewWindowInternal(
}
RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal(
- int route_id) {
+ int route_id,
+ bool focus_on_show) {
// Create the widget and its associated view.
// TODO(brettw) can widget creation be cross-platform?
RenderWidgetHost* widget_host =
@@ -394,6 +395,7 @@ RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal(
widget_view->set_parent_hwnd(
web_contents_->render_widget_host_view()->GetPluginHWND());
widget_view->set_close_on_deactivate(true);
+ widget_view->set_focus_on_show(focus_on_show);
return widget_view;
}
@@ -438,7 +440,8 @@ void WebContentsViewWin::ShowCreatedWidgetInternal(
widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(),
initial_pos.width(), initial_pos.height(),
TRUE);
- widget_host_view_win->ShowWindow(SW_SHOW);
+ widget_host_view_win->ShowWindow(widget_host_view_win->focus_on_show() ?
+ SW_SHOW : SW_SHOWNOACTIVATE);
widget_host->Init();
}
diff --git a/chrome/browser/web_contents_view_win.h b/chrome/browser/web_contents_view_win.h
index d1ea193..ca03829 100644
--- a/chrome/browser/web_contents_view_win.h
+++ b/chrome/browser/web_contents_view_win.h
@@ -56,7 +56,8 @@ class WebContentsViewWin : public WebContentsView,
// Backend implementation of RenderViewHostDelegate::View.
virtual WebContents* CreateNewWindowInternal(
int route_id, HANDLE modal_dialog_event);
- virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id);
+ virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id,
+ bool focus_on_show);
virtual void ShowCreatedWindowInternal(WebContents* new_web_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index ea97bc7..4e7e3dc 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -462,6 +462,14 @@ IPC_BEGIN_MESSAGES(View, 1)
// into a full window).
IPC_MESSAGE_ROUTED0(ViewMsg_DisassociateFromPopupCount)
+ // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the autofill
+ // suggestions.
+ IPC_MESSAGE_ROUTED4(ViewMsg_AutofillSuggestions,
+ int64 /* id of the text input field */,
+ int /* id of the request message */,
+ std::vector<std::wstring> /* suggestions */,
+ int /* index of default suggestion */)
+
IPC_END_MESSAGES(View)
@@ -483,8 +491,9 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
// Similar to ViewHostMsg_CreateView, except used for sub-widgets, like
// <select> dropdowns. This message is sent to the WebContents that
// contains the widget being created.
- IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_CreateWidget,
+ IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWidget,
int /* opener_id */,
+ bool /* focus on show */,
int /* route_id */)
// These two messages are sent as a result of the above two, in the browser
@@ -493,8 +502,9 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
int /* route_id */,
HANDLE /* modal_dialog_event */)
- IPC_MESSAGE_ROUTED1(ViewHostMsg_CreateWidgetWithRoute,
- int /* route_id */)
+ IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateWidgetWithRoute,
+ int /* route_id */,
+ bool /* focus on show */)
// These two messages are sent to the parent RenderViewHost to display the
// page/widget that was created by CreateView/CreateWidget. routing_id
@@ -1061,4 +1071,11 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
HWND /* window */,
gfx::Rect /* Out: Window location */)
+ // Queries the browser for suggestion for autofill in a form input field.
+ IPC_MESSAGE_ROUTED4(ViewHostMsg_QueryFormFieldAutofill,
+ std::wstring /* field name */,
+ std::wstring /* user entered text */,
+ int64 /* id of the text input field */,
+ int /* id of this message */)
+
IPC_END_MESSAGES(ViewHost)
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 7cebc16..cbae9d0 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -142,7 +142,7 @@ class RenderViewExtraRequestData : public WebRequest::ExtraData {
///////////////////////////////////////////////////////////////////////////////
RenderView::RenderView()
- : RenderWidget(RenderThread::current()),
+ : RenderWidget(RenderThread::current(), true),
is_loading_(false),
page_id_(-1),
last_page_id_sent_to_browser_(-1),
@@ -161,7 +161,8 @@ RenderView::RenderView()
has_unload_listener_(false),
decrement_shared_popup_at_destruction_(false),
greasemonkey_enabled_(false),
- waiting_for_create_window_ack_(false) {
+ waiting_for_create_window_ack_(false),
+ form_field_autofill_request_id_(0) {
resource_dispatcher_ = new ResourceDispatcher(this);
#ifdef CHROME_PERSONALIZATION
personalization_ = Personalization::CreateRendererPersonalization();
@@ -384,6 +385,8 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
OnMessageFromExternalHost)
IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount,
OnDisassociateFromPopupCount)
+ IPC_MESSAGE_HANDLER(ViewMsg_AutofillSuggestions,
+ OnReceivedAutofillSuggestions)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
IPC_END_MESSAGE_MAP()
@@ -1664,6 +1667,29 @@ void RenderView::OnUnloadListenerChanged(WebView* webview, WebFrame* webframe) {
}
}
+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++;
+ Send(new ViewHostMsg_QueryFormFieldAutofill(routing_id_,
+ field_name, text,
+ node_id,
+ form_field_autofill_request_id_));
+}
+
+void RenderView::OnReceivedAutofillSuggestions(
+ int64 node_id,
+ int request_id,
+ const std::vector<std::wstring> suggestions,
+ int default_suggestion_index) {
+ if (!webview() || request_id != form_field_autofill_request_id_)
+ return;
+
+ webview()->AutofillSuggestionsForNode(node_id, suggestions,
+ default_suggestion_index);
+}
+
void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height,
const std::string& json_arguments,
std::string* json_retval) {
@@ -1762,9 +1788,11 @@ WebView* RenderView::CreateWebView(WebView* webview, bool user_gesture) {
return view->webview();
}
-WebWidget* RenderView::CreatePopupWidget(WebView* webview) {
+WebWidget* RenderView::CreatePopupWidget(WebView* webview,
+ bool focus_on_show) {
RenderWidget* widget = RenderWidget::Create(routing_id_,
- RenderThread::current());
+ RenderThread::current(),
+ focus_on_show);
return widget->webwidget();
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index eee08e1..8484afd 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -127,6 +127,9 @@ class RenderView : public RenderWidget, public WebViewDelegate,
virtual bool RunBeforeUnloadConfirm(WebView* webview,
const std::wstring& message);
virtual void OnUnloadListenerChanged(WebView* webview, WebFrame* webframe);
+ virtual void QueryFormFieldAutofill(const std::wstring& field_name,
+ const std::wstring& text,
+ int64 node_id);
virtual void UpdateTargetURL(WebView* webview,
const GURL& url);
virtual void RunFileChooser(const std::wstring& default_filename,
@@ -197,7 +200,8 @@ class RenderView : public RenderWidget, public WebViewDelegate,
bool is_redirect);
virtual WebView* CreateWebView(WebView* webview, bool user_gesture);
- virtual WebWidget* CreatePopupWidget(WebView* webview);
+ virtual WebWidget* CreatePopupWidget(WebView* webview,
+ bool focus_on_show);
virtual WebPluginDelegate* CreatePluginDelegate(
WebView* webview,
const GURL& url,
@@ -457,6 +461,13 @@ class RenderView : public RenderWidget, public WebViewDelegate,
// Notification about ui theme changes.
void OnThemeChanged();
+ // Notification that we have received autofill suggestion.
+ void OnReceivedAutofillSuggestions(
+ int64 node_id,
+ int request_id,
+ const std::vector<std::wstring> suggestions,
+ int default_suggestion_index);
+
#ifdef CHROME_PERSONALIZATION
void OnPersonalizationEvent(std::string event_name, std::string event_args);
#endif
@@ -673,6 +684,10 @@ class RenderView : public RenderWidget, public WebViewDelegate,
// Set if we are waiting for an ack for ViewHostMsg_CreateWindow
bool waiting_for_create_window_ack_;
+ // The id of the last request sent for form field autofill. Used to ignore
+ // out of date responses.
+ int form_field_autofill_request_id_;
+
// A cached WebHistoryItem used for back/forward navigations initiated by
// WebCore (via the window.history.go API). We only have one such navigation
// pending at a time.
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 874768b..c8d3070 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -69,7 +69,8 @@ DeferredCloses* DeferredCloses::current_ = NULL;
///////////////////////////////////////////////////////////////////////////////
-RenderWidget::RenderWidget(RenderThreadBase* render_thread)
+RenderWidget::RenderWidget(RenderThreadBase* render_thread,
+ bool focus_on_show)
: routing_id_(MSG_ROUTING_NONE),
opener_id_(MSG_ROUTING_NONE),
render_thread_(render_thread),
@@ -88,7 +89,8 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread)
ime_control_x_(-1),
ime_control_y_(-1),
ime_control_new_state_(false),
- ime_control_updated_(false) {
+ ime_control_updated_(false),
+ focus_on_show_(focus_on_show) {
RenderProcess::AddRefProcess();
DCHECK(render_thread_);
}
@@ -107,9 +109,11 @@ RenderWidget::~RenderWidget() {
/*static*/
RenderWidget* RenderWidget::Create(int32 opener_id,
- RenderThreadBase* render_thread) {
+ RenderThreadBase* render_thread,
+ bool focus_on_show) {
DCHECK(opener_id != MSG_ROUTING_NONE);
- scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread);
+ scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread,
+ focus_on_show);
widget->Init(opener_id); // adds reference
return widget;
}
@@ -125,7 +129,7 @@ void RenderWidget::Init(int32 opener_id) {
webwidget_.swap(&webwidget);
bool result = render_thread_->Send(
- new ViewHostMsg_CreateWidget(opener_id, &routing_id_));
+ new ViewHostMsg_CreateWidget(opener_id, focus_on_show_, &routing_id_));
if (result) {
render_thread_->AddRoute(routing_id_, this);
// Take a reference on behalf of the RenderThread. This will be balanced
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 98d0377..f597dff 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -30,7 +30,9 @@ class RenderWidget : public IPC::Channel::Listener,
// Creates a new RenderWidget. The opener_id is the routing ID of the
// RenderView that this widget lives inside. The render_thread is any
// RenderThreadBase implementation, mostly commonly RenderThread::current().
- static RenderWidget* Create(int32 opener_id, RenderThreadBase* render_thread);
+ static RenderWidget* Create(int32 opener_id,
+ RenderThreadBase* render_thread,
+ bool focus_on_show);
// The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
// not yet assigned a view ID, in which case, the process MUST NOT send
@@ -86,7 +88,7 @@ class RenderWidget : public IPC::Channel::Listener,
// without ref-counting is an error.
friend class base::RefCounted<RenderWidget>;
- RenderWidget(RenderThreadBase* render_thread);
+ RenderWidget(RenderThreadBase* render_thread, bool focus_on_show);
virtual ~RenderWidget();
// Initializes this view with the given opener. CompleteInit must be called
@@ -261,6 +263,9 @@ class RenderWidget : public IPC::Channel::Listener,
bool ime_control_new_state_;
bool ime_control_updated_;
+ // Whether the window for this RenderWidget should be focused when shown.
+ bool focus_on_show_;
+
// Holds all the needed plugin window moves for a scroll.
std::vector<WebPluginGeometry> plugin_window_moves_;
diff --git a/chrome/renderer/render_widget_unittest.cc b/chrome/renderer/render_widget_unittest.cc
index 086f8bf..f280aa7 100644
--- a/chrome/renderer/render_widget_unittest.cc
+++ b/chrome/renderer/render_widget_unittest.cc
@@ -114,7 +114,9 @@ class MockRenderThread : public RenderThreadBase {
}
// The Widget expects to be returned valid route_id.
- void OnMsgCreateWidget(int opener_id, int* route_id) {
+ void OnMsgCreateWidget(int opener_id,
+ bool focus_on_show,
+ int* route_id) {
opener_id_ = opener_id;
*route_id = routing_id_;
}
@@ -141,7 +143,7 @@ TEST(RenderWidgetTest, CreateAndCloseWidget) {
{
scoped_refptr<RenderWidget> rw =
- RenderWidget::Create(kOpenerId, &render_thread);
+ RenderWidget::Create(kOpenerId, &render_thread, true);
ASSERT_TRUE(rw != NULL);
// After the RenderWidget it must have sent a message to the render thread