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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "content/public/common/browser_side_navigation_policy.h" | 72 #include "content/public/common/browser_side_navigation_policy.h" |
73 #include "content/public/common/content_constants.h" | 73 #include "content/public/common/content_constants.h" |
74 #include "content/public/common/content_features.h" | 74 #include "content/public/common/content_features.h" |
75 #include "content/public/common/content_switches.h" | 75 #include "content/public/common/content_switches.h" |
76 #include "content/public/common/context_menu_params.h" | 76 #include "content/public/common/context_menu_params.h" |
77 #include "content/public/common/file_chooser_file_info.h" | 77 #include "content/public/common/file_chooser_file_info.h" |
78 #include "content/public/common/file_chooser_params.h" | 78 #include "content/public/common/file_chooser_params.h" |
79 #include "content/public/common/form_field_data.h" | 79 #include "content/public/common/form_field_data.h" |
80 #include "content/public/common/isolated_world_ids.h" | 80 #include "content/public/common/isolated_world_ids.h" |
81 #include "content/public/common/page_state.h" | 81 #include "content/public/common/page_state.h" |
| 82 #include "content/public/common/previews_state.h" |
82 #include "content/public/common/resource_response.h" | 83 #include "content/public/common/resource_response.h" |
83 #include "content/public/common/service_manager_connection.h" | 84 #include "content/public/common/service_manager_connection.h" |
84 #include "content/public/common/url_constants.h" | 85 #include "content/public/common/url_constants.h" |
85 #include "content/public/common/url_utils.h" | 86 #include "content/public/common/url_utils.h" |
86 #include "content/public/renderer/browser_plugin_delegate.h" | 87 #include "content/public/renderer/browser_plugin_delegate.h" |
87 #include "content/public/renderer/content_renderer_client.h" | 88 #include "content/public/renderer/content_renderer_client.h" |
88 #include "content/public/renderer/context_menu_client.h" | 89 #include "content/public/renderer/context_menu_client.h" |
89 #include "content/public/renderer/document_state.h" | 90 #include "content/public/renderer/document_state.h" |
90 #include "content/public/renderer/navigation_state.h" | 91 #include "content/public/renderer/navigation_state.h" |
91 #include "content/public/renderer/render_frame_observer.h" | 92 #include "content/public/renderer/render_frame_observer.h" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 common_params.referrer.policy, | 561 common_params.referrer.policy, |
561 common_params.url, | 562 common_params.url, |
562 WebString::fromUTF8(common_params.referrer.url.spec())); | 563 WebString::fromUTF8(common_params.referrer.url.spec())); |
563 if (!web_referrer.isEmpty()) { | 564 if (!web_referrer.isEmpty()) { |
564 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 565 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
565 request.addHTTPOriginIfNeeded( | 566 request.addHTTPOriginIfNeeded( |
566 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 567 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
567 } | 568 } |
568 } | 569 } |
569 | 570 |
570 request.setLoFiState( | 571 request.setPreviewsState(common_params.previews_state); |
571 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | |
572 | 572 |
573 RequestExtraData* extra_data = new RequestExtraData(); | 573 RequestExtraData* extra_data = new RequestExtraData(); |
574 extra_data->set_stream_override(std::move(stream_override)); | 574 extra_data->set_stream_override(std::move(stream_override)); |
575 request.setExtraData(extra_data); | 575 request.setExtraData(extra_data); |
576 | 576 |
577 // Set the ui timestamp for this navigation. Currently the timestamp here is | 577 // Set the ui timestamp for this navigation. Currently the timestamp here is |
578 // only non empty when the navigation was triggered by an Android intent. The | 578 // only non empty when the navigation was triggered by an Android intent. The |
579 // timestamp is converted to a double version supported by blink. It will be | 579 // timestamp is converted to a double version supported by blink. It will be |
580 // passed back to the browser in the DidCommitProvisionalLoad and the | 580 // passed back to the browser in the DidCommitProvisionalLoad and the |
581 // DocumentLoadComplete IPCs. | 581 // DocumentLoadComplete IPCs. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 NavigationGesture gesture = info.urlRequest.hasUserGesture() | 643 NavigationGesture gesture = info.urlRequest.hasUserGesture() |
644 ? NavigationGestureUser | 644 ? NavigationGestureUser |
645 : NavigationGestureAuto; | 645 : NavigationGestureAuto; |
646 const RequestExtraData* extra_data = | 646 const RequestExtraData* extra_data = |
647 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 647 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
648 DCHECK(extra_data); | 648 DCHECK(extra_data); |
649 return CommonNavigationParams( | 649 return CommonNavigationParams( |
650 info.urlRequest.url(), referrer, extra_data->transition_type(), | 650 info.urlRequest.url(), referrer, extra_data->transition_type(), |
651 navigation_type, gesture, true, info.replacesCurrentHistoryItem, | 651 navigation_type, gesture, true, info.replacesCurrentHistoryItem, |
652 ui_timestamp, report_type, GURL(), GURL(), | 652 ui_timestamp, report_type, GURL(), GURL(), |
653 static_cast<LoFiState>(info.urlRequest.getLoFiState()), | 653 info.urlRequest.getPreviewsState(), |
654 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 654 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
655 GetRequestBodyForWebURLRequest(info.urlRequest)); | 655 GetRequestBodyForWebURLRequest(info.urlRequest)); |
656 } | 656 } |
657 | 657 |
658 media::Context3D GetSharedMainThreadContext3D( | 658 media::Context3D GetSharedMainThreadContext3D( |
659 scoped_refptr<ContextProviderCommandBuffer> provider) { | 659 scoped_refptr<ContextProviderCommandBuffer> provider) { |
660 if (!provider) | 660 if (!provider) |
661 return media::Context3D(); | 661 return media::Context3D(); |
662 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 662 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
663 } | 663 } |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 #endif | 1091 #endif |
1092 media_surface_manager_(nullptr), | 1092 media_surface_manager_(nullptr), |
1093 devtools_agent_(nullptr), | 1093 devtools_agent_(nullptr), |
1094 push_messaging_dispatcher_(NULL), | 1094 push_messaging_dispatcher_(NULL), |
1095 presentation_dispatcher_(NULL), | 1095 presentation_dispatcher_(NULL), |
1096 screen_orientation_dispatcher_(NULL), | 1096 screen_orientation_dispatcher_(NULL), |
1097 manifest_manager_(NULL), | 1097 manifest_manager_(NULL), |
1098 accessibility_mode_(AccessibilityModeOff), | 1098 accessibility_mode_(AccessibilityModeOff), |
1099 render_accessibility_(NULL), | 1099 render_accessibility_(NULL), |
1100 media_player_delegate_(NULL), | 1100 media_player_delegate_(NULL), |
1101 is_using_lofi_(false), | 1101 previews_state_(0), |
1102 effective_connection_type_( | 1102 effective_connection_type_( |
1103 blink::WebEffectiveConnectionType::TypeUnknown), | 1103 blink::WebEffectiveConnectionType::TypeUnknown), |
1104 is_pasting_(false), | 1104 is_pasting_(false), |
1105 suppress_further_dialogs_(false), | 1105 suppress_further_dialogs_(false), |
1106 blame_context_(nullptr), | 1106 blame_context_(nullptr), |
1107 #if BUILDFLAG(ENABLE_PLUGINS) | 1107 #if BUILDFLAG(ENABLE_PLUGINS) |
1108 focused_pepper_plugin_(nullptr), | 1108 focused_pepper_plugin_(nullptr), |
1109 pepper_last_mouse_event_target_(nullptr), | 1109 pepper_last_mouse_event_target_(nullptr), |
1110 #endif | 1110 #endif |
1111 frame_binding_(this), | 1111 frame_binding_(this), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1207 |
1208 frame_ = web_frame; | 1208 frame_ = web_frame; |
1209 } | 1209 } |
1210 | 1210 |
1211 void RenderFrameImpl::Initialize() { | 1211 void RenderFrameImpl::Initialize() { |
1212 is_main_frame_ = !frame_->parent(); | 1212 is_main_frame_ = !frame_->parent(); |
1213 | 1213 |
1214 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1214 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
1215 frame_->parent()); | 1215 frame_->parent()); |
1216 if (parent_frame) { | 1216 if (parent_frame) { |
1217 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1217 previews_state_ = parent_frame->GetPreviewsState(); |
1218 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1218 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
1219 } | 1219 } |
1220 | 1220 |
1221 bool is_tracing_rail = false; | 1221 bool is_tracing_rail = false; |
1222 bool is_tracing_navigation = false; | 1222 bool is_tracing_navigation = false; |
1223 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1223 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1224 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1224 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1225 if (is_tracing_rail || is_tracing_navigation) { | 1225 if (is_tracing_rail || is_tracing_navigation) { |
1226 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1226 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
1227 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1227 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 channels); | 2243 channels); |
2244 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2244 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
2245 } | 2245 } |
2246 | 2246 |
2247 void RenderFrameImpl::OnReload(bool bypass_cache) { | 2247 void RenderFrameImpl::OnReload(bool bypass_cache) { |
2248 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache | 2248 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache |
2249 : WebFrameLoadType::Reload); | 2249 : WebFrameLoadType::Reload); |
2250 } | 2250 } |
2251 | 2251 |
2252 void RenderFrameImpl::OnReloadLoFiImages() { | 2252 void RenderFrameImpl::OnReloadLoFiImages() { |
2253 is_using_lofi_ = false; | 2253 previews_state_ = PREVIEWS_OFF; |
2254 GetWebFrame()->reloadLoFiImages(); | 2254 GetWebFrame()->reloadLoFiImages(); |
2255 } | 2255 } |
2256 | 2256 |
2257 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { | 2257 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { |
2258 blink::WebSurroundingText surroundingText; | 2258 blink::WebSurroundingText surroundingText; |
2259 surroundingText.initializeFromCurrentSelection(frame_, max_length); | 2259 surroundingText.initializeFromCurrentSelection(frame_, max_length); |
2260 | 2260 |
2261 if (surroundingText.isNull()) { | 2261 if (surroundingText.isNull()) { |
2262 // |surroundingText| might not be correctly initialized, for example if | 2262 // |surroundingText| might not be correctly initialized, for example if |
2263 // |frame_->selectionRange().isNull()|, in other words, if there was no | 2263 // |frame_->selectionRange().isNull()|, in other words, if there was no |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 break; | 2634 break; |
2635 case CONSOLE_MESSAGE_LEVEL_ERROR: | 2635 case CONSOLE_MESSAGE_LEVEL_ERROR: |
2636 target_level = blink::WebConsoleMessage::LevelError; | 2636 target_level = blink::WebConsoleMessage::LevelError; |
2637 break; | 2637 break; |
2638 } | 2638 } |
2639 | 2639 |
2640 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); | 2640 blink::WebConsoleMessage wcm(target_level, WebString::fromUTF8(message)); |
2641 frame_->addMessageToConsole(wcm); | 2641 frame_->addMessageToConsole(wcm); |
2642 } | 2642 } |
2643 | 2643 |
2644 bool RenderFrameImpl::IsUsingLoFi() const { | 2644 int RenderFrameImpl::GetPreviewsState() const { |
2645 return is_using_lofi_; | 2645 return previews_state_; |
2646 } | 2646 } |
2647 | 2647 |
2648 bool RenderFrameImpl::IsPasting() const { | 2648 bool RenderFrameImpl::IsPasting() const { |
2649 return is_pasting_; | 2649 return is_pasting_; |
2650 } | 2650 } |
2651 | 2651 |
2652 // mojom::Frame implementation ------------------------------------------------- | 2652 // mojom::Frame implementation ------------------------------------------------- |
2653 | 2653 |
2654 void RenderFrameImpl::GetInterfaceProvider( | 2654 void RenderFrameImpl::GetInterfaceProvider( |
2655 service_manager::mojom::InterfaceProviderRequest request) { | 2655 service_manager::mojom::InterfaceProviderRequest request) { |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3513 } | 3513 } |
3514 committed_first_load_ = true; | 3514 committed_first_load_ = true; |
3515 } | 3515 } |
3516 | 3516 |
3517 DocumentState* document_state = | 3517 DocumentState* document_state = |
3518 DocumentState::FromDataSource(frame->dataSource()); | 3518 DocumentState::FromDataSource(frame->dataSource()); |
3519 NavigationStateImpl* navigation_state = | 3519 NavigationStateImpl* navigation_state = |
3520 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3520 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3521 WebURLResponseExtraDataImpl* extra_data = | 3521 WebURLResponseExtraDataImpl* extra_data = |
3522 GetExtraDataFromResponse(frame->dataSource()->response()); | 3522 GetExtraDataFromResponse(frame->dataSource()->response()); |
3523 // Only update the Lo-Fi and effective connection type states for new main | 3523 // Only update the PreviewsState and effective connection type states for new |
3524 // frame documents. Subframes inherit from the main frame and should not | 3524 // main frame documents. Subframes inherit from the main frame and should not |
3525 // change at commit time. | 3525 // change at commit time. |
3526 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3526 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
3527 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | 3527 previews_state_ = |
| 3528 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; |
3528 if (extra_data) { | 3529 if (extra_data) { |
3529 effective_connection_type_ = | 3530 effective_connection_type_ = |
3530 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3531 EffectiveConnectionTypeToWebEffectiveConnectionType( |
3531 extra_data->effective_connection_type()); | 3532 extra_data->effective_connection_type()); |
3532 } | 3533 } |
3533 } | 3534 } |
3534 | 3535 |
3535 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3536 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
3536 RenderFrameProxy* proxy = | 3537 RenderFrameProxy* proxy = |
3537 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 3538 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 request.getFrameType() != WebURLRequest::FrameTypeNone; | 4259 request.getFrameType() != WebURLRequest::FrameTypeNone; |
4259 if (is_navigational_request) { | 4260 if (is_navigational_request) { |
4260 extra_data->set_transferred_request_child_id( | 4261 extra_data->set_transferred_request_child_id( |
4261 navigation_state->start_params().transferred_request_child_id); | 4262 navigation_state->start_params().transferred_request_child_id); |
4262 extra_data->set_transferred_request_request_id( | 4263 extra_data->set_transferred_request_request_id( |
4263 navigation_state->start_params().transferred_request_request_id); | 4264 navigation_state->start_params().transferred_request_request_id); |
4264 } | 4265 } |
4265 | 4266 |
4266 request.setExtraData(extra_data); | 4267 request.setExtraData(extra_data); |
4267 | 4268 |
4268 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { | 4269 if (request.getPreviewsState() == 0) { |
4269 if (is_main_frame_ && !navigation_state->request_committed()) { | 4270 if (is_main_frame_ && !navigation_state->request_committed()) { |
4270 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( | 4271 request.setPreviewsState( |
4271 navigation_state->common_params().lofi_state)); | 4272 navigation_state->common_params().previews_state); |
4272 } else { | 4273 } else { |
4273 request.setLoFiState( | 4274 request.setPreviewsState(previews_state_ == 0 ? WebURLRequest::PreviewsOff |
4274 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); | 4275 : previews_state_); |
4275 } | 4276 } |
4276 } | 4277 } |
4277 | 4278 |
4278 // This is an instance where we embed a copy of the routing id | 4279 // This is an instance where we embed a copy of the routing id |
4279 // into the data portion of the message. This can cause problems if we | 4280 // into the data portion of the message. This can cause problems if we |
4280 // don't register this id on the browser side, since the download manager | 4281 // don't register this id on the browser side, since the download manager |
4281 // expects to find a RenderViewHost based off the id. | 4282 // expects to find a RenderViewHost based off the id. |
4282 request.setRequestorID(render_view_->GetRoutingID()); | 4283 request.setRequestorID(render_view_->GetRoutingID()); |
4283 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 4284 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
4284 | 4285 |
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6671 // event target. Potentially a Pepper plugin will receive the event. | 6672 // event target. Potentially a Pepper plugin will receive the event. |
6672 // In order to tell whether a plugin gets the last mouse event and which it | 6673 // In order to tell whether a plugin gets the last mouse event and which it |
6673 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6674 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6674 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6675 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6675 // |pepper_last_mouse_event_target_|. | 6676 // |pepper_last_mouse_event_target_|. |
6676 pepper_last_mouse_event_target_ = nullptr; | 6677 pepper_last_mouse_event_target_ = nullptr; |
6677 #endif | 6678 #endif |
6678 } | 6679 } |
6679 | 6680 |
6680 } // namespace content | 6681 } // namespace content |
OLD | NEW |