diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 19:46:28 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 19:46:28 +0000 |
commit | 98b3860142549f66f841c1a073182628a05a823e (patch) | |
tree | f5d8db358c4a7f5d8a58c41b20cb9a0abcd1102f /chrome/browser/tab_contents/web_contents_view.cc | |
parent | e4d8e1c51a06fee5e6c35d47feea83b1c7347dc4 (diff) | |
download | chromium_src-98b3860142549f66f841c1a073182628a05a823e.zip chromium_src-98b3860142549f66f841c1a073182628a05a823e.tar.gz chromium_src-98b3860142549f66f841c1a073182628a05a823e.tar.bz2 |
Refactor some widget creation code in web_contents_view and render_widget_host_view.
This only affects popups. The advantages of this refactoring are to get rid of a TODO and allow some unforking of web_contents_view_*.
Review URL: http://codereview.chromium.org/48103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/web_contents_view.cc')
-rw-r--r-- | chrome/browser/tab_contents/web_contents_view.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/web_contents_view.cc b/chrome/browser/tab_contents/web_contents_view.cc index eee0d98..5ac141f 100644 --- a/chrome/browser/tab_contents/web_contents_view.cc +++ b/chrome/browser/tab_contents/web_contents_view.cc @@ -4,7 +4,15 @@ #include "chrome/browser/tab_contents/web_contents_view.h" +#include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" +#include "chrome/browser/tab_contents/tab_contents_delegate.h" +#include "chrome/browser/tab_contents/web_contents.h" + +WebContentsView::WebContentsView(WebContents* web_contents) + : web_contents_(web_contents) { +} void WebContentsView::RenderWidgetHostDestroyed(RenderWidgetHost* host) { for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); @@ -59,3 +67,30 @@ void WebContentsView::ShowCreatedWidget(int route_id, ShowCreatedWidgetInternal(widget_host_view, initial_pos); } + +RenderWidgetHostView* WebContentsView::CreateNewWidgetInternal( + int route_id, + bool activatable) { + RenderWidgetHost* widget_host = + new RenderWidgetHost(web_contents_->process(), route_id); + RenderWidgetHostView* widget_view = + RenderWidgetHostView::CreateViewForWidget(widget_host); + widget_view->set_activatable(activatable); + + return widget_view; +} + +void WebContentsView::ShowCreatedWidgetInternal( + RenderWidgetHostView* widget_host_view, + const gfx::Rect& initial_pos) { + RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); + if (!widget_host->process()->channel()) { + // The view has gone away or the renderer crashed. Nothing to do. + return; + } + + widget_host_view->InitAsPopup( + web_contents_->render_widget_host_view(), initial_pos); + web_contents_->delegate()->RenderWidgetShowing(); + widget_host->Init(); +} |