| 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 common_params.referrer.policy, | 563 common_params.referrer.policy, |
| 564 common_params.url, | 564 common_params.url, |
| 565 WebString::fromUTF8(common_params.referrer.url.spec())); | 565 WebString::fromUTF8(common_params.referrer.url.spec())); |
| 566 if (!web_referrer.isEmpty()) { | 566 if (!web_referrer.isEmpty()) { |
| 567 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 567 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
| 568 request.addHTTPOriginIfNeeded( | 568 request.addHTTPOriginIfNeeded( |
| 569 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 569 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 request.setLoFiState( | 573 request.setPreviewsState( |
| 574 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | 574 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); |
| 575 | 575 |
| 576 RequestExtraData* extra_data = new RequestExtraData(); | 576 RequestExtraData* extra_data = new RequestExtraData(); |
| 577 extra_data->set_stream_override(std::move(stream_override)); | 577 extra_data->set_stream_override(std::move(stream_override)); |
| 578 request.setExtraData(extra_data); | 578 request.setExtraData(extra_data); |
| 579 | 579 |
| 580 // Set the ui timestamp for this navigation. Currently the timestamp here is | 580 // Set the ui timestamp for this navigation. Currently the timestamp here is |
| 581 // only non empty when the navigation was triggered by an Android intent. The | 581 // only non empty when the navigation was triggered by an Android intent. The |
| 582 // timestamp is converted to a double version supported by blink. It will be | 582 // timestamp is converted to a double version supported by blink. It will be |
| 583 // passed back to the browser in the DidCommitProvisionalLoad and the | 583 // passed back to the browser in the DidCommitProvisionalLoad and the |
| 584 // DocumentLoadComplete IPCs. | 584 // DocumentLoadComplete IPCs. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 ? FrameMsg_Navigate_Type::RELOAD | 632 ? FrameMsg_Navigate_Type::RELOAD |
| 633 : FrameMsg_Navigate_Type::NORMAL; | 633 : FrameMsg_Navigate_Type::NORMAL; |
| 634 | 634 |
| 635 const RequestExtraData* extra_data = | 635 const RequestExtraData* extra_data = |
| 636 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 636 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
| 637 DCHECK(extra_data); | 637 DCHECK(extra_data); |
| 638 return CommonNavigationParams( | 638 return CommonNavigationParams( |
| 639 info.urlRequest.url(), referrer, extra_data->transition_type(), | 639 info.urlRequest.url(), referrer, extra_data->transition_type(), |
| 640 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp, | 640 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp, |
| 641 report_type, GURL(), GURL(), | 641 report_type, GURL(), GURL(), |
| 642 static_cast<LoFiState>(info.urlRequest.getLoFiState()), | 642 static_cast<PreviewsState>(info.urlRequest.getPreviewsState()), |
| 643 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 643 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
| 644 GetRequestBodyForWebURLRequest(info.urlRequest)); | 644 GetRequestBodyForWebURLRequest(info.urlRequest)); |
| 645 } | 645 } |
| 646 | 646 |
| 647 media::Context3D GetSharedMainThreadContext3D( | 647 media::Context3D GetSharedMainThreadContext3D( |
| 648 scoped_refptr<ui::ContextProviderCommandBuffer> provider) { | 648 scoped_refptr<ui::ContextProviderCommandBuffer> provider) { |
| 649 if (!provider) | 649 if (!provider) |
| 650 return media::Context3D(); | 650 return media::Context3D(); |
| 651 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 651 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 652 } | 652 } |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 #endif | 1095 #endif |
| 1096 media_surface_manager_(nullptr), | 1096 media_surface_manager_(nullptr), |
| 1097 devtools_agent_(nullptr), | 1097 devtools_agent_(nullptr), |
| 1098 push_messaging_dispatcher_(NULL), | 1098 push_messaging_dispatcher_(NULL), |
| 1099 presentation_dispatcher_(NULL), | 1099 presentation_dispatcher_(NULL), |
| 1100 screen_orientation_dispatcher_(NULL), | 1100 screen_orientation_dispatcher_(NULL), |
| 1101 manifest_manager_(NULL), | 1101 manifest_manager_(NULL), |
| 1102 accessibility_mode_(AccessibilityModeOff), | 1102 accessibility_mode_(AccessibilityModeOff), |
| 1103 render_accessibility_(NULL), | 1103 render_accessibility_(NULL), |
| 1104 media_player_delegate_(NULL), | 1104 media_player_delegate_(NULL), |
| 1105 is_using_lofi_(false), | 1105 previews_state_(PREVIEWS_UNSPECIFIED), |
| 1106 effective_connection_type_( | 1106 effective_connection_type_( |
| 1107 blink::WebEffectiveConnectionType::TypeUnknown), | 1107 blink::WebEffectiveConnectionType::TypeUnknown), |
| 1108 is_pasting_(false), | 1108 is_pasting_(false), |
| 1109 suppress_further_dialogs_(false), | 1109 suppress_further_dialogs_(false), |
| 1110 blame_context_(nullptr), | 1110 blame_context_(nullptr), |
| 1111 #if BUILDFLAG(ENABLE_PLUGINS) | 1111 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1112 focused_pepper_plugin_(nullptr), | 1112 focused_pepper_plugin_(nullptr), |
| 1113 pepper_last_mouse_event_target_(nullptr), | 1113 pepper_last_mouse_event_target_(nullptr), |
| 1114 #endif | 1114 #endif |
| 1115 engagement_binding_(this), | 1115 engagement_binding_(this), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 | 1211 |
| 1212 frame_ = web_frame; | 1212 frame_ = web_frame; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 void RenderFrameImpl::Initialize() { | 1215 void RenderFrameImpl::Initialize() { |
| 1216 is_main_frame_ = !frame_->parent(); | 1216 is_main_frame_ = !frame_->parent(); |
| 1217 | 1217 |
| 1218 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1218 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
| 1219 frame_->parent()); | 1219 frame_->parent()); |
| 1220 if (parent_frame) { | 1220 if (parent_frame) { |
| 1221 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1221 previews_state_ = parent_frame->GetPreviewsState(); |
| 1222 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1222 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool is_tracing_rail = false; | 1225 bool is_tracing_rail = false; |
| 1226 bool is_tracing_navigation = false; | 1226 bool is_tracing_navigation = false; |
| 1227 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1227 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
| 1228 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1228 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
| 1229 if (is_tracing_rail || is_tracing_navigation) { | 1229 if (is_tracing_rail || is_tracing_navigation) { |
| 1230 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1230 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
| 1231 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1231 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 channels); | 2245 channels); |
| 2246 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2246 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
| 2247 } | 2247 } |
| 2248 | 2248 |
| 2249 void RenderFrameImpl::OnReload(bool bypass_cache) { | 2249 void RenderFrameImpl::OnReload(bool bypass_cache) { |
| 2250 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache | 2250 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache |
| 2251 : WebFrameLoadType::ReloadMainResource); | 2251 : WebFrameLoadType::ReloadMainResource); |
| 2252 } | 2252 } |
| 2253 | 2253 |
| 2254 void RenderFrameImpl::OnReloadLoFiImages() { | 2254 void RenderFrameImpl::OnReloadLoFiImages() { |
| 2255 is_using_lofi_ = false; | 2255 previews_state_ = PREVIEWS_OFF; |
| 2256 GetWebFrame()->reloadLoFiImages(); | 2256 GetWebFrame()->reloadLoFiImages(); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { | 2259 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { |
| 2260 blink::WebSurroundingText surroundingText; | 2260 blink::WebSurroundingText surroundingText; |
| 2261 surroundingText.initializeFromCurrentSelection(frame_, max_length); | 2261 surroundingText.initializeFromCurrentSelection(frame_, max_length); |
| 2262 | 2262 |
| 2263 if (surroundingText.isNull()) { | 2263 if (surroundingText.isNull()) { |
| 2264 // |surroundingText| might not be correctly initialized, for example if | 2264 // |surroundingText| might not be correctly initialized, for example if |
| 2265 // |frame_->selectionRange().isNull()|, in other words, if there was no | 2265 // |frame_->selectionRange().isNull()|, in other words, if there was no |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 break; | 2651 break; |
| 2652 case CONSOLE_MESSAGE_LEVEL_ERROR: | 2652 case CONSOLE_MESSAGE_LEVEL_ERROR: |
| 2653 target_level = blink::WebConsoleMessage::LevelError; | 2653 target_level = blink::WebConsoleMessage::LevelError; |
| 2654 break; | 2654 break; |
| 2655 } | 2655 } |
| 2656 | 2656 |
| 2657 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); | 2657 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); |
| 2658 frame_->addMessageToConsole(wcm); | 2658 frame_->addMessageToConsole(wcm); |
| 2659 } | 2659 } |
| 2660 | 2660 |
| 2661 bool RenderFrameImpl::IsUsingLoFi() const { | 2661 PreviewsState RenderFrameImpl::GetPreviewsState() const { |
| 2662 return is_using_lofi_; | 2662 return previews_state_; |
| 2663 } | 2663 } |
| 2664 | 2664 |
| 2665 bool RenderFrameImpl::IsPasting() const { | 2665 bool RenderFrameImpl::IsPasting() const { |
| 2666 return is_pasting_; | 2666 return is_pasting_; |
| 2667 } | 2667 } |
| 2668 | 2668 |
| 2669 // blink::mojom::EngagementClient implementation ------------------------------- | 2669 // blink::mojom::EngagementClient implementation ------------------------------- |
| 2670 | 2670 |
| 2671 void RenderFrameImpl::SetEngagementLevel(const url::Origin& origin, | 2671 void RenderFrameImpl::SetEngagementLevel(const url::Origin& origin, |
| 2672 blink::mojom::EngagementLevel level) { | 2672 blink::mojom::EngagementLevel level) { |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3570 } | 3570 } |
| 3571 committed_first_load_ = true; | 3571 committed_first_load_ = true; |
| 3572 } | 3572 } |
| 3573 | 3573 |
| 3574 DocumentState* document_state = | 3574 DocumentState* document_state = |
| 3575 DocumentState::FromDataSource(frame->dataSource()); | 3575 DocumentState::FromDataSource(frame->dataSource()); |
| 3576 NavigationStateImpl* navigation_state = | 3576 NavigationStateImpl* navigation_state = |
| 3577 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3577 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 3578 WebURLResponseExtraDataImpl* extra_data = | 3578 WebURLResponseExtraDataImpl* extra_data = |
| 3579 GetExtraDataFromResponse(frame->dataSource()->response()); | 3579 GetExtraDataFromResponse(frame->dataSource()->response()); |
| 3580 // Only update the Lo-Fi and effective connection type states for new main | 3580 // Only update the PreviewsState and effective connection type states for new |
| 3581 // frame documents. Subframes inherit from the main frame and should not | 3581 // main frame documents. Subframes inherit from the main frame and should not |
| 3582 // change at commit time. | 3582 // change at commit time. |
| 3583 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3583 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
| 3584 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | 3584 previews_state_ = |
| 3585 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; |
| 3585 if (extra_data) { | 3586 if (extra_data) { |
| 3586 effective_connection_type_ = | 3587 effective_connection_type_ = |
| 3587 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3588 EffectiveConnectionTypeToWebEffectiveConnectionType( |
| 3588 extra_data->effective_connection_type()); | 3589 extra_data->effective_connection_type()); |
| 3589 } | 3590 } |
| 3590 } | 3591 } |
| 3591 | 3592 |
| 3592 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3593 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
| 3593 RenderFrameProxy* proxy = | 3594 RenderFrameProxy* proxy = |
| 3594 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 3595 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4314 request.getFrameType() != WebURLRequest::FrameTypeNone; | 4315 request.getFrameType() != WebURLRequest::FrameTypeNone; |
| 4315 if (is_navigational_request) { | 4316 if (is_navigational_request) { |
| 4316 extra_data->set_transferred_request_child_id( | 4317 extra_data->set_transferred_request_child_id( |
| 4317 navigation_state->start_params().transferred_request_child_id); | 4318 navigation_state->start_params().transferred_request_child_id); |
| 4318 extra_data->set_transferred_request_request_id( | 4319 extra_data->set_transferred_request_request_id( |
| 4319 navigation_state->start_params().transferred_request_request_id); | 4320 navigation_state->start_params().transferred_request_request_id); |
| 4320 } | 4321 } |
| 4321 | 4322 |
| 4322 request.setExtraData(extra_data); | 4323 request.setExtraData(extra_data); |
| 4323 | 4324 |
| 4324 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { | 4325 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { |
| 4325 if (is_main_frame_ && !navigation_state->request_committed()) { | 4326 if (is_main_frame_ && !navigation_state->request_committed()) { |
| 4326 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( | 4327 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( |
| 4327 navigation_state->common_params().lofi_state)); | 4328 navigation_state->common_params().previews_state)); |
| 4328 } else { | 4329 } else { |
| 4329 request.setLoFiState( | 4330 request.setPreviewsState( |
| 4330 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); | 4331 previews_state_ == PREVIEWS_UNSPECIFIED |
| 4332 ? WebURLRequest::PreviewsOff |
| 4333 : static_cast<WebURLRequest::PreviewsState>(previews_state_)); |
| 4331 } | 4334 } |
| 4332 } | 4335 } |
| 4333 | 4336 |
| 4334 // This is an instance where we embed a copy of the routing id | 4337 // This is an instance where we embed a copy of the routing id |
| 4335 // into the data portion of the message. This can cause problems if we | 4338 // into the data portion of the message. This can cause problems if we |
| 4336 // don't register this id on the browser side, since the download manager | 4339 // don't register this id on the browser side, since the download manager |
| 4337 // expects to find a RenderViewHost based off the id. | 4340 // expects to find a RenderViewHost based off the id. |
| 4338 request.setRequestorID(render_view_->GetRoutingID()); | 4341 request.setRequestorID(render_view_->GetRoutingID()); |
| 4339 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 4342 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
| 4340 | 4343 |
| (...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6785 // event target. Potentially a Pepper plugin will receive the event. | 6788 // event target. Potentially a Pepper plugin will receive the event. |
| 6786 // In order to tell whether a plugin gets the last mouse event and which it | 6789 // In order to tell whether a plugin gets the last mouse event and which it |
| 6787 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6790 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6788 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6791 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6789 // |pepper_last_mouse_event_target_|. | 6792 // |pepper_last_mouse_event_target_|. |
| 6790 pepper_last_mouse_event_target_ = nullptr; | 6793 pepper_last_mouse_event_target_ = nullptr; |
| 6791 #endif | 6794 #endif |
| 6792 } | 6795 } |
| 6793 | 6796 |
| 6794 } // namespace content | 6797 } // namespace content |
| OLD | NEW |