| OLD | NEW |
| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 CHECK(proxy); | 637 CHECK(proxy); |
| 638 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); | 638 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); |
| 639 web_frame = | 639 web_frame = |
| 640 blink::WebLocalFrame::create(replicated_state.scope, render_frame); | 640 blink::WebLocalFrame::create(replicated_state.scope, render_frame); |
| 641 render_frame->proxy_routing_id_ = proxy_routing_id; | 641 render_frame->proxy_routing_id_ = proxy_routing_id; |
| 642 web_frame->initializeToReplaceRemoteFrame( | 642 web_frame->initializeToReplaceRemoteFrame( |
| 643 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), | 643 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), |
| 644 replicated_state.sandbox_flags); | 644 replicated_state.sandbox_flags); |
| 645 } | 645 } |
| 646 render_frame->SetWebFrame(web_frame); | 646 render_frame->SetWebFrame(web_frame); |
| 647 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); | 647 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); |
| 648 | 648 |
| 649 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); | 649 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); |
| 650 web_frame->setOpener(opener); | 650 web_frame->setOpener(opener); |
| 651 | 651 |
| 652 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 652 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
| 653 CHECK_IMPLIES(web_frame->parent(), | 653 CHECK(!web_frame->parent() || |
| 654 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 654 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 655 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 655 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
| 656 widget_params.routing_id, widget_params.hidden, | 656 widget_params.routing_id, widget_params.hidden, |
| 657 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 657 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
| 658 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 658 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
| 659 // avoid double-registering the frame as an observer. | 659 // avoid double-registering the frame as an observer. |
| 660 // https://crbug.com/545684 | 660 // https://crbug.com/545684 |
| 661 if (web_frame->parent()) { | 661 if (web_frame->parent()) { |
| 662 // TODO(kenrb): Observing shouldn't be necessary when we sort out | 662 // TODO(kenrb): Observing shouldn't be necessary when we sort out |
| 663 // WasShown and WasHidden, separating page-level visibility from | 663 // WasShown and WasHidden, separating page-level visibility from |
| 664 // frame-level visibility. | 664 // frame-level visibility. |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 void RenderFrameImpl::OnSwapOut( | 1249 void RenderFrameImpl::OnSwapOut( |
| 1250 int proxy_routing_id, | 1250 int proxy_routing_id, |
| 1251 bool is_loading, | 1251 bool is_loading, |
| 1252 const FrameReplicationState& replicated_frame_state) { | 1252 const FrameReplicationState& replicated_frame_state) { |
| 1253 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); | 1253 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); |
| 1254 RenderFrameProxy* proxy = NULL; | 1254 RenderFrameProxy* proxy = NULL; |
| 1255 bool swapped_out_forbidden = | 1255 bool swapped_out_forbidden = |
| 1256 SiteIsolationPolicy::IsSwappedOutStateForbidden(); | 1256 SiteIsolationPolicy::IsSwappedOutStateForbidden(); |
| 1257 | 1257 |
| 1258 // This codepath should only be hit for subframes when in --site-per-process. | 1258 // This codepath should only be hit for subframes when in --site-per-process. |
| 1259 CHECK_IMPLIES(!is_main_frame_, | 1259 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 1260 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | |
| 1261 | 1260 |
| 1262 // Only run unload if we're not swapped out yet, but send the ack either way. | 1261 // Only run unload if we're not swapped out yet, but send the ack either way. |
| 1263 if (!is_swapped_out_) { | 1262 if (!is_swapped_out_) { |
| 1264 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1263 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
| 1265 // a different process. This involves running the unload handler and | 1264 // a different process. This involves running the unload handler and |
| 1266 // clearing the page. We also allow this process to exit if there are no | 1265 // clearing the page. We also allow this process to exit if there are no |
| 1267 // other active RenderFrames in it. | 1266 // other active RenderFrames in it. |
| 1268 | 1267 |
| 1269 // Send an UpdateState message before we get swapped out. | 1268 // Send an UpdateState message before we get swapped out. |
| 1270 render_view_->SendUpdateState(); | 1269 render_view_->SendUpdateState(); |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 // callback is invoked. | 2669 // callback is invoked. |
| 2671 if (!ds) | 2670 if (!ds) |
| 2672 return; | 2671 return; |
| 2673 | 2672 |
| 2674 TRACE_EVENT2("navigation,benchmark", | 2673 TRACE_EVENT2("navigation,benchmark", |
| 2675 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 2674 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
| 2676 "url", ds->request().url().string().utf8()); | 2675 "url", ds->request().url().string().utf8()); |
| 2677 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2676 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2678 | 2677 |
| 2679 // We should only navigate to swappedout:// when is_swapped_out_ is true. | 2678 // We should only navigate to swappedout:// when is_swapped_out_ is true. |
| 2680 CHECK_IMPLIES(ds->request().url() == GURL(kSwappedOutURL), is_swapped_out_) | 2679 CHECK(ds->request().url() != GURL(kSwappedOutURL) || is_swapped_out_) |
| 2681 << "Heard swappedout:// when not swapped out."; | 2680 << "Heard swappedout:// when not swapped out."; |
| 2682 | 2681 |
| 2683 // Update the request time if WebKit has better knowledge of it. | 2682 // Update the request time if WebKit has better knowledge of it. |
| 2684 if (document_state->request_time().is_null() && | 2683 if (document_state->request_time().is_null() && |
| 2685 triggering_event_time != 0.0) { | 2684 triggering_event_time != 0.0) { |
| 2686 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); | 2685 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); |
| 2687 } | 2686 } |
| 2688 | 2687 |
| 2689 // Start time is only set after request time. | 2688 // Start time is only set after request time. |
| 2690 document_state->set_start_load_time(Time::Now()); | 2689 document_state->set_start_load_time(Time::Now()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2836 if (is_new_navigation) { | 2835 if (is_new_navigation) { |
| 2837 // We bump our Page ID to correspond with the new session history entry. | 2836 // We bump our Page ID to correspond with the new session history entry. |
| 2838 render_view_->page_id_ = render_view_->next_page_id_++; | 2837 render_view_->page_id_ = render_view_->next_page_id_++; |
| 2839 | 2838 |
| 2840 // Don't update history list values for kSwappedOutURL, since | 2839 // Don't update history list values for kSwappedOutURL, since |
| 2841 // we don't want to forget the entry that was there, and since we will | 2840 // we don't want to forget the entry that was there, and since we will |
| 2842 // never come back to kSwappedOutURL. Note that we have to call | 2841 // never come back to kSwappedOutURL. Note that we have to call |
| 2843 // SendUpdateState and update page_id_ even in this case, so that | 2842 // SendUpdateState and update page_id_ even in this case, so that |
| 2844 // the current entry gets a state update and so that we don't send a | 2843 // the current entry gets a state update and so that we don't send a |
| 2845 // state update to the wrong entry when we swap back in. | 2844 // state update to the wrong entry when we swap back in. |
| 2846 DCHECK_IMPLIES( | 2845 DCHECK(!navigation_state->common_params().should_replace_current_entry || |
| 2847 navigation_state->common_params().should_replace_current_entry, | 2846 render_view_->history_list_length_ > 0); |
| 2848 render_view_->history_list_length_ > 0); | |
| 2849 if (GetLoadingUrl() != GURL(kSwappedOutURL) && | 2847 if (GetLoadingUrl() != GURL(kSwappedOutURL) && |
| 2850 !navigation_state->common_params().should_replace_current_entry) { | 2848 !navigation_state->common_params().should_replace_current_entry) { |
| 2851 // Advance our offset in session history, applying the length limit. | 2849 // Advance our offset in session history, applying the length limit. |
| 2852 // There is now no forward history. | 2850 // There is now no forward history. |
| 2853 render_view_->history_list_offset_++; | 2851 render_view_->history_list_offset_++; |
| 2854 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2852 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
| 2855 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2853 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
| 2856 render_view_->history_list_length_ = | 2854 render_view_->history_list_length_ = |
| 2857 render_view_->history_list_offset_ + 1; | 2855 render_view_->history_list_offset_ + 1; |
| 2858 } | 2856 } |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 | 3999 |
| 4002 void RenderFrameImpl::WasHidden() { | 4000 void RenderFrameImpl::WasHidden() { |
| 4003 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4001 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4004 } | 4002 } |
| 4005 | 4003 |
| 4006 void RenderFrameImpl::WasShown() { | 4004 void RenderFrameImpl::WasShown() { |
| 4007 // TODO(kenrb): Need to figure out how to do this better. Should | 4005 // TODO(kenrb): Need to figure out how to do this better. Should |
| 4008 // VisibilityState remain a page-level concept or move to frames? | 4006 // VisibilityState remain a page-level concept or move to frames? |
| 4009 // The semantics of 'Show' might have to change here. | 4007 // The semantics of 'Show' might have to change here. |
| 4010 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 4008 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
| 4011 DCHECK_IMPLIES(IsMainFrame(), render_widget_.get() == render_view_.get()) | 4009 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) |
| 4012 << "The main render frame is no longer reusing the RenderView as its " | 4010 << "The main render frame is no longer reusing the RenderView as its " |
| 4013 << "RenderWidget!"; | 4011 << "RenderWidget!"; |
| 4014 if (render_widget_ && render_view_.get() != render_widget_.get()) { | 4012 if (render_widget_ && render_view_.get() != render_widget_.get()) { |
| 4015 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | 4013 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> |
| 4016 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | 4014 setVisibilityState(blink::WebPageVisibilityStateVisible, false); |
| 4017 } | 4015 } |
| 4018 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4016 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
| 4019 } | 4017 } |
| 4020 | 4018 |
| 4021 void RenderFrameImpl::WidgetWillClose() { | 4019 void RenderFrameImpl::WidgetWillClose() { |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5006 } | 5004 } |
| 5007 | 5005 |
| 5008 // These values are assumed on the browser side for navigations. These checks | 5006 // These values are assumed on the browser side for navigations. These checks |
| 5009 // ensure the renderer has the correct values. | 5007 // ensure the renderer has the correct values. |
| 5010 DCHECK_EQ(FETCH_REQUEST_MODE_SAME_ORIGIN, | 5008 DCHECK_EQ(FETCH_REQUEST_MODE_SAME_ORIGIN, |
| 5011 GetFetchRequestModeForWebURLRequest(*request)); | 5009 GetFetchRequestModeForWebURLRequest(*request)); |
| 5012 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, | 5010 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, |
| 5013 GetFetchCredentialsModeForWebURLRequest(*request)); | 5011 GetFetchCredentialsModeForWebURLRequest(*request)); |
| 5014 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == | 5012 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == |
| 5015 FetchRedirectMode::MANUAL_MODE); | 5013 FetchRedirectMode::MANUAL_MODE); |
| 5016 DCHECK_IMPLIES(!frame_->parent(), | 5014 DCHECK(frame_->parent() || |
| 5017 GetRequestContextFrameTypeForWebURLRequest(*request) == | 5015 GetRequestContextFrameTypeForWebURLRequest(*request) == |
| 5018 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 5016 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
| 5019 DCHECK_IMPLIES(frame_->parent(), | 5017 DCHECK(!frame_->parent() || |
| 5020 GetRequestContextFrameTypeForWebURLRequest(*request) == | 5018 GetRequestContextFrameTypeForWebURLRequest(*request) == |
| 5021 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 5019 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
| 5022 | 5020 |
| 5023 Send(new FrameHostMsg_BeginNavigation( | 5021 Send(new FrameHostMsg_BeginNavigation( |
| 5024 routing_id_, | 5022 routing_id_, |
| 5025 MakeCommonNavigationParams(request, should_replace_current_entry), | 5023 MakeCommonNavigationParams(request, should_replace_current_entry), |
| 5026 BeginNavigationParams( | 5024 BeginNavigationParams( |
| 5027 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), | 5025 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), |
| 5028 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), | 5026 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), |
| 5029 request->skipServiceWorker(), | 5027 request->skipServiceWorker(), |
| 5030 GetRequestContextTypeForWebURLRequest(*request)), | 5028 GetRequestContextTypeForWebURLRequest(*request)), |
| 5031 GetRequestBodyForWebURLRequest(*request))); | 5029 GetRequestBodyForWebURLRequest(*request))); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5287 mojo::ServiceProviderPtr service_provider; | 5285 mojo::ServiceProviderPtr service_provider; |
| 5288 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5286 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 5289 request->url = mojo::String::From(url); | 5287 request->url = mojo::String::From(url); |
| 5290 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5288 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
| 5291 nullptr, nullptr, | 5289 nullptr, nullptr, |
| 5292 base::Bind(&OnGotContentHandlerID)); | 5290 base::Bind(&OnGotContentHandlerID)); |
| 5293 return service_provider.Pass(); | 5291 return service_provider.Pass(); |
| 5294 } | 5292 } |
| 5295 | 5293 |
| 5296 } // namespace content | 5294 } // namespace content |
| OLD | NEW |