diff options
37 files changed, 152 insertions, 81 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index eb3a334..7e15d48 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -548,13 +548,14 @@ void ExtensionHost::CreateNewWindow(int route_id) { site_instance(), DOMUIFactory::GetDOMUIType(url_), NULL); } -void ExtensionHost::CreateNewWidget(int route_id, bool activatable) { - CreateNewWidgetInternal(route_id, activatable); +void ExtensionHost::CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type) { + CreateNewWidgetInternal(route_id, popup_type); } -RenderWidgetHostView* ExtensionHost::CreateNewWidgetInternal(int route_id, - bool activatable) { - return delegate_view_helper_.CreateNewWidget(route_id, activatable, +RenderWidgetHostView* ExtensionHost::CreateNewWidgetInternal( + int route_id, WebKit::WebPopupType popup_type) { + return delegate_view_helper_.CreateNewWidget(route_id, popup_type, site_instance()->GetProcess()); } diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 4d6ca59..f30593c 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -135,7 +135,7 @@ class ExtensionHost : public RenderViewHostDelegate, // RenderViewHostDelegate::View virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable); + virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, @@ -183,8 +183,9 @@ class ExtensionHost : public RenderViewHostDelegate, // associated with the given route. When the widget needs to be shown later, // we'll look it up again and pass the object to the Show functions rather // than the route ID. - virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, - bool activatable); + virtual RenderWidgetHostView* CreateNewWidgetInternal( + int route_id, + WebKit::WebPopupType popup_type); virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos); private: diff --git a/chrome/browser/extensions/extension_host_mac.h b/chrome/browser/extensions/extension_host_mac.h index 6a97e62..1bdbcfc 100644 --- a/chrome/browser/extensions/extension_host_mac.h +++ b/chrome/browser/extensions/extension_host_mac.h @@ -16,8 +16,9 @@ class ExtensionHostMac : public ExtensionHost { ExtensionHost(extension, site_instance, url, host_type) {} virtual ~ExtensionHostMac(); protected: - virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, - bool activatable); + virtual RenderWidgetHostView* CreateNewWidgetInternal( + int route_id, + WebKit::WebPopupType popup_type); virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos); private: diff --git a/chrome/browser/extensions/extension_host_mac.mm b/chrome/browser/extensions/extension_host_mac.mm index 29d58ca..3239ebd 100644 --- a/chrome/browser/extensions/extension_host_mac.mm +++ b/chrome/browser/extensions/extension_host_mac.mm @@ -22,11 +22,11 @@ ExtensionHostMac::~ExtensionHostMac() { RenderWidgetHostView* ExtensionHostMac::CreateNewWidgetInternal( int route_id, - bool activatable) { + WebKit::WebPopupType popup_type) { // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it // to allow it to survive the trip without being hosed. RenderWidgetHostView* widget_view = - ExtensionHost::CreateNewWidgetInternal(route_id, activatable); + ExtensionHost::CreateNewWidgetInternal(route_id, popup_type); RenderWidgetHostViewMac* widget_view_mac = static_cast<RenderWidgetHostViewMac*>(widget_view); [widget_view_mac->native_view() retain]; diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 8cc397c..5935cf7 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -74,7 +74,7 @@ class BalloonHost : public RenderViewHostDelegate, // RenderViewHostDelegate::View methods. Only the ones for opening new // windows are currently implemented. virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable) {} + virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type) {} virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 3697719..0dfd106 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -860,10 +860,11 @@ void RenderViewHost::CreateNewWindow(int route_id) { view->CreateNewWindow(route_id); } -void RenderViewHost::CreateNewWidget(int route_id, bool activatable) { +void RenderViewHost::CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); if (view) - view->CreateNewWidget(route_id, activatable); + view->CreateNewWidget(route_id, popup_type); } void RenderViewHost::OnMsgShowView(int route_id, diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 48300d9..37b9c46 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -18,6 +18,7 @@ #include "net/base/load_states.h" #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/window_open_disposition.h" @@ -419,8 +420,9 @@ class RenderViewHost : public RenderWidgetHost { // Creates a new RenderView with the given route id. void CreateNewWindow(int route_id); - // Creates a new RenderWidget with the given route id. - void CreateNewWidget(int route_id, bool activatable); + // Creates a new RenderWidget with the given route id. |popup_type| indicates + // if this widget is a popup and what kind of popup it is (select, autofill). + void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); // Sends the response to an extension api call. void SendExtensionResponse(int request_id, bool success, diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index f522a6dc..829ee9e 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -15,6 +15,7 @@ #include "chrome/common/view_types.h" #include "net/base/load_states.h" #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "webkit/glue/window_open_disposition.h" @@ -97,8 +98,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. - // If |activatable| is false, the widget cannot be activated or get focus. - virtual void CreateNewWidget(int route_id, bool activatable) = 0; + // |popup_type| indicates if the widget is a popup and what kind of popup it + // is (select, autofill...). + virtual void CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type) = 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/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index dffc9c5..a6fbd5c 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -232,21 +232,21 @@ void RenderWidgetHelper::OnCreateWindowOnIO(int route_id) { } void RenderWidgetHelper::CreateNewWidget(int opener_id, - bool activatable, + WebKit::WebPopupType popup_type, int* route_id) { *route_id = GetNextRoutingID(); ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableMethod( this, &RenderWidgetHelper::OnCreateWidgetOnUI, opener_id, *route_id, - activatable)); + popup_type)); } void RenderWidgetHelper::OnCreateWidgetOnUI( - int opener_id, int route_id, bool activatable) { + int opener_id, int route_id, WebKit::WebPopupType popup_type) { RenderViewHost* host = RenderViewHost::FromID(render_process_id_, opener_id); if (host) - host->CreateNewWidget(route_id, activatable); + host->CreateNewWidget(route_id, popup_type); } #if defined(OS_MACOSX) diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h index 1fa5973..728bb7c 100644 --- a/chrome/browser/renderer_host/render_widget_helper.h +++ b/chrome/browser/renderer_host/render_widget_helper.h @@ -14,6 +14,7 @@ #include "base/ref_counted.h" #include "base/lock.h" #include "base/waitable_event.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" namespace IPC { class Message; @@ -122,7 +123,9 @@ class RenderWidgetHelper bool user_gesture, base::ProcessHandle render_process, int* route_id); - void CreateNewWidget(int opener_id, bool activatable, int* route_id); + void CreateNewWidget(int opener_id, + WebKit::WebPopupType popup_type, + int* route_id); #if defined(OS_MACOSX) // Called on the IO thread to handle the allocation of a transport DIB @@ -158,7 +161,9 @@ class RenderWidgetHelper void OnCreateWindowOnIO(int route_id); // Called on the UI thread to finish creating a widget. - void OnCreateWidgetOnUI(int opener_id, int route_id, bool activatable); + void OnCreateWidgetOnUI(int opener_id, + int route_id, + WebKit::WebPopupType popup_type); // Called on the IO thread to cancel resource requests for the render widget. void OnCancelResourceRequests(int render_widget_id); diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index 625f098..7b516ed 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -13,6 +13,7 @@ #include "base/shared_memory.h" #include "gfx/native_widget_types.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "webkit/glue/plugins/webplugin.h" namespace gfx { @@ -217,10 +218,10 @@ class RenderWidgetHostView { // constrained window is showing. virtual void SetVisuallyDeemphasized(bool deemphasized) = 0; - void set_activatable(bool activatable) { - activatable_ = activatable; + void set_popup_type(WebKit::WebPopupType popup_type) { + popup_type_ = popup_type; } - bool activatable() const { return activatable_; } + WebKit::WebPopupType popup_type() const { return popup_type_; } // Subclasses should override this method to do whatever is appropriate to set // the custom background for their platform. @@ -235,11 +236,11 @@ class RenderWidgetHostView { protected: // Interface class only, do not construct. - RenderWidgetHostView() : activatable_(true) {} + RenderWidgetHostView() : popup_type_(WebKit::WebPopupTypeNone) {} - // Whether the window can be activated. Autocomplete popup windows for example - // cannot be activated. Default is true. - bool activatable_; + // Whether this view is a popup and what kind of popup it is (select, + // autofill...). + WebKit::WebPopupType popup_type_; // A custom background to paint behind the web content. This will be tiled // horizontally. Can be null, in which case we fall back to painting white. diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 966c643..874fb29 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -121,7 +121,7 @@ class RenderWidgetHostViewGtkWidget { static gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event, RenderWidgetHostViewGtk* host_view) { - if (host_view->parent_ && host_view->activatable() && + if (host_view->parent_ && host_view->IsActivatable() && GDK_Escape == event->keyval) { // Force popups to close on Esc just in case the renderer is hung. This // allows us to release our keyboard grab. @@ -368,7 +368,7 @@ void RenderWidgetHostViewGtk::InitAsPopup( // If we are not activatable, we don't want to grab keyboard input, // and webkit will manage our destruction. - if (activatable()) { + if (IsActivatable()) { // Grab all input for the app. If a click lands outside the bounds of the // popup, WebKit will notice and destroy us. Before doing this we need // to ensure that the the popup is added to the browser's window group, @@ -570,7 +570,7 @@ void RenderWidgetHostViewGtk::Destroy() { // If |parent_| is non-null, we are a popup and we must disconnect from our // parent and destroy the popup window. if (parent_) { - if (activatable()) { + if (IsActivatable()) { GdkDisplay *display = gtk_widget_get_display(parent_); gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); @@ -624,6 +624,12 @@ void RenderWidgetHostViewGtk::AppendInputMethodsContextMenu(MenuGtk* menu) { im_context_->AppendInputMethodsContextMenu(menu); } +bool RenderWidgetHostViewGtk::IsActivatable() { + // Popups should not be activated. + // TODO(estade): fix focus issue with select. + return popup_type_ == WebKit::WebPopupTypeNone; +} + BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( const gfx::Size& size) { if (enable_gpu_rendering_) { diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index de6c480..06f8482 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -91,6 +91,9 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { // submenu. void AppendInputMethodsContextMenu(MenuGtk* menu); + // Returns whether the widget should be activated when shown. + bool IsActivatable(); + private: friend class RenderWidgetHostViewGtkWidget; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 6908baa..741af9b 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -152,8 +152,9 @@ RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { void RenderWidgetHostViewMac::InitAsPopup( RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { + bool activatable = popup_type_ != WebKit::WebPopupTypeNone; [cocoa_view_ setCloseOnDeactivate:YES]; - [cocoa_view_ setCanBeKeyView:activatable_ ? YES : NO]; + [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; [parent_host_view->GetNativeView() addSubview:cocoa_view_]; NSPoint global_origin = NSPointFromCGPoint(pos.origin().ToCGPoint()); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index d70b674..975609e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -316,7 +316,8 @@ void RenderWidgetHostViewWin::InitAsPopup( close_on_deactivate_ = true; Create(parent_hwnd_, NULL, NULL, WS_POPUP, WS_EX_TOOLWINDOW); MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); - ShowWindow(activatable_ ? SW_SHOW : SW_SHOWNA); + // Popups are not activated. + ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); } RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { @@ -498,6 +499,11 @@ HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) { return parent; } +bool RenderWidgetHostViewWin::IsActivatable() const { + // Popups should not be activated. + return popup_type_ == WebKit::WebPopupTypeNone; +} + void RenderWidgetHostViewWin::Focus() { if (IsWindow()) SetFocus(); @@ -1427,7 +1433,7 @@ LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM, BOOL& handled) { - if (!activatable_) + if (!IsActivatable()) return MA_NOACTIVATE; HWND focus_window = GetFocus(); @@ -1591,7 +1597,7 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, break; } - if (activatable_ && event.type == WebInputEvent::MouseDown) { + if (IsActivatable() && event.type == WebInputEvent::MouseDown) { // This is a temporary workaround for bug 765011 to get focus when the // mouse is clicked. This happens after the mouse down event is sent to // the renderer because normally Windows does a WM_SETFOCUS after diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index c140d14..09686ad 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -229,6 +229,9 @@ class RenderWidgetHostViewWin // Create an intermediate window between the given HWND and its parent. HWND ReparentWindow(HWND window); + // Whether the window should be activated. + bool IsActivatable() const; + // The associated Model. RenderWidgetHost* render_widget_host_; diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 0657913..951ed86 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -606,9 +606,9 @@ void ResourceMessageFilter::OnMsgCreateWindow( } void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, - bool activatable, + WebKit::WebPopupType popup_type, int* route_id) { - render_widget_helper_->CreateNewWidget(opener_id, activatable, route_id); + render_widget_helper_->CreateNewWidget(opener_id, popup_type, route_id); } void ResourceMessageFilter::OnSetCookie(const IPC::Message& message, diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 20be786..c673c7c 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -31,6 +31,7 @@ #include "gfx/rect.h" #include "ipc/ipc_channel_proxy.h" #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" class AppCacheDispatcherHost; class AudioRendererHost; @@ -133,7 +134,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnMsgCreateWindow(int opener_id, bool user_gesture, int64 session_storage_namespace_id, int* route_id, int64* cloned_session_storage_namespace_id); - void OnMsgCreateWidget(int opener_id, bool activatable, int* route_id); + void OnMsgCreateWidget(int opener_id, + WebKit::WebPopupType popup_type, + int* route_id); void OnSetCookie(const IPC::Message& message, const GURL& url, const GURL& first_party_for_cookies, diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 31fa713..14eb26b 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -87,7 +87,8 @@ class InterstitialPage::InterstitialPageRVHViewDelegate // RenderViewHostDelegate::View implementation: virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable); + virtual void CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type); virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, @@ -561,7 +562,7 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWindow( } void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget( - int route_id, bool activatable) { + int route_id, WebKit::WebPopupType popup_type) { NOTREACHED() << "InterstitialPage does not support showing drop-downs yet."; } diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 2385069..977674d 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -47,12 +47,13 @@ TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( } RenderWidgetHostView* RenderViewHostDelegateViewHelper::CreateNewWidget( - int route_id, bool activatable, RenderProcessHost* process) { + int route_id, WebKit::WebPopupType popup_type, RenderProcessHost* process) { RenderWidgetHost* widget_host = new RenderWidgetHost(process, route_id); RenderWidgetHostView* widget_view = RenderWidgetHostView::CreateViewForWidget(widget_host); - widget_view->set_activatable(activatable); + // Popups should not get activated. + widget_view->set_popup_type(popup_type); // Save the created widget associated with the route so we can show it later. pending_widget_views_[route_id] = widget_view; return widget_view; diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.h b/chrome/browser/tab_contents/render_view_host_delegate_helper.h index 8248c0f..42052b9 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.h +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.h @@ -11,6 +11,7 @@ #include "base/waitable_event.h" #include "chrome/browser/dom_ui/dom_ui_factory.h" #include "gfx/rect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/window_open_disposition.h" @@ -35,7 +36,8 @@ class RenderViewHostDelegateViewHelper { SiteInstance* site, DOMUITypeID domui_type, TabContents* old_tab_contents); - virtual RenderWidgetHostView* CreateNewWidget(int route_id, bool activatable, + virtual RenderWidgetHostView* CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type, RenderProcessHost* process); virtual TabContents* GetCreatedWindow(int route_id); virtual RenderWidgetHostView* GetCreatedWidget(int route_id); diff --git a/chrome/browser/tab_contents/tab_contents_view.cc b/chrome/browser/tab_contents/tab_contents_view.cc index fc5455e..bce9a50 100644 --- a/chrome/browser/tab_contents/tab_contents_view.cc +++ b/chrome/browser/tab_contents/tab_contents_view.cc @@ -39,8 +39,9 @@ void TabContentsView::CreateNewWindow(int route_id) { tab_contents_->delegate()->TabContentsCreated(new_contents); } -void TabContentsView::CreateNewWidget(int route_id, bool activatable) { - CreateNewWidgetInternal(route_id, activatable); +void TabContentsView::CreateNewWidget(int route_id, + WebKit::WebPopupType popup_type) { + CreateNewWidgetInternal(route_id, popup_type); } void TabContentsView::ShowCreatedWindow(int route_id, @@ -74,8 +75,8 @@ void TabContentsView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { } RenderWidgetHostView* TabContentsView::CreateNewWidgetInternal( - int route_id, bool activatable) { - return delegate_view_helper_.CreateNewWidget(route_id, activatable, + int route_id, WebKit::WebPopupType popup_type) { + return delegate_view_helper_.CreateNewWidget(route_id, popup_type, tab_contents()->render_view_host()->process()); } diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index 9d2c712..48c1558 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -166,8 +166,9 @@ class TabContentsView : public RenderViewHostDelegate::View { // associated with the given route. When the widget needs to be shown later, // we'll look it up again and pass the object to the Show functions rather // than the route ID. - virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, - bool activatable); + virtual RenderWidgetHostView* CreateNewWidgetInternal( + int route_id, + WebKit::WebPopupType popup_type); virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos); @@ -179,7 +180,7 @@ class TabContentsView : 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); - virtual void CreateNewWidget(int route_id, bool activatable); + virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.h b/chrome/browser/tab_contents/tab_contents_view_mac.h index e195cbc..38853ac 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.h +++ b/chrome/browser/tab_contents/tab_contents_view_mac.h @@ -67,8 +67,9 @@ class TabContentsViewMac : public TabContentsView, virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); - virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, - bool activatable); + virtual RenderWidgetHostView* CreateNewWidgetInternal( + int route_id, + WebKit::WebPopupType popup_type); virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos); virtual bool IsEventTracking() const; diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 731425f..23cfdf6 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -247,11 +247,11 @@ void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { RenderWidgetHostView* TabContentsViewMac::CreateNewWidgetInternal( int route_id, - bool activatable) { + WebKit::WebPopupType popup_type) { // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it // to allow it to survive the trip without being hosted. RenderWidgetHostView* widget_view = - TabContentsView::CreateNewWidgetInternal(route_id, activatable); + TabContentsView::CreateNewWidgetInternal(route_id, popup_type); RenderWidgetHostViewMac* widget_view_mac = static_cast<RenderWidgetHostViewMac*>(widget_view); [widget_view_mac->native_view() retain]; diff --git a/chrome/browser/views/app_launcher.h b/chrome/browser/views/app_launcher.h index c98d435..e9d084d 100644 --- a/chrome/browser/views/app_launcher.h +++ b/chrome/browser/views/app_launcher.h @@ -92,7 +92,7 @@ class AppLauncher : public InfoBubbleDelegate, // RenderViewHostDelegate::View overrides. virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable) {} + virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type) {} virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 68d69d0..eb84df0 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -953,7 +953,7 @@ IPC_BEGIN_MESSAGES(ViewHost) // contains the widget being created. IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWidget, int /* opener_id */, - bool /* focus on show */, + WebKit::WebPopupType /* popup type */, int /* route_id */) // These two messages are sent to the parent RenderViewHost to display the diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h index 5dfd90d..270c2f7 100644 --- a/chrome/common/webkit_param_traits.h +++ b/chrome/common/webkit_param_traits.h @@ -32,6 +32,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" @@ -136,6 +137,24 @@ struct ParamTraits<WebKit::WebConsoleMessage::Level> { }; template <> +struct ParamTraits<WebKit::WebPopupType> { + typedef WebKit::WebPopupType param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p)); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int value; + if (!ReadParam(m, iter, &value)) + return false; + *r = static_cast<param_type>(value); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + LogParam(static_cast<int>(p), l); + } +}; + +template <> struct ParamTraits<WebKit::WebFindOptions> { typedef WebKit::WebFindOptions param_type; static void Write(Message* m, const param_type& p) { diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index cda4fef..49d59c7 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -107,7 +107,7 @@ void MockRenderThread::OnMessageReceived(const IPC::Message& msg) { // The Widget expects to be returned valid route_id. void MockRenderThread::OnMsgCreateWidget(int opener_id, - bool activatable, + WebKit::WebPopupType popup_type, int* route_id) { opener_id_ = opener_id; *route_id = routing_id_; diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index 03fe08f..635174b 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -11,6 +11,7 @@ #include "chrome/common/ipc_test_sink.h" #include "chrome/renderer/mock_printer.h" #include "chrome/renderer/render_thread.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" struct ViewMsg_Print_Params; struct ViewMsg_PrintPages_Params; @@ -78,7 +79,7 @@ class MockRenderThread : public RenderThreadBase { // The Widget expects to be returned valid route_id. void OnMsgCreateWidget(int opener_id, - bool activatable, + WebKit::WebPopupType popup_type, int* route_id); // The callee expects to be returned a valid channel_id. diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 1a1e882..5545780 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -310,7 +310,7 @@ struct RenderView::PendingFileChooser { RenderView::RenderView(RenderThreadBase* render_thread, const WebPreferences& webkit_preferences, int64 session_storage_namespace_id) - : RenderWidget(render_thread, true), + : RenderWidget(render_thread, WebKit::WebPopupTypeNone), enabled_bindings_(0), target_url_status_(TARGET_NONE), is_loading_(false), @@ -1556,17 +1556,17 @@ WebView* RenderView::createView(WebFrame* creator) { return view->webview(); } -WebWidget* RenderView::createPopupMenu(bool activatable) { +WebWidget* RenderView::createPopupMenu(WebKit::WebPopupType popup_type) { RenderWidget* widget = RenderWidget::Create(routing_id_, render_thread_, - activatable); + popup_type); return widget->webwidget(); } WebWidget* RenderView::createPopupMenu(const WebPopupMenuInfo& info) { RenderWidget* widget = RenderWidget::Create(routing_id_, render_thread_, - true); + WebKit::WebPopupTypeSelect); widget->ConfigureAsExternalPopupMenu(info); return widget->webwidget(); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index cd42daf..97cc7ea 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -201,7 +201,7 @@ class RenderView : public RenderWidget, // WebKit::WebViewClient virtual WebKit::WebView* createView(WebKit::WebFrame* creator); - virtual WebKit::WebWidget* createPopupMenu(bool activatable); + virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); virtual WebKit::WebWidget* createPopupMenu( const WebKit::WebPopupMenuInfo& info); virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(); diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 50af08f..77ec85f 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -45,7 +45,8 @@ using WebKit::WebScreenInfo; using WebKit::WebSize; using WebKit::WebTextDirection; -RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) +RenderWidget::RenderWidget(RenderThreadBase* render_thread, + WebKit::WebPopupType popup_type) : routing_id_(MSG_ROUTING_NONE), webwidget_(NULL), opener_id_(MSG_ROUTING_NONE), @@ -67,7 +68,7 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) ime_control_new_state_(false), ime_control_updated_(false), ime_control_busy_(false), - activatable_(activatable), + popup_type_(popup_type), pending_window_rect_count_(0), suppress_next_char_events_(false) { RenderProcess::current()->AddRefProcess(); @@ -86,10 +87,10 @@ RenderWidget::~RenderWidget() { /*static*/ RenderWidget* RenderWidget::Create(int32 opener_id, RenderThreadBase* render_thread, - bool activatable) { + WebKit::WebPopupType popup_type) { DCHECK(opener_id != MSG_ROUTING_NONE); scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, - activatable); + popup_type); widget->Init(opener_id); // adds reference return widget; } @@ -112,7 +113,7 @@ void RenderWidget::Init(int32 opener_id) { webwidget_ = WebPopupMenu::create(this); bool result = render_thread_->Send( - new ViewHostMsg_CreateWidget(opener_id, activatable_, &routing_id_)); + new ViewHostMsg_CreateWidget(opener_id, popup_type_, &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 4781790..2fdc1e5 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -20,6 +20,7 @@ #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/WebKit/chromium/public/WebCompositionCommand.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" #include "third_party/WebKit/WebKit/chromium/public/WebWidgetClient.h" @@ -48,7 +49,7 @@ class RenderWidget : public IPC::Channel::Listener, // RenderThreadBase implementation, mostly commonly RenderThread::current(). static RenderWidget* Create(int32 opener_id, RenderThreadBase* render_thread, - bool activatable); + WebKit::WebPopupType popup_type); // Called after Create to configure a RenderWidget to be rendered by the host // as a popup menu with the given data. @@ -110,7 +111,8 @@ class RenderWidget : public IPC::Channel::Listener, // without ref-counting is an error. friend class base::RefCounted<RenderWidget>; - RenderWidget(RenderThreadBase* render_thread, bool activatable); + RenderWidget(RenderThreadBase* render_thread, + WebKit::WebPopupType popup_type); virtual ~RenderWidget(); // Initializes this view with the given opener. CompleteInit must be called @@ -298,8 +300,8 @@ class RenderWidget : public IPC::Channel::Listener, bool ime_control_updated_; bool ime_control_busy_; - // Whether the window for this RenderWidget can be activated. - bool activatable_; + // The kind of popup this widget represents, NONE if not a popup. + WebKit::WebPopupType popup_type_; // Holds all the needed plugin window moves for a scroll. typedef std::vector<webkit_glue::WebPluginGeometry> WebPluginGeometryVector; diff --git a/chrome/renderer/render_widget_unittest.cc b/chrome/renderer/render_widget_unittest.cc index 5808bc0..e1b5ac0 100644 --- a/chrome/renderer/render_widget_unittest.cc +++ b/chrome/renderer/render_widget_unittest.cc @@ -9,6 +9,7 @@ #include "chrome/renderer/mock_render_thread.h" #include "chrome/renderer/render_widget.h" #include "chrome/renderer/render_thread.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" namespace { @@ -30,7 +31,8 @@ class RenderWidgetTest : public testing::Test { virtual void SetUp() { mock_process_.reset(new MockRenderProcess); render_thread_.set_routing_id(kRouteId); - widget_ = RenderWidget::Create(kOpenerId, &render_thread_, true); + widget_ = RenderWidget::Create(kOpenerId, &render_thread_, + WebKit::WebPopupTypeNone); ASSERT_TRUE(widget_); } virtual void TearDown() { diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index e3600cd..7083247 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -85,6 +85,7 @@ using WebKit::WebPlugin; using WebKit::WebPluginParams; using WebKit::WebPoint; using WebKit::WebPopupMenu; +using WebKit::WebPopupType; using WebKit::WebRange; using WebKit::WebRect; using WebKit::WebScreenInfo; @@ -300,9 +301,9 @@ WebView* TestWebViewDelegate::createView(WebFrame* creator) { return shell_->CreateWebView(); } -WebWidget* TestWebViewDelegate::createPopupMenu( - bool activatable) { - // TODO(darin): Should we honor activatable? +WebWidget* TestWebViewDelegate::createPopupMenu(WebPopupType popup_type) { + // TODO(darin): Should we take into account |popup_type| (for activation + // purpose)? return shell_->CreatePopupWidget(); } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index cfdabe0..ad42917b 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -32,6 +32,7 @@ #if defined(OS_MACOSX) #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenuInfo.h" #endif +#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/plugins/webplugin_page_delegate.h" @@ -74,7 +75,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient, // WebKit::WebViewClient virtual WebKit::WebView* createView(WebKit::WebFrame* creator); - virtual WebKit::WebWidget* createPopupMenu(bool activatable); + virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); virtual WebKit::WebWidget* createPopupMenu( const WebKit::WebPopupMenuInfo& info); virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(); |