| 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 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 4697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4708 // provide it with the response to the request. | 4708 // provide it with the response to the request. |
| 4709 scoped_ptr<StreamOverrideParameters> stream_override( | 4709 scoped_ptr<StreamOverrideParameters> stream_override( |
| 4710 new StreamOverrideParameters()); | 4710 new StreamOverrideParameters()); |
| 4711 stream_override->stream_url = stream_url; | 4711 stream_override->stream_url = stream_url; |
| 4712 stream_override->response = response; | 4712 stream_override->response = response; |
| 4713 | 4713 |
| 4714 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4714 NavigateInternal(common_params, StartNavigationParams(), request_params, |
| 4715 std::move(stream_override)); | 4715 std::move(stream_override)); |
| 4716 } | 4716 } |
| 4717 | 4717 |
| 4718 // PlzNavigate |
| 4718 void RenderFrameImpl::OnFailedNavigation( | 4719 void RenderFrameImpl::OnFailedNavigation( |
| 4719 const CommonNavigationParams& common_params, | 4720 const CommonNavigationParams& common_params, |
| 4720 const RequestNavigationParams& request_params, | 4721 const RequestNavigationParams& request_params, |
| 4721 bool has_stale_copy_in_cache, | 4722 bool has_stale_copy_in_cache, |
| 4722 int error_code) { | 4723 int error_code) { |
| 4724 DCHECK(IsBrowserSideNavigationEnabled()); |
| 4723 bool is_reload = IsReload(common_params.navigation_type); | 4725 bool is_reload = IsReload(common_params.navigation_type); |
| 4724 bool is_history_navigation = request_params.page_state.IsValid(); | 4726 bool is_history_navigation = request_params.page_state.IsValid(); |
| 4725 WebURLRequest::CachePolicy cache_policy = | 4727 WebURLRequest::CachePolicy cache_policy = |
| 4726 WebURLRequest::UseProtocolCachePolicy; | 4728 WebURLRequest::UseProtocolCachePolicy; |
| 4727 RenderFrameImpl::PrepareRenderViewForNavigation( | 4729 RenderFrameImpl::PrepareRenderViewForNavigation( |
| 4728 common_params.url, request_params, &is_reload, &cache_policy); | 4730 common_params.url, request_params, &is_reload, &cache_policy); |
| 4729 | 4731 |
| 4730 GetContentClient()->SetActiveURL(common_params.url); | 4732 GetContentClient()->SetActiveURL(common_params.url); |
| 4731 | 4733 |
| 4732 pending_navigation_params_.reset(new NavigationParams( | 4734 pending_navigation_params_.reset(new NavigationParams( |
| 4733 common_params, StartNavigationParams(), request_params)); | 4735 common_params, StartNavigationParams(), request_params)); |
| 4734 | 4736 |
| 4735 // Inform the browser of the start of the provisional load. This is needed so | 4737 // Inform the browser of the start of the provisional load. This is needed so |
| 4736 // that the load is properly tracked by the WebNavigation API. | 4738 // that the load is properly tracked by the WebNavigation API. |
| 4737 Send(new FrameHostMsg_DidStartProvisionalLoad( | 4739 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 4738 routing_id_, common_params.url, common_params.navigation_start)); | 4740 routing_id_, common_params.url, common_params.navigation_start)); |
| 4739 | 4741 |
| 4740 // Send the provisional load failure. | 4742 // Send the provisional load failure. |
| 4741 blink::WebURLError error = | 4743 blink::WebURLError error = |
| 4742 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4744 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 4743 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4745 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 4744 common_params, scoped_ptr<StreamOverrideParameters>(), | 4746 common_params, scoped_ptr<StreamOverrideParameters>(), |
| 4745 frame_->isViewSourceModeEnabled()); | 4747 frame_->isViewSourceModeEnabled()); |
| 4746 SendFailedProvisionalLoad(failed_request, error, frame_); | 4748 SendFailedProvisionalLoad(failed_request, error, frame_); |
| 4747 | 4749 |
| 4750 // This check should have been done on the browser side already. |
| 4748 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4751 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
| 4749 // TODO(avi): Remove this; we shouldn't ever be dropping navigations. | 4752 NOTREACHED(); |
| 4750 // http://crbug.com/501960 | |
| 4751 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | |
| 4752 return; | 4753 return; |
| 4753 } | 4754 } |
| 4754 | 4755 |
| 4755 // Make sure errors are not shown in view source mode. | 4756 // Make sure errors are not shown in view source mode. |
| 4756 frame_->enableViewSourceMode(false); | 4757 frame_->enableViewSourceMode(false); |
| 4757 | 4758 |
| 4758 // Replace the current history entry in reloads, history navigations and loads | 4759 // Replace the current history entry in reloads, history navigations and loads |
| 4759 // of the same url. This corresponds to Blink's notion of a standard | 4760 // of the same url. This corresponds to Blink's notion of a standard |
| 4760 // commit. | 4761 // commit. |
| 4761 // TODO(clamy): see if initial commits in subframes should be handled | 4762 // TODO(clamy): see if initial commits in subframes should be handled |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5373 | 5374 |
| 5374 // Create parameters for a standard navigation. | 5375 // Create parameters for a standard navigation. |
| 5375 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 5376 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; |
| 5376 blink::WebHistoryLoadType history_load_type = | 5377 blink::WebHistoryLoadType history_load_type = |
| 5377 blink::WebHistoryDifferentDocumentLoad; | 5378 blink::WebHistoryDifferentDocumentLoad; |
| 5378 bool should_load_request = false; | 5379 bool should_load_request = false; |
| 5379 WebHistoryItem item_for_history_navigation; | 5380 WebHistoryItem item_for_history_navigation; |
| 5380 WebURLRequest request = | 5381 WebURLRequest request = |
| 5381 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5382 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| 5382 frame_->isViewSourceModeEnabled()); | 5383 frame_->isViewSourceModeEnabled()); |
| 5384 |
| 5385 // Used to determine whether this frame is actually loading a request as part |
| 5386 // of a history navigation. |
| 5387 bool has_history_navigation_in_frame = false; |
| 5388 |
| 5383 #if defined(OS_ANDROID) | 5389 #if defined(OS_ANDROID) |
| 5384 request.setHasUserGesture(start_params.has_user_gesture); | 5390 request.setHasUserGesture(start_params.has_user_gesture); |
| 5385 #endif | 5391 #endif |
| 5386 | 5392 |
| 5387 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5393 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
| 5388 // navigation for this request (since it already went to the browser). | 5394 // navigation for this request (since it already went to the browser). |
| 5389 if (browser_side_navigation) | 5395 if (browser_side_navigation) |
| 5390 request.setCheckForBrowserSideNavigation(false); | 5396 request.setCheckForBrowserSideNavigation(false); |
| 5391 | 5397 |
| 5392 // If we are reloading, then use the history state of the current frame. | 5398 // If we are reloading, then use the history state of the current frame. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5423 CHECK(entry->root().urlString() != kSwappedOutURL); | 5429 CHECK(entry->root().urlString() != kSwappedOutURL); |
| 5424 | 5430 |
| 5425 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5431 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 5426 // By default, tell the HistoryController to go the deserialized | 5432 // By default, tell the HistoryController to go the deserialized |
| 5427 // HistoryEntry. This only works if all frames are in the same | 5433 // HistoryEntry. This only works if all frames are in the same |
| 5428 // process. | 5434 // process. |
| 5429 DCHECK(!frame_->parent()); | 5435 DCHECK(!frame_->parent()); |
| 5430 DCHECK(!browser_side_navigation); | 5436 DCHECK(!browser_side_navigation); |
| 5431 scoped_ptr<NavigationParams> navigation_params( | 5437 scoped_ptr<NavigationParams> navigation_params( |
| 5432 new NavigationParams(*pending_navigation_params_.get())); | 5438 new NavigationParams(*pending_navigation_params_.get())); |
| 5433 render_view_->history_controller()->GoToEntry( | 5439 has_history_navigation_in_frame = |
| 5434 frame_, std::move(entry), std::move(navigation_params), | 5440 render_view_->history_controller()->GoToEntry( |
| 5435 cache_policy); | 5441 frame_, std::move(entry), std::move(navigation_params), |
| 5442 cache_policy); |
| 5436 } else { | 5443 } else { |
| 5437 // In --site-per-process, the browser process sends a single | 5444 // In --site-per-process, the browser process sends a single |
| 5438 // WebHistoryItem destined for this frame. | 5445 // WebHistoryItem destined for this frame. |
| 5439 // TODO(creis): Change PageState to FrameState. In the meantime, we | 5446 // TODO(creis): Change PageState to FrameState. In the meantime, we |
| 5440 // store the relevant frame's WebHistoryItem in the root of the | 5447 // store the relevant frame's WebHistoryItem in the root of the |
| 5441 // PageState. | 5448 // PageState. |
| 5442 item_for_history_navigation = entry->root(); | 5449 item_for_history_navigation = entry->root(); |
| 5443 history_load_type = request_params.is_same_document_history_load | 5450 history_load_type = request_params.is_same_document_history_load |
| 5444 ? blink::WebHistorySameDocumentLoad | 5451 ? blink::WebHistorySameDocumentLoad |
| 5445 : blink::WebHistoryDifferentDocumentLoad; | 5452 : blink::WebHistoryDifferentDocumentLoad; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5519 bool is_client_redirect = browser_side_navigation | 5526 bool is_client_redirect = browser_side_navigation |
| 5520 ? !!(common_params.transition & | 5527 ? !!(common_params.transition & |
| 5521 ui::PAGE_TRANSITION_CLIENT_REDIRECT) | 5528 ui::PAGE_TRANSITION_CLIENT_REDIRECT) |
| 5522 : false; | 5529 : false; |
| 5523 | 5530 |
| 5524 // Load the request. | 5531 // Load the request. |
| 5525 frame_->toWebLocalFrame()->load(request, load_type, | 5532 frame_->toWebLocalFrame()->load(request, load_type, |
| 5526 item_for_history_navigation, | 5533 item_for_history_navigation, |
| 5527 history_load_type, is_client_redirect); | 5534 history_load_type, is_client_redirect); |
| 5528 } | 5535 } |
| 5536 } else { |
| 5537 // The browser expects the frame to be loading this navigation. Inform it |
| 5538 // that the load stopped if needed. |
| 5539 // Note: in the case of history navigations, |should_load_request| will be |
| 5540 // false, and the frame may not have been set in a loading state. Do not |
| 5541 // send a stop message if the HistoryController is loading in this frame |
| 5542 // nonetheless. This behavior will go away with subframe navigation |
| 5543 // entries. |
| 5544 if (!frame_->isLoading() && !has_history_navigation_in_frame) |
| 5545 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 5529 } | 5546 } |
| 5530 | 5547 |
| 5531 // In case LoadRequest failed before didCreateDataSource was called. | 5548 // In case LoadRequest failed before didCreateDataSource was called. |
| 5532 pending_navigation_params_.reset(); | 5549 pending_navigation_params_.reset(); |
| 5533 } | 5550 } |
| 5534 | 5551 |
| 5535 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, | 5552 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
| 5536 const std::string& encoding_name) { | 5553 const std::string& encoding_name) { |
| 5537 // Only update main frame's encoding_name. | 5554 // Only update main frame's encoding_name. |
| 5538 if (!frame->parent()) | 5555 if (!frame->parent()) |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6124 int match_count, | 6141 int match_count, |
| 6125 int ordinal, | 6142 int ordinal, |
| 6126 const WebRect& selection_rect, | 6143 const WebRect& selection_rect, |
| 6127 bool final_status_update) { | 6144 bool final_status_update) { |
| 6128 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6145 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6129 selection_rect, ordinal, | 6146 selection_rect, ordinal, |
| 6130 final_status_update)); | 6147 final_status_update)); |
| 6131 } | 6148 } |
| 6132 | 6149 |
| 6133 } // namespace content | 6150 } // namespace content |
| OLD | NEW |