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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 common_params.referrer.policy, | 561 common_params.referrer.policy, |
562 common_params.url, | 562 common_params.url, |
563 WebString::fromUTF8(common_params.referrer.url.spec())); | 563 WebString::fromUTF8(common_params.referrer.url.spec())); |
564 if (!web_referrer.isEmpty()) { | 564 if (!web_referrer.isEmpty()) { |
565 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 565 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
566 request.addHTTPOriginIfNeeded( | 566 request.addHTTPOriginIfNeeded( |
567 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 567 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
568 } | 568 } |
569 } | 569 } |
570 | 570 |
571 request.setLoFiState( | 571 request.setPreviewsState( |
572 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | 572 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); |
573 | 573 |
574 RequestExtraData* extra_data = new RequestExtraData(); | 574 RequestExtraData* extra_data = new RequestExtraData(); |
575 extra_data->set_stream_override(std::move(stream_override)); | 575 extra_data->set_stream_override(std::move(stream_override)); |
576 request.setExtraData(extra_data); | 576 request.setExtraData(extra_data); |
577 | 577 |
578 // Set the ui timestamp for this navigation. Currently the timestamp here is | 578 // Set the ui timestamp for this navigation. Currently the timestamp here is |
579 // only non empty when the navigation was triggered by an Android intent. The | 579 // only non empty when the navigation was triggered by an Android intent. The |
580 // timestamp is converted to a double version supported by blink. It will be | 580 // timestamp is converted to a double version supported by blink. It will be |
581 // passed back to the browser in the DidCommitProvisionalLoad and the | 581 // passed back to the browser in the DidCommitProvisionalLoad and the |
582 // DocumentLoadComplete IPCs. | 582 // DocumentLoadComplete IPCs. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 NavigationGesture gesture = info.urlRequest.hasUserGesture() | 644 NavigationGesture gesture = info.urlRequest.hasUserGesture() |
645 ? NavigationGestureUser | 645 ? NavigationGestureUser |
646 : NavigationGestureAuto; | 646 : NavigationGestureAuto; |
647 const RequestExtraData* extra_data = | 647 const RequestExtraData* extra_data = |
648 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 648 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
649 DCHECK(extra_data); | 649 DCHECK(extra_data); |
650 return CommonNavigationParams( | 650 return CommonNavigationParams( |
651 info.urlRequest.url(), referrer, extra_data->transition_type(), | 651 info.urlRequest.url(), referrer, extra_data->transition_type(), |
652 navigation_type, gesture, true, info.replacesCurrentHistoryItem, | 652 navigation_type, gesture, true, info.replacesCurrentHistoryItem, |
653 ui_timestamp, report_type, GURL(), GURL(), | 653 ui_timestamp, report_type, GURL(), GURL(), |
654 static_cast<LoFiState>(info.urlRequest.getLoFiState()), | 654 static_cast<PreviewsState>(info.urlRequest.getPreviewsState()), |
655 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 655 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
656 GetRequestBodyForWebURLRequest(info.urlRequest)); | 656 GetRequestBodyForWebURLRequest(info.urlRequest)); |
657 } | 657 } |
658 | 658 |
659 media::Context3D GetSharedMainThreadContext3D( | 659 media::Context3D GetSharedMainThreadContext3D( |
660 scoped_refptr<ContextProviderCommandBuffer> provider) { | 660 scoped_refptr<ContextProviderCommandBuffer> provider) { |
661 if (!provider) | 661 if (!provider) |
662 return media::Context3D(); | 662 return media::Context3D(); |
663 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 663 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
664 } | 664 } |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 #endif | 1107 #endif |
1108 media_surface_manager_(nullptr), | 1108 media_surface_manager_(nullptr), |
1109 devtools_agent_(nullptr), | 1109 devtools_agent_(nullptr), |
1110 push_messaging_dispatcher_(NULL), | 1110 push_messaging_dispatcher_(NULL), |
1111 presentation_dispatcher_(NULL), | 1111 presentation_dispatcher_(NULL), |
1112 screen_orientation_dispatcher_(NULL), | 1112 screen_orientation_dispatcher_(NULL), |
1113 manifest_manager_(NULL), | 1113 manifest_manager_(NULL), |
1114 accessibility_mode_(AccessibilityModeOff), | 1114 accessibility_mode_(AccessibilityModeOff), |
1115 render_accessibility_(NULL), | 1115 render_accessibility_(NULL), |
1116 media_player_delegate_(NULL), | 1116 media_player_delegate_(NULL), |
1117 is_using_lofi_(false), | 1117 previews_state_(PREVIEWS_UNSPECIFIED), |
1118 effective_connection_type_( | 1118 effective_connection_type_( |
1119 blink::WebEffectiveConnectionType::TypeUnknown), | 1119 blink::WebEffectiveConnectionType::TypeUnknown), |
1120 is_pasting_(false), | 1120 is_pasting_(false), |
1121 suppress_further_dialogs_(false), | 1121 suppress_further_dialogs_(false), |
1122 blame_context_(nullptr), | 1122 blame_context_(nullptr), |
1123 #if BUILDFLAG(ENABLE_PLUGINS) | 1123 #if BUILDFLAG(ENABLE_PLUGINS) |
1124 focused_pepper_plugin_(nullptr), | 1124 focused_pepper_plugin_(nullptr), |
1125 pepper_last_mouse_event_target_(nullptr), | 1125 pepper_last_mouse_event_target_(nullptr), |
1126 #endif | 1126 #endif |
1127 frame_binding_(this), | 1127 frame_binding_(this), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 | 1223 |
1224 frame_ = web_frame; | 1224 frame_ = web_frame; |
1225 } | 1225 } |
1226 | 1226 |
1227 void RenderFrameImpl::Initialize() { | 1227 void RenderFrameImpl::Initialize() { |
1228 is_main_frame_ = !frame_->parent(); | 1228 is_main_frame_ = !frame_->parent(); |
1229 | 1229 |
1230 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1230 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
1231 frame_->parent()); | 1231 frame_->parent()); |
1232 if (parent_frame) { | 1232 if (parent_frame) { |
1233 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1233 previews_state_ = parent_frame->GetPreviewsState(); |
1234 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1234 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
1235 } | 1235 } |
1236 | 1236 |
1237 bool is_tracing_rail = false; | 1237 bool is_tracing_rail = false; |
1238 bool is_tracing_navigation = false; | 1238 bool is_tracing_navigation = false; |
1239 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1239 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1240 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1240 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1241 if (is_tracing_rail || is_tracing_navigation) { | 1241 if (is_tracing_rail || is_tracing_navigation) { |
1242 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1242 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
1243 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1243 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 channels); | 2259 channels); |
2260 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2260 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
2261 } | 2261 } |
2262 | 2262 |
2263 void RenderFrameImpl::OnReload(bool bypass_cache) { | 2263 void RenderFrameImpl::OnReload(bool bypass_cache) { |
2264 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache | 2264 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache |
2265 : WebFrameLoadType::ReloadMainResource); | 2265 : WebFrameLoadType::ReloadMainResource); |
2266 } | 2266 } |
2267 | 2267 |
2268 void RenderFrameImpl::OnReloadLoFiImages() { | 2268 void RenderFrameImpl::OnReloadLoFiImages() { |
2269 is_using_lofi_ = false; | 2269 previews_state_ = PREVIEWS_OFF; |
2270 GetWebFrame()->reloadLoFiImages(); | 2270 GetWebFrame()->reloadLoFiImages(); |
2271 } | 2271 } |
2272 | 2272 |
2273 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { | 2273 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { |
2274 blink::WebSurroundingText surroundingText; | 2274 blink::WebSurroundingText surroundingText; |
2275 surroundingText.initializeFromCurrentSelection(frame_, max_length); | 2275 surroundingText.initializeFromCurrentSelection(frame_, max_length); |
2276 | 2276 |
2277 if (surroundingText.isNull()) { | 2277 if (surroundingText.isNull()) { |
2278 // |surroundingText| might not be correctly initialized, for example if | 2278 // |surroundingText| might not be correctly initialized, for example if |
2279 // |frame_->selectionRange().isNull()|, in other words, if there was no | 2279 // |frame_->selectionRange().isNull()|, in other words, if there was no |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2650 break; | 2650 break; |
2651 case CONSOLE_MESSAGE_LEVEL_ERROR: | 2651 case CONSOLE_MESSAGE_LEVEL_ERROR: |
2652 target_level = blink::WebConsoleMessage::LevelError; | 2652 target_level = blink::WebConsoleMessage::LevelError; |
2653 break; | 2653 break; |
2654 } | 2654 } |
2655 | 2655 |
2656 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); | 2656 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); |
2657 frame_->addMessageToConsole(wcm); | 2657 frame_->addMessageToConsole(wcm); |
2658 } | 2658 } |
2659 | 2659 |
2660 bool RenderFrameImpl::IsUsingLoFi() const { | 2660 PreviewsState RenderFrameImpl::GetPreviewsState() const { |
2661 return is_using_lofi_; | 2661 return previews_state_; |
2662 } | 2662 } |
2663 | 2663 |
2664 bool RenderFrameImpl::IsPasting() const { | 2664 bool RenderFrameImpl::IsPasting() const { |
2665 return is_pasting_; | 2665 return is_pasting_; |
2666 } | 2666 } |
2667 | 2667 |
2668 // mojom::Frame implementation ------------------------------------------------- | 2668 // mojom::Frame implementation ------------------------------------------------- |
2669 | 2669 |
2670 void RenderFrameImpl::GetInterfaceProvider( | 2670 void RenderFrameImpl::GetInterfaceProvider( |
2671 service_manager::mojom::InterfaceProviderRequest request) { | 2671 service_manager::mojom::InterfaceProviderRequest request) { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3539 } | 3539 } |
3540 committed_first_load_ = true; | 3540 committed_first_load_ = true; |
3541 } | 3541 } |
3542 | 3542 |
3543 DocumentState* document_state = | 3543 DocumentState* document_state = |
3544 DocumentState::FromDataSource(frame->dataSource()); | 3544 DocumentState::FromDataSource(frame->dataSource()); |
3545 NavigationStateImpl* navigation_state = | 3545 NavigationStateImpl* navigation_state = |
3546 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3546 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3547 WebURLResponseExtraDataImpl* extra_data = | 3547 WebURLResponseExtraDataImpl* extra_data = |
3548 GetExtraDataFromResponse(frame->dataSource()->response()); | 3548 GetExtraDataFromResponse(frame->dataSource()->response()); |
3549 // Only update the Lo-Fi and effective connection type states for new main | 3549 // Only update the PreviewsState and effective connection type states for new |
3550 // frame documents. Subframes inherit from the main frame and should not | 3550 // main frame documents. Subframes inherit from the main frame and should not |
3551 // change at commit time. | 3551 // change at commit time. |
3552 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3552 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
3553 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | 3553 previews_state_ = |
| 3554 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; |
3554 if (extra_data) { | 3555 if (extra_data) { |
3555 effective_connection_type_ = | 3556 effective_connection_type_ = |
3556 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3557 EffectiveConnectionTypeToWebEffectiveConnectionType( |
3557 extra_data->effective_connection_type()); | 3558 extra_data->effective_connection_type()); |
3558 } | 3559 } |
3559 } | 3560 } |
3560 | 3561 |
3561 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3562 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
3562 RenderFrameProxy* proxy = | 3563 RenderFrameProxy* proxy = |
3563 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 3564 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4284 request.getFrameType() != WebURLRequest::FrameTypeNone; | 4285 request.getFrameType() != WebURLRequest::FrameTypeNone; |
4285 if (is_navigational_request) { | 4286 if (is_navigational_request) { |
4286 extra_data->set_transferred_request_child_id( | 4287 extra_data->set_transferred_request_child_id( |
4287 navigation_state->start_params().transferred_request_child_id); | 4288 navigation_state->start_params().transferred_request_child_id); |
4288 extra_data->set_transferred_request_request_id( | 4289 extra_data->set_transferred_request_request_id( |
4289 navigation_state->start_params().transferred_request_request_id); | 4290 navigation_state->start_params().transferred_request_request_id); |
4290 } | 4291 } |
4291 | 4292 |
4292 request.setExtraData(extra_data); | 4293 request.setExtraData(extra_data); |
4293 | 4294 |
4294 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { | 4295 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { |
4295 if (is_main_frame_ && !navigation_state->request_committed()) { | 4296 if (is_main_frame_ && !navigation_state->request_committed()) { |
4296 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( | 4297 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( |
4297 navigation_state->common_params().lofi_state)); | 4298 navigation_state->common_params().previews_state)); |
4298 } else { | 4299 } else { |
4299 request.setLoFiState( | 4300 request.setPreviewsState( |
4300 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); | 4301 previews_state_ == PREVIEWS_UNSPECIFIED |
| 4302 ? WebURLRequest::PreviewsOff |
| 4303 : static_cast<WebURLRequest::PreviewsState>(previews_state_)); |
4301 } | 4304 } |
4302 } | 4305 } |
4303 | 4306 |
4304 // This is an instance where we embed a copy of the routing id | 4307 // This is an instance where we embed a copy of the routing id |
4305 // into the data portion of the message. This can cause problems if we | 4308 // into the data portion of the message. This can cause problems if we |
4306 // don't register this id on the browser side, since the download manager | 4309 // don't register this id on the browser side, since the download manager |
4307 // expects to find a RenderViewHost based off the id. | 4310 // expects to find a RenderViewHost based off the id. |
4308 request.setRequestorID(render_view_->GetRoutingID()); | 4311 request.setRequestorID(render_view_->GetRoutingID()); |
4309 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 4312 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
4310 | 4313 |
(...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6696 // event target. Potentially a Pepper plugin will receive the event. | 6699 // event target. Potentially a Pepper plugin will receive the event. |
6697 // In order to tell whether a plugin gets the last mouse event and which it | 6700 // In order to tell whether a plugin gets the last mouse event and which it |
6698 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6701 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6699 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6702 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6700 // |pepper_last_mouse_event_target_|. | 6703 // |pepper_last_mouse_event_target_|. |
6701 pepper_last_mouse_event_target_ = nullptr; | 6704 pepper_last_mouse_event_target_ = nullptr; |
6702 #endif | 6705 #endif |
6703 } | 6706 } |
6704 | 6707 |
6705 } // namespace content | 6708 } // namespace content |
OLD | NEW |