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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 #endif | 736 #endif |
737 has_played_media_(false), | 737 has_played_media_(false), |
738 devtools_agent_(nullptr), | 738 devtools_agent_(nullptr), |
739 geolocation_dispatcher_(NULL), | 739 geolocation_dispatcher_(NULL), |
740 push_messaging_dispatcher_(NULL), | 740 push_messaging_dispatcher_(NULL), |
741 presentation_dispatcher_(NULL), | 741 presentation_dispatcher_(NULL), |
742 screen_orientation_dispatcher_(NULL), | 742 screen_orientation_dispatcher_(NULL), |
743 manifest_manager_(NULL), | 743 manifest_manager_(NULL), |
744 accessibility_mode_(AccessibilityModeOff), | 744 accessibility_mode_(AccessibilityModeOff), |
745 renderer_accessibility_(NULL), | 745 renderer_accessibility_(NULL), |
746 lofi_state_(LOFI_DEFAULT), | |
746 weak_factory_(this) { | 747 weak_factory_(this) { |
747 std::pair<RoutingIDFrameMap::iterator, bool> result = | 748 std::pair<RoutingIDFrameMap::iterator, bool> result = |
748 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 749 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
749 CHECK(result.second) << "Inserting a duplicate item."; | 750 CHECK(result.second) << "Inserting a duplicate item."; |
750 | 751 |
751 RenderThread::Get()->AddRoute(routing_id_, this); | 752 RenderThread::Get()->AddRoute(routing_id_, this); |
752 | 753 |
753 render_view_->RegisterRenderFrame(this); | 754 render_view_->RegisterRenderFrame(this); |
754 | 755 |
755 // Everything below subclasses RenderFrameObserver and is automatically | 756 // Everything below subclasses RenderFrameObserver and is automatically |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { | 806 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { |
806 DCHECK(!frame_); | 807 DCHECK(!frame_); |
807 | 808 |
808 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( | 809 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( |
809 std::make_pair(web_frame, this)); | 810 std::make_pair(web_frame, this)); |
810 CHECK(result.second) << "Inserting a duplicate item."; | 811 CHECK(result.second) << "Inserting a duplicate item."; |
811 | 812 |
812 frame_ = web_frame; | 813 frame_ = web_frame; |
813 } | 814 } |
814 | 815 |
815 void RenderFrameImpl::Initialize() { | 816 void RenderFrameImpl::Initialize(LoFiState lofi_state) { |
816 is_subframe_ = !!frame_->parent(); | 817 is_subframe_ = !!frame_->parent(); |
817 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); | 818 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); |
819 lofi_state_ = lofi_state; | |
818 | 820 |
819 #if defined(ENABLE_PLUGINS) | 821 #if defined(ENABLE_PLUGINS) |
820 new PepperBrowserConnection(this); | 822 new PepperBrowserConnection(this); |
821 #endif | 823 #endif |
822 new SharedWorkerRepository(this); | 824 new SharedWorkerRepository(this); |
823 | 825 |
824 if (is_local_root_ && !render_frame_proxy_) { | 826 if (is_local_root_ && !render_frame_proxy_) { |
825 // DevToolsAgent is a RenderFrameObserver, and will destruct itself | 827 // DevToolsAgent is a RenderFrameObserver, and will destruct itself |
826 // when |this| is deleted. | 828 // when |this| is deleted. |
827 devtools_agent_ = new DevToolsAgent(this); | 829 devtools_agent_ = new DevToolsAgent(this); |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2005 ServiceRegistryJsWrapper::kModuleName, | 2007 ServiceRegistryJsWrapper::kModuleName, |
2006 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); | 2008 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); |
2007 } | 2009 } |
2008 | 2010 |
2009 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, | 2011 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, |
2010 const std::string& message) { | 2012 const std::string& message) { |
2011 if (devtools_agent_) | 2013 if (devtools_agent_) |
2012 devtools_agent_->AddMessageToConsole(level, message); | 2014 devtools_agent_->AddMessageToConsole(level, message); |
2013 } | 2015 } |
2014 | 2016 |
2017 bool RenderFrameImpl::IsLoFiOn() { | |
2018 return lofi_state_ == LOFI_ON; | |
2019 } | |
2020 | |
2015 // blink::WebFrameClient implementation ---------------------------------------- | 2021 // blink::WebFrameClient implementation ---------------------------------------- |
2016 | 2022 |
2017 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2023 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2018 blink::WebLocalFrame* frame, | 2024 blink::WebLocalFrame* frame, |
2019 const blink::WebPluginParams& params) { | 2025 const blink::WebPluginParams& params) { |
2020 DCHECK_EQ(frame_, frame); | 2026 DCHECK_EQ(frame_, frame); |
2021 blink::WebPlugin* plugin = NULL; | 2027 blink::WebPlugin* plugin = NULL; |
2022 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2028 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2023 this, frame, params, &plugin)) { | 2029 this, frame, params, &plugin)) { |
2024 return plugin; | 2030 return plugin; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 | 2230 |
2225 // Create the RenderFrame and WebLocalFrame, linking the two. | 2231 // Create the RenderFrame and WebLocalFrame, linking the two. |
2226 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( | 2232 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( |
2227 render_view_.get(), child_routing_id); | 2233 render_view_.get(), child_routing_id); |
2228 blink::WebLocalFrame* web_frame = | 2234 blink::WebLocalFrame* web_frame = |
2229 WebLocalFrame::create(scope, child_render_frame); | 2235 WebLocalFrame::create(scope, child_render_frame); |
2230 child_render_frame->SetWebFrame(web_frame); | 2236 child_render_frame->SetWebFrame(web_frame); |
2231 | 2237 |
2232 // Add the frame to the frame tree and initialize it. | 2238 // Add the frame to the frame tree and initialize it. |
2233 parent->appendChild(web_frame); | 2239 parent->appendChild(web_frame); |
2234 child_render_frame->Initialize(); | 2240 child_render_frame->Initialize(lofi_state_); |
2235 | 2241 |
2236 return web_frame; | 2242 return web_frame; |
2237 } | 2243 } |
2238 | 2244 |
2239 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { | 2245 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { |
2240 // Only active frames are able to disown their opener. | 2246 // Only active frames are able to disown their opener. |
2241 if (!opener && is_swapped_out_) | 2247 if (!opener && is_swapped_out_) |
2242 return; | 2248 return; |
2243 | 2249 |
2244 // Only a local frame should be able to update another frame's opener. | 2250 // Only a local frame should be able to update another frame's opener. |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2696 const blink::WebHistoryItem& item, | 2702 const blink::WebHistoryItem& item, |
2697 blink::WebHistoryCommitType commit_type) { | 2703 blink::WebHistoryCommitType commit_type) { |
2698 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", | 2704 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", |
2699 "id", routing_id_, | 2705 "id", routing_id_, |
2700 "url", GetLoadingUrl().possibly_invalid_spec()); | 2706 "url", GetLoadingUrl().possibly_invalid_spec()); |
2701 DCHECK(!frame_ || frame_ == frame); | 2707 DCHECK(!frame_ || frame_ == frame); |
2702 DocumentState* document_state = | 2708 DocumentState* document_state = |
2703 DocumentState::FromDataSource(frame->dataSource()); | 2709 DocumentState::FromDataSource(frame->dataSource()); |
2704 NavigationStateImpl* navigation_state = | 2710 NavigationStateImpl* navigation_state = |
2705 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2711 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2712 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse( | |
2713 frame->dataSource()->response()); | |
2714 lofi_state_ = extra_data && extra_data->is_lofi() ? LOFI_ON : LOFI_OFF; | |
2706 | 2715 |
2707 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2716 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2708 RenderFrameProxy* proxy = | 2717 RenderFrameProxy* proxy = |
2709 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2718 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2710 CHECK(proxy); | 2719 CHECK(proxy); |
2711 proxy->web_frame()->swap(frame_); | 2720 proxy->web_frame()->swap(frame_); |
2712 proxy_routing_id_ = MSG_ROUTING_NONE; | 2721 proxy_routing_id_ = MSG_ROUTING_NONE; |
2713 | 2722 |
2714 // If this is the main frame going from a remote frame to a local frame, | 2723 // If this is the main frame going from a remote frame to a local frame, |
2715 // it needs to set RenderViewImpl's pointer for the main frame to itself | 2724 // it needs to set RenderViewImpl's pointer for the main frame to itself |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3350 extra_data->set_allow_download( | 3359 extra_data->set_allow_download( |
3351 navigation_state->common_params().allow_download); | 3360 navigation_state->common_params().allow_download); |
3352 extra_data->set_transition_type(transition_type); | 3361 extra_data->set_transition_type(transition_type); |
3353 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3362 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
3354 extra_data->set_transferred_request_child_id( | 3363 extra_data->set_transferred_request_child_id( |
3355 navigation_state->start_params().transferred_request_child_id); | 3364 navigation_state->start_params().transferred_request_child_id); |
3356 extra_data->set_transferred_request_request_id( | 3365 extra_data->set_transferred_request_request_id( |
3357 navigation_state->start_params().transferred_request_request_id); | 3366 navigation_state->start_params().transferred_request_request_id); |
3358 extra_data->set_service_worker_provider_id(provider_id); | 3367 extra_data->set_service_worker_provider_id(provider_id); |
3359 extra_data->set_stream_override(stream_override.Pass()); | 3368 extra_data->set_stream_override(stream_override.Pass()); |
3369 // TODO(megjablon): Set the navigation params for single image loads to | |
3370 // LOFI_OFF and remove the dependency on ReloadBypassingCache. | |
3371 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache) | |
3372 extra_data->set_lofi_state(LOFI_OFF); | |
3373 else | |
3374 extra_data->set_lofi_state(lofi_state_); | |
3360 request.setExtraData(extra_data); | 3375 request.setExtraData(extra_data); |
3361 | 3376 |
3362 // TODO(creis): Update prefetching to work with out-of-process iframes. | 3377 // TODO(creis): Update prefetching to work with out-of-process iframes. |
3363 WebFrame* top_frame = frame->top(); | 3378 WebFrame* top_frame = frame->top(); |
3364 if (top_frame && top_frame->isWebLocalFrame()) { | 3379 if (top_frame && top_frame->isWebLocalFrame()) { |
3365 DocumentState* top_document_state = | 3380 DocumentState* top_document_state = |
3366 DocumentState::FromDataSource(top_frame->dataSource()); | 3381 DocumentState::FromDataSource(top_frame->dataSource()); |
3367 if (top_document_state) { | 3382 if (top_document_state) { |
3368 // TODO(gavinp): separate out prefetching and prerender field trials | 3383 // TODO(gavinp): separate out prefetching and prerender field trials |
3369 // if the rel=prerender rel type is sticking around. | 3384 // if the rel=prerender rel type is sticking around. |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4476 switches::kEnableBrowserSideNavigation); | 4491 switches::kEnableBrowserSideNavigation); |
4477 bool is_reload = IsReload(common_params.navigation_type); | 4492 bool is_reload = IsReload(common_params.navigation_type); |
4478 bool is_history_navigation = request_params.page_state.IsValid(); | 4493 bool is_history_navigation = request_params.page_state.IsValid(); |
4479 WebURLRequest::CachePolicy cache_policy = | 4494 WebURLRequest::CachePolicy cache_policy = |
4480 WebURLRequest::UseProtocolCachePolicy; | 4495 WebURLRequest::UseProtocolCachePolicy; |
4481 RenderFrameImpl::PrepareRenderViewForNavigation( | 4496 RenderFrameImpl::PrepareRenderViewForNavigation( |
4482 common_params.url, request_params, &is_reload, &cache_policy); | 4497 common_params.url, request_params, &is_reload, &cache_policy); |
4483 | 4498 |
4484 GetContentClient()->SetActiveURL(common_params.url); | 4499 GetContentClient()->SetActiveURL(common_params.url); |
4485 | 4500 |
4501 lofi_state_ = request_params.lofi_state; | |
davidben
2015/09/21 17:58:15
This still hasn't been resolved. lofi_state_ must
davidben
2015/09/21 18:09:01
To clarify, this isn't a "layering; we'll fix this
megjablon
2015/09/22 20:35:52
For renderer initiated navigations, we don't need
davidben
2015/09/22 22:20:50
I think we were talking about different things. Th
megjablon
2015/09/23 01:39:04
This sounds good. I'm working on implementing this
megjablon
2015/09/23 23:15:24
I took a stab at this. PTAL!
| |
4502 | |
4486 // If this frame isn't in the same process as the main frame, it may naively | 4503 // If this frame isn't in the same process as the main frame, it may naively |
4487 // assume that this is the first navigation in the iframe, but this may not | 4504 // assume that this is the first navigation in the iframe, but this may not |
4488 // actually be the case. Inform the frame's state machine if this frame has | 4505 // actually be the case. Inform the frame's state machine if this frame has |
4489 // already committed other loads. | 4506 // already committed other loads. |
4490 if (request_params.has_committed_real_load && frame_->parent()) | 4507 if (request_params.has_committed_real_load && frame_->parent()) |
4491 frame_->setCommittedFirstRealLoad(); | 4508 frame_->setCommittedFirstRealLoad(); |
4492 | 4509 |
4493 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4510 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
4494 // We cannot reload if we do not have any history state. This happens, for | 4511 // We cannot reload if we do not have any history state. This happens, for |
4495 // example, when recovering from a crash. | 4512 // example, when recovering from a crash. |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5112 mojo::ServiceProviderPtr service_provider; | 5129 mojo::ServiceProviderPtr service_provider; |
5113 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5130 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5114 request->url = mojo::String::From(url); | 5131 request->url = mojo::String::From(url); |
5115 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5132 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5116 nullptr, nullptr, | 5133 nullptr, nullptr, |
5117 base::Bind(&OnGotContentHandlerID)); | 5134 base::Bind(&OnGotContentHandlerID)); |
5118 return service_provider.Pass(); | 5135 return service_provider.Pass(); |
5119 } | 5136 } |
5120 | 5137 |
5121 } // namespace content | 5138 } // namespace content |
OLD | NEW |