OLD | NEW |
---|---|
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 Loading... | |
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 = | |
darin (slow to review)
2012/03/06 17:54:34
looks like you don't need a line break here
| |
1454 NavigationPolicyToDisposition(policy); | |
1462 if (!request.isNull()) | 1455 if (!request.isNull()) |
1463 params.target_url = request.url(); | 1456 params.target_url = request.url(); |
1464 | 1457 |
1465 int32 routing_id = MSG_ROUTING_NONE; | 1458 int32 routing_id = MSG_ROUTING_NONE; |
1466 int32 surface_id = 0; | 1459 int32 surface_id = 0; |
1467 int64 cloned_session_storage_namespace_id; | 1460 int64 cloned_session_storage_namespace_id; |
1468 bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); | |
1469 | 1461 |
1470 RenderThread::Get()->Send( | 1462 RenderThread::Get()->Send( |
1471 new ViewHostMsg_CreateWindow(params, | 1463 new ViewHostMsg_CreateWindow(params, |
1472 &routing_id, | 1464 &routing_id, |
1473 &surface_id, | 1465 &surface_id, |
1474 &cloned_session_storage_namespace_id)); | 1466 &cloned_session_storage_namespace_id)); |
1475 if (routing_id == MSG_ROUTING_NONE) | 1467 if (routing_id == MSG_ROUTING_NONE) |
1476 return NULL; | 1468 return NULL; |
1477 | 1469 |
1478 RenderViewImpl* view = RenderViewImpl::Create( | 1470 RenderViewImpl* view = RenderViewImpl::Create( |
1479 0, | 1471 0, |
1480 routing_id_, | 1472 routing_id_, |
1481 renderer_preferences_, | 1473 renderer_preferences_, |
1482 webkit_preferences_, | 1474 webkit_preferences_, |
1483 shared_popup_counter_, | 1475 shared_popup_counter_, |
1484 routing_id, | 1476 routing_id, |
1485 surface_id, | 1477 surface_id, |
1486 cloned_session_storage_namespace_id, | 1478 cloned_session_storage_namespace_id, |
1487 frame_name, | 1479 frame_name, |
1488 1, | 1480 1, |
1489 screen_info_); | 1481 screen_info_); |
1490 view->opened_by_user_gesture_ = params.user_gesture; | 1482 view->opened_by_user_gesture_ = params.user_gesture; |
1491 | 1483 |
1492 // Record whether the creator frame is trying to suppress the opener field. | 1484 // Record whether the creator frame is trying to suppress the opener field. |
1493 view->opener_suppressed_ = opener_suppressed; | 1485 view->opener_suppressed_ = params.opener_suppressed; |
1494 | 1486 |
1495 // Record the security origin of the creator. | 1487 // Record the security origin of the creator. |
1496 GURL creator_url(creator->document().securityOrigin().toString().utf8()); | 1488 GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
1497 if (!creator_url.is_valid() || !creator_url.IsStandard()) | 1489 if (!creator_url.is_valid() || !creator_url.IsStandard()) |
1498 creator_url = GURL(); | 1490 creator_url = GURL(); |
1499 view->creator_url_ = creator_url; | 1491 view->creator_url_ = creator_url; |
1500 | 1492 |
1501 // Copy over the alternate error page URL so we can have alt error pages in | 1493 // 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). | 1494 // 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_; | 1495 view->alternate_error_page_url_ = alternate_error_page_url_; |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2351 frame->opener() == NULL && | 2343 frame->opener() == NULL && |
2352 // Must be a top-level frame. | 2344 // Must be a top-level frame. |
2353 frame->parent() == NULL && | 2345 frame->parent() == NULL && |
2354 // Must not have issued the request from this page. | 2346 // Must not have issued the request from this page. |
2355 is_content_initiated && | 2347 is_content_initiated && |
2356 // Must be targeted at the current tab. | 2348 // Must be targeted at the current tab. |
2357 default_policy == WebKit::WebNavigationPolicyCurrentTab && | 2349 default_policy == WebKit::WebNavigationPolicyCurrentTab && |
2358 // Must be a JavaScript navigation, which appears as "other". | 2350 // Must be a JavaScript navigation, which appears as "other". |
2359 type == WebKit::WebNavigationTypeOther; | 2351 type == WebKit::WebNavigationTypeOther; |
2360 | 2352 |
2361 // Recognize if this navigation is from a link with rel=noreferrer and | 2353 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. | 2354 // Open the URL via the browser, not via WebKit. |
2389 OpenURL(frame, url, Referrer(), default_policy); | 2355 OpenURL(frame, url, Referrer(), default_policy); |
2390 return WebKit::WebNavigationPolicyIgnore; | 2356 return WebKit::WebNavigationPolicyIgnore; |
2391 } | 2357 } |
2392 | 2358 |
2393 return default_policy; | 2359 return default_policy; |
2394 } | 2360 } |
2395 | 2361 |
2396 bool RenderViewImpl::canHandleRequest( | 2362 bool RenderViewImpl::canHandleRequest( |
2397 WebFrame* frame, const WebURLRequest& request) { | 2363 WebFrame* frame, const WebURLRequest& request) { |
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5146 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5112 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5147 return !!RenderThreadImpl::current()->compositor_thread(); | 5113 return !!RenderThreadImpl::current()->compositor_thread(); |
5148 } | 5114 } |
5149 | 5115 |
5150 void RenderViewImpl::OnJavaBridgeInit() { | 5116 void RenderViewImpl::OnJavaBridgeInit() { |
5151 DCHECK(!java_bridge_dispatcher_.get()); | 5117 DCHECK(!java_bridge_dispatcher_.get()); |
5152 #if defined(ENABLE_JAVA_BRIDGE) | 5118 #if defined(ENABLE_JAVA_BRIDGE) |
5153 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 5119 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
5154 #endif | 5120 #endif |
5155 } | 5121 } |
OLD | NEW |