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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 9325082: Create window in a new BrowsingInstance when opening a link in a new process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix line break Created 8 years, 9 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 | « content/renderer/render_view_impl.h ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | 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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 // that would defer resource loads for the dialog itself. 1422 // that would defer resource loads for the dialog itself.
1423 if (RenderThreadImpl::current()) // Will be NULL during unit tests. 1423 if (RenderThreadImpl::current()) // Will be NULL during unit tests.
1424 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); 1424 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop();
1425 1425
1426 message->EnableMessagePumping(); // Runs a nested message loop. 1426 message->EnableMessagePumping(); // Runs a nested message loop.
1427 return Send(message); 1427 return Send(message);
1428 } 1428 }
1429 1429
1430 // WebKit::WebViewClient ------------------------------------------------------ 1430 // WebKit::WebViewClient ------------------------------------------------------
1431 1431
1432 // TODO(creis): New contract for createView temporarily redirects to the old
1433 // contract. Remove the old one as part of http://crbug.com/69267.
1434 WebView* RenderViewImpl::createView( 1432 WebView* RenderViewImpl::createView(
1435 WebFrame* creator, 1433 WebFrame* creator,
1436 const WebURLRequest& request, 1434 const WebURLRequest& request,
1437 const WebWindowFeatures& features, 1435 const WebWindowFeatures& features,
1438 const WebString& frame_name, 1436 const WebString& frame_name,
1439 WebNavigationPolicy policy) { 1437 WebNavigationPolicy policy) {
1440 return createView(creator, request, features, frame_name);
1441 }
1442
1443 WebView* RenderViewImpl::createView(
1444 WebFrame* creator,
1445 const WebURLRequest& request,
1446 const WebWindowFeatures& features,
1447 const WebString& frame_name) {
1448 // Check to make sure we aren't overloading on popups. 1438 // Check to make sure we aren't overloading on popups.
1449 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) 1439 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)
1450 return NULL; 1440 return NULL;
1451 1441
1452 ViewHostMsg_CreateWindow_Params params; 1442 ViewHostMsg_CreateWindow_Params params;
1453 params.opener_id = routing_id_; 1443 params.opener_id = routing_id_;
1454 params.user_gesture = creator->isProcessingUserGesture(); 1444 params.user_gesture = creator->isProcessingUserGesture();
1455 params.window_container_type = WindowFeaturesToContainerType(features); 1445 params.window_container_type = WindowFeaturesToContainerType(features);
1456 params.session_storage_namespace_id = session_storage_namespace_id_; 1446 params.session_storage_namespace_id = session_storage_namespace_id_;
1457 params.frame_name = frame_name; 1447 params.frame_name = frame_name;
1458 params.opener_frame_id = creator->identifier(); 1448 params.opener_frame_id = creator->identifier();
1459 params.opener_url = creator->document().url(); 1449 params.opener_url = creator->document().url();
1460 params.opener_security_origin = 1450 params.opener_security_origin =
1461 creator->document().securityOrigin().toString().utf8(); 1451 creator->document().securityOrigin().toString().utf8();
1452 params.opener_suppressed = creator->willSuppressOpenerInNewFrame();
1453 params.disposition = NavigationPolicyToDisposition(policy);
1462 if (!request.isNull()) 1454 if (!request.isNull())
1463 params.target_url = request.url(); 1455 params.target_url = request.url();
1464 1456
1465 int32 routing_id = MSG_ROUTING_NONE; 1457 int32 routing_id = MSG_ROUTING_NONE;
1466 int32 surface_id = 0; 1458 int32 surface_id = 0;
1467 int64 cloned_session_storage_namespace_id; 1459 int64 cloned_session_storage_namespace_id;
1468 bool opener_suppressed = creator->willSuppressOpenerInNewFrame();
1469 1460
1470 RenderThread::Get()->Send( 1461 RenderThread::Get()->Send(
1471 new ViewHostMsg_CreateWindow(params, 1462 new ViewHostMsg_CreateWindow(params,
1472 &routing_id, 1463 &routing_id,
1473 &surface_id, 1464 &surface_id,
1474 &cloned_session_storage_namespace_id)); 1465 &cloned_session_storage_namespace_id));
1475 if (routing_id == MSG_ROUTING_NONE) 1466 if (routing_id == MSG_ROUTING_NONE)
1476 return NULL; 1467 return NULL;
1477 1468
1478 RenderViewImpl* view = RenderViewImpl::Create( 1469 RenderViewImpl* view = RenderViewImpl::Create(
1479 0, 1470 0,
1480 routing_id_, 1471 routing_id_,
1481 renderer_preferences_, 1472 renderer_preferences_,
1482 webkit_preferences_, 1473 webkit_preferences_,
1483 shared_popup_counter_, 1474 shared_popup_counter_,
1484 routing_id, 1475 routing_id,
1485 surface_id, 1476 surface_id,
1486 cloned_session_storage_namespace_id, 1477 cloned_session_storage_namespace_id,
1487 frame_name, 1478 frame_name,
1488 1, 1479 1,
1489 screen_info_); 1480 screen_info_);
1490 view->opened_by_user_gesture_ = params.user_gesture; 1481 view->opened_by_user_gesture_ = params.user_gesture;
1491 1482
1492 // Record whether the creator frame is trying to suppress the opener field. 1483 // Record whether the creator frame is trying to suppress the opener field.
1493 view->opener_suppressed_ = opener_suppressed; 1484 view->opener_suppressed_ = params.opener_suppressed;
1494 1485
1495 // Record the security origin of the creator. 1486 // Record the security origin of the creator.
1496 GURL creator_url(creator->document().securityOrigin().toString().utf8()); 1487 GURL creator_url(creator->document().securityOrigin().toString().utf8());
1497 if (!creator_url.is_valid() || !creator_url.IsStandard()) 1488 if (!creator_url.is_valid() || !creator_url.IsStandard())
1498 creator_url = GURL(); 1489 creator_url = GURL();
1499 view->creator_url_ = creator_url; 1490 view->creator_url_ = creator_url;
1500 1491
1501 // Copy over the alternate error page URL so we can have alt error pages in 1492 // Copy over the alternate error page URL so we can have alt error pages in
1502 // the new render view (we don't need the browser to send the URL back down). 1493 // the new render view (we don't need the browser to send the URL back down).
1503 view->alternate_error_page_url_ = alternate_error_page_url_; 1494 view->alternate_error_page_url_ = alternate_error_page_url_;
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 frame->opener() == NULL && 2342 frame->opener() == NULL &&
2352 // Must be a top-level frame. 2343 // Must be a top-level frame.
2353 frame->parent() == NULL && 2344 frame->parent() == NULL &&
2354 // Must not have issued the request from this page. 2345 // Must not have issued the request from this page.
2355 is_content_initiated && 2346 is_content_initiated &&
2356 // Must be targeted at the current tab. 2347 // Must be targeted at the current tab.
2357 default_policy == WebKit::WebNavigationPolicyCurrentTab && 2348 default_policy == WebKit::WebNavigationPolicyCurrentTab &&
2358 // Must be a JavaScript navigation, which appears as "other". 2349 // Must be a JavaScript navigation, which appears as "other".
2359 type == WebKit::WebNavigationTypeOther; 2350 type == WebKit::WebNavigationTypeOther;
2360 2351
2361 // Recognize if this navigation is from a link with rel=noreferrer and 2352 if (is_fork) {
2362 // target=_blank attributes, in which case the opener will be suppressed. If
2363 // so, it is safe to load cross-site pages in a separate process, so we
2364 // should let the browser handle it.
2365 bool is_noreferrer_and_blank_target =
2366 // Frame should be top level and not yet navigated.
2367 frame->parent() == NULL &&
2368 frame->document().url().isEmpty() &&
2369 historyBackListCount() < 1 &&
2370 historyForwardListCount() < 1 &&
2371 // Links with rel=noreferrer will have no Referer field, and their
2372 // resulting frame will have its window.opener suppressed.
2373 // TODO(creis): should add a request.httpReferrer() method to help avoid
2374 // typos on the unusual spelling of Referer.
2375 request.httpHeaderField(WebString::fromUTF8("Referer")).isNull() &&
2376 opener_suppressed_ &&
2377 frame->opener() == NULL &&
2378 // Links with target=_blank will have no name.
2379 frame->name().isNull() &&
2380 // Another frame (with a non-empty creator) should have initiated the
2381 // request, targeted at this frame.
2382 !creator_url_.is_empty() &&
2383 is_content_initiated &&
2384 default_policy == WebKit::WebNavigationPolicyCurrentTab &&
2385 type == WebKit::WebNavigationTypeOther;
2386
2387 if (is_fork || is_noreferrer_and_blank_target) {
2388 // Open the URL via the browser, not via WebKit. 2353 // Open the URL via the browser, not via WebKit.
2389 OpenURL(frame, url, Referrer(), default_policy); 2354 OpenURL(frame, url, Referrer(), default_policy);
2390 return WebKit::WebNavigationPolicyIgnore; 2355 return WebKit::WebNavigationPolicyIgnore;
2391 } 2356 }
2392 2357
2393 return default_policy; 2358 return default_policy;
2394 } 2359 }
2395 2360
2396 bool RenderViewImpl::canHandleRequest( 2361 bool RenderViewImpl::canHandleRequest(
2397 WebFrame* frame, const WebURLRequest& request) { 2362 WebFrame* frame, const WebURLRequest& request) {
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5146 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5111 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5147 return !!RenderThreadImpl::current()->compositor_thread(); 5112 return !!RenderThreadImpl::current()->compositor_thread();
5148 } 5113 }
5149 5114
5150 void RenderViewImpl::OnJavaBridgeInit() { 5115 void RenderViewImpl::OnJavaBridgeInit() {
5151 DCHECK(!java_bridge_dispatcher_.get()); 5116 DCHECK(!java_bridge_dispatcher_.get());
5152 #if defined(ENABLE_JAVA_BRIDGE) 5117 #if defined(ENABLE_JAVA_BRIDGE)
5153 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5118 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5154 #endif 5119 #endif
5155 } 5120 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698