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

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

Issue 2506183002: Make window.open() IPCs be frame-based (Closed)
Patch Set: Rebase. Created 3 years, 11 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.cc » ('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 <memory> 9 #include <memory>
10 10
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 } 1363 }
1364 1364
1365 void RenderViewImpl::ShowCreatedFullscreenWidget( 1365 void RenderViewImpl::ShowCreatedFullscreenWidget(
1366 RenderWidget* fullscreen_widget, 1366 RenderWidget* fullscreen_widget,
1367 WebNavigationPolicy policy, 1367 WebNavigationPolicy policy,
1368 const gfx::Rect& initial_rect) { 1368 const gfx::Rect& initial_rect) {
1369 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), 1369 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(),
1370 fullscreen_widget->routing_id())); 1370 fullscreen_widget->routing_id()));
1371 } 1371 }
1372 1372
1373 void RenderViewImpl::ShowCreatedViewWidget(bool opened_by_user_gesture,
1374 RenderWidget* render_view_to_show,
1375 WebNavigationPolicy policy,
1376 const gfx::Rect& initial_rect) {
1377 // |render_view_to_show| represents a pending view opened (e.g. a popup opened
1378 // via window.open()) by this object, but not yet shown (it's offscreen, and
1379 // still owned by the opener). Sending |ViewHostMsg_ShowView| will move it off
1380 // the opener's pending list, into e.g. its own tab or window.
1381 Send(new ViewHostMsg_ShowView(GetRoutingID(),
1382 render_view_to_show->routing_id(),
1383 NavigationPolicyToDisposition(policy),
1384 initial_rect, opened_by_user_gesture));
1385 }
1386
1387 void RenderViewImpl::SendFrameStateUpdates() { 1373 void RenderViewImpl::SendFrameStateUpdates() {
1388 // We only use this path in OOPIF-enabled modes. 1374 // We only use this path in OOPIF-enabled modes.
1389 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); 1375 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
1390 1376
1391 // Tell each frame with pending state to send its UpdateState message. 1377 // Tell each frame with pending state to send its UpdateState message.
1392 for (int render_frame_routing_id : frames_with_pending_state_) { 1378 for (int render_frame_routing_id : frames_with_pending_state_) {
1393 RenderFrameImpl* frame = 1379 RenderFrameImpl* frame =
1394 RenderFrameImpl::FromRoutingID(render_frame_routing_id); 1380 RenderFrameImpl::FromRoutingID(render_frame_routing_id);
1395 if (frame) 1381 if (frame)
1396 frame->SendUpdateState(); 1382 frame->SendUpdateState();
(...skipping 17 matching lines...) Expand all
1414 } 1400 }
1415 1401
1416 // blink::WebViewClient ------------------------------------------------------ 1402 // blink::WebViewClient ------------------------------------------------------
1417 1403
1418 WebView* RenderViewImpl::createView(WebLocalFrame* creator, 1404 WebView* RenderViewImpl::createView(WebLocalFrame* creator,
1419 const WebURLRequest& request, 1405 const WebURLRequest& request,
1420 const WebWindowFeatures& features, 1406 const WebWindowFeatures& features,
1421 const WebString& frame_name, 1407 const WebString& frame_name,
1422 WebNavigationPolicy policy, 1408 WebNavigationPolicy policy,
1423 bool suppress_opener) { 1409 bool suppress_opener) {
1410 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator);
1424 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); 1411 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New();
1425 params->opener_id = GetRoutingID(); 1412 params->opener_render_frame_id = creator_frame->GetRoutingID();
1426 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 1413 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
1427 if (GetContentClient()->renderer()->AllowPopup()) 1414 if (GetContentClient()->renderer()->AllowPopup())
1428 params->user_gesture = true; 1415 params->user_gesture = true;
1429 params->window_container_type = WindowFeaturesToContainerType(features); 1416 params->window_container_type = WindowFeaturesToContainerType(features);
1430 params->session_storage_namespace_id = session_storage_namespace_id_; 1417 params->session_storage_namespace_id = session_storage_namespace_id_;
1431 if (frame_name != "_blank") 1418 if (frame_name != "_blank")
1432 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); 1419 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name));
1433 params->opener_render_frame_id =
1434 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID();
1435 params->opener_url = creator->document().url(); 1420 params->opener_url = creator->document().url();
1436 1421
1437 // The browser process uses the top frame's URL for a content settings check 1422 // The browser process uses the top frame's URL for a content settings check
1438 // to determine whether the popup is allowed. If the top frame is remote, 1423 // to determine whether the popup is allowed. If the top frame is remote,
1439 // its URL is not available, so use its replicated origin instead. 1424 // its URL is not available, so use its replicated origin instead.
1440 // 1425 //
1441 // TODO(alexmos): This works fine for regular origins but may break path 1426 // TODO(alexmos): This works fine for regular origins but may break path
1442 // matching for file URLs with OOP subframes that open popups. This should 1427 // matching for file URLs with OOP subframes that open popups. This should
1443 // be fixed by either moving this lookup to the browser process or removing 1428 // be fixed by either moving this lookup to the browser process or removing
1444 // path-based matching for file URLs from content settings. See 1429 // path-based matching for file URLs from content settings. See
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 ResizeParams initial_size = ResizeParams(); 1471 ResizeParams initial_size = ResizeParams();
1487 initial_size.screen_info = screen_info_; 1472 initial_size.screen_info = screen_info_;
1488 1473
1489 // The initial hidden state for the RenderViewImpl here has to match what the 1474 // The initial hidden state for the RenderViewImpl here has to match what the
1490 // browser will eventually decide for the given disposition. Since we have to 1475 // browser will eventually decide for the given disposition. Since we have to
1491 // return from this call synchronously, we just have to make our best guess 1476 // return from this call synchronously, we just have to make our best guess
1492 // and rely on the browser sending a WasHidden / WasShown message if it 1477 // and rely on the browser sending a WasHidden / WasShown message if it
1493 // disagrees. 1478 // disagrees.
1494 mojom::CreateViewParams view_params; 1479 mojom::CreateViewParams view_params;
1495 1480
1496 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator);
1497 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); 1481 view_params.opener_frame_route_id = creator_frame->GetRoutingID();
1498 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); 1482 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID());
1499 1483
1500 view_params.window_was_created_with_opener = true; 1484 view_params.window_was_created_with_opener = true;
1501 view_params.renderer_preferences = renderer_preferences_; 1485 view_params.renderer_preferences = renderer_preferences_;
1502 view_params.web_preferences = webkit_preferences_; 1486 view_params.web_preferences = webkit_preferences_;
1503 view_params.view_id = reply->route_id; 1487 view_params.view_id = reply->route_id;
1504 view_params.main_frame_routing_id = reply->main_frame_route_id; 1488 view_params.main_frame_routing_id = reply->main_frame_route_id;
1505 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; 1489 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id;
1506 view_params.session_storage_namespace_id = 1490 view_params.session_storage_namespace_id =
1507 reply->cloned_session_storage_namespace_id; 1491 reply->cloned_session_storage_namespace_id;
1508 view_params.swapped_out = false; 1492 view_params.swapped_out = false;
1509 // WebCore will take care of setting the correct name. 1493 // WebCore will take care of setting the correct name.
1510 view_params.replicated_frame_state = FrameReplicationState(); 1494 view_params.replicated_frame_state = FrameReplicationState();
1511 view_params.hidden = is_background_tab; 1495 view_params.hidden = is_background_tab;
1512 view_params.never_visible = never_visible; 1496 view_params.never_visible = never_visible;
1513 view_params.initial_size = initial_size; 1497 view_params.initial_size = initial_size;
1514 view_params.enable_auto_resize = false; 1498 view_params.enable_auto_resize = false;
1515 view_params.min_size = gfx::Size(); 1499 view_params.min_size = gfx::Size();
1516 view_params.max_size = gfx::Size(); 1500 view_params.max_size = gfx::Size();
1517 view_params.page_zoom_level = page_zoom_level_; 1501 view_params.page_zoom_level = page_zoom_level_;
1518 1502
1503 // Unretained() is safe here because our calling function will also call
1504 // show().
1519 RenderWidget::ShowCallback show_callback = 1505 RenderWidget::ShowCallback show_callback =
1520 base::Bind(&RenderViewImpl::ShowCreatedViewWidget, this->AsWeakPtr(), 1506 base::Bind(&RenderFrameImpl::ShowCreatedWindow,
1521 opened_by_user_gesture); 1507 base::Unretained(creator_frame), opened_by_user_gesture);
1522 1508
1523 RenderViewImpl* view = 1509 RenderViewImpl* view =
1524 RenderViewImpl::Create(compositor_deps_, view_params, show_callback); 1510 RenderViewImpl::Create(compositor_deps_, view_params, show_callback);
1525 1511
1526 return view->webview(); 1512 return view->webview();
1527 } 1513 }
1528 1514
1529 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { 1515 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) {
1530 RenderWidget* widget = RenderWidget::CreateForPopup(this, compositor_deps_, 1516 RenderWidget* widget = RenderWidget::CreateForPopup(this, compositor_deps_,
1531 popup_type, screen_info_); 1517 popup_type, screen_info_);
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2732 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2747 } 2733 }
2748 2734
2749 std::unique_ptr<InputEventAck> ack( 2735 std::unique_ptr<InputEventAck> ack(
2750 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, 2736 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type,
2751 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2737 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2752 OnInputEventAck(std::move(ack)); 2738 OnInputEventAck(std::move(ack));
2753 } 2739 }
2754 2740
2755 } // namespace content 2741 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698