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

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

Issue 1807893002: Remove swapped out state from RenderFrameImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove stale comment. Created 4 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 } 971 }
972 972
973 // RenderFrameImpl ---------------------------------------------------------- 973 // RenderFrameImpl ----------------------------------------------------------
974 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) 974 RenderFrameImpl::RenderFrameImpl(const CreateParams& params)
975 : frame_(NULL), 975 : frame_(NULL),
976 is_main_frame_(true), 976 is_main_frame_(true),
977 in_browser_initiated_detach_(false), 977 in_browser_initiated_detach_(false),
978 in_frame_tree_(false), 978 in_frame_tree_(false),
979 render_view_(params.render_view->AsWeakPtr()), 979 render_view_(params.render_view->AsWeakPtr()),
980 routing_id_(params.routing_id), 980 routing_id_(params.routing_id),
981 is_swapped_out_(false),
982 render_frame_proxy_(NULL), 981 render_frame_proxy_(NULL),
983 is_detaching_(false), 982 is_detaching_(false),
984 proxy_routing_id_(MSG_ROUTING_NONE), 983 proxy_routing_id_(MSG_ROUTING_NONE),
985 #if defined(ENABLE_PLUGINS) 984 #if defined(ENABLE_PLUGINS)
986 plugin_power_saver_helper_(nullptr), 985 plugin_power_saver_helper_(nullptr),
987 plugin_find_handler_(nullptr), 986 plugin_find_handler_(nullptr),
988 #endif 987 #endif
989 cookie_jar_(this), 988 cookie_jar_(this),
990 selection_text_offset_(0), 989 selection_text_offset_(0),
991 selection_range_(gfx::Range::InvalidRange()), 990 selection_range_(gfx::Range::InvalidRange()),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 "parent", parent_id); 1089 "parent", parent_id);
1091 } 1090 }
1092 1091
1093 MaybeEnableMojoBindings(); 1092 MaybeEnableMojoBindings();
1094 1093
1095 #if defined(ENABLE_PLUGINS) 1094 #if defined(ENABLE_PLUGINS)
1096 new PepperBrowserConnection(this); 1095 new PepperBrowserConnection(this);
1097 #endif 1096 #endif
1098 new SharedWorkerRepository(this); 1097 new SharedWorkerRepository(this);
1099 1098
1100 if (IsLocalRoot() && !is_swapped_out_) { 1099 if (IsLocalRoot()) {
1101 // DevToolsAgent is a RenderFrameObserver, and will destruct itself 1100 // DevToolsAgent is a RenderFrameObserver, and will destruct itself
1102 // when |this| is deleted. 1101 // when |this| is deleted.
1103 devtools_agent_ = new DevToolsAgent(this); 1102 devtools_agent_ = new DevToolsAgent(this);
1104 } 1103 }
1105 1104
1106 RegisterMojoServices(); 1105 RegisterMojoServices();
1107 1106
1108 // We delay calling this until we have the WebFrame so that any observer or 1107 // We delay calling this until we have the WebFrame so that any observer or
1109 // embedder can call GetWebFrame on any RenderFrame. 1108 // embedder can call GetWebFrame on any RenderFrame.
1110 GetContentClient()->renderer()->RenderFrameCreated(this); 1109 GetContentClient()->renderer()->RenderFrameCreated(this);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 InitializeUserMediaClient(); 1304 InitializeUserMediaClient();
1306 return web_user_media_client_ ? 1305 return web_user_media_client_ ?
1307 web_user_media_client_->media_stream_dispatcher() : NULL; 1306 web_user_media_client_->media_stream_dispatcher() : NULL;
1308 } 1307 }
1309 1308
1310 bool RenderFrameImpl::Send(IPC::Message* message) { 1309 bool RenderFrameImpl::Send(IPC::Message* message) {
1311 if (is_detaching_) { 1310 if (is_detaching_) {
1312 delete message; 1311 delete message;
1313 return false; 1312 return false;
1314 } 1313 }
1315 if (is_swapped_out_) {
1316 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) {
1317 delete message;
1318 return false;
1319 }
1320 }
1321 1314
1322 return RenderThread::Get()->Send(message); 1315 return RenderThread::Get()->Send(message);
1323 } 1316 }
1324 1317
1325 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1318 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1326 void RenderFrameImpl::DidHideExternalPopupMenu() { 1319 void RenderFrameImpl::DidHideExternalPopupMenu() {
1327 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close 1320 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close
1328 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. 1321 // is called. Otherwise, createExternalPopupMenu() for new popup will fail.
1329 external_popup_menu_.reset(); 1322 external_popup_menu_.reset();
1330 } 1323 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // Can be NULL in tests. 1457 // Can be NULL in tests.
1465 if (render_thread_impl) 1458 if (render_thread_impl)
1466 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); 1459 render_thread_impl->GetRendererScheduler()->OnNavigationStarted();
1467 DCHECK(!IsBrowserSideNavigationEnabled()); 1460 DCHECK(!IsBrowserSideNavigationEnabled());
1468 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, 1461 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1469 "url", common_params.url.possibly_invalid_spec()); 1462 "url", common_params.url.possibly_invalid_spec());
1470 NavigateInternal(common_params, start_params, request_params, 1463 NavigateInternal(common_params, start_params, request_params,
1471 scoped_ptr<StreamOverrideParameters>()); 1464 scoped_ptr<StreamOverrideParameters>());
1472 } 1465 }
1473 1466
1474 void RenderFrameImpl::NavigateToSwappedOutURL() {
1475 // We use loadRequest instead of loadHTMLString because the former commits
1476 // synchronously. Otherwise a new navigation can interrupt the navigation
1477 // to kSwappedOutURL. If that happens to be to the page we had been
1478 // showing, then WebKit will never send a commit and we'll be left spinning.
1479 // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and
1480 // the navigation to swappedout:// is not announced to the browser side.
1481 is_swapped_out_ = true;
1482 GURL swappedOutURL(kSwappedOutURL);
1483 WebURLRequest request(swappedOutURL);
1484 frame_->loadRequest(request);
1485 }
1486
1487 void RenderFrameImpl::BindServiceRegistry( 1467 void RenderFrameImpl::BindServiceRegistry(
1488 mojo::shell::mojom::InterfaceProviderRequest services, 1468 mojo::shell::mojom::InterfaceProviderRequest services,
1489 mojo::shell::mojom::InterfaceProviderPtr exposed_services) { 1469 mojo::shell::mojom::InterfaceProviderPtr exposed_services) {
1490 service_registry_.Bind(std::move(services)); 1470 service_registry_.Bind(std::move(services));
1491 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); 1471 service_registry_.BindRemoteServiceProvider(std::move(exposed_services));
1492 } 1472 }
1493 1473
1494 ManifestManager* RenderFrameImpl::manifest_manager() { 1474 ManifestManager* RenderFrameImpl::manifest_manager() {
1495 return manifest_manager_; 1475 return manifest_manager_;
1496 } 1476 }
(...skipping 22 matching lines...) Expand all
1519 void RenderFrameImpl::OnSwapOut( 1499 void RenderFrameImpl::OnSwapOut(
1520 int proxy_routing_id, 1500 int proxy_routing_id,
1521 bool is_loading, 1501 bool is_loading,
1522 const FrameReplicationState& replicated_frame_state) { 1502 const FrameReplicationState& replicated_frame_state) {
1523 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); 1503 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_);
1524 RenderFrameProxy* proxy = NULL; 1504 RenderFrameProxy* proxy = NULL;
1525 1505
1526 // This codepath should only be hit for subframes when in --site-per-process. 1506 // This codepath should only be hit for subframes when in --site-per-process.
1527 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); 1507 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible());
1528 1508
1529 // Only run unload if we're not swapped out yet, but send the ack either way. 1509 // Swap this RenderFrame out so the frame can navigate to a page rendered by
1530 if (!is_swapped_out_) { 1510 // a different process. This involves running the unload handler and
1531 // Swap this RenderFrame out so the frame can navigate to a page rendered by 1511 // clearing the page. We also allow this process to exit if there are no
1532 // a different process. This involves running the unload handler and 1512 // other active RenderFrames in it.
1533 // clearing the page. We also allow this process to exit if there are no
1534 // other active RenderFrames in it.
1535 1513
1536 // Send an UpdateState message before we get swapped out. 1514 // Send an UpdateState message before we get deleted.
1537 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 1515 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
1538 SendUpdateState(); 1516 SendUpdateState();
1539 else 1517 else
1540 render_view_->SendUpdateState(); 1518 render_view_->SendUpdateState();
1541 1519
1542 // If we need a proxy to replace this, create it now so its routing id is 1520 // If we need a proxy to replace this, create it now so its routing id is
1543 // registered for receiving IPC messages. 1521 // registered for receiving IPC messages.
1544 if (proxy_routing_id != MSG_ROUTING_NONE) { 1522 if (proxy_routing_id != MSG_ROUTING_NONE) {
1545 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( 1523 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(
1546 this, proxy_routing_id, replicated_frame_state.scope); 1524 this, proxy_routing_id, replicated_frame_state.scope);
1547 } 1525 }
1548 1526
1549 // Synchronously run the unload handler before sending the ACK. 1527 // Synchronously run the unload handler before sending the ACK.
1550 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 1528 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
1551 // unload on subframes as well. 1529 // unload on subframes as well.
1552 if (is_main_frame_) 1530 if (is_main_frame_)
1553 frame_->dispatchUnloadEvent(); 1531 frame_->dispatchUnloadEvent();
1554 1532
1555 // Swap out and stop sending any IPC messages that are not ACKs. 1533 // Swap out and stop sending any IPC messages that are not ACKs.
1556 if (is_main_frame_) 1534 if (is_main_frame_)
1557 render_view_->SetSwappedOut(true); 1535 render_view_->SetSwappedOut(true);
1558 is_swapped_out_ = true;
1559 1536
1560 // Set the proxy here, since OnStop() below could cause an onload event 1537 // Set the proxy here, since OnStop() below could cause an onload event
1561 // handler to execute, which could trigger code such as 1538 // handler to execute, which could trigger code such as
1562 // willCheckAndDispatchMessageEvent() that needs the proxy. 1539 // willCheckAndDispatchMessageEvent() that needs the proxy.
1563 if (proxy) 1540 if (proxy)
1564 set_render_frame_proxy(proxy); 1541 set_render_frame_proxy(proxy);
1565 1542
1566 // Transfer settings such as initial drawing parameters to the remote frame, 1543 // Transfer settings such as initial drawing parameters to the remote frame,
1567 // if one is created, that will replace this frame. 1544 // if one is created, that will replace this frame.
1568 if (!is_main_frame_ && proxy) 1545 if (!is_main_frame_ && proxy)
1569 proxy->web_frame()->initializeFromFrame(frame_); 1546 proxy->web_frame()->initializeFromFrame(frame_);
1570 1547
1571 // Let WebKit know that this view is hidden so it can drop resources and 1548 // Let WebKit know that this view is hidden so it can drop resources and
1572 // stop compositing. 1549 // stop compositing.
1573 // TODO(creis): Support this for subframes as well. 1550 // TODO(creis): Support this for subframes as well.
1574 if (is_main_frame_) { 1551 if (is_main_frame_) {
1575 render_view_->webview()->setVisibilityState( 1552 render_view_->webview()->setVisibilityState(
1576 blink::WebPageVisibilityStateHidden, false); 1553 blink::WebPageVisibilityStateHidden, false);
1577 }
1578 } 1554 }
1579 1555
1580 // It is now safe to show modal dialogs again. 1556 // It is now safe to show modal dialogs again.
1581 // TODO(creis): Deal with modal dialogs from subframes. 1557 // TODO(creis): Deal with modal dialogs from subframes.
1582 if (is_main_frame_) 1558 if (is_main_frame_)
1583 render_view_->suppress_dialogs_until_swap_out_ = false; 1559 render_view_->suppress_dialogs_until_swap_out_ = false;
1584 1560
1585 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1561 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1586 1562
1587 RenderViewImpl* render_view = render_view_.get(); 1563 RenderViewImpl* render_view = render_view_.get();
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 params.parent_routing_id = routing_id_; 2569 params.parent_routing_id = routing_id_;
2594 params.scope = scope; 2570 params.scope = scope;
2595 params.frame_name = base::UTF16ToUTF8(base::StringPiece16(name)); 2571 params.frame_name = base::UTF16ToUTF8(base::StringPiece16(name));
2596 params.frame_unique_name = 2572 params.frame_unique_name =
2597 base::UTF16ToUTF8(base::StringPiece16(unique_name)); 2573 base::UTF16ToUTF8(base::StringPiece16(unique_name));
2598 params.sandbox_flags = sandbox_flags; 2574 params.sandbox_flags = sandbox_flags;
2599 params.frame_owner_properties = frame_owner_properties; 2575 params.frame_owner_properties = frame_owner_properties;
2600 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id)); 2576 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id));
2601 2577
2602 // Allocation of routing id failed, so we can't create a child frame. This can 2578 // Allocation of routing id failed, so we can't create a child frame. This can
2603 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2579 // happen if the synchronous IPC message above has failed.
2604 // out state or synchronous IPC message above has failed.
2605 if (child_routing_id == MSG_ROUTING_NONE) { 2580 if (child_routing_id == MSG_ROUTING_NONE) {
2606 NOTREACHED() << "Failed to allocate routing id for child frame."; 2581 NOTREACHED() << "Failed to allocate routing id for child frame.";
2607 return nullptr; 2582 return nullptr;
2608 } 2583 }
2609 2584
2610 // This method is always called by local frames, never remote frames. 2585 // This method is always called by local frames, never remote frames.
2611 2586
2612 // Tracing analysis uses this to find main frames when this value is 2587 // Tracing analysis uses this to find main frames when this value is
2613 // MSG_ROUTING_NONE, and build the frame tree otherwise. 2588 // MSG_ROUTING_NONE, and build the frame tree otherwise.
2614 TRACE_EVENT2("navigation", "RenderFrameImpl::createChildFrame", 2589 TRACE_EVENT2("navigation", "RenderFrameImpl::createChildFrame",
2615 "id", routing_id_, 2590 "id", routing_id_,
2616 "child", child_routing_id); 2591 "child", child_routing_id);
2617 2592
2618 // Create the RenderFrame and WebLocalFrame, linking the two. 2593 // Create the RenderFrame and WebLocalFrame, linking the two.
2619 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( 2594 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(
2620 render_view_.get(), child_routing_id); 2595 render_view_.get(), child_routing_id);
2621 blink::WebLocalFrame* web_frame = 2596 blink::WebLocalFrame* web_frame =
2622 WebLocalFrame::create(scope, child_render_frame); 2597 WebLocalFrame::create(scope, child_render_frame);
2623 child_render_frame->BindToWebFrame(web_frame); 2598 child_render_frame->BindToWebFrame(web_frame);
2624 2599
2625 // Add the frame to the frame tree and initialize it. 2600 // Add the frame to the frame tree and initialize it.
2626 parent->appendChild(web_frame); 2601 parent->appendChild(web_frame);
2627 child_render_frame->in_frame_tree_ = true; 2602 child_render_frame->in_frame_tree_ = true;
2628 child_render_frame->Initialize(); 2603 child_render_frame->Initialize();
2629 2604
2630 return web_frame; 2605 return web_frame;
2631 } 2606 }
2632 2607
2633 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { 2608 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) {
2634 // Only active frames are able to disown their opener.
2635 if (!opener && is_swapped_out_)
2636 return;
2637
2638 // Only a local frame should be able to update another frame's opener. 2609 // Only a local frame should be able to update another frame's opener.
2639 DCHECK(!opener || opener->isWebLocalFrame()); 2610 DCHECK(!opener || opener->isWebLocalFrame());
2640 2611
2641 int opener_routing_id = opener ? 2612 int opener_routing_id = opener ?
2642 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() : 2613 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() :
2643 MSG_ROUTING_NONE; 2614 MSG_ROUTING_NONE;
2644 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); 2615 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id));
2645 } 2616 }
2646 2617
2647 void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { 2618 void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 // In fast/loader/stop-provisional-loads.html, we abort the load before this 2951 // In fast/loader/stop-provisional-loads.html, we abort the load before this
2981 // callback is invoked. 2952 // callback is invoked.
2982 if (!ds) 2953 if (!ds)
2983 return; 2954 return;
2984 2955
2985 TRACE_EVENT2("navigation,benchmark", 2956 TRACE_EVENT2("navigation,benchmark",
2986 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, 2957 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_,
2987 "url", ds->request().url().string().utf8()); 2958 "url", ds->request().url().string().utf8());
2988 DocumentState* document_state = DocumentState::FromDataSource(ds); 2959 DocumentState* document_state = DocumentState::FromDataSource(ds);
2989 2960
2990 // We should only navigate to swappedout:// when is_swapped_out_ is true. 2961 // We should never navigate to swappedout://.
2991 CHECK(ds->request().url() != GURL(kSwappedOutURL) || is_swapped_out_) 2962 CHECK(ds->request().url() != GURL(kSwappedOutURL)) << "Heard swappedout://.";
2992 << "Heard swappedout:// when not swapped out.";
2993 2963
2994 // Update the request time if WebKit has better knowledge of it. 2964 // Update the request time if WebKit has better knowledge of it.
2995 if (document_state->request_time().is_null() && 2965 if (document_state->request_time().is_null() &&
2996 triggering_event_time != 0.0) { 2966 triggering_event_time != 0.0) {
2997 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); 2967 document_state->set_request_time(Time::FromDoubleT(triggering_event_time));
2998 } 2968 }
2999 2969
3000 // Start time is only set after request time. 2970 // Start time is only set after request time.
3001 document_state->set_start_load_time(Time::Now()); 2971 document_state->set_start_load_time(Time::Now());
3002 2972
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 TRACE_EVENT_INSTANT0("WebCore,benchmark", "LoadFinished", 3422 TRACE_EVENT_INSTANT0("WebCore,benchmark", "LoadFinished",
3453 TRACE_EVENT_SCOPE_PROCESS); 3423 TRACE_EVENT_SCOPE_PROCESS);
3454 } 3424 }
3455 document_state->set_finish_load_time(Time::Now()); 3425 document_state->set_finish_load_time(Time::Now());
3456 } 3426 }
3457 3427
3458 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 3428 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
3459 DidFinishLoad(frame)); 3429 DidFinishLoad(frame));
3460 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishLoad()); 3430 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishLoad());
3461 3431
3462 // Don't send this message while the frame is swapped out.
3463 if (is_swapped_out())
3464 return;
3465
3466 Send(new FrameHostMsg_DidFinishLoad(routing_id_, 3432 Send(new FrameHostMsg_DidFinishLoad(routing_id_,
3467 ds->request().url())); 3433 ds->request().url()));
3468 } 3434 }
3469 3435
3470 void RenderFrameImpl::didNavigateWithinPage(blink::WebLocalFrame* frame, 3436 void RenderFrameImpl::didNavigateWithinPage(blink::WebLocalFrame* frame,
3471 const blink::WebHistoryItem& item, 3437 const blink::WebHistoryItem& item,
3472 blink::WebHistoryCommitType commit_type) { 3438 blink::WebHistoryCommitType commit_type) {
3473 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", 3439 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage",
3474 "id", routing_id_); 3440 "id", routing_id_);
3475 DCHECK_EQ(frame_, frame); 3441 DCHECK_EQ(frame_, frame);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 message, 3539 message,
3574 default_value, 3540 default_value,
3575 frame_->document().url(), 3541 frame_->document().url(),
3576 &result); 3542 &result);
3577 if (ok) 3543 if (ok)
3578 actual_value->assign(result); 3544 actual_value->assign(result);
3579 return ok; 3545 return ok;
3580 } 3546 }
3581 3547
3582 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { 3548 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) {
3583 // If we are swapping out, we have already run the beforeunload handler.
3584 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload
3585 // at all, to avoid running it twice.
3586 if (is_swapped_out_)
3587 return true;
3588
3589 // Don't allow further dialogs if we are waiting to swap out, since the 3549 // Don't allow further dialogs if we are waiting to swap out, since the
3590 // PageGroupLoadDeferrer in our stack prevents it. 3550 // PageGroupLoadDeferrer in our stack prevents it.
3591 if (render_view()->suppress_dialogs_until_swap_out_) 3551 if (render_view()->suppress_dialogs_until_swap_out_)
3592 return false; 3552 return false;
3593 3553
3594 bool success = false; 3554 bool success = false;
3595 // This is an ignored return value, but is included so we can accept the same 3555 // This is an ignored return value, but is included so we can accept the same
3596 // response as RunJavaScriptMessage. 3556 // response as RunJavaScriptMessage.
3597 base::string16 ignored_result; 3557 base::string16 ignored_result;
3598 render_view()->SendAndRunNestedMessageLoop( 3558 render_view()->SendAndRunNestedMessageLoop(
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
4086 return midi_dispatcher_; 4046 return midi_dispatcher_;
4087 } 4047 }
4088 4048
4089 bool RenderFrameImpl::willCheckAndDispatchMessageEvent( 4049 bool RenderFrameImpl::willCheckAndDispatchMessageEvent(
4090 blink::WebLocalFrame* source_frame, 4050 blink::WebLocalFrame* source_frame,
4091 blink::WebFrame* target_frame, 4051 blink::WebFrame* target_frame,
4092 blink::WebSecurityOrigin target_origin, 4052 blink::WebSecurityOrigin target_origin,
4093 blink::WebDOMMessageEvent event) { 4053 blink::WebDOMMessageEvent event) {
4094 DCHECK(!frame_ || frame_ == target_frame); 4054 DCHECK(!frame_ || frame_ == target_frame);
4095 4055
4096 // Currently, a postMessage that targets a cross-process frame can be plumbed
4097 // either through this function or RenderFrameProxy::postMessageEvent. This
4098 // function is used when the target cross-process frame is a top-level frame
4099 // which has been swapped out. In that case, the corresponding WebLocalFrame
4100 // currently remains in the frame tree even in site-per-process mode (see
4101 // OnSwapOut). RenderFrameProxy::postMessageEvent is used in
4102 // --site-per-process mode for all other cases.
4103 //
4104 // TODO(alexmos, nasko): When swapped-out:// disappears, this should be 4056 // TODO(alexmos, nasko): When swapped-out:// disappears, this should be
4105 // cleaned up so that RenderFrameProxy::postMessageEvent is the only path for 4057 // cleaned up so that RenderFrameProxy::postMessageEvent is the only path for
4106 // cross-process postMessages. 4058 // cross-process postMessages.
4107 if (!is_swapped_out_)
4108 return false;
4109 4059
4110 // It is possible to get here on a swapped-out frame without a 4060 // It is possible to get here on a swapped-out frame without a
4111 // |render_frame_proxy_|. This happens when: 4061 // |render_frame_proxy_|. This happens when:
4112 // - This process only has one active RenderView and is about to go away 4062 // - This process only has one active RenderView and is about to go away
4113 // (e.g., due to cross-process navigation). 4063 // (e.g., due to cross-process navigation).
4114 // - The top frame has a subframe with an unload handler. 4064 // - The top frame has a subframe with an unload handler.
4115 // - The subframe sends a postMessage to the top-level frame in its unload 4065 // - The subframe sends a postMessage to the top-level frame in its unload
4116 // handler. 4066 // handler.
4117 // See https://crbug.com/475651 for details. We return false here, since we 4067 // See https://crbug.com/475651 for details. We return false here, since we
4118 // don't want to deliver the message to the new process in this case. 4068 // don't want to deliver the message to the new process in this case.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
4404 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); 4354 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response);
4405 if (extra_data) 4355 if (extra_data)
4406 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); 4356 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy();
4407 params.was_within_same_page = navigation_state->WasWithinSamePage(); 4357 params.was_within_same_page = navigation_state->WasWithinSamePage();
4408 params.security_info = response.securityInfo(); 4358 params.security_info = response.securityInfo();
4409 4359
4410 // Set the origin of the frame. This will be replicated to the corresponding 4360 // Set the origin of the frame. This will be replicated to the corresponding
4411 // RenderFrameProxies in other processes. 4361 // RenderFrameProxies in other processes.
4412 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due 4362 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due
4413 // to https://crbug.com/439608 and will be replicated as unique origins. 4363 // to https://crbug.com/439608 and will be replicated as unique origins.
4414 if (!is_swapped_out_) { 4364 std::string scheme = frame->document().getSecurityOrigin().protocol().utf8();
4415 std::string scheme = 4365 if (url::IsStandard(scheme.c_str(),
4416 frame->document().getSecurityOrigin().protocol().utf8(); 4366 url::Component(0, static_cast<int>(scheme.length())))) {
4417 if (url::IsStandard(scheme.c_str(), 4367 params.origin = frame->document().getSecurityOrigin();
4418 url::Component(0, static_cast<int>(scheme.length())))) {
4419 params.origin = frame->document().getSecurityOrigin();
4420 }
4421 } 4368 }
4422 4369
4423 params.should_enforce_strict_mixed_content_checking = 4370 params.should_enforce_strict_mixed_content_checking =
4424 frame->shouldEnforceStrictMixedContentChecking(); 4371 frame->shouldEnforceStrictMixedContentChecking();
4425 4372
4426 params.has_potentially_trustworthy_unique_origin = 4373 params.has_potentially_trustworthy_unique_origin =
4427 frame->document().getSecurityOrigin().isUnique() && 4374 frame->document().getSecurityOrigin().isUnique() &&
4428 frame->document().getSecurityOrigin().isPotentiallyTrustworthy(); 4375 frame->document().getSecurityOrigin().isPotentiallyTrustworthy();
4429 4376
4430 // Set the URL to be displayed in the browser UI to the user. 4377 // Set the URL to be displayed in the browser UI to the user.
4431 params.url = GetLoadingUrl(); 4378 params.url = GetLoadingUrl();
4432 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL));
4433
4434 if (frame->document().baseURL() != params.url) 4379 if (frame->document().baseURL() != params.url)
4435 params.base_url = frame->document().baseURL(); 4380 params.base_url = frame->document().baseURL();
4436 4381
4437 GetRedirectChain(ds, &params.redirects); 4382 GetRedirectChain(ds, &params.redirects);
4438 params.should_update_history = 4383 params.should_update_history =
4439 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; 4384 !ds->hasUnreachableURL() && response.httpStatusCode() != 404;
4440 4385
4441 params.searchable_form_url = internal_data->searchable_form_url(); 4386 params.searchable_form_url = internal_data->searchable_form_url();
4442 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 4387 params.searchable_form_encoding = internal_data->searchable_form_encoding();
4443 4388
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4545 // process. 4490 // process.
4546 params.original_request_url = GetOriginalRequestURL(ds); 4491 params.original_request_url = GetOriginalRequestURL(ds);
4547 4492
4548 params.history_list_was_cleared = 4493 params.history_list_was_cleared =
4549 navigation_state->request_params().should_clear_history_list; 4494 navigation_state->request_params().should_clear_history_list;
4550 4495
4551 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( 4496 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>(
4552 frame->dataSource()->request().inputPerfMetricReportPolicy()); 4497 frame->dataSource()->request().inputPerfMetricReportPolicy());
4553 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( 4498 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD(
4554 frame->dataSource()->request().uiStartTime()); 4499 frame->dataSource()->request().uiStartTime());
4555
4556 // This message needs to be sent before any of allowScripts(),
4557 // allowImages(), allowPlugins() is called for the new page, so that when
4558 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
4559 // after the FrameHostMsg_DidCommitProvisionalLoad message.
4560 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
4561 } else { 4500 } else {
4562 // Subframe navigation: the type depends on whether this navigation 4501 // Subframe navigation: the type depends on whether this navigation
4563 // generated a new session history entry. When they do generate a session 4502 // generated a new session history entry. When they do generate a session
4564 // history entry, it means the user initiated the navigation and we should 4503 // history entry, it means the user initiated the navigation and we should
4565 // mark it as such. 4504 // mark it as such.
4566 if (commit_type == blink::WebStandardCommit) 4505 if (commit_type == blink::WebStandardCommit)
4567 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; 4506 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
4568 else 4507 else
4569 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; 4508 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
4570 4509
4571 DCHECK(!navigation_state->request_params().should_clear_history_list); 4510 DCHECK(!navigation_state->request_params().should_clear_history_list);
4572 params.history_list_was_cleared = false; 4511 params.history_list_was_cleared = false;
4573 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; 4512 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT;
4513 }
4574 4514
4575 // Don't send this message while the subframe is swapped out. 4515 // This message needs to be sent before any of allowScripts(),
4576 if (!is_swapped_out()) 4516 // allowImages(), allowPlugins() is called for the new page, so that when
4577 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 4517 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
4578 } 4518 // after the FrameHostMsg_DidCommitProvisionalLoad message.
4519 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
4579 4520
4580 // If we end up reusing this WebRequest (for example, due to a #ref click), 4521 // If we end up reusing this WebRequest (for example, due to a #ref click),
4581 // we don't want the transition type to persist. Just clear it. 4522 // we don't want the transition type to persist. Just clear it.
4582 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); 4523 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK);
4583 } 4524 }
4584 4525
4585 void RenderFrameImpl::didStartLoading(bool to_different_document) { 4526 void RenderFrameImpl::didStartLoading(bool to_different_document) {
4586 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading", 4527 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading",
4587 "id", routing_id_); 4528 "id", routing_id_);
4588 render_view_->FrameDidStartLoading(frame_); 4529 render_view_->FrameDidStartLoading(frame_);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
4721 this, is_content_initiated, render_view_->opener_id_, frame_, 4662 this, is_content_initiated, render_view_->opener_id_, frame_,
4722 info.urlRequest, info.navigationType, info.defaultPolicy, 4663 info.urlRequest, info.navigationType, info.defaultPolicy,
4723 is_redirect)) { 4664 is_redirect)) {
4724 return blink::WebNavigationPolicyIgnore; 4665 return blink::WebNavigationPolicyIgnore;
4725 } 4666 }
4726 #endif 4667 #endif
4727 4668
4728 Referrer referrer( 4669 Referrer referrer(
4729 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); 4670 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest));
4730 4671
4731 // TODO(nick): Is consulting |is_main_frame| here correct?
4732 if (is_main_frame_ && is_swapped_out_) {
4733 if (info.urlRequest.url() != GURL(kSwappedOutURL)) {
4734 // Targeted links may try to navigate a swapped out frame. Allow the
4735 // browser process to navigate the tab instead. Note that it is also
4736 // possible for non-targeted navigations (from this view) to arrive
4737 // here just after we are swapped out. It's ok to send them to the
4738 // browser, as long as they're for the top level frame.
4739 // TODO(creis): Ensure this supports targeted form submissions when
4740 // fixing http://crbug.com/101395.
4741 if (frame_->parent() == NULL) {
4742 OpenURL(info.urlRequest.url(), referrer, info.defaultPolicy,
4743 info.replacesCurrentHistoryItem, false);
4744 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4745 }
4746
4747 // We should otherwise ignore in-process iframe navigations, if they
4748 // arrive just after we are swapped out.
4749 return blink::WebNavigationPolicyIgnore;
4750 }
4751
4752 // Allow kSwappedOutURL to complete.
4753 return info.defaultPolicy;
4754 }
4755
4756 // Webkit is asking whether to navigate to a new URL. 4672 // Webkit is asking whether to navigate to a new URL.
4757 // This is fine normally, except if we're showing UI from one security 4673 // This is fine normally, except if we're showing UI from one security
4758 // context and they're trying to navigate to a different context. 4674 // context and they're trying to navigate to a different context.
4759 const GURL& url = info.urlRequest.url(); 4675 const GURL& url = info.urlRequest.url();
4760 4676
4761 // If the browser is interested, then give it a chance to look at the request. 4677 // If the browser is interested, then give it a chance to look at the request.
4762 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4678 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4763 render_view_->renderer_preferences_ 4679 render_view_->renderer_preferences_
4764 .browser_handles_all_top_level_requests) { 4680 .browser_handles_all_top_level_requests) {
4765 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, 4681 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem,
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
5613 RenderViewObserver, render_view_->observers_, Navigate(url)); 5529 RenderViewObserver, render_view_->observers_, Navigate(url));
5614 5530
5615 render_view_->history_list_offset_ = 5531 render_view_->history_list_offset_ =
5616 request_params.current_history_list_offset; 5532 request_params.current_history_list_offset;
5617 render_view_->history_list_length_ = 5533 render_view_->history_list_length_ =
5618 request_params.current_history_list_length; 5534 request_params.current_history_list_length;
5619 if (request_params.should_clear_history_list) { 5535 if (request_params.should_clear_history_list) {
5620 CHECK_EQ(-1, render_view_->history_list_offset_); 5536 CHECK_EQ(-1, render_view_->history_list_offset_);
5621 CHECK_EQ(0, render_view_->history_list_length_); 5537 CHECK_EQ(0, render_view_->history_list_length_);
5622 } 5538 }
5623
5624 if (!is_swapped_out_ || frame_->parent())
5625 return;
5626
5627 // This is a swapped out main frame, so swap the renderer back in.
5628 // We marked the view as hidden when swapping the view out, so be sure to
5629 // reset the visibility state before navigating to the new URL.
5630 render_view_->webview()->setVisibilityState(
5631 render_view_->visibilityState(), false);
5632
5633 // If this is an attempt to reload while we are swapped out, we should not
5634 // reload swappedout://, but the previous page, which is stored in
5635 // params.state. Setting is_reload to false will treat this like a back
5636 // navigation to accomplish that.
5637 *is_reload = false;
5638 *cache_policy = WebURLRequest::ReloadIgnoringCacheData;
5639
5640 // We refresh timezone when a view is swapped in since timezone
5641 // can get out of sync when the system timezone is updated while
5642 // the view is swapped out.
5643 RenderThreadImpl::NotifyTimezoneChange();
5644
5645 render_view_->SetSwappedOut(false);
5646 is_swapped_out_ = false;
5647 return;
5648 } 5539 }
5649 5540
5650 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, 5541 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request,
5651 bool should_replace_current_entry, 5542 bool should_replace_current_entry,
5652 bool is_client_redirect) { 5543 bool is_client_redirect) {
5653 CHECK(IsBrowserSideNavigationEnabled()); 5544 CHECK(IsBrowserSideNavigationEnabled());
5654 DCHECK(request); 5545 DCHECK(request);
5655 // TODO(clamy): Execute the beforeunload event. 5546 // TODO(clamy): Execute the beforeunload event.
5656 5547
5657 // Note: At this stage, the goal is to apply all the modifications the 5548 // Note: At this stage, the goal is to apply all the modifications the
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
6084 int match_count, 5975 int match_count,
6085 int ordinal, 5976 int ordinal,
6086 const WebRect& selection_rect, 5977 const WebRect& selection_rect,
6087 bool final_status_update) { 5978 bool final_status_update) {
6088 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 5979 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6089 selection_rect, ordinal, 5980 selection_rect, ordinal,
6090 final_status_update)); 5981 final_status_update));
6091 } 5982 }
6092 5983
6093 } // namespace content 5984 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698