Chromium Code Reviews| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 void RenderViewImpl::ShowCreatedFullscreenWidget( | 1359 void RenderViewImpl::ShowCreatedFullscreenWidget( |
| 1360 RenderWidget* fullscreen_widget, | 1360 RenderWidget* fullscreen_widget, |
| 1361 WebNavigationPolicy policy, | 1361 WebNavigationPolicy policy, |
| 1362 const gfx::Rect& initial_rect) { | 1362 const gfx::Rect& initial_rect) { |
| 1363 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), | 1363 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), |
| 1364 fullscreen_widget->routing_id())); | 1364 fullscreen_widget->routing_id())); |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 void RenderViewImpl::ShowCreatedViewWidget(bool opened_by_user_gesture, | |
| 1368 RenderWidget* render_view_to_show, | |
| 1369 WebNavigationPolicy policy, | |
| 1370 const gfx::Rect& initial_rect) { | |
| 1371 // |render_view_to_show| represents a pending view opened (e.g. a popup opened | |
| 1372 // via window.open()) by this object, but not yet shown (it's offscreen, and | |
| 1373 // still owned by the opener). Sending |ViewHostMsg_ShowView| will move it off | |
| 1374 // the opener's pending list, into e.g. its own tab or window. | |
| 1375 Send(new ViewHostMsg_ShowView(GetRoutingID(), | |
| 1376 render_view_to_show->routing_id(), | |
| 1377 NavigationPolicyToDisposition(policy), | |
| 1378 initial_rect, opened_by_user_gesture)); | |
| 1379 } | |
| 1380 | |
| 1381 void RenderViewImpl::SendFrameStateUpdates() { | 1367 void RenderViewImpl::SendFrameStateUpdates() { |
| 1382 // We only use this path in OOPIF-enabled modes. | 1368 // We only use this path in OOPIF-enabled modes. |
| 1383 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | 1369 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 1384 | 1370 |
| 1385 // Tell each frame with pending state to send its UpdateState message. | 1371 // Tell each frame with pending state to send its UpdateState message. |
| 1386 for (int render_frame_routing_id : frames_with_pending_state_) { | 1372 for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1387 RenderFrameImpl* frame = | 1373 RenderFrameImpl* frame = |
| 1388 RenderFrameImpl::FromRoutingID(render_frame_routing_id); | 1374 RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1389 if (frame) | 1375 if (frame) |
| 1390 frame->SendUpdateState(); | 1376 frame->SendUpdateState(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1408 } | 1394 } |
| 1409 | 1395 |
| 1410 // blink::WebViewClient ------------------------------------------------------ | 1396 // blink::WebViewClient ------------------------------------------------------ |
| 1411 | 1397 |
| 1412 WebView* RenderViewImpl::createView(WebLocalFrame* creator, | 1398 WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
| 1413 const WebURLRequest& request, | 1399 const WebURLRequest& request, |
| 1414 const WebWindowFeatures& features, | 1400 const WebWindowFeatures& features, |
| 1415 const WebString& frame_name, | 1401 const WebString& frame_name, |
| 1416 WebNavigationPolicy policy, | 1402 WebNavigationPolicy policy, |
| 1417 bool suppress_opener) { | 1403 bool suppress_opener) { |
| 1404 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | |
| 1418 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); | 1405 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
| 1419 params->opener_id = GetRoutingID(); | 1406 params->opener_render_frame_id = creator_frame->GetRoutingID(); |
| 1420 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 1407 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
| 1421 if (GetContentClient()->renderer()->AllowPopup()) | 1408 if (GetContentClient()->renderer()->AllowPopup()) |
| 1422 params->user_gesture = true; | 1409 params->user_gesture = true; |
| 1423 params->window_container_type = WindowFeaturesToContainerType(features); | 1410 params->window_container_type = WindowFeaturesToContainerType(features); |
| 1424 params->session_storage_namespace_id = session_storage_namespace_id_; | 1411 params->session_storage_namespace_id = session_storage_namespace_id_; |
| 1425 if (frame_name != "_blank") | 1412 if (frame_name != "_blank") |
| 1426 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); | 1413 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); |
| 1427 params->opener_render_frame_id = | |
| 1428 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); | |
| 1429 params->opener_url = creator->document().url(); | 1414 params->opener_url = creator->document().url(); |
| 1430 | 1415 |
| 1431 // The browser process uses the top frame's URL for a content settings check | 1416 // The browser process uses the top frame's URL for a content settings check |
| 1432 // to determine whether the popup is allowed. If the top frame is remote, | 1417 // to determine whether the popup is allowed. If the top frame is remote, |
| 1433 // its URL is not available, so use its replicated origin instead. | 1418 // its URL is not available, so use its replicated origin instead. |
| 1434 // | 1419 // |
| 1435 // TODO(alexmos): This works fine for regular origins but may break path | 1420 // TODO(alexmos): This works fine for regular origins but may break path |
| 1436 // matching for file URLs with OOP subframes that open popups. This should | 1421 // matching for file URLs with OOP subframes that open popups. This should |
| 1437 // be fixed by either moving this lookup to the browser process or removing | 1422 // be fixed by either moving this lookup to the browser process or removing |
| 1438 // path-based matching for file URLs from content settings. See | 1423 // path-based matching for file URLs from content settings. See |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1480 ResizeParams initial_size = ResizeParams(); | 1465 ResizeParams initial_size = ResizeParams(); |
| 1481 initial_size.screen_info = screen_info_; | 1466 initial_size.screen_info = screen_info_; |
| 1482 | 1467 |
| 1483 // The initial hidden state for the RenderViewImpl here has to match what the | 1468 // The initial hidden state for the RenderViewImpl here has to match what the |
| 1484 // browser will eventually decide for the given disposition. Since we have to | 1469 // browser will eventually decide for the given disposition. Since we have to |
| 1485 // return from this call synchronously, we just have to make our best guess | 1470 // return from this call synchronously, we just have to make our best guess |
| 1486 // and rely on the browser sending a WasHidden / WasShown message if it | 1471 // and rely on the browser sending a WasHidden / WasShown message if it |
| 1487 // disagrees. | 1472 // disagrees. |
| 1488 mojom::CreateViewParams view_params; | 1473 mojom::CreateViewParams view_params; |
| 1489 | 1474 |
| 1490 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | |
| 1491 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | 1475 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
| 1492 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); | 1476 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
| 1493 | 1477 |
| 1494 view_params.window_was_created_with_opener = true; | 1478 view_params.window_was_created_with_opener = true; |
| 1495 view_params.renderer_preferences = renderer_preferences_; | 1479 view_params.renderer_preferences = renderer_preferences_; |
| 1496 view_params.web_preferences = webkit_preferences_; | 1480 view_params.web_preferences = webkit_preferences_; |
| 1497 view_params.view_id = reply->route_id; | 1481 view_params.view_id = reply->route_id; |
| 1498 view_params.main_frame_routing_id = reply->main_frame_route_id; | 1482 view_params.main_frame_routing_id = reply->main_frame_route_id; |
| 1499 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; | 1483 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
| 1500 view_params.session_storage_namespace_id = | 1484 view_params.session_storage_namespace_id = |
| 1501 reply->cloned_session_storage_namespace_id; | 1485 reply->cloned_session_storage_namespace_id; |
| 1502 view_params.swapped_out = false; | 1486 view_params.swapped_out = false; |
| 1503 // WebCore will take care of setting the correct name. | 1487 // WebCore will take care of setting the correct name. |
| 1504 view_params.replicated_frame_state = FrameReplicationState(); | 1488 view_params.replicated_frame_state = FrameReplicationState(); |
| 1505 view_params.hidden = is_background_tab; | 1489 view_params.hidden = is_background_tab; |
| 1506 view_params.never_visible = never_visible; | 1490 view_params.never_visible = never_visible; |
| 1507 view_params.initial_size = initial_size; | 1491 view_params.initial_size = initial_size; |
| 1508 view_params.enable_auto_resize = false; | 1492 view_params.enable_auto_resize = false; |
| 1509 view_params.min_size = gfx::Size(); | 1493 view_params.min_size = gfx::Size(); |
| 1510 view_params.max_size = gfx::Size(); | 1494 view_params.max_size = gfx::Size(); |
| 1511 view_params.page_zoom_level = page_zoom_level_; | 1495 view_params.page_zoom_level = page_zoom_level_; |
| 1512 | 1496 |
| 1497 // Unretained() is safe here because our calling function will also call | |
| 1498 // show(). | |
|
alexmos
2016/12/13 18:41:41
Ack. Earlier in the CL I was thinking whether we
ncarter (slow)
2016/12/15 00:33:17
SYN/ACK. I actually spent a lot of time worrying a
| |
| 1513 RenderWidget::ShowCallback show_callback = | 1499 RenderWidget::ShowCallback show_callback = |
| 1514 base::Bind(&RenderViewImpl::ShowCreatedViewWidget, this->AsWeakPtr(), | 1500 base::Bind(&RenderFrameImpl::ShowCreatedWindow, |
| 1515 opened_by_user_gesture); | 1501 base::Unretained(creator_frame), opened_by_user_gesture); |
| 1516 | 1502 |
| 1517 RenderViewImpl* view = | 1503 RenderViewImpl* view = |
| 1518 RenderViewImpl::Create(compositor_deps_, view_params, show_callback); | 1504 RenderViewImpl::Create(compositor_deps_, view_params, show_callback); |
| 1519 | 1505 |
| 1520 return view->webview(); | 1506 return view->webview(); |
| 1521 } | 1507 } |
| 1522 | 1508 |
| 1523 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1509 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
| 1524 RenderWidget* widget = RenderWidget::CreateForPopup(this, compositor_deps_, | 1510 RenderWidget* widget = RenderWidget::CreateForPopup(this, compositor_deps_, |
| 1525 popup_type, screen_info_); | 1511 popup_type, screen_info_); |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2815 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2801 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2816 } | 2802 } |
| 2817 | 2803 |
| 2818 std::unique_ptr<InputEventAck> ack( | 2804 std::unique_ptr<InputEventAck> ack( |
| 2819 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, | 2805 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, |
| 2820 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2806 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 2821 OnInputEventAck(std::move(ack)); | 2807 OnInputEventAck(std::move(ack)); |
| 2822 } | 2808 } |
| 2823 | 2809 |
| 2824 } // namespace content | 2810 } // namespace content |
| OLD | NEW |