Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: content/browser/tab_contents/tab_contents_view_helper.cc

Issue 9141035: Move RenderWidgetHost::Init() call up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/tab_contents/tab_contents_view_helper.h" 5 #include "content/browser/tab_contents/tab_contents_view_helper.h"
6 6
7 #include "content/browser/renderer_host/render_view_host.h" 7 #include "content/browser/renderer_host/render_view_host.h"
8 #include "content/browser/renderer_host/render_widget_host.h" 8 #include "content/browser/renderer_host/render_widget_host.h"
9 #include "content/browser/renderer_host/render_widget_host_view.h" 9 #include "content/browser/renderer_host/render_widget_host_view.h"
10 #include "content/browser/tab_contents/tab_contents.h" 10 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Save the created window associated with the route so we can show it later. 76 // Save the created window associated with the route so we can show it later.
77 pending_contents_[route_id] = new_contents; 77 pending_contents_[route_id] = new_contents;
78 78
79 if (web_contents->GetDelegate()) 79 if (web_contents->GetDelegate())
80 web_contents->GetDelegate()->WebContentsCreated(web_contents, 80 web_contents->GetDelegate()->WebContentsCreated(web_contents,
81 params.opener_frame_id, 81 params.opener_frame_id,
82 params.target_url, 82 params.target_url,
83 new_contents); 83 new_contents);
84 84
85 // TODO(brettw): It seems bogus to reach into here and initialize the host.
86 new_contents->GetRenderViewHost()->Init();
85 return new_contents; 87 return new_contents;
86 } 88 }
87 89
88 RenderWidgetHostView* TabContentsViewHelper::CreateNewWidget( 90 RenderWidgetHostView* TabContentsViewHelper::CreateNewWidget(
89 WebContents* web_contents, 91 WebContents* web_contents,
90 int route_id, 92 int route_id,
91 bool is_fullscreen, 93 bool is_fullscreen,
92 WebKit::WebPopupType popup_type) { 94 WebKit::WebPopupType popup_type) {
93 content::RenderProcessHost* process = web_contents->GetRenderProcessHost(); 95 content::RenderProcessHost* process = web_contents->GetRenderProcessHost();
94 RenderWidgetHost* widget_host = new RenderWidgetHost(process, route_id); 96 RenderWidgetHost* widget_host = new RenderWidgetHost(process, route_id);
95 RenderWidgetHostView* widget_view = 97 RenderWidgetHostView* widget_view =
96 RenderWidgetHostView::CreateViewForWidget(widget_host); 98 RenderWidgetHostView::CreateViewForWidget(widget_host);
97 if (!is_fullscreen) { 99 if (!is_fullscreen) {
98 // Popups should not get activated. 100 // Popups should not get activated.
99 widget_view->set_popup_type(popup_type); 101 widget_view->set_popup_type(popup_type);
100 } 102 }
101 // Save the created widget associated with the route so we can show it later. 103 // Save the created widget associated with the route so we can show it later.
102 pending_widget_views_[route_id] = widget_view; 104 pending_widget_views_[route_id] = widget_view;
105
106 // TODO(jamesr): Check if this is bogus. If it's not, remove the
107 // pending_contents_ stuff.
108 widget_host->Init();
103 return widget_view; 109 return widget_view;
104 } 110 }
105 111
106 TabContents* TabContentsViewHelper::GetCreatedWindow(int route_id) { 112 TabContents* TabContentsViewHelper::GetCreatedWindow(int route_id) {
107 PendingContents::iterator iter = pending_contents_.find(route_id); 113 PendingContents::iterator iter = pending_contents_.find(route_id);
108 114
109 // Certain systems can block the creation of new windows. If we didn't succeed 115 // Certain systems can block the creation of new windows. If we didn't succeed
110 // in creating one, just return NULL. 116 // in creating one, just return NULL.
111 if (iter == pending_contents_.end()) { 117 if (iter == pending_contents_.end()) {
112 return NULL; 118 return NULL;
113 } 119 }
114 120
115 TabContents* new_contents = iter->second; 121 TabContents* new_contents = iter->second;
116 pending_contents_.erase(route_id); 122 pending_contents_.erase(route_id);
117 123
118 if (!new_contents->GetRenderProcessHost()->HasConnection() || 124 if (!new_contents->GetRenderProcessHost()->HasConnection() ||
119 !new_contents->GetRenderViewHost()->view()) 125 !new_contents->GetRenderViewHost()->view())
120 return NULL; 126 return NULL;
121 127
122 // TODO(brettw): It seems bogus to reach into here and initialize the host.
123 new_contents->GetRenderViewHost()->Init();
124 return new_contents; 128 return new_contents;
125 } 129 }
126 130
127 RenderWidgetHostView* TabContentsViewHelper::GetCreatedWidget(int route_id) { 131 RenderWidgetHostView* TabContentsViewHelper::GetCreatedWidget(int route_id) {
128 PendingWidgetViews::iterator iter = pending_widget_views_.find(route_id); 132 PendingWidgetViews::iterator iter = pending_widget_views_.find(route_id);
129 if (iter == pending_widget_views_.end()) { 133 if (iter == pending_widget_views_.end()) {
130 DCHECK(false); 134 DCHECK(false);
131 return NULL; 135 return NULL;
132 } 136 }
133 137
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id); 174 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id);
171 if (is_fullscreen) { 175 if (is_fullscreen) {
172 widget_host_view->InitAsFullscreen(web_contents->GetRenderWidgetHostView()); 176 widget_host_view->InitAsFullscreen(web_contents->GetRenderWidgetHostView());
173 } else { 177 } else {
174 widget_host_view->InitAsPopup(web_contents->GetRenderWidgetHostView(), 178 widget_host_view->InitAsPopup(web_contents->GetRenderWidgetHostView(),
175 initial_pos); 179 initial_pos);
176 } 180 }
177 widget_host_view->GetRenderWidgetHost()->Init(); 181 widget_host_view->GetRenderWidgetHost()->Init();
178 return widget_host_view; 182 return widget_host_view;
179 } 183 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698