diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-07 21:35:03 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-07 21:35:03 +0000 |
commit | 0ebf38756f3a68b30fe0d8e9336dbfafda52b5d5 (patch) | |
tree | a9ce0236b330fab3f39124c52fa0c1f184eb3965 /chrome/browser | |
parent | 5e91242859811aef980a929253e6c33eb2cfec6e (diff) | |
download | chromium_src-0ebf38756f3a68b30fe0d8e9336dbfafda52b5d5.zip chromium_src-0ebf38756f3a68b30fe0d8e9336dbfafda52b5d5.tar.gz chromium_src-0ebf38756f3a68b30fe0d8e9336dbfafda52b5d5.tar.bz2 |
Landing this again as I cannot reproduce the perf regression locally.
Will investigate on the bot.
TBR=nsylvain
Review URL: http://codereview.chromium.org/9700
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/render_view_host.cc | 44 | ||||
-rw-r--r-- | chrome/browser/render_view_host.h | 7 | ||||
-rw-r--r-- | chrome/browser/render_view_host_delegate.h | 5 | ||||
-rw-r--r-- | chrome/browser/render_widget_helper.cc | 6 | ||||
-rw-r--r-- | chrome/browser/render_widget_helper.h | 2 | ||||
-rw-r--r-- | chrome/browser/render_widget_host_view_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/render_widget_host_view_win.h | 8 | ||||
-rw-r--r-- | chrome/browser/resource_message_filter.cc | 6 | ||||
-rw-r--r-- | chrome/browser/resource_message_filter.h | 2 | ||||
-rw-r--r-- | chrome/browser/web_contents_view.cc | 6 | ||||
-rw-r--r-- | chrome/browser/web_contents_view.h | 6 | ||||
-rw-r--r-- | chrome/browser/web_contents_view_win.cc | 7 | ||||
-rw-r--r-- | chrome/browser/web_contents_view_win.h | 3 |
13 files changed, 86 insertions, 19 deletions
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 6c127a7..71c9574 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -696,6 +696,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() @@ -725,10 +727,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, @@ -1226,6 +1229,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 the debugger is attached, we're going to be unresponsive anytime it's // stopped at a breakpoint. diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index ae0a729..6c9fede 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -399,7 +399,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, @@ -498,7 +498,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 27910d7..4230438 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 ece55bc..3c86595 100644 --- a/chrome/browser/render_widget_host_view_win.cc +++ b/chrome/browser/render_widget_host_view_win.cc @@ -77,7 +77,8 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) 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 ff609f3..d1b7730 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); @@ -260,6 +265,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, |