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 3702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3713 // Attach |should_replace_current_entry| state to requests so that, should | 3713 // Attach |should_replace_current_entry| state to requests so that, should |
3714 // this navigation later require a request transfer, all state is preserved | 3714 // this navigation later require a request transfer, all state is preserved |
3715 // when it is re-created in the new process. | 3715 // when it is re-created in the new process. |
3716 bool should_replace_current_entry = false; | 3716 bool should_replace_current_entry = false; |
3717 if (navigation_state->IsContentInitiated()) { | 3717 if (navigation_state->IsContentInitiated()) { |
3718 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 3718 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
3719 } else { | 3719 } else { |
3720 // If the navigation is browser-initiated, the NavigationState contains the | 3720 // If the navigation is browser-initiated, the NavigationState contains the |
3721 // correct value instead of the WebDataSource. | 3721 // correct value instead of the WebDataSource. |
3722 // | 3722 // |
3723 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 3723 // TODO(creis): Remove should_replace_current_entry from NavigationState |
3724 // NavigationState::should_replace_current_entry(). | 3724 // once we verify this is correct, since the WebDataSource should now be |
| 3725 // correct. Currently failing in NewAndAutoSubframe test with CHECK_EQ. |
| 3726 CHECK( |
| 3727 !navigation_state->common_params().should_replace_current_entry || |
| 3728 data_source->replacesCurrentHistoryItem()); |
3725 should_replace_current_entry = | 3729 should_replace_current_entry = |
3726 navigation_state->common_params().should_replace_current_entry; | 3730 navigation_state->common_params().should_replace_current_entry; |
3727 } | 3731 } |
3728 | 3732 |
3729 int provider_id = kInvalidServiceWorkerProviderId; | 3733 int provider_id = kInvalidServiceWorkerProviderId; |
3730 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3734 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || |
3731 request.frameType() == blink::WebURLRequest::FrameTypeNested) { | 3735 request.frameType() == blink::WebURLRequest::FrameTypeNested) { |
3732 // |provisionalDataSource| may be null in some content::ResourceFetcher | 3736 // |provisionalDataSource| may be null in some content::ResourceFetcher |
3733 // use cases, we don't hook those requests. | 3737 // use cases, we don't hook those requests. |
3734 if (frame->provisionalDataSource()) { | 3738 if (frame->provisionalDataSource()) { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4375 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4379 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
4376 InternalDocumentStateData* internal_data = | 4380 InternalDocumentStateData* internal_data = |
4377 InternalDocumentStateData::FromDocumentState(document_state); | 4381 InternalDocumentStateData::FromDocumentState(document_state); |
4378 | 4382 |
4379 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4383 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4380 params.http_status_code = response.httpStatusCode(); | 4384 params.http_status_code = response.httpStatusCode(); |
4381 params.url_is_unreachable = ds->hasUnreachableURL(); | 4385 params.url_is_unreachable = ds->hasUnreachableURL(); |
4382 params.is_post = false; | 4386 params.is_post = false; |
4383 params.intended_as_new_entry = | 4387 params.intended_as_new_entry = |
4384 navigation_state->request_params().intended_as_new_entry; | 4388 navigation_state->request_params().intended_as_new_entry; |
4385 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4389 // We create a new entry for standard commits, as well as location.replace |
| 4390 // navigations that replace the current entry with a different document. |
| 4391 params.did_create_new_entry = commit_type == blink::WebStandardCommit || |
| 4392 (ds->replacesCurrentHistoryItem() && |
| 4393 !navigation_state->WasWithinSamePage()); |
| 4394 CHECK(!navigation_state->common_params().should_replace_current_entry || |
| 4395 ds->replacesCurrentHistoryItem()); |
| 4396 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
4386 params.post_id = -1; | 4397 params.post_id = -1; |
4387 params.page_id = render_view_->page_id_; | 4398 params.page_id = render_view_->page_id_; |
4388 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4399 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
4389 // We need to track the RenderViewHost routing_id because of downstream | 4400 // We need to track the RenderViewHost routing_id because of downstream |
4390 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 4401 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
4391 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 4402 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
4392 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 4403 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
4393 // based on the ID stored in the resource requests. Once those dependencies | 4404 // based on the ID stored in the resource requests. Once those dependencies |
4394 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 4405 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
4395 // client to be based on the routing_id of the RenderFrameHost. | 4406 // client to be based on the routing_id of the RenderFrameHost. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4544 // This message needs to be sent before any of allowScripts(), | 4555 // This message needs to be sent before any of allowScripts(), |
4545 // allowImages(), allowPlugins() is called for the new page, so that when | 4556 // allowImages(), allowPlugins() is called for the new page, so that when |
4546 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 4557 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
4547 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 4558 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
4548 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 4559 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
4549 } else { | 4560 } else { |
4550 // Subframe navigation: the type depends on whether this navigation | 4561 // Subframe navigation: the type depends on whether this navigation |
4551 // generated a new session history entry. When they do generate a session | 4562 // generated a new session history entry. When they do generate a session |
4552 // history entry, it means the user initiated the navigation and we should | 4563 // history entry, it means the user initiated the navigation and we should |
4553 // mark it as such. | 4564 // mark it as such. |
4554 if (commit_type == blink::WebStandardCommit) | 4565 if (params.did_create_new_entry) |
4555 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 4566 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
4556 else | 4567 else |
4557 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 4568 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
4558 | 4569 |
4559 DCHECK(!navigation_state->request_params().should_clear_history_list); | 4570 DCHECK(!navigation_state->request_params().should_clear_history_list); |
4560 params.history_list_was_cleared = false; | 4571 params.history_list_was_cleared = false; |
4561 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; | 4572 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; |
4562 | 4573 |
4563 // Don't send this message while the subframe is swapped out. | 4574 // Don't send this message while the subframe is swapped out. |
4564 if (!is_swapped_out()) | 4575 if (!is_swapped_out()) |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4965 bool is_history_navigation_in_new_child) { | 4976 bool is_history_navigation_in_new_child) { |
4966 FrameHostMsg_OpenURL_Params params; | 4977 FrameHostMsg_OpenURL_Params params; |
4967 params.url = url; | 4978 params.url = url; |
4968 params.referrer = referrer; | 4979 params.referrer = referrer; |
4969 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 4980 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
4970 | 4981 |
4971 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 4982 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
4972 // This is necessary to preserve the should_replace_current_entry value on | 4983 // This is necessary to preserve the should_replace_current_entry value on |
4973 // cross-process redirects, in the event it was set by a previous process. | 4984 // cross-process redirects, in the event it was set by a previous process. |
4974 // | 4985 // |
4975 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 4986 // TODO(creis): Remove should_replace_current_entry from NavigationState |
4976 // NavigationState::should_replace_current_entry(). | 4987 // once we verify this is correct, since the WebDataSource should now be |
| 4988 // correct. |
| 4989 WebDataSource* ds = frame_->provisionalDataSource(); |
| 4990 if (ds) { |
| 4991 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 4992 NavigationStateImpl* navigation_state = |
| 4993 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 4994 CHECK_EQ(navigation_state->common_params().should_replace_current_entry, |
| 4995 ds->replacesCurrentHistoryItem()); |
| 4996 } |
4977 params.should_replace_current_entry = | 4997 params.should_replace_current_entry = |
4978 pending_navigation_params_->common_params.should_replace_current_entry; | 4998 pending_navigation_params_->common_params.should_replace_current_entry; |
4979 } else { | 4999 } else { |
4980 params.should_replace_current_entry = | 5000 params.should_replace_current_entry = |
4981 should_replace_current_entry && render_view_->history_list_length_; | 5001 should_replace_current_entry && render_view_->history_list_length_; |
4982 } | 5002 } |
4983 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 5003 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
4984 if (GetContentClient()->renderer()->AllowPopup()) | 5004 if (GetContentClient()->renderer()->AllowPopup()) |
4985 params.user_gesture = true; | 5005 params.user_gesture = true; |
4986 | 5006 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5053 base::TimeTicks(); | 5073 base::TimeTicks(); |
5054 | 5074 |
5055 // Unless the load is a WebFrameLoadType::Standard, this should remain | 5075 // Unless the load is a WebFrameLoadType::Standard, this should remain |
5056 // uninitialized. It will be updated when the load type is determined to be | 5076 // uninitialized. It will be updated when the load type is determined to be |
5057 // Standard, or after the previous document's unload handler has been | 5077 // Standard, or after the previous document's unload handler has been |
5058 // triggered. This occurs in UpdateNavigationState. | 5078 // triggered. This occurs in UpdateNavigationState. |
5059 // TODO(csharrison) See if we can always use the browser timestamp. | 5079 // TODO(csharrison) See if we can always use the browser timestamp. |
5060 pending_navigation_params_->common_params.navigation_start = | 5080 pending_navigation_params_->common_params.navigation_start = |
5061 base::TimeTicks(); | 5081 base::TimeTicks(); |
5062 | 5082 |
5063 // Create parameters for a standard navigation. | 5083 // Create parameters for a standard navigation, indicating whether it should |
5064 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 5084 // replace the current NavigationEntry. |
| 5085 blink::WebFrameLoadType load_type = |
| 5086 common_params.should_replace_current_entry ? |
| 5087 blink::WebFrameLoadType::ReplaceCurrentItem : |
| 5088 blink::WebFrameLoadType::Standard; |
5065 blink::WebHistoryLoadType history_load_type = | 5089 blink::WebHistoryLoadType history_load_type = |
5066 blink::WebHistoryDifferentDocumentLoad; | 5090 blink::WebHistoryDifferentDocumentLoad; |
5067 bool should_load_request = false; | 5091 bool should_load_request = false; |
5068 WebHistoryItem item_for_history_navigation; | 5092 WebHistoryItem item_for_history_navigation; |
5069 WebURLRequest request = | 5093 WebURLRequest request = |
5070 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5094 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5071 frame_->isViewSourceModeEnabled()); | 5095 frame_->isViewSourceModeEnabled()); |
5072 #if defined(OS_ANDROID) | 5096 #if defined(OS_ANDROID) |
5073 request.setHasUserGesture(start_params.has_user_gesture); | 5097 request.setHasUserGesture(start_params.has_user_gesture); |
5074 #endif | 5098 #endif |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5772 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5796 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5773 scoped_refptr<media::AudioOutputDevice> device = | 5797 scoped_refptr<media::AudioOutputDevice> device = |
5774 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5798 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5775 security_origin); | 5799 security_origin); |
5776 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5800 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5777 device->Stop(); | 5801 device->Stop(); |
5778 callback.Run(status); | 5802 callback.Run(status); |
5779 } | 5803 } |
5780 | 5804 |
5781 } // namespace content | 5805 } // namespace content |
OLD | NEW |