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 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 // provide it with the response to the request. | 4568 // provide it with the response to the request. |
4569 scoped_ptr<StreamOverrideParameters> stream_override( | 4569 scoped_ptr<StreamOverrideParameters> stream_override( |
4570 new StreamOverrideParameters()); | 4570 new StreamOverrideParameters()); |
4571 stream_override->stream_url = stream_url; | 4571 stream_override->stream_url = stream_url; |
4572 stream_override->response = response; | 4572 stream_override->response = response; |
4573 | 4573 |
4574 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4574 NavigateInternal(common_params, StartNavigationParams(), request_params, |
4575 std::move(stream_override)); | 4575 std::move(stream_override)); |
4576 } | 4576 } |
4577 | 4577 |
| 4578 // PlzNavigate |
4578 void RenderFrameImpl::OnFailedNavigation( | 4579 void RenderFrameImpl::OnFailedNavigation( |
4579 const CommonNavigationParams& common_params, | 4580 const CommonNavigationParams& common_params, |
4580 const RequestNavigationParams& request_params, | 4581 const RequestNavigationParams& request_params, |
4581 bool has_stale_copy_in_cache, | 4582 bool has_stale_copy_in_cache, |
4582 int error_code) { | 4583 int error_code) { |
| 4584 DCHECK(IsBrowserSideNavigationEnabled()); |
4583 bool is_reload = IsReload(common_params.navigation_type); | 4585 bool is_reload = IsReload(common_params.navigation_type); |
4584 bool is_history_navigation = request_params.page_state.IsValid(); | 4586 bool is_history_navigation = request_params.page_state.IsValid(); |
4585 WebURLRequest::CachePolicy cache_policy = | 4587 WebURLRequest::CachePolicy cache_policy = |
4586 WebURLRequest::UseProtocolCachePolicy; | 4588 WebURLRequest::UseProtocolCachePolicy; |
4587 RenderFrameImpl::PrepareRenderViewForNavigation( | 4589 RenderFrameImpl::PrepareRenderViewForNavigation( |
4588 common_params.url, request_params, &is_reload, &cache_policy); | 4590 common_params.url, request_params, &is_reload, &cache_policy); |
4589 | 4591 |
4590 GetContentClient()->SetActiveURL(common_params.url); | 4592 GetContentClient()->SetActiveURL(common_params.url); |
4591 | 4593 |
4592 pending_navigation_params_.reset(new NavigationParams( | 4594 pending_navigation_params_.reset(new NavigationParams( |
4593 common_params, StartNavigationParams(), request_params)); | 4595 common_params, StartNavigationParams(), request_params)); |
4594 | 4596 |
4595 // Inform the browser of the start of the provisional load. This is needed so | 4597 // Inform the browser of the start of the provisional load. This is needed so |
4596 // that the load is properly tracked by the WebNavigation API. | 4598 // that the load is properly tracked by the WebNavigation API. |
4597 Send(new FrameHostMsg_DidStartProvisionalLoad( | 4599 Send(new FrameHostMsg_DidStartProvisionalLoad( |
4598 routing_id_, common_params.url, common_params.navigation_start)); | 4600 routing_id_, common_params.url, common_params.navigation_start)); |
4599 | 4601 |
4600 // Send the provisional load failure. | 4602 // Send the provisional load failure. |
4601 blink::WebURLError error = | 4603 blink::WebURLError error = |
4602 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4604 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
4603 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4605 WebURLRequest failed_request = CreateURLRequestForNavigation( |
4604 common_params, scoped_ptr<StreamOverrideParameters>(), | 4606 common_params, scoped_ptr<StreamOverrideParameters>(), |
4605 frame_->isViewSourceModeEnabled()); | 4607 frame_->isViewSourceModeEnabled()); |
4606 SendFailedProvisionalLoad(failed_request, error, frame_); | 4608 SendFailedProvisionalLoad(failed_request, error, frame_); |
4607 | 4609 |
| 4610 // This check should have been done on the browser side already. |
4608 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4611 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
4609 // TODO(avi): Remove this; we shouldn't ever be dropping navigations. | 4612 NOTREACHED(); |
4610 // http://crbug.com/501960 | |
4611 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | |
4612 return; | 4613 return; |
4613 } | 4614 } |
4614 | 4615 |
4615 // Make sure errors are not shown in view source mode. | 4616 // Make sure errors are not shown in view source mode. |
4616 frame_->enableViewSourceMode(false); | 4617 frame_->enableViewSourceMode(false); |
4617 | 4618 |
4618 // Replace the current history entry in reloads, history navigations and loads | 4619 // Replace the current history entry in reloads, history navigations and loads |
4619 // of the same url. This corresponds to Blink's notion of a standard | 4620 // of the same url. This corresponds to Blink's notion of a standard |
4620 // commit. | 4621 // commit. |
4621 // TODO(clamy): see if initial commits in subframes should be handled | 4622 // TODO(clamy): see if initial commits in subframes should be handled |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5145 if (!common_params.base_url_for_data_url.is_empty() || | 5146 if (!common_params.base_url_for_data_url.is_empty() || |
5146 (browser_side_navigation && | 5147 (browser_side_navigation && |
5147 common_params.url.SchemeIs(url::kDataScheme))) { | 5148 common_params.url.SchemeIs(url::kDataScheme))) { |
5148 LoadDataURL(common_params, request_params, frame_, load_type); | 5149 LoadDataURL(common_params, request_params, frame_, load_type); |
5149 } else { | 5150 } else { |
5150 // Load the request. | 5151 // Load the request. |
5151 frame_->toWebLocalFrame()->load(request, load_type, | 5152 frame_->toWebLocalFrame()->load(request, load_type, |
5152 item_for_history_navigation, | 5153 item_for_history_navigation, |
5153 history_load_type); | 5154 history_load_type); |
5154 } | 5155 } |
| 5156 } else { |
| 5157 // The browser expects the frame to be loading this navigation. Inform it |
| 5158 // that the load stopped if needed. |
| 5159 if (!frame_->isLoading()) |
| 5160 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
5155 } | 5161 } |
5156 | 5162 |
5157 // In case LoadRequest failed before didCreateDataSource was called. | 5163 // In case LoadRequest failed before didCreateDataSource was called. |
5158 pending_navigation_params_.reset(); | 5164 pending_navigation_params_.reset(); |
5159 } | 5165 } |
5160 | 5166 |
5161 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, | 5167 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
5162 const std::string& encoding_name) { | 5168 const std::string& encoding_name) { |
5163 // Only update main frame's encoding_name. | 5169 // Only update main frame's encoding_name. |
5164 if (!frame->parent()) | 5170 if (!frame->parent()) |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5726 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5732 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5727 scoped_refptr<media::AudioOutputDevice> device = | 5733 scoped_refptr<media::AudioOutputDevice> device = |
5728 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5734 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5729 security_origin); | 5735 security_origin); |
5730 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5736 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5731 device->Stop(); | 5737 device->Stop(); |
5732 callback.Run(status); | 5738 callback.Run(status); |
5733 } | 5739 } |
5734 | 5740 |
5735 } // namespace content | 5741 } // namespace content |
OLD | NEW |