| 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 4672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4683 // provide it with the response to the request. | 4683 // provide it with the response to the request. |
| 4684 scoped_ptr<StreamOverrideParameters> stream_override( | 4684 scoped_ptr<StreamOverrideParameters> stream_override( |
| 4685 new StreamOverrideParameters()); | 4685 new StreamOverrideParameters()); |
| 4686 stream_override->stream_url = stream_url; | 4686 stream_override->stream_url = stream_url; |
| 4687 stream_override->response = response; | 4687 stream_override->response = response; |
| 4688 | 4688 |
| 4689 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4689 NavigateInternal(common_params, StartNavigationParams(), request_params, |
| 4690 std::move(stream_override)); | 4690 std::move(stream_override)); |
| 4691 } | 4691 } |
| 4692 | 4692 |
| 4693 // PlzNavigate |
| 4693 void RenderFrameImpl::OnFailedNavigation( | 4694 void RenderFrameImpl::OnFailedNavigation( |
| 4694 const CommonNavigationParams& common_params, | 4695 const CommonNavigationParams& common_params, |
| 4695 const RequestNavigationParams& request_params, | 4696 const RequestNavigationParams& request_params, |
| 4696 bool has_stale_copy_in_cache, | 4697 bool has_stale_copy_in_cache, |
| 4697 int error_code) { | 4698 int error_code) { |
| 4699 DCHECK(IsBrowserSideNavigationEnabled()); |
| 4698 bool is_reload = IsReload(common_params.navigation_type); | 4700 bool is_reload = IsReload(common_params.navigation_type); |
| 4699 bool is_history_navigation = request_params.page_state.IsValid(); | 4701 bool is_history_navigation = request_params.page_state.IsValid(); |
| 4700 WebURLRequest::CachePolicy cache_policy = | 4702 WebURLRequest::CachePolicy cache_policy = |
| 4701 WebURLRequest::UseProtocolCachePolicy; | 4703 WebURLRequest::UseProtocolCachePolicy; |
| 4702 RenderFrameImpl::PrepareRenderViewForNavigation( | 4704 RenderFrameImpl::PrepareRenderViewForNavigation( |
| 4703 common_params.url, request_params, &is_reload, &cache_policy); | 4705 common_params.url, request_params, &is_reload, &cache_policy); |
| 4704 | 4706 |
| 4705 GetContentClient()->SetActiveURL(common_params.url); | 4707 GetContentClient()->SetActiveURL(common_params.url); |
| 4706 | 4708 |
| 4707 pending_navigation_params_.reset(new NavigationParams( | 4709 pending_navigation_params_.reset(new NavigationParams( |
| 4708 common_params, StartNavigationParams(), request_params)); | 4710 common_params, StartNavigationParams(), request_params)); |
| 4709 | 4711 |
| 4710 // Inform the browser of the start of the provisional load. This is needed so | 4712 // Inform the browser of the start of the provisional load. This is needed so |
| 4711 // that the load is properly tracked by the WebNavigation API. | 4713 // that the load is properly tracked by the WebNavigation API. |
| 4712 Send(new FrameHostMsg_DidStartProvisionalLoad( | 4714 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 4713 routing_id_, common_params.url, common_params.navigation_start)); | 4715 routing_id_, common_params.url, common_params.navigation_start)); |
| 4714 | 4716 |
| 4715 // Send the provisional load failure. | 4717 // Send the provisional load failure. |
| 4716 blink::WebURLError error = | 4718 blink::WebURLError error = |
| 4717 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4719 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 4718 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4720 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 4719 common_params, scoped_ptr<StreamOverrideParameters>(), | 4721 common_params, scoped_ptr<StreamOverrideParameters>(), |
| 4720 frame_->isViewSourceModeEnabled()); | 4722 frame_->isViewSourceModeEnabled()); |
| 4721 SendFailedProvisionalLoad(failed_request, error, frame_); | 4723 SendFailedProvisionalLoad(failed_request, error, frame_); |
| 4722 | 4724 |
| 4725 // This check should have been done on the browser side already. |
| 4723 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4726 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
| 4724 // TODO(avi): Remove this; we shouldn't ever be dropping navigations. | 4727 NOTREACHED(); |
| 4725 // http://crbug.com/501960 | |
| 4726 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | |
| 4727 return; | 4728 return; |
| 4728 } | 4729 } |
| 4729 | 4730 |
| 4730 // Make sure errors are not shown in view source mode. | 4731 // Make sure errors are not shown in view source mode. |
| 4731 frame_->enableViewSourceMode(false); | 4732 frame_->enableViewSourceMode(false); |
| 4732 | 4733 |
| 4733 // Replace the current history entry in reloads, history navigations and loads | 4734 // Replace the current history entry in reloads, history navigations and loads |
| 4734 // of the same url. This corresponds to Blink's notion of a standard | 4735 // of the same url. This corresponds to Blink's notion of a standard |
| 4735 // commit. | 4736 // commit. |
| 4736 // TODO(clamy): see if initial commits in subframes should be handled | 4737 // TODO(clamy): see if initial commits in subframes should be handled |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5348 | 5349 |
| 5349 // Create parameters for a standard navigation. | 5350 // Create parameters for a standard navigation. |
| 5350 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 5351 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; |
| 5351 blink::WebHistoryLoadType history_load_type = | 5352 blink::WebHistoryLoadType history_load_type = |
| 5352 blink::WebHistoryDifferentDocumentLoad; | 5353 blink::WebHistoryDifferentDocumentLoad; |
| 5353 bool should_load_request = false; | 5354 bool should_load_request = false; |
| 5354 WebHistoryItem item_for_history_navigation; | 5355 WebHistoryItem item_for_history_navigation; |
| 5355 WebURLRequest request = | 5356 WebURLRequest request = |
| 5356 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5357 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| 5357 frame_->isViewSourceModeEnabled()); | 5358 frame_->isViewSourceModeEnabled()); |
| 5359 |
| 5360 // Used to determine whether this frame is actually loading a request as part |
| 5361 // of a history navigation. |
| 5362 bool has_history_navigation_in_frame = false; |
| 5363 |
| 5358 #if defined(OS_ANDROID) | 5364 #if defined(OS_ANDROID) |
| 5359 request.setHasUserGesture(start_params.has_user_gesture); | 5365 request.setHasUserGesture(start_params.has_user_gesture); |
| 5360 #endif | 5366 #endif |
| 5361 | 5367 |
| 5362 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5368 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
| 5363 // navigation for this request (since it already went to the browser). | 5369 // navigation for this request (since it already went to the browser). |
| 5364 if (browser_side_navigation) | 5370 if (browser_side_navigation) |
| 5365 request.setCheckForBrowserSideNavigation(false); | 5371 request.setCheckForBrowserSideNavigation(false); |
| 5366 | 5372 |
| 5367 // If we are reloading, then use the history state of the current frame. | 5373 // If we are reloading, then use the history state of the current frame. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5398 CHECK(entry->root().urlString() != kSwappedOutURL); | 5404 CHECK(entry->root().urlString() != kSwappedOutURL); |
| 5399 | 5405 |
| 5400 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5406 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 5401 // By default, tell the HistoryController to go the deserialized | 5407 // By default, tell the HistoryController to go the deserialized |
| 5402 // HistoryEntry. This only works if all frames are in the same | 5408 // HistoryEntry. This only works if all frames are in the same |
| 5403 // process. | 5409 // process. |
| 5404 DCHECK(!frame_->parent()); | 5410 DCHECK(!frame_->parent()); |
| 5405 DCHECK(!browser_side_navigation); | 5411 DCHECK(!browser_side_navigation); |
| 5406 scoped_ptr<NavigationParams> navigation_params( | 5412 scoped_ptr<NavigationParams> navigation_params( |
| 5407 new NavigationParams(*pending_navigation_params_.get())); | 5413 new NavigationParams(*pending_navigation_params_.get())); |
| 5408 render_view_->history_controller()->GoToEntry( | 5414 has_history_navigation_in_frame = |
| 5409 frame_, std::move(entry), std::move(navigation_params), | 5415 render_view_->history_controller()->GoToEntry( |
| 5410 cache_policy); | 5416 frame_, std::move(entry), std::move(navigation_params), |
| 5417 cache_policy); |
| 5411 } else { | 5418 } else { |
| 5412 // In --site-per-process, the browser process sends a single | 5419 // In --site-per-process, the browser process sends a single |
| 5413 // WebHistoryItem destined for this frame. | 5420 // WebHistoryItem destined for this frame. |
| 5414 // TODO(creis): Change PageState to FrameState. In the meantime, we | 5421 // TODO(creis): Change PageState to FrameState. In the meantime, we |
| 5415 // store the relevant frame's WebHistoryItem in the root of the | 5422 // store the relevant frame's WebHistoryItem in the root of the |
| 5416 // PageState. | 5423 // PageState. |
| 5417 item_for_history_navigation = entry->root(); | 5424 item_for_history_navigation = entry->root(); |
| 5418 history_load_type = request_params.is_same_document_history_load | 5425 history_load_type = request_params.is_same_document_history_load |
| 5419 ? blink::WebHistorySameDocumentLoad | 5426 ? blink::WebHistorySameDocumentLoad |
| 5420 : blink::WebHistoryDifferentDocumentLoad; | 5427 : blink::WebHistoryDifferentDocumentLoad; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5497 // client redirect. | 5504 // client redirect. |
| 5498 bool is_client_redirect = browser_side_navigation | 5505 bool is_client_redirect = browser_side_navigation |
| 5499 ? !!(common_params.transition & | 5506 ? !!(common_params.transition & |
| 5500 ui::PAGE_TRANSITION_CLIENT_REDIRECT) | 5507 ui::PAGE_TRANSITION_CLIENT_REDIRECT) |
| 5501 : false; | 5508 : false; |
| 5502 | 5509 |
| 5503 // Load the request. | 5510 // Load the request. |
| 5504 frame_->load(request, load_type, item_for_history_navigation, | 5511 frame_->load(request, load_type, item_for_history_navigation, |
| 5505 history_load_type, is_client_redirect); | 5512 history_load_type, is_client_redirect); |
| 5506 } | 5513 } |
| 5514 } else { |
| 5515 // The browser expects the frame to be loading this navigation. Inform it |
| 5516 // that the load stopped if needed. |
| 5517 // Note: in the case of history navigations, |should_load_request| will be |
| 5518 // false, and the frame may not have been set in a loading state. Do not |
| 5519 // send a stop message if the HistoryController is loading in this frame |
| 5520 // nonetheless. This behavior will go away with subframe navigation |
| 5521 // entries. |
| 5522 if (!frame_->isLoading() && !has_history_navigation_in_frame) |
| 5523 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 5507 } | 5524 } |
| 5508 | 5525 |
| 5509 // In case LoadRequest failed before didCreateDataSource was called. | 5526 // In case LoadRequest failed before didCreateDataSource was called. |
| 5510 pending_navigation_params_.reset(); | 5527 pending_navigation_params_.reset(); |
| 5511 } | 5528 } |
| 5512 | 5529 |
| 5513 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, | 5530 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
| 5514 const std::string& encoding_name) { | 5531 const std::string& encoding_name) { |
| 5515 // Only update main frame's encoding_name. | 5532 // Only update main frame's encoding_name. |
| 5516 if (!frame->parent()) | 5533 if (!frame->parent()) |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6098 int match_count, | 6115 int match_count, |
| 6099 int ordinal, | 6116 int ordinal, |
| 6100 const WebRect& selection_rect, | 6117 const WebRect& selection_rect, |
| 6101 bool final_status_update) { | 6118 bool final_status_update) { |
| 6102 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6119 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6103 selection_rect, ordinal, | 6120 selection_rect, ordinal, |
| 6104 final_status_update)); | 6121 final_status_update)); |
| 6105 } | 6122 } |
| 6106 | 6123 |
| 6107 } // namespace content | 6124 } // namespace content |
| OLD | NEW |