| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (common_params.referrer.url.is_valid()) { | 529 if (common_params.referrer.url.is_valid()) { |
| 530 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 530 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
| 531 common_params.referrer.policy, | 531 common_params.referrer.policy, |
| 532 common_params.url, | 532 common_params.url, |
| 533 WebString::fromUTF8(common_params.referrer.url.spec())); | 533 WebString::fromUTF8(common_params.referrer.url.spec())); |
| 534 if (!web_referrer.isEmpty()) | 534 if (!web_referrer.isEmpty()) |
| 535 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 535 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
| 536 } | 536 } |
| 537 | 537 |
| 538 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); | 538 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); |
| 539 request.setLoFiState( |
| 540 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); |
| 539 | 541 |
| 540 RequestExtraData* extra_data = new RequestExtraData(); | 542 RequestExtraData* extra_data = new RequestExtraData(); |
| 541 extra_data->set_stream_override(std::move(stream_override)); | 543 extra_data->set_stream_override(std::move(stream_override)); |
| 542 extra_data->set_lofi_state(common_params.lofi_state); | |
| 543 request.setExtraData(extra_data); | 544 request.setExtraData(extra_data); |
| 544 | 545 |
| 545 // Set the ui timestamp for this navigation. Currently the timestamp here is | 546 // Set the ui timestamp for this navigation. Currently the timestamp here is |
| 546 // only non empty when the navigation was triggered by an Android intent. The | 547 // only non empty when the navigation was triggered by an Android intent. The |
| 547 // timestamp is converted to a double version supported by blink. It will be | 548 // timestamp is converted to a double version supported by blink. It will be |
| 548 // passed back to the browser in the DidCommitProvisionalLoad and the | 549 // passed back to the browser in the DidCommitProvisionalLoad and the |
| 549 // DocumentLoadComplete IPCs. | 550 // DocumentLoadComplete IPCs. |
| 550 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 551 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
| 551 request.setUiStartTime(ui_timestamp.InSecondsF()); | 552 request.setUiStartTime(ui_timestamp.InSecondsF()); |
| 552 request.setInputPerfMetricReportPolicy( | 553 request.setInputPerfMetricReportPolicy( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 FrameMsg_UILoadMetricsReportType::Value report_type = | 605 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 605 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 606 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 606 request->inputPerfMetricReportPolicy()); | 607 request->inputPerfMetricReportPolicy()); |
| 607 | 608 |
| 608 const RequestExtraData* extra_data = | 609 const RequestExtraData* extra_data = |
| 609 static_cast<RequestExtraData*>(request->getExtraData()); | 610 static_cast<RequestExtraData*>(request->getExtraData()); |
| 610 DCHECK(extra_data); | 611 DCHECK(extra_data); |
| 611 return CommonNavigationParams( | 612 return CommonNavigationParams( |
| 612 request->url(), referrer, extra_data->transition_type(), | 613 request->url(), referrer, extra_data->transition_type(), |
| 613 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, | 614 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, |
| 614 ui_timestamp, report_type, GURL(), GURL(), extra_data->lofi_state(), | 615 ui_timestamp, report_type, GURL(), GURL(), |
| 615 base::TimeTicks::Now(), request->httpMethod().latin1(), | 616 static_cast<LoFiState>(request->getLoFiState()), base::TimeTicks::Now(), |
| 616 GetRequestBodyForWebURLRequest(*request)); | 617 request->httpMethod().latin1(), GetRequestBodyForWebURLRequest(*request)); |
| 617 } | 618 } |
| 618 | 619 |
| 619 media::Context3D GetSharedMainThreadContext3D( | 620 media::Context3D GetSharedMainThreadContext3D( |
| 620 scoped_refptr<ContextProviderCommandBuffer> provider) { | 621 scoped_refptr<ContextProviderCommandBuffer> provider) { |
| 621 if (!provider) | 622 if (!provider) |
| 622 return media::Context3D(); | 623 return media::Context3D(); |
| 623 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 624 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 624 } | 625 } |
| 625 | 626 |
| 626 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { | 627 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 IPC_MESSAGE_HANDLER(FrameMsg_AddMessageToConsole, OnAddMessageToConsole) | 1520 IPC_MESSAGE_HANDLER(FrameMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 1520 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, | 1521 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, |
| 1521 OnJavaScriptExecuteRequest) | 1522 OnJavaScriptExecuteRequest) |
| 1522 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequestForTests, | 1523 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequestForTests, |
| 1523 OnJavaScriptExecuteRequestForTests) | 1524 OnJavaScriptExecuteRequestForTests) |
| 1524 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequestInIsolatedWorld, | 1525 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequestInIsolatedWorld, |
| 1525 OnJavaScriptExecuteRequestInIsolatedWorld) | 1526 OnJavaScriptExecuteRequestInIsolatedWorld) |
| 1526 IPC_MESSAGE_HANDLER(FrameMsg_VisualStateRequest, | 1527 IPC_MESSAGE_HANDLER(FrameMsg_VisualStateRequest, |
| 1527 OnVisualStateRequest) | 1528 OnVisualStateRequest) |
| 1528 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) | 1529 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) |
| 1530 IPC_MESSAGE_HANDLER(FrameMsg_DisableLoFiImages, OnDisableLoFiImages) |
| 1529 IPC_MESSAGE_HANDLER(FrameMsg_ReloadLoFiImages, OnReloadLoFiImages) | 1531 IPC_MESSAGE_HANDLER(FrameMsg_ReloadLoFiImages, OnReloadLoFiImages) |
| 1530 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, | 1532 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, |
| 1531 OnTextSurroundingSelectionRequest) | 1533 OnTextSurroundingSelectionRequest) |
| 1532 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, | 1534 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, |
| 1533 OnSetAccessibilityMode) | 1535 OnSetAccessibilityMode) |
| 1534 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, | 1536 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, |
| 1535 OnSnapshotAccessibilityTree) | 1537 OnSnapshotAccessibilityTree) |
| 1536 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) | 1538 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) |
| 1537 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) | 1539 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) |
| 1538 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) | 1540 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 frame_->document(), | 2220 frame_->document(), |
| 2219 channels); | 2221 channels); |
| 2220 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2222 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
| 2221 } | 2223 } |
| 2222 | 2224 |
| 2223 void RenderFrameImpl::OnReload(bool bypass_cache) { | 2225 void RenderFrameImpl::OnReload(bool bypass_cache) { |
| 2224 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache | 2226 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache |
| 2225 : WebFrameLoadType::Reload); | 2227 : WebFrameLoadType::Reload); |
| 2226 } | 2228 } |
| 2227 | 2229 |
| 2230 void RenderFrameImpl::OnDisableLoFiImages() { |
| 2231 is_using_lofi_ = false; |
| 2232 } |
| 2233 |
| 2228 void RenderFrameImpl::OnReloadLoFiImages() { | 2234 void RenderFrameImpl::OnReloadLoFiImages() { |
| 2229 is_using_lofi_ = false; | |
| 2230 GetWebFrame()->reloadLoFiImages(); | 2235 GetWebFrame()->reloadLoFiImages(); |
| 2231 } | 2236 } |
| 2232 | 2237 |
| 2233 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { | 2238 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { |
| 2234 blink::WebSurroundingText surroundingText; | 2239 blink::WebSurroundingText surroundingText; |
| 2235 surroundingText.initialize(frame_->selectionRange(), max_length); | 2240 surroundingText.initialize(frame_->selectionRange(), max_length); |
| 2236 | 2241 |
| 2237 if (surroundingText.isNull()) { | 2242 if (surroundingText.isNull()) { |
| 2238 // |surroundingText| might not be correctly initialized, for example if | 2243 // |surroundingText| might not be correctly initialized, for example if |
| 2239 // |frame_->selectionRange().isNull()|, in other words, if there was no | 2244 // |frame_->selectionRange().isNull()|, in other words, if there was no |
| (...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4051 extra_data->set_allow_download( | 4056 extra_data->set_allow_download( |
| 4052 navigation_state->common_params().allow_download); | 4057 navigation_state->common_params().allow_download); |
| 4053 extra_data->set_transition_type(transition_type); | 4058 extra_data->set_transition_type(transition_type); |
| 4054 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 4059 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
| 4055 extra_data->set_transferred_request_child_id( | 4060 extra_data->set_transferred_request_child_id( |
| 4056 navigation_state->start_params().transferred_request_child_id); | 4061 navigation_state->start_params().transferred_request_child_id); |
| 4057 extra_data->set_transferred_request_request_id( | 4062 extra_data->set_transferred_request_request_id( |
| 4058 navigation_state->start_params().transferred_request_request_id); | 4063 navigation_state->start_params().transferred_request_request_id); |
| 4059 extra_data->set_service_worker_provider_id(provider_id); | 4064 extra_data->set_service_worker_provider_id(provider_id); |
| 4060 extra_data->set_stream_override(std::move(stream_override)); | 4065 extra_data->set_stream_override(std::move(stream_override)); |
| 4061 if (request.getLoFiState() != WebURLRequest::LoFiUnspecified) | |
| 4062 extra_data->set_lofi_state(static_cast<LoFiState>(request.getLoFiState())); | |
| 4063 else if (is_main_frame_ && !navigation_state->request_committed()) | |
| 4064 extra_data->set_lofi_state(navigation_state->common_params().lofi_state); | |
| 4065 else | |
| 4066 extra_data->set_lofi_state(is_using_lofi_ ? LOFI_ON : LOFI_OFF); | |
| 4067 WebString error; | 4066 WebString error; |
| 4068 extra_data->set_initiated_in_secure_context( | 4067 extra_data->set_initiated_in_secure_context( |
| 4069 frame->document().isSecureContext(error)); | 4068 frame->document().isSecureContext(error)); |
| 4070 request.setExtraData(extra_data); | 4069 request.setExtraData(extra_data); |
| 4071 | 4070 |
| 4071 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { |
| 4072 if (is_main_frame_ && !navigation_state->request_committed()) { |
| 4073 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( |
| 4074 navigation_state->common_params().lofi_state)); |
| 4075 } else { |
| 4076 request.setLoFiState( |
| 4077 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); |
| 4078 } |
| 4079 } |
| 4080 |
| 4072 // TODO(creis): Update prefetching to work with out-of-process iframes. | 4081 // TODO(creis): Update prefetching to work with out-of-process iframes. |
| 4073 WebFrame* top_frame = frame->top(); | 4082 WebFrame* top_frame = frame->top(); |
| 4074 if (top_frame && top_frame->isWebLocalFrame()) { | 4083 if (top_frame && top_frame->isWebLocalFrame()) { |
| 4075 DocumentState* top_document_state = | 4084 DocumentState* top_document_state = |
| 4076 DocumentState::FromDataSource(top_frame->dataSource()); | 4085 DocumentState::FromDataSource(top_frame->dataSource()); |
| 4077 if (top_document_state) { | 4086 if (top_document_state) { |
| 4078 // TODO(gavinp): separate out prefetching and prerender field trials | 4087 // TODO(gavinp): separate out prefetching and prerender field trials |
| 4079 // if the rel=prerender rel type is sticking around. | 4088 // if the rel=prerender rel type is sticking around. |
| 4080 if (request.getRequestContext() == WebURLRequest::RequestContextPrefetch) | 4089 if (request.getRequestContext() == WebURLRequest::RequestContextPrefetch) |
| 4081 top_document_state->set_was_prefetcher(true); | 4090 top_document_state->set_was_prefetcher(true); |
| (...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6328 // event target. Potentially a Pepper plugin will receive the event. | 6337 // event target. Potentially a Pepper plugin will receive the event. |
| 6329 // In order to tell whether a plugin gets the last mouse event and which it | 6338 // In order to tell whether a plugin gets the last mouse event and which it |
| 6330 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6339 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6331 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6340 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6332 // |pepper_last_mouse_event_target_|. | 6341 // |pepper_last_mouse_event_target_|. |
| 6333 pepper_last_mouse_event_target_ = nullptr; | 6342 pepper_last_mouse_event_target_ = nullptr; |
| 6334 #endif | 6343 #endif |
| 6335 } | 6344 } |
| 6336 | 6345 |
| 6337 } // namespace content | 6346 } // namespace content |
| OLD | NEW |