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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 421 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
422 common_params.referrer.policy, | 422 common_params.referrer.policy, |
423 common_params.url, | 423 common_params.url, |
424 WebString::fromUTF8(common_params.referrer.url.spec())); | 424 WebString::fromUTF8(common_params.referrer.url.spec())); |
425 if (!web_referrer.isEmpty()) | 425 if (!web_referrer.isEmpty()) |
426 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 426 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
427 } | 427 } |
428 | 428 |
429 RequestExtraData* extra_data = new RequestExtraData(); | 429 RequestExtraData* extra_data = new RequestExtraData(); |
430 extra_data->set_stream_override(stream_override.Pass()); | 430 extra_data->set_stream_override(stream_override.Pass()); |
431 extra_data->set_lofi_state(common_params.lofi_state); | |
431 request.setExtraData(extra_data); | 432 request.setExtraData(extra_data); |
432 | 433 |
433 // Set the ui timestamp for this navigation. Currently the timestamp here is | 434 // Set the ui timestamp for this navigation. Currently the timestamp here is |
434 // only non empty when the navigation was triggered by an Android intent. The | 435 // only non empty when the navigation was triggered by an Android intent. The |
435 // timestamp is converted to a double version supported by blink. It will be | 436 // timestamp is converted to a double version supported by blink. It will be |
436 // passed back to the browser in the DidCommitProvisionalLoad and the | 437 // passed back to the browser in the DidCommitProvisionalLoad and the |
437 // DocumentLoadComplete IPCs. | 438 // DocumentLoadComplete IPCs. |
438 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 439 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
439 request.setUiStartTime(ui_timestamp.InSecondsF()); | 440 request.setUiStartTime(ui_timestamp.InSecondsF()); |
440 request.setInputPerfMetricReportPolicy( | 441 request.setInputPerfMetricReportPolicy( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 #endif | 715 #endif |
715 has_played_media_(false), | 716 has_played_media_(false), |
716 devtools_agent_(nullptr), | 717 devtools_agent_(nullptr), |
717 geolocation_dispatcher_(NULL), | 718 geolocation_dispatcher_(NULL), |
718 push_messaging_dispatcher_(NULL), | 719 push_messaging_dispatcher_(NULL), |
719 presentation_dispatcher_(NULL), | 720 presentation_dispatcher_(NULL), |
720 screen_orientation_dispatcher_(NULL), | 721 screen_orientation_dispatcher_(NULL), |
721 manifest_manager_(NULL), | 722 manifest_manager_(NULL), |
722 accessibility_mode_(AccessibilityModeOff), | 723 accessibility_mode_(AccessibilityModeOff), |
723 renderer_accessibility_(NULL), | 724 renderer_accessibility_(NULL), |
725 is_using_lofi_(false), | |
724 weak_factory_(this) { | 726 weak_factory_(this) { |
725 std::pair<RoutingIDFrameMap::iterator, bool> result = | 727 std::pair<RoutingIDFrameMap::iterator, bool> result = |
726 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 728 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
727 CHECK(result.second) << "Inserting a duplicate item."; | 729 CHECK(result.second) << "Inserting a duplicate item."; |
728 | 730 |
729 RenderThread::Get()->AddRoute(routing_id_, this); | 731 RenderThread::Get()->AddRoute(routing_id_, this); |
730 | 732 |
731 render_view_->RegisterRenderFrame(this); | 733 render_view_->RegisterRenderFrame(this); |
732 | 734 |
733 // Everything below subclasses RenderFrameObserver and is automatically | 735 // Everything below subclasses RenderFrameObserver and is automatically |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 std::make_pair(web_frame, this)); | 790 std::make_pair(web_frame, this)); |
789 CHECK(result.second) << "Inserting a duplicate item."; | 791 CHECK(result.second) << "Inserting a duplicate item."; |
790 | 792 |
791 frame_ = web_frame; | 793 frame_ = web_frame; |
792 } | 794 } |
793 | 795 |
794 void RenderFrameImpl::Initialize() { | 796 void RenderFrameImpl::Initialize() { |
795 is_main_frame_ = !frame_->parent(); | 797 is_main_frame_ = !frame_->parent(); |
796 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); | 798 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); |
797 | 799 |
800 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | |
801 frame_->parent()); | |
802 if (parent_frame) | |
803 is_using_lofi_ = parent_frame->IsUsingLoFi(); | |
804 | |
798 bool is_tracing = false; | 805 bool is_tracing = false; |
799 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); | 806 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); |
800 if (is_tracing) { | 807 if (is_tracing) { |
801 int parent_id = MSG_ROUTING_NONE; | 808 int parent_id = MSG_ROUTING_NONE; |
802 if (!is_main_frame_) { | 809 if (!is_main_frame_) { |
803 if (frame_->parent()->isWebRemoteFrame()) { | 810 if (frame_->parent()->isWebRemoteFrame()) { |
804 RenderFrameProxy* parent_proxy = RenderFrameProxy::FromWebFrame( | 811 RenderFrameProxy* parent_proxy = RenderFrameProxy::FromWebFrame( |
805 frame_->parent()); | 812 frame_->parent()); |
806 if (parent_proxy) | 813 if (parent_proxy) |
807 parent_id = parent_proxy->routing_id(); | 814 parent_id = parent_proxy->routing_id(); |
808 } else { | 815 } else { |
809 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | |
810 frame_->parent()); | |
811 if (parent_frame) | 816 if (parent_frame) |
812 parent_id = parent_frame->GetRoutingID(); | 817 parent_id = parent_frame->GetRoutingID(); |
813 } | 818 } |
814 } | 819 } |
815 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", | 820 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", |
816 "id", routing_id_, | 821 "id", routing_id_, |
817 "parent", parent_id); | 822 "parent", parent_id); |
818 } | 823 } |
819 | 824 |
820 #if defined(ENABLE_PLUGINS) | 825 #if defined(ENABLE_PLUGINS) |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2010 ServiceRegistryJsWrapper::kModuleName, | 2015 ServiceRegistryJsWrapper::kModuleName, |
2011 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); | 2016 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); |
2012 } | 2017 } |
2013 | 2018 |
2014 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, | 2019 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, |
2015 const std::string& message) { | 2020 const std::string& message) { |
2016 if (devtools_agent_) | 2021 if (devtools_agent_) |
2017 devtools_agent_->AddMessageToConsole(level, message); | 2022 devtools_agent_->AddMessageToConsole(level, message); |
2018 } | 2023 } |
2019 | 2024 |
2025 bool RenderFrameImpl::IsUsingLoFi() { | |
2026 return is_using_lofi_; | |
2027 } | |
2028 | |
2020 // blink::WebFrameClient implementation ---------------------------------------- | 2029 // blink::WebFrameClient implementation ---------------------------------------- |
2021 | 2030 |
2022 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2031 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2023 blink::WebLocalFrame* frame, | 2032 blink::WebLocalFrame* frame, |
2024 const blink::WebPluginParams& params) { | 2033 const blink::WebPluginParams& params) { |
2025 DCHECK_EQ(frame_, frame); | 2034 DCHECK_EQ(frame_, frame); |
2026 blink::WebPlugin* plugin = NULL; | 2035 blink::WebPlugin* plugin = NULL; |
2027 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2036 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2028 this, frame, params, &plugin)) { | 2037 this, frame, params, &plugin)) { |
2029 return plugin; | 2038 return plugin; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2709 const blink::WebHistoryItem& item, | 2718 const blink::WebHistoryItem& item, |
2710 blink::WebHistoryCommitType commit_type) { | 2719 blink::WebHistoryCommitType commit_type) { |
2711 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", | 2720 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", |
2712 "id", routing_id_, | 2721 "id", routing_id_, |
2713 "url", GetLoadingUrl().possibly_invalid_spec()); | 2722 "url", GetLoadingUrl().possibly_invalid_spec()); |
2714 DCHECK(!frame_ || frame_ == frame); | 2723 DCHECK(!frame_ || frame_ == frame); |
2715 DocumentState* document_state = | 2724 DocumentState* document_state = |
2716 DocumentState::FromDataSource(frame->dataSource()); | 2725 DocumentState::FromDataSource(frame->dataSource()); |
2717 NavigationStateImpl* navigation_state = | 2726 NavigationStateImpl* navigation_state = |
2718 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2727 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2728 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse( | |
2729 frame->dataSource()->response()); | |
2730 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | |
2719 | 2731 |
2720 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2732 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2721 RenderFrameProxy* proxy = | 2733 RenderFrameProxy* proxy = |
2722 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2734 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2723 CHECK(proxy); | 2735 CHECK(proxy); |
2724 proxy->web_frame()->swap(frame_); | 2736 proxy->web_frame()->swap(frame_); |
2725 proxy_routing_id_ = MSG_ROUTING_NONE; | 2737 proxy_routing_id_ = MSG_ROUTING_NONE; |
2726 | 2738 |
2727 // If this is the main frame going from a remote frame to a local frame, | 2739 // If this is the main frame going from a remote frame to a local frame, |
2728 // it needs to set RenderViewImpl's pointer for the main frame to itself | 2740 // it needs to set RenderViewImpl's pointer for the main frame to itself |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3265 | 3277 |
3266 // The request's extra data may indicate that we should set a custom user | 3278 // The request's extra data may indicate that we should set a custom user |
3267 // agent. This needs to be done here, after WebKit is through with setting the | 3279 // agent. This needs to be done here, after WebKit is through with setting the |
3268 // user agent on its own. Similarly, it may indicate that we should set an | 3280 // user agent on its own. Similarly, it may indicate that we should set an |
3269 // X-Requested-With header. This must be done here to avoid breaking CORS | 3281 // X-Requested-With header. This must be done here to avoid breaking CORS |
3270 // checks. | 3282 // checks. |
3271 // PlzNavigate: there may also be a stream url associated with the request. | 3283 // PlzNavigate: there may also be a stream url associated with the request. |
3272 WebString custom_user_agent; | 3284 WebString custom_user_agent; |
3273 WebString requested_with; | 3285 WebString requested_with; |
3274 scoped_ptr<StreamOverrideParameters> stream_override; | 3286 scoped_ptr<StreamOverrideParameters> stream_override; |
3287 LoFiState lofi_state = LOFI_UNSPECIFIED; | |
3275 if (request.extraData()) { | 3288 if (request.extraData()) { |
3276 RequestExtraData* old_extra_data = | 3289 RequestExtraData* old_extra_data = |
3277 static_cast<RequestExtraData*>(request.extraData()); | 3290 static_cast<RequestExtraData*>(request.extraData()); |
3278 | 3291 |
3279 custom_user_agent = old_extra_data->custom_user_agent(); | 3292 custom_user_agent = old_extra_data->custom_user_agent(); |
3280 if (!custom_user_agent.isNull()) { | 3293 if (!custom_user_agent.isNull()) { |
3281 if (custom_user_agent.isEmpty()) | 3294 if (custom_user_agent.isEmpty()) |
3282 request.clearHTTPHeaderField("User-Agent"); | 3295 request.clearHTTPHeaderField("User-Agent"); |
3283 else | 3296 else |
3284 request.setHTTPHeaderField("User-Agent", custom_user_agent); | 3297 request.setHTTPHeaderField("User-Agent", custom_user_agent); |
3285 } | 3298 } |
3286 | 3299 |
3287 requested_with = old_extra_data->requested_with(); | 3300 requested_with = old_extra_data->requested_with(); |
3288 if (!requested_with.isNull()) { | 3301 if (!requested_with.isNull()) { |
3289 if (requested_with.isEmpty()) | 3302 if (requested_with.isEmpty()) |
3290 request.clearHTTPHeaderField("X-Requested-With"); | 3303 request.clearHTTPHeaderField("X-Requested-With"); |
3291 else | 3304 else |
3292 request.setHTTPHeaderField("X-Requested-With", requested_with); | 3305 request.setHTTPHeaderField("X-Requested-With", requested_with); |
3293 } | 3306 } |
3294 stream_override = old_extra_data->TakeStreamOverrideOwnership(); | 3307 stream_override = old_extra_data->TakeStreamOverrideOwnership(); |
3308 lofi_state = old_extra_data->lofi_state(); | |
3295 } | 3309 } |
3296 | 3310 |
3297 // Add the default accept header for frame request if it has not been set | 3311 // Add the default accept header for frame request if it has not been set |
3298 // already. | 3312 // already. |
3299 if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3313 if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || |
3300 request.frameType() == blink::WebURLRequest::FrameTypeNested) && | 3314 request.frameType() == blink::WebURLRequest::FrameTypeNested) && |
3301 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) { | 3315 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) { |
3302 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader), | 3316 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader), |
3303 WebString::fromUTF8(kDefaultAcceptHeader)); | 3317 WebString::fromUTF8(kDefaultAcceptHeader)); |
3304 } | 3318 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3368 extra_data->set_allow_download( | 3382 extra_data->set_allow_download( |
3369 navigation_state->common_params().allow_download); | 3383 navigation_state->common_params().allow_download); |
3370 extra_data->set_transition_type(transition_type); | 3384 extra_data->set_transition_type(transition_type); |
3371 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3385 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
3372 extra_data->set_transferred_request_child_id( | 3386 extra_data->set_transferred_request_child_id( |
3373 navigation_state->start_params().transferred_request_child_id); | 3387 navigation_state->start_params().transferred_request_child_id); |
3374 extra_data->set_transferred_request_request_id( | 3388 extra_data->set_transferred_request_request_id( |
3375 navigation_state->start_params().transferred_request_request_id); | 3389 navigation_state->start_params().transferred_request_request_id); |
3376 extra_data->set_service_worker_provider_id(provider_id); | 3390 extra_data->set_service_worker_provider_id(provider_id); |
3377 extra_data->set_stream_override(stream_override.Pass()); | 3391 extra_data->set_stream_override(stream_override.Pass()); |
3392 // TODO(megjablon): Set the navigation params for single image loads to | |
3393 // LOFI_OFF and remove the dependency on ReloadBypassingCache. | |
3394 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache) | |
3395 extra_data->set_lofi_state(LOFI_OFF); | |
3396 else if (is_main_frame_) | |
nasko
2015/10/01 20:13:57
Was this change intentional?
megjablon
2015/10/01 20:20:56
Whoops, nope. Fixed.
| |
3397 extra_data->set_lofi_state(lofi_state); | |
3398 else | |
3399 extra_data->set_lofi_state(is_using_lofi_ ? LOFI_ON : LOFI_OFF); | |
3378 request.setExtraData(extra_data); | 3400 request.setExtraData(extra_data); |
3379 | 3401 |
3380 // TODO(creis): Update prefetching to work with out-of-process iframes. | 3402 // TODO(creis): Update prefetching to work with out-of-process iframes. |
3381 WebFrame* top_frame = frame->top(); | 3403 WebFrame* top_frame = frame->top(); |
3382 if (top_frame && top_frame->isWebLocalFrame()) { | 3404 if (top_frame && top_frame->isWebLocalFrame()) { |
3383 DocumentState* top_document_state = | 3405 DocumentState* top_document_state = |
3384 DocumentState::FromDataSource(top_frame->dataSource()); | 3406 DocumentState::FromDataSource(top_frame->dataSource()); |
3385 if (top_document_state) { | 3407 if (top_document_state) { |
3386 // TODO(gavinp): separate out prefetching and prerender field trials | 3408 // TODO(gavinp): separate out prefetching and prerender field trials |
3387 // if the rel=prerender rel type is sticking around. | 3409 // if the rel=prerender rel type is sticking around. |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5173 mojo::ServiceProviderPtr service_provider; | 5195 mojo::ServiceProviderPtr service_provider; |
5174 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5196 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5175 request->url = mojo::String::From(url); | 5197 request->url = mojo::String::From(url); |
5176 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5198 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5177 nullptr, nullptr, | 5199 nullptr, nullptr, |
5178 base::Bind(&OnGotContentHandlerID)); | 5200 base::Bind(&OnGotContentHandlerID)); |
5179 return service_provider.Pass(); | 5201 return service_provider.Pass(); |
5180 } | 5202 } |
5181 | 5203 |
5182 } // namespace content | 5204 } // namespace content |
OLD | NEW |