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

Side by Side Diff: content/browser/web_contents/web_contents_view_helper.cc

Issue 10038026: TabContents -> WebContentsImpl, part 12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: *web*contents Created 8 years, 8 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
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/web_contents/web_contents_view_helper.h" 5 #include "content/browser/web_contents/web_contents_view_helper.h"
6 6
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
10 #include "content/port/browser/render_widget_host_view_port.h" 10 #include "content/port/browser/render_widget_host_view_port.h"
(...skipping 28 matching lines...) Expand all
39 RenderWidgetHost* host = content::Source<RenderWidgetHost>(source).ptr(); 39 RenderWidgetHost* host = content::Source<RenderWidgetHost>(source).ptr();
40 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); 40 for (PendingWidgetViews::iterator i = pending_widget_views_.begin();
41 i != pending_widget_views_.end(); ++i) { 41 i != pending_widget_views_.end(); ++i) {
42 if (host->GetView() == i->second) { 42 if (host->GetView() == i->second) {
43 pending_widget_views_.erase(i); 43 pending_widget_views_.erase(i);
44 break; 44 break;
45 } 45 }
46 } 46 }
47 } 47 }
48 48
49 TabContents* WebContentsViewHelper::CreateNewWindow( 49 WebContentsImpl* WebContentsViewHelper::CreateNewWindow(
50 WebContents* web_contents, 50 WebContents* web_contents,
51 int route_id, 51 int route_id,
52 const ViewHostMsg_CreateWindow_Params& params) { 52 const ViewHostMsg_CreateWindow_Params& params) {
53 bool should_create = true; 53 bool should_create = true;
54 if (web_contents->GetDelegate()) { 54 if (web_contents->GetDelegate()) {
55 should_create = web_contents->GetDelegate()->ShouldCreateWebContents( 55 should_create = web_contents->GetDelegate()->ShouldCreateWebContents(
56 web_contents, 56 web_contents,
57 route_id, 57 route_id,
58 params.window_container_type, 58 params.window_container_type,
59 params.frame_name, 59 params.frame_name,
60 params.target_url); 60 params.target_url);
61 } 61 }
62 62
63 if (!should_create) 63 if (!should_create)
64 return NULL; 64 return NULL;
65 65
66 // We usually create the new window in the same BrowsingInstance (group of 66 // We usually create the new window in the same BrowsingInstance (group of
67 // script-related windows), by passing in the current SiteInstance. However, 67 // script-related windows), by passing in the current SiteInstance. However,
68 // if the opener is being suppressed, we create a new SiteInstance in its own 68 // if the opener is being suppressed, we create a new SiteInstance in its own
69 // BrowsingInstance. 69 // BrowsingInstance.
70 scoped_refptr<content::SiteInstance> site_instance = 70 scoped_refptr<content::SiteInstance> site_instance =
71 params.opener_suppressed ? 71 params.opener_suppressed ?
72 content::SiteInstance::Create(web_contents->GetBrowserContext()) : 72 content::SiteInstance::Create(web_contents->GetBrowserContext()) :
73 web_contents->GetSiteInstance(); 73 web_contents->GetSiteInstance();
74 74
75 // Create the new web contents. This will automatically create the new 75 // Create the new web contents. This will automatically create the new
76 // WebContentsView. In the future, we may want to create the view separately. 76 // WebContentsView. In the future, we may want to create the view separately.
77 TabContents* new_contents = 77 WebContentsImpl* new_contents =
78 new TabContents(web_contents->GetBrowserContext(), 78 new WebContentsImpl(web_contents->GetBrowserContext(),
79 site_instance, 79 site_instance,
80 route_id, 80 route_id,
81 static_cast<TabContents*>(web_contents), 81 static_cast<WebContentsImpl*>(web_contents),
82 NULL); 82 NULL);
83 new_contents->set_opener_web_ui_type( 83 new_contents->set_opener_web_ui_type(
84 web_contents->GetWebUITypeForCurrentState()); 84 web_contents->GetWebUITypeForCurrentState());
85 new_contents->set_has_opener(!params.opener_url.is_empty()); 85 new_contents->set_has_opener(!params.opener_url.is_empty());
86 86
87 if (!params.opener_suppressed) { 87 if (!params.opener_suppressed) {
88 content::WebContentsView* new_view = new_contents->GetView(); 88 content::WebContentsView* new_view = new_contents->GetView();
89 89
90 // TODO(brettw): It seems bogus that we have to call this function on the 90 // TODO(brettw): It seems bogus that we have to call this function on the
91 // newly created object and give it one of its own member variables. 91 // newly created object and give it one of its own member variables.
92 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); 92 new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 RenderWidgetHostViewPort::CreateViewForWidget(widget_host); 134 RenderWidgetHostViewPort::CreateViewForWidget(widget_host);
135 if (!is_fullscreen) { 135 if (!is_fullscreen) {
136 // Popups should not get activated. 136 // Popups should not get activated.
137 widget_view->SetPopupType(popup_type); 137 widget_view->SetPopupType(popup_type);
138 } 138 }
139 // Save the created widget associated with the route so we can show it later. 139 // Save the created widget associated with the route so we can show it later.
140 pending_widget_views_[route_id] = widget_view; 140 pending_widget_views_[route_id] = widget_view;
141 return widget_view; 141 return widget_view;
142 } 142 }
143 143
144 TabContents* WebContentsViewHelper::GetCreatedWindow(int route_id) { 144 WebContentsImpl* WebContentsViewHelper::GetCreatedWindow(int route_id) {
145 PendingContents::iterator iter = pending_contents_.find(route_id); 145 PendingContents::iterator iter = pending_contents_.find(route_id);
146 146
147 // Certain systems can block the creation of new windows. If we didn't succeed 147 // Certain systems can block the creation of new windows. If we didn't succeed
148 // in creating one, just return NULL. 148 // in creating one, just return NULL.
149 if (iter == pending_contents_.end()) { 149 if (iter == pending_contents_.end()) {
150 return NULL; 150 return NULL;
151 } 151 }
152 152
153 TabContents* new_contents = iter->second; 153 WebContentsImpl* new_contents = iter->second;
154 pending_contents_.erase(route_id); 154 pending_contents_.erase(route_id);
155 155
156 if (!new_contents->GetRenderProcessHost()->HasConnection() || 156 if (!new_contents->GetRenderProcessHost()->HasConnection() ||
157 !new_contents->GetRenderViewHost()->GetView()) 157 !new_contents->GetRenderViewHost()->GetView())
158 return NULL; 158 return NULL;
159 159
160 // TODO(brettw): It seems bogus to reach into here and initialize the host. 160 // TODO(brettw): It seems bogus to reach into here and initialize the host.
161 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); 161 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init();
162 return new_contents; 162 return new_contents;
163 } 163 }
(...skipping 10 matching lines...) Expand all
174 174
175 RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); 175 RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost();
176 if (!widget_host->GetProcess()->HasConnection()) { 176 if (!widget_host->GetProcess()->HasConnection()) {
177 // The view has gone away or the renderer crashed. Nothing to do. 177 // The view has gone away or the renderer crashed. Nothing to do.
178 return NULL; 178 return NULL;
179 } 179 }
180 180
181 return widget_host_view; 181 return widget_host_view;
182 } 182 }
183 183
184 TabContents* WebContentsViewHelper::ShowCreatedWindow( 184 WebContentsImpl* WebContentsViewHelper::ShowCreatedWindow(
185 WebContents* web_contents, 185 WebContents* web_contents,
186 int route_id, 186 int route_id,
187 WindowOpenDisposition disposition, 187 WindowOpenDisposition disposition,
188 const gfx::Rect& initial_pos, 188 const gfx::Rect& initial_pos,
189 bool user_gesture) { 189 bool user_gesture) {
190 TabContents* contents = GetCreatedWindow(route_id); 190 WebContentsImpl* contents = GetCreatedWindow(route_id);
191 if (contents) { 191 if (contents) {
192 web_contents->AddNewContents(contents, 192 web_contents->AddNewContents(contents,
193 disposition, 193 disposition,
194 initial_pos, 194 initial_pos,
195 user_gesture); 195 user_gesture);
196 } 196 }
197 return contents; 197 return contents;
198 } 198 }
199 199
200 RenderWidgetHostView* WebContentsViewHelper::ShowCreatedWidget( 200 RenderWidgetHostView* WebContentsViewHelper::ShowCreatedWidget(
201 WebContents* web_contents, 201 WebContents* web_contents,
202 int route_id, 202 int route_id,
203 bool is_fullscreen, 203 bool is_fullscreen,
204 const gfx::Rect& initial_pos) { 204 const gfx::Rect& initial_pos) {
205 if (web_contents->GetDelegate()) 205 if (web_contents->GetDelegate())
206 web_contents->GetDelegate()->RenderWidgetShowing(); 206 web_contents->GetDelegate()->RenderWidgetShowing();
207 207
208 RenderWidgetHostViewPort* widget_host_view = 208 RenderWidgetHostViewPort* widget_host_view =
209 RenderWidgetHostViewPort::FromRWHV(GetCreatedWidget(route_id)); 209 RenderWidgetHostViewPort::FromRWHV(GetCreatedWidget(route_id));
210 if (is_fullscreen) { 210 if (is_fullscreen) {
211 widget_host_view->InitAsFullscreen(web_contents->GetRenderWidgetHostView()); 211 widget_host_view->InitAsFullscreen(web_contents->GetRenderWidgetHostView());
212 } else { 212 } else {
213 widget_host_view->InitAsPopup(web_contents->GetRenderWidgetHostView(), 213 widget_host_view->InitAsPopup(web_contents->GetRenderWidgetHostView(),
214 initial_pos); 214 initial_pos);
215 } 215 }
216 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost())->Init(); 216 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost())->Init();
217 return widget_host_view; 217 return widget_host_view;
218 } 218 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_helper.h ('k') | content/browser/web_contents/web_contents_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698