Commit 83918ec0 authored by rosca@adobe.com's avatar rosca@adobe.com

Allow embedders to provide a custom view for popup (select box) widgets,

the same way they have the ability to provide a custom view for page widgets.
All the widget views are created using WebContentsView, which can be
overriden by embedders with ContentBrowserClient::OverrideCreateWebContentsView
Contributed by rosca@adobe.com

BUG=155761

Review URL: https://chromiumcodereview.appspot.com/11773042

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176092 0039d316-1c4b-4281-b951-d872f2087c98
parent 716290b0
...@@ -217,3 +217,4 @@ Martin Bednorz <m.s.bednorz@gmail.com> ...@@ -217,3 +217,4 @@ Martin Bednorz <m.s.bednorz@gmail.com>
Kamil Jiwa <kamil.jiwa@gmail.com> Kamil Jiwa <kamil.jiwa@gmail.com>
Keene Pan <keenepan@linpus.com> Keene Pan <keenepan@linpus.com>
Trevor Perrin <unsafe@trevp.net> Trevor Perrin <unsafe@trevp.net>
Ion Rosca <rosca@adobe.com>
...@@ -1390,8 +1390,10 @@ void WebContentsImpl::CreateNewWidget(int route_id, ...@@ -1390,8 +1390,10 @@ void WebContentsImpl::CreateNewWidget(int route_id,
new RenderWidgetHostImpl(this, process, route_id); new RenderWidgetHostImpl(this, process, route_id);
created_widgets_.insert(widget_host); created_widgets_.insert(widget_host);
RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort::FromRWHV(
RenderWidgetHostViewPort::CreateViewForWidget(widget_host); view_->CreateViewForPopupWidget(widget_host));
if (!widget_view)
return;
if (!is_fullscreen) { if (!is_fullscreen) {
// Popups should not get activated. // Popups should not get activated.
widget_view->SetPopupType(popup_type); widget_view->SetPopupType(popup_type);
......
...@@ -80,6 +80,11 @@ RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget( ...@@ -80,6 +80,11 @@ RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewAndroid::GetNativeView() const { gfx::NativeView WebContentsViewAndroid::GetNativeView() const {
return content_view_core_; return content_view_core_;
} }
......
...@@ -34,6 +34,8 @@ class WebContentsViewAndroid : public WebContentsView, ...@@ -34,6 +34,8 @@ class WebContentsViewAndroid : public WebContentsView,
const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -680,6 +680,11 @@ RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget( ...@@ -680,6 +680,11 @@ RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewAura::GetNativeView() const { gfx::NativeView WebContentsViewAura::GetNativeView() const {
return window_.get(); return window_.get();
} }
......
...@@ -82,6 +82,8 @@ class CONTENT_EXPORT WebContentsViewAura ...@@ -82,6 +82,8 @@ class CONTENT_EXPORT WebContentsViewAura
const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -149,6 +149,11 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( ...@@ -149,6 +149,11 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewGtk::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewGtk::GetNativeView() const { gfx::NativeView WebContentsViewGtk::GetNativeView() const {
if (delegate_.get()) if (delegate_.get())
return delegate_->GetNativeView(); return delegate_->GetNativeView();
......
...@@ -49,6 +49,8 @@ class CONTENT_EXPORT WebContentsViewGtk ...@@ -49,6 +49,8 @@ class CONTENT_EXPORT WebContentsViewGtk
const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -56,6 +56,11 @@ RenderWidgetHostView* WebContentsViewGuest::CreateViewForWidget( ...@@ -56,6 +56,11 @@ RenderWidgetHostView* WebContentsViewGuest::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewGuest::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewGuest::GetNativeView() const { gfx::NativeView WebContentsViewGuest::GetNativeView() const {
return NULL; return NULL;
} }
......
...@@ -40,6 +40,8 @@ class CONTENT_EXPORT WebContentsViewGuest ...@@ -40,6 +40,8 @@ class CONTENT_EXPORT WebContentsViewGuest
gfx::NativeView context) OVERRIDE; gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -68,6 +68,8 @@ class WebContentsViewMac : public WebContentsView, ...@@ -68,6 +68,8 @@ class WebContentsViewMac : public WebContentsView,
const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -142,6 +142,11 @@ RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget( ...@@ -142,6 +142,11 @@ RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewMac::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewMac::GetNativeView() const { gfx::NativeView WebContentsViewMac::GetNativeView() const {
return cocoa_view_.get(); return cocoa_view_.get();
} }
......
...@@ -139,6 +139,11 @@ RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget( ...@@ -139,6 +139,11 @@ RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget(
return view; return view;
} }
RenderWidgetHostView* WebContentsViewWin::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
gfx::NativeView WebContentsViewWin::GetNativeView() const { gfx::NativeView WebContentsViewWin::GetNativeView() const {
return hwnd(); return hwnd();
} }
......
...@@ -57,6 +57,8 @@ class CONTENT_EXPORT WebContentsViewWin ...@@ -57,6 +57,8 @@ class CONTENT_EXPORT WebContentsViewWin
const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
...@@ -38,6 +38,10 @@ class CONTENT_EXPORT WebContentsView { ...@@ -38,6 +38,10 @@ class CONTENT_EXPORT WebContentsView {
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) = 0; RenderWidgetHost* render_widget_host) = 0;
// Creates a new View that holds a popup and receives messages for it.
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) = 0;
// Returns the native widget that contains the contents of the tab. // Returns the native widget that contains the contents of the tab.
virtual gfx::NativeView GetNativeView() const = 0; virtual gfx::NativeView GetNativeView() const = 0;
......
...@@ -51,6 +51,11 @@ RenderWidgetHostView* TestWebContentsView::CreateViewForWidget( ...@@ -51,6 +51,11 @@ RenderWidgetHostView* TestWebContentsView::CreateViewForWidget(
return NULL; return NULL;
} }
RenderWidgetHostView* TestWebContentsView::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return NULL;
}
gfx::NativeView TestWebContentsView::GetNativeView() const { gfx::NativeView TestWebContentsView::GetNativeView() const {
return gfx::NativeView(); return gfx::NativeView();
} }
......
...@@ -41,6 +41,8 @@ class TestWebContentsView : public WebContentsView, ...@@ -41,6 +41,8 @@ class TestWebContentsView : public WebContentsView,
gfx::NativeView context) OVERRIDE; gfx::NativeView context) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget( virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) OVERRIDE; RenderWidgetHost* render_widget_host) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment