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

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

Issue 10868116: Pass result of blockage across content API when new tab blocked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 using content::RenderWidgetHost; 153 using content::RenderWidgetHost;
154 using content::RenderWidgetHostImpl; 154 using content::RenderWidgetHostImpl;
155 using content::RenderWidgetHostView; 155 using content::RenderWidgetHostView;
156 using content::RenderWidgetHostViewPort; 156 using content::RenderWidgetHostViewPort;
157 using content::ResourceDispatcherHostImpl; 157 using content::ResourceDispatcherHostImpl;
158 using content::SSLStatus; 158 using content::SSLStatus;
159 using content::SessionStorageNamespace; 159 using content::SessionStorageNamespace;
160 using content::SiteInstance; 160 using content::SiteInstance;
161 using content::UserMetricsAction; 161 using content::UserMetricsAction;
162 using content::WebContents; 162 using content::WebContents;
163 using content::WebContentsDelegate;
163 using content::WebContentsObserver; 164 using content::WebContentsObserver;
164 using content::WebUI; 165 using content::WebUI;
165 using content::WebUIController; 166 using content::WebUIController;
166 using content::WebUIControllerFactory; 167 using content::WebUIControllerFactory;
167 using webkit_glue::WebPreferences; 168 using webkit_glue::WebPreferences;
168 169
169 namespace { 170 namespace {
170 171
171 // Amount of time we wait between when a key event is received and the renderer 172 // Amount of time we wait between when a key event is received and the renderer
172 // is queried for its state and pushed to the NavigationEntry. 173 // is queried for its state and pushed to the NavigationEntry.
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 // We use our current SiteInstance since the cloned entry will use it anyway. 1023 // We use our current SiteInstance since the cloned entry will use it anyway.
1023 // We pass |this| for the |base_web_contents| to size the view correctly, and 1024 // We pass |this| for the |base_web_contents| to size the view correctly, and
1024 // our own opener so that the cloned page can access it if it was before. 1025 // our own opener so that the cloned page can access it if it was before.
1025 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), 1026 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(),
1026 GetSiteInstance(), MSG_ROUTING_NONE, 1027 GetSiteInstance(), MSG_ROUTING_NONE,
1027 this, opener_); 1028 this, opener_);
1028 tc->GetController().CopyStateFrom(controller_); 1029 tc->GetController().CopyStateFrom(controller_);
1029 return tc; 1030 return tc;
1030 } 1031 }
1031 1032
1032 void WebContentsImpl::AddNewContents(WebContents* new_contents,
1033 WindowOpenDisposition disposition,
1034 const gfx::Rect& initial_pos,
1035 bool user_gesture) {
1036 if (!delegate_)
1037 return;
1038
1039 delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
1040 user_gesture);
1041 }
1042
1043 gfx::NativeView WebContentsImpl::GetContentNativeView() const { 1033 gfx::NativeView WebContentsImpl::GetContentNativeView() const {
1044 return view_->GetContentNativeView(); 1034 return view_->GetContentNativeView();
1045 } 1035 }
1046 1036
1047 gfx::NativeView WebContentsImpl::GetNativeView() const { 1037 gfx::NativeView WebContentsImpl::GetNativeView() const {
1048 return view_->GetNativeView(); 1038 return view_->GetNativeView();
1049 } 1039 }
1050 1040
1051 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { 1041 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const {
1052 view_->GetContainerBounds(out); 1042 view_->GetContainerBounds(out);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 // TODO(brettw): It seems bogus that we have to call this function on the 1258 // TODO(brettw): It seems bogus that we have to call this function on the
1269 // newly created object and give it one of its own member variables. 1259 // newly created object and give it one of its own member variables.
1270 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); 1260 new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
1271 1261
1272 // Save the created window associated with the route so we can show it 1262 // Save the created window associated with the route so we can show it
1273 // later. 1263 // later.
1274 DCHECK_NE(MSG_ROUTING_NONE, route_id); 1264 DCHECK_NE(MSG_ROUTING_NONE, route_id);
1275 pending_contents_[route_id] = new_contents; 1265 pending_contents_[route_id] = new_contents;
1276 } 1266 }
1277 1267
1268 bool not_blocked = true;
1278 if (delegate_) { 1269 if (delegate_) {
1279 delegate_->WebContentsCreated( 1270 not_blocked = delegate_->WebContentsCreated(
1280 this, params.opener_frame_id, params.target_url, new_contents); 1271 this, params.opener_frame_id, params.target_url, new_contents);
1281 } 1272 }
1282 1273
1283 if (params.opener_suppressed) { 1274 if (params.opener_suppressed && not_blocked) {
1284 // When the opener is suppressed, the original renderer cannot access the 1275 // When the opener is suppressed, the original renderer cannot access the
1285 // new window. As a result, we need to show and navigate the window here. 1276 // new window. As a result, we need to show and navigate the window here.
1286 gfx::Rect initial_pos; 1277 if (delegate_) {
1287 // TODO(cdn) Fix popup white-listing for links that open in a new process. 1278 gfx::Rect initial_pos;
1288 AddNewContents( 1279 not_blocked = delegate_->AddNewContents(
jam 2012/09/04 19:50:46 it's confusing to read this block of code, since t
Tom Sepez 2012/09/04 20:46:16 You're right. I think the first call need not ret
1289 new_contents, params.user_gesture ? params.disposition : NEW_POPUP, 1280 this, new_contents, params.disposition, initial_pos,
1290 initial_pos, params.user_gesture); 1281 params.user_gesture);
1291 1282 }
1292 content::OpenURLParams open_params(params.target_url, content::Referrer(), 1283 if (not_blocked) {
1293 CURRENT_TAB, 1284 content::OpenURLParams open_params(params.target_url,
1294 content::PAGE_TRANSITION_LINK, 1285 content::Referrer(),
1295 true /* is_renderer_initiated */); 1286 CURRENT_TAB,
1296 new_contents->OpenURL(open_params); 1287 content::PAGE_TRANSITION_LINK,
1288 true /* is_renderer_initiated */);
1289 new_contents->OpenURL(open_params);
1290 }
1297 } 1291 }
1298 } 1292 }
1299 1293
1300 void WebContentsImpl::CreateNewWidget(int route_id, 1294 void WebContentsImpl::CreateNewWidget(int route_id,
1301 WebKit::WebPopupType popup_type) { 1295 WebKit::WebPopupType popup_type) {
1302 CreateNewWidget(route_id, false, popup_type); 1296 CreateNewWidget(route_id, false, popup_type);
1303 } 1297 }
1304 1298
1305 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { 1299 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) {
1306 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); 1300 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone);
(...skipping 19 matching lines...) Expand all
1326 // to allow it to survive the trip without being hosted. 1320 // to allow it to survive the trip without being hosted.
1327 base::mac::NSObjectRetain(widget_view->GetNativeView()); 1321 base::mac::NSObjectRetain(widget_view->GetNativeView());
1328 #endif 1322 #endif
1329 } 1323 }
1330 1324
1331 void WebContentsImpl::ShowCreatedWindow(int route_id, 1325 void WebContentsImpl::ShowCreatedWindow(int route_id,
1332 WindowOpenDisposition disposition, 1326 WindowOpenDisposition disposition,
1333 const gfx::Rect& initial_pos, 1327 const gfx::Rect& initial_pos,
1334 bool user_gesture) { 1328 bool user_gesture) {
1335 WebContentsImpl* contents = GetCreatedWindow(route_id); 1329 WebContentsImpl* contents = GetCreatedWindow(route_id);
1336 if (contents) 1330 if (contents) {
1337 AddNewContents(contents, disposition, initial_pos, user_gesture); 1331 WebContentsDelegate* delegate = GetDelegate();
1332 if (delegate) {
1333 delegate->AddNewContents(
1334 this, contents, disposition, initial_pos, user_gesture);
1335 }
1336 }
1338 } 1337 }
1339 1338
1340 void WebContentsImpl::ShowCreatedWidget(int route_id, 1339 void WebContentsImpl::ShowCreatedWidget(int route_id,
1341 const gfx::Rect& initial_pos) { 1340 const gfx::Rect& initial_pos) {
1342 ShowCreatedWidget(route_id, false, initial_pos); 1341 ShowCreatedWidget(route_id, false, initial_pos);
1343 } 1342 }
1344 1343
1345 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { 1344 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) {
1346 ShowCreatedWidget(route_id, true, gfx::Rect()); 1345 ShowCreatedWidget(route_id, true, gfx::Rect());
1347 } 1346 }
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 old_browser_plugin_host()->embedder_render_process_host(); 3252 old_browser_plugin_host()->embedder_render_process_host();
3254 *embedder_container_id = old_browser_plugin_host()->instance_id(); 3253 *embedder_container_id = old_browser_plugin_host()->instance_id();
3255 int embedder_process_id = 3254 int embedder_process_id =
3256 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; 3255 embedder_render_process_host ? embedder_render_process_host->GetID() : -1;
3257 if (embedder_process_id != -1) { 3256 if (embedder_process_id != -1) {
3258 *embedder_channel_name = 3257 *embedder_channel_name =
3259 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), 3258 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(),
3260 embedder_process_id); 3259 embedder_process_id);
3261 } 3260 }
3262 } 3261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698