diff options
Diffstat (limited to 'chrome/browser/render_view_host.cc')
-rw-r--r-- | chrome/browser/render_view_host.cc | 44 |
1 files changed, 42 insertions, 2 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( |