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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 common_params.referrer.policy, | 562 common_params.referrer.policy, |
563 common_params.url, | 563 common_params.url, |
564 WebString::fromUTF8(common_params.referrer.url.spec())); | 564 WebString::fromUTF8(common_params.referrer.url.spec())); |
565 if (!web_referrer.isEmpty()) { | 565 if (!web_referrer.isEmpty()) { |
566 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 566 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
567 request.addHTTPOriginIfNeeded( | 567 request.addHTTPOriginIfNeeded( |
568 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 568 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 request.setLoFiState( | 572 request.setPreviewsState( |
573 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | 573 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); |
574 | 574 |
575 RequestExtraData* extra_data = new RequestExtraData(); | 575 RequestExtraData* extra_data = new RequestExtraData(); |
576 extra_data->set_stream_override(std::move(stream_override)); | 576 extra_data->set_stream_override(std::move(stream_override)); |
577 request.setExtraData(extra_data); | 577 request.setExtraData(extra_data); |
578 | 578 |
579 // Set the ui timestamp for this navigation. Currently the timestamp here is | 579 // Set the ui timestamp for this navigation. Currently the timestamp here is |
580 // only non empty when the navigation was triggered by an Android intent. The | 580 // only non empty when the navigation was triggered by an Android intent. The |
581 // timestamp is converted to a double version supported by blink. It will be | 581 // timestamp is converted to a double version supported by blink. It will be |
582 // passed back to the browser in the DidCommitProvisionalLoad and the | 582 // passed back to the browser in the DidCommitProvisionalLoad and the |
583 // DocumentLoadComplete IPCs. | 583 // DocumentLoadComplete IPCs. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 NavigationGesture gesture = info.urlRequest.hasUserGesture() | 645 NavigationGesture gesture = info.urlRequest.hasUserGesture() |
646 ? NavigationGestureUser | 646 ? NavigationGestureUser |
647 : NavigationGestureAuto; | 647 : NavigationGestureAuto; |
648 const RequestExtraData* extra_data = | 648 const RequestExtraData* extra_data = |
649 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 649 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
650 DCHECK(extra_data); | 650 DCHECK(extra_data); |
651 return CommonNavigationParams( | 651 return CommonNavigationParams( |
652 info.urlRequest.url(), referrer, extra_data->transition_type(), | 652 info.urlRequest.url(), referrer, extra_data->transition_type(), |
653 navigation_type, gesture, true, info.replacesCurrentHistoryItem, | 653 navigation_type, gesture, true, info.replacesCurrentHistoryItem, |
654 ui_timestamp, report_type, GURL(), GURL(), | 654 ui_timestamp, report_type, GURL(), GURL(), |
655 static_cast<LoFiState>(info.urlRequest.getLoFiState()), | 655 static_cast<PreviewsState>(info.urlRequest.getPreviewsState()), |
656 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 656 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
657 GetRequestBodyForWebURLRequest(info.urlRequest)); | 657 GetRequestBodyForWebURLRequest(info.urlRequest)); |
658 } | 658 } |
659 | 659 |
660 media::Context3D GetSharedMainThreadContext3D( | 660 media::Context3D GetSharedMainThreadContext3D( |
661 scoped_refptr<ContextProviderCommandBuffer> provider) { | 661 scoped_refptr<ContextProviderCommandBuffer> provider) { |
662 if (!provider) | 662 if (!provider) |
663 return media::Context3D(); | 663 return media::Context3D(); |
664 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 664 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
665 } | 665 } |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 #endif | 1108 #endif |
1109 media_surface_manager_(nullptr), | 1109 media_surface_manager_(nullptr), |
1110 devtools_agent_(nullptr), | 1110 devtools_agent_(nullptr), |
1111 push_messaging_dispatcher_(NULL), | 1111 push_messaging_dispatcher_(NULL), |
1112 presentation_dispatcher_(NULL), | 1112 presentation_dispatcher_(NULL), |
1113 screen_orientation_dispatcher_(NULL), | 1113 screen_orientation_dispatcher_(NULL), |
1114 manifest_manager_(NULL), | 1114 manifest_manager_(NULL), |
1115 accessibility_mode_(AccessibilityModeOff), | 1115 accessibility_mode_(AccessibilityModeOff), |
1116 render_accessibility_(NULL), | 1116 render_accessibility_(NULL), |
1117 media_player_delegate_(NULL), | 1117 media_player_delegate_(NULL), |
1118 is_using_lofi_(false), | 1118 previews_state_(PREVIEWS_UNSPECIFIED), |
1119 effective_connection_type_( | 1119 effective_connection_type_( |
1120 blink::WebEffectiveConnectionType::TypeUnknown), | 1120 blink::WebEffectiveConnectionType::TypeUnknown), |
1121 is_pasting_(false), | 1121 is_pasting_(false), |
1122 suppress_further_dialogs_(false), | 1122 suppress_further_dialogs_(false), |
1123 blame_context_(nullptr), | 1123 blame_context_(nullptr), |
1124 #if BUILDFLAG(ENABLE_PLUGINS) | 1124 #if BUILDFLAG(ENABLE_PLUGINS) |
1125 focused_pepper_plugin_(nullptr), | 1125 focused_pepper_plugin_(nullptr), |
1126 pepper_last_mouse_event_target_(nullptr), | 1126 pepper_last_mouse_event_target_(nullptr), |
1127 #endif | 1127 #endif |
1128 frame_binding_(this), | 1128 frame_binding_(this), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 | 1224 |
1225 frame_ = web_frame; | 1225 frame_ = web_frame; |
1226 } | 1226 } |
1227 | 1227 |
1228 void RenderFrameImpl::Initialize() { | 1228 void RenderFrameImpl::Initialize() { |
1229 is_main_frame_ = !frame_->parent(); | 1229 is_main_frame_ = !frame_->parent(); |
1230 | 1230 |
1231 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1231 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
1232 frame_->parent()); | 1232 frame_->parent()); |
1233 if (parent_frame) { | 1233 if (parent_frame) { |
1234 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1234 previews_state_ = parent_frame->GetPreviewsState(); |
1235 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1235 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
1236 } | 1236 } |
1237 | 1237 |
1238 bool is_tracing_rail = false; | 1238 bool is_tracing_rail = false; |
1239 bool is_tracing_navigation = false; | 1239 bool is_tracing_navigation = false; |
1240 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1240 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1241 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1241 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1242 if (is_tracing_rail || is_tracing_navigation) { | 1242 if (is_tracing_rail || is_tracing_navigation) { |
1243 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1243 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
1244 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1244 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2244 channels); | 2244 channels); |
2245 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2245 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
2246 } | 2246 } |
2247 | 2247 |
2248 void RenderFrameImpl::OnReload(bool bypass_cache) { | 2248 void RenderFrameImpl::OnReload(bool bypass_cache) { |
2249 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache | 2249 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache |
2250 : WebFrameLoadType::ReloadMainResource); | 2250 : WebFrameLoadType::ReloadMainResource); |
2251 } | 2251 } |
2252 | 2252 |
2253 void RenderFrameImpl::OnReloadLoFiImages() { | 2253 void RenderFrameImpl::OnReloadLoFiImages() { |
2254 is_using_lofi_ = false; | 2254 previews_state_ = PREVIEWS_OFF; |
2255 GetWebFrame()->reloadLoFiImages(); | 2255 GetWebFrame()->reloadLoFiImages(); |
2256 } | 2256 } |
2257 | 2257 |
2258 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { | 2258 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { |
2259 blink::WebSurroundingText surroundingText; | 2259 blink::WebSurroundingText surroundingText; |
2260 surroundingText.initializeFromCurrentSelection(frame_, max_length); | 2260 surroundingText.initializeFromCurrentSelection(frame_, max_length); |
2261 | 2261 |
2262 if (surroundingText.isNull()) { | 2262 if (surroundingText.isNull()) { |
2263 // |surroundingText| might not be correctly initialized, for example if | 2263 // |surroundingText| might not be correctly initialized, for example if |
2264 // |frame_->selectionRange().isNull()|, in other words, if there was no | 2264 // |frame_->selectionRange().isNull()|, in other words, if there was no |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2635 break; | 2635 break; |
2636 case CONSOLE_MESSAGE_LEVEL_ERROR: | 2636 case CONSOLE_MESSAGE_LEVEL_ERROR: |
2637 target_level = blink::WebConsoleMessage::LevelError; | 2637 target_level = blink::WebConsoleMessage::LevelError; |
2638 break; | 2638 break; |
2639 } | 2639 } |
2640 | 2640 |
2641 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); | 2641 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); |
2642 frame_->addMessageToConsole(wcm); | 2642 frame_->addMessageToConsole(wcm); |
2643 } | 2643 } |
2644 | 2644 |
2645 bool RenderFrameImpl::IsUsingLoFi() const { | 2645 PreviewsState RenderFrameImpl::GetPreviewsState() const { |
2646 return is_using_lofi_; | 2646 return previews_state_; |
2647 } | 2647 } |
2648 | 2648 |
2649 bool RenderFrameImpl::IsPasting() const { | 2649 bool RenderFrameImpl::IsPasting() const { |
2650 return is_pasting_; | 2650 return is_pasting_; |
2651 } | 2651 } |
2652 | 2652 |
2653 // mojom::Frame implementation ------------------------------------------------- | 2653 // mojom::Frame implementation ------------------------------------------------- |
2654 | 2654 |
2655 void RenderFrameImpl::GetInterfaceProvider( | 2655 void RenderFrameImpl::GetInterfaceProvider( |
2656 service_manager::mojom::InterfaceProviderRequest request) { | 2656 service_manager::mojom::InterfaceProviderRequest request) { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3524 } | 3524 } |
3525 committed_first_load_ = true; | 3525 committed_first_load_ = true; |
3526 } | 3526 } |
3527 | 3527 |
3528 DocumentState* document_state = | 3528 DocumentState* document_state = |
3529 DocumentState::FromDataSource(frame->dataSource()); | 3529 DocumentState::FromDataSource(frame->dataSource()); |
3530 NavigationStateImpl* navigation_state = | 3530 NavigationStateImpl* navigation_state = |
3531 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3531 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3532 WebURLResponseExtraDataImpl* extra_data = | 3532 WebURLResponseExtraDataImpl* extra_data = |
3533 GetExtraDataFromResponse(frame->dataSource()->response()); | 3533 GetExtraDataFromResponse(frame->dataSource()->response()); |
3534 // Only update the Lo-Fi and effective connection type states for new main | 3534 // Only update the PreviewsState and effective connection type states for new |
3535 // frame documents. Subframes inherit from the main frame and should not | 3535 // main frame documents. Subframes inherit from the main frame and should not |
3536 // change at commit time. | 3536 // change at commit time. |
3537 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3537 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
3538 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | 3538 previews_state_ = |
3539 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; | |
3539 if (extra_data) { | 3540 if (extra_data) { |
3540 effective_connection_type_ = | 3541 effective_connection_type_ = |
3541 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3542 EffectiveConnectionTypeToWebEffectiveConnectionType( |
3542 extra_data->effective_connection_type()); | 3543 extra_data->effective_connection_type()); |
3543 } | 3544 } |
3544 } | 3545 } |
3545 | 3546 |
3546 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3547 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
3547 RenderFrameProxy* proxy = | 3548 RenderFrameProxy* proxy = |
3548 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 3549 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4264 request.getFrameType() != WebURLRequest::FrameTypeNone; | 4265 request.getFrameType() != WebURLRequest::FrameTypeNone; |
4265 if (is_navigational_request) { | 4266 if (is_navigational_request) { |
4266 extra_data->set_transferred_request_child_id( | 4267 extra_data->set_transferred_request_child_id( |
4267 navigation_state->start_params().transferred_request_child_id); | 4268 navigation_state->start_params().transferred_request_child_id); |
4268 extra_data->set_transferred_request_request_id( | 4269 extra_data->set_transferred_request_request_id( |
4269 navigation_state->start_params().transferred_request_request_id); | 4270 navigation_state->start_params().transferred_request_request_id); |
4270 } | 4271 } |
4271 | 4272 |
4272 request.setExtraData(extra_data); | 4273 request.setExtraData(extra_data); |
4273 | 4274 |
4274 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { | 4275 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { |
4275 if (is_main_frame_ && !navigation_state->request_committed()) { | 4276 if (is_main_frame_ && !navigation_state->request_committed()) { |
4276 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( | 4277 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( |
4277 navigation_state->common_params().lofi_state)); | 4278 navigation_state->common_params().previews_state)); |
4278 } else { | 4279 } else { |
4279 request.setLoFiState( | 4280 request.setPreviewsState( |
4280 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); | 4281 previews_state_ == PREVIEWS_UNSPECIFIED |
4282 ? WebURLRequest::PreviewsOff | |
4283 : static_cast<WebURLRequest::PreviewsState>(previews_state_)); | |
4281 } | 4284 } |
4282 } | 4285 } |
4283 | 4286 |
4284 // This is an instance where we embed a copy of the routing id | 4287 // This is an instance where we embed a copy of the routing id |
4285 // into the data portion of the message. This can cause problems if we | 4288 // into the data portion of the message. This can cause problems if we |
4286 // don't register this id on the browser side, since the download manager | 4289 // don't register this id on the browser side, since the download manager |
4287 // expects to find a RenderViewHost based off the id. | 4290 // expects to find a RenderViewHost based off the id. |
4288 request.setRequestorID(render_view_->GetRoutingID()); | 4291 request.setRequestorID(render_view_->GetRoutingID()); |
4289 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 4292 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
4290 | 4293 |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5504 | 5507 |
5505 // Ensure that content::StopFindAction and blink::WebLocalFrame::StopFindAction | 5508 // Ensure that content::StopFindAction and blink::WebLocalFrame::StopFindAction |
5506 // are kept in sync. | 5509 // are kept in sync. |
5507 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_CLEAR_SELECTION, | 5510 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_CLEAR_SELECTION, |
5508 WebLocalFrame::StopFindActionClearSelection); | 5511 WebLocalFrame::StopFindActionClearSelection); |
5509 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_KEEP_SELECTION, | 5512 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_KEEP_SELECTION, |
5510 WebLocalFrame::StopFindActionKeepSelection); | 5513 WebLocalFrame::StopFindActionKeepSelection); |
5511 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_ACTIVATE_SELECTION, | 5514 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_ACTIVATE_SELECTION, |
5512 WebLocalFrame::StopFindActionActivateSelection); | 5515 WebLocalFrame::StopFindActionActivateSelection); |
5513 | 5516 |
5517 // Ensure that content::PreviewsState and blink::WebURLRequest::PreviewsState | |
5518 // are kept in sync. | |
nasko
2016/12/14 00:16:42
This doesn't seem to fit right here, as it splits
megjablon
2016/12/14 01:10:32
moved to previews_state.h
| |
5519 STATIC_ASSERT_ENUM(PREVIEWS_UNSPECIFIED, | |
5520 WebURLRequest::PreviewsUnspecified); | |
5521 STATIC_ASSERT_ENUM(SERVER_LOFI_ON, | |
5522 WebURLRequest::ServerLoFiOn); | |
5523 STATIC_ASSERT_ENUM(CLIENT_LOFI_ON, | |
5524 WebURLRequest::ClientLoFiOn); | |
5525 STATIC_ASSERT_ENUM(PREVIEWS_OFF, | |
5526 WebURLRequest::PreviewsOff); | |
5527 STATIC_ASSERT_ENUM(PREVIEWS_STATE_LAST, | |
5528 WebURLRequest::PreviewsStateLast); | |
5529 | |
5514 void RenderFrameImpl::OnStopFinding(StopFindAction action) { | 5530 void RenderFrameImpl::OnStopFinding(StopFindAction action) { |
5515 blink::WebPlugin* plugin = GetWebPluginForFind(); | 5531 blink::WebPlugin* plugin = GetWebPluginForFind(); |
5516 if (plugin) { | 5532 if (plugin) { |
5517 plugin->stopFind(); | 5533 plugin->stopFind(); |
5518 return; | 5534 return; |
5519 } | 5535 } |
5520 | 5536 |
5521 frame_->stopFinding(static_cast<WebLocalFrame::StopFindAction>(action)); | 5537 frame_->stopFinding(static_cast<WebLocalFrame::StopFindAction>(action)); |
5522 } | 5538 } |
5523 | 5539 |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6681 // event target. Potentially a Pepper plugin will receive the event. | 6697 // event target. Potentially a Pepper plugin will receive the event. |
6682 // In order to tell whether a plugin gets the last mouse event and which it | 6698 // In order to tell whether a plugin gets the last mouse event and which it |
6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6699 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6700 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6685 // |pepper_last_mouse_event_target_|. | 6701 // |pepper_last_mouse_event_target_|. |
6686 pepper_last_mouse_event_target_ = nullptr; | 6702 pepper_last_mouse_event_target_ = nullptr; |
6687 #endif | 6703 #endif |
6688 } | 6704 } |
6689 | 6705 |
6690 } // namespace content | 6706 } // namespace content |
OLD | NEW |