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 22 matching lines...) Expand all Loading... | |
33 #include "content/child/web_url_loader_impl.h" | 33 #include "content/child/web_url_loader_impl.h" |
34 #include "content/child/web_url_request_util.h" | 34 #include "content/child/web_url_request_util.h" |
35 #include "content/child/webmessageportchannel_impl.h" | 35 #include "content/child/webmessageportchannel_impl.h" |
36 #include "content/child/websocket_bridge.h" | 36 #include "content/child/websocket_bridge.h" |
37 #include "content/child/weburlresponse_extradata_impl.h" | 37 #include "content/child/weburlresponse_extradata_impl.h" |
38 #include "content/common/accessibility_messages.h" | 38 #include "content/common/accessibility_messages.h" |
39 #include "content/common/clipboard_messages.h" | 39 #include "content/common/clipboard_messages.h" |
40 #include "content/common/frame_messages.h" | 40 #include "content/common/frame_messages.h" |
41 #include "content/common/frame_replication_state.h" | 41 #include "content/common/frame_replication_state.h" |
42 #include "content/common/input_messages.h" | 42 #include "content/common/input_messages.h" |
43 #include "content/common/navigation_params.h" | |
44 #include "content/common/service_worker/service_worker_types.h" | 43 #include "content/common/service_worker/service_worker_types.h" |
45 #include "content/common/site_isolation_policy.h" | 44 #include "content/common/site_isolation_policy.h" |
46 #include "content/common/swapped_out_messages.h" | 45 #include "content/common/swapped_out_messages.h" |
47 #include "content/common/view_messages.h" | 46 #include "content/common/view_messages.h" |
48 #include "content/public/common/bindings_policy.h" | 47 #include "content/public/common/bindings_policy.h" |
49 #include "content/public/common/content_constants.h" | 48 #include "content/public/common/content_constants.h" |
50 #include "content/public/common/content_switches.h" | 49 #include "content/public/common/content_switches.h" |
51 #include "content/public/common/context_menu_params.h" | 50 #include "content/public/common/context_menu_params.h" |
52 #include "content/public/common/isolated_world_ids.h" | 51 #include "content/public/common/isolated_world_ids.h" |
53 #include "content/public/common/page_state.h" | 52 #include "content/public/common/page_state.h" |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 634 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
636 widget_params.routing_id, widget_params.surface_id, | 635 widget_params.routing_id, widget_params.surface_id, |
637 widget_params.hidden, render_frame->render_view_->screen_info(), | 636 widget_params.hidden, render_frame->render_view_->screen_info(), |
638 compositor_deps, web_frame); | 637 compositor_deps, web_frame); |
639 // TODO(kenrb): Observing shouldn't be necessary when we sort out | 638 // TODO(kenrb): Observing shouldn't be necessary when we sort out |
640 // WasShown and WasHidden, separating page-level visibility from | 639 // WasShown and WasHidden, separating page-level visibility from |
641 // frame-level visibility. | 640 // frame-level visibility. |
642 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 641 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
643 } | 642 } |
644 | 643 |
645 render_frame->Initialize(); | 644 render_frame->Initialize(LOFI_DEFAULT); |
646 } | 645 } |
647 | 646 |
648 // static | 647 // static |
649 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 648 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
650 return RenderFrameImpl::FromWebFrame(web_frame); | 649 return RenderFrameImpl::FromWebFrame(web_frame); |
651 } | 650 } |
652 | 651 |
653 // static | 652 // static |
654 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { | 653 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { |
655 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 654 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 #endif | 735 #endif |
737 has_played_media_(false), | 736 has_played_media_(false), |
738 devtools_agent_(nullptr), | 737 devtools_agent_(nullptr), |
739 geolocation_dispatcher_(NULL), | 738 geolocation_dispatcher_(NULL), |
740 push_messaging_dispatcher_(NULL), | 739 push_messaging_dispatcher_(NULL), |
741 presentation_dispatcher_(NULL), | 740 presentation_dispatcher_(NULL), |
742 screen_orientation_dispatcher_(NULL), | 741 screen_orientation_dispatcher_(NULL), |
743 manifest_manager_(NULL), | 742 manifest_manager_(NULL), |
744 accessibility_mode_(AccessibilityModeOff), | 743 accessibility_mode_(AccessibilityModeOff), |
745 renderer_accessibility_(NULL), | 744 renderer_accessibility_(NULL), |
745 lofi_state_(LOFI_DEFAULT), | |
746 weak_factory_(this) { | 746 weak_factory_(this) { |
747 std::pair<RoutingIDFrameMap::iterator, bool> result = | 747 std::pair<RoutingIDFrameMap::iterator, bool> result = |
748 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 748 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
749 CHECK(result.second) << "Inserting a duplicate item."; | 749 CHECK(result.second) << "Inserting a duplicate item."; |
750 | 750 |
751 RenderThread::Get()->AddRoute(routing_id_, this); | 751 RenderThread::Get()->AddRoute(routing_id_, this); |
752 | 752 |
753 render_view_->RegisterRenderFrame(this); | 753 render_view_->RegisterRenderFrame(this); |
754 | 754 |
755 // Everything below subclasses RenderFrameObserver and is automatically | 755 // 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) { | 805 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { |
806 DCHECK(!frame_); | 806 DCHECK(!frame_); |
807 | 807 |
808 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( | 808 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( |
809 std::make_pair(web_frame, this)); | 809 std::make_pair(web_frame, this)); |
810 CHECK(result.second) << "Inserting a duplicate item."; | 810 CHECK(result.second) << "Inserting a duplicate item."; |
811 | 811 |
812 frame_ = web_frame; | 812 frame_ = web_frame; |
813 } | 813 } |
814 | 814 |
815 void RenderFrameImpl::Initialize() { | 815 void RenderFrameImpl::Initialize(LoFiState lofi_state) { |
816 is_subframe_ = !!frame_->parent(); | 816 is_subframe_ = !!frame_->parent(); |
817 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); | 817 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); |
818 lofi_state_ = lofi_state; | |
818 | 819 |
819 #if defined(ENABLE_PLUGINS) | 820 #if defined(ENABLE_PLUGINS) |
820 new PepperBrowserConnection(this); | 821 new PepperBrowserConnection(this); |
821 #endif | 822 #endif |
822 new SharedWorkerRepository(this); | 823 new SharedWorkerRepository(this); |
823 | 824 |
824 if (is_local_root_ && !render_frame_proxy_) { | 825 if (is_local_root_ && !render_frame_proxy_) { |
825 // DevToolsAgent is a RenderFrameObserver, and will destruct itself | 826 // DevToolsAgent is a RenderFrameObserver, and will destruct itself |
826 // when |this| is deleted. | 827 // when |this| is deleted. |
827 devtools_agent_ = new DevToolsAgent(this); | 828 devtools_agent_ = new DevToolsAgent(this); |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2005 ServiceRegistryJsWrapper::kModuleName, | 2006 ServiceRegistryJsWrapper::kModuleName, |
2006 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); | 2007 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); |
2007 } | 2008 } |
2008 | 2009 |
2009 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, | 2010 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, |
2010 const std::string& message) { | 2011 const std::string& message) { |
2011 if (devtools_agent_) | 2012 if (devtools_agent_) |
2012 devtools_agent_->AddMessageToConsole(level, message); | 2013 devtools_agent_->AddMessageToConsole(level, message); |
2013 } | 2014 } |
2014 | 2015 |
2016 bool RenderFrameImpl::LoFiOn() { | |
2017 return lofi_state_ == LOFI_ON; | |
2018 } | |
2019 | |
2015 // blink::WebFrameClient implementation ---------------------------------------- | 2020 // blink::WebFrameClient implementation ---------------------------------------- |
2016 | 2021 |
2017 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2022 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2018 blink::WebLocalFrame* frame, | 2023 blink::WebLocalFrame* frame, |
2019 const blink::WebPluginParams& params) { | 2024 const blink::WebPluginParams& params) { |
2020 DCHECK_EQ(frame_, frame); | 2025 DCHECK_EQ(frame_, frame); |
2021 blink::WebPlugin* plugin = NULL; | 2026 blink::WebPlugin* plugin = NULL; |
2022 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2027 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2023 this, frame, params, &plugin)) { | 2028 this, frame, params, &plugin)) { |
2024 return plugin; | 2029 return plugin; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 | 2229 |
2225 // Create the RenderFrame and WebLocalFrame, linking the two. | 2230 // Create the RenderFrame and WebLocalFrame, linking the two. |
2226 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( | 2231 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( |
2227 render_view_.get(), child_routing_id); | 2232 render_view_.get(), child_routing_id); |
2228 blink::WebLocalFrame* web_frame = | 2233 blink::WebLocalFrame* web_frame = |
2229 WebLocalFrame::create(scope, child_render_frame); | 2234 WebLocalFrame::create(scope, child_render_frame); |
2230 child_render_frame->SetWebFrame(web_frame); | 2235 child_render_frame->SetWebFrame(web_frame); |
2231 | 2236 |
2232 // Add the frame to the frame tree and initialize it. | 2237 // Add the frame to the frame tree and initialize it. |
2233 parent->appendChild(web_frame); | 2238 parent->appendChild(web_frame); |
2234 child_render_frame->Initialize(); | 2239 child_render_frame->Initialize(lofi_state_); |
2235 | 2240 |
2236 return web_frame; | 2241 return web_frame; |
2237 } | 2242 } |
2238 | 2243 |
2239 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { | 2244 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { |
2240 // Only active frames are able to disown their opener. | 2245 // Only active frames are able to disown their opener. |
2241 if (!opener && is_swapped_out_) | 2246 if (!opener && is_swapped_out_) |
2242 return; | 2247 return; |
2243 | 2248 |
2244 // Only a local frame should be able to update another frame's opener. | 2249 // 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, | 2701 const blink::WebHistoryItem& item, |
2697 blink::WebHistoryCommitType commit_type) { | 2702 blink::WebHistoryCommitType commit_type) { |
2698 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", | 2703 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", |
2699 "id", routing_id_, | 2704 "id", routing_id_, |
2700 "url", GetLoadingUrl().possibly_invalid_spec()); | 2705 "url", GetLoadingUrl().possibly_invalid_spec()); |
2701 DCHECK(!frame_ || frame_ == frame); | 2706 DCHECK(!frame_ || frame_ == frame); |
2702 DocumentState* document_state = | 2707 DocumentState* document_state = |
2703 DocumentState::FromDataSource(frame->dataSource()); | 2708 DocumentState::FromDataSource(frame->dataSource()); |
2704 NavigationStateImpl* navigation_state = | 2709 NavigationStateImpl* navigation_state = |
2705 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2710 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2711 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse( | |
2712 frame->dataSource()->response()); | |
2713 lofi_state_ = extra_data && extra_data->is_lofi() ? LOFI_ON : LOFI_OFF; | |
2706 | 2714 |
2707 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2715 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2708 RenderFrameProxy* proxy = | 2716 RenderFrameProxy* proxy = |
2709 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2717 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2710 CHECK(proxy); | 2718 CHECK(proxy); |
2711 proxy->web_frame()->swap(frame_); | 2719 proxy->web_frame()->swap(frame_); |
2712 proxy_routing_id_ = MSG_ROUTING_NONE; | 2720 proxy_routing_id_ = MSG_ROUTING_NONE; |
2713 | 2721 |
2714 // If this is the main frame going from a remote frame to a local frame, | 2722 // 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 | 2723 // 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( | 3358 extra_data->set_allow_download( |
3351 navigation_state->common_params().allow_download); | 3359 navigation_state->common_params().allow_download); |
3352 extra_data->set_transition_type(transition_type); | 3360 extra_data->set_transition_type(transition_type); |
3353 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3361 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
3354 extra_data->set_transferred_request_child_id( | 3362 extra_data->set_transferred_request_child_id( |
3355 navigation_state->start_params().transferred_request_child_id); | 3363 navigation_state->start_params().transferred_request_child_id); |
3356 extra_data->set_transferred_request_request_id( | 3364 extra_data->set_transferred_request_request_id( |
3357 navigation_state->start_params().transferred_request_request_id); | 3365 navigation_state->start_params().transferred_request_request_id); |
3358 extra_data->set_service_worker_provider_id(provider_id); | 3366 extra_data->set_service_worker_provider_id(provider_id); |
3359 extra_data->set_stream_override(stream_override.Pass()); | 3367 extra_data->set_stream_override(stream_override.Pass()); |
3368 // TODO(megjablon): Set the navigation params for single image loads to | |
3369 // LOFI_OFF and remove the dependency on ReloadBypassingCache. | |
3370 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache) | |
3371 extra_data->set_lofi_state(LOFI_OFF); | |
3372 else | |
3373 extra_data->set_lofi_state(lofi_state_); | |
3360 request.setExtraData(extra_data); | 3374 request.setExtraData(extra_data); |
3361 | 3375 |
3362 // TODO(creis): Update prefetching to work with out-of-process iframes. | 3376 // TODO(creis): Update prefetching to work with out-of-process iframes. |
3363 WebFrame* top_frame = frame->top(); | 3377 WebFrame* top_frame = frame->top(); |
3364 if (top_frame && top_frame->isWebLocalFrame()) { | 3378 if (top_frame && top_frame->isWebLocalFrame()) { |
3365 DocumentState* top_document_state = | 3379 DocumentState* top_document_state = |
3366 DocumentState::FromDataSource(top_frame->dataSource()); | 3380 DocumentState::FromDataSource(top_frame->dataSource()); |
3367 if (top_document_state) { | 3381 if (top_document_state) { |
3368 // TODO(gavinp): separate out prefetching and prerender field trials | 3382 // TODO(gavinp): separate out prefetching and prerender field trials |
3369 // if the rel=prerender rel type is sticking around. | 3383 // 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); | 4490 switches::kEnableBrowserSideNavigation); |
4477 bool is_reload = IsReload(common_params.navigation_type); | 4491 bool is_reload = IsReload(common_params.navigation_type); |
4478 bool is_history_navigation = request_params.page_state.IsValid(); | 4492 bool is_history_navigation = request_params.page_state.IsValid(); |
4479 WebURLRequest::CachePolicy cache_policy = | 4493 WebURLRequest::CachePolicy cache_policy = |
4480 WebURLRequest::UseProtocolCachePolicy; | 4494 WebURLRequest::UseProtocolCachePolicy; |
4481 RenderFrameImpl::PrepareRenderViewForNavigation( | 4495 RenderFrameImpl::PrepareRenderViewForNavigation( |
4482 common_params.url, request_params, &is_reload, &cache_policy); | 4496 common_params.url, request_params, &is_reload, &cache_policy); |
4483 | 4497 |
4484 GetContentClient()->SetActiveURL(common_params.url); | 4498 GetContentClient()->SetActiveURL(common_params.url); |
4485 | 4499 |
4500 lofi_state_ = (LoFiState) request_params.lofi_state; | |
nasko
2015/09/17 23:09:00
Why do we need a cast here?
megjablon
2015/09/18 23:22:11
Done.
| |
4501 | |
4486 // If this frame isn't in the same process as the main frame, it may naively | 4502 // 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 | 4503 // 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 | 4504 // actually be the case. Inform the frame's state machine if this frame has |
4489 // already committed other loads. | 4505 // already committed other loads. |
4490 if (request_params.has_committed_real_load && frame_->parent()) | 4506 if (request_params.has_committed_real_load && frame_->parent()) |
4491 frame_->setCommittedFirstRealLoad(); | 4507 frame_->setCommittedFirstRealLoad(); |
4492 | 4508 |
4493 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4509 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
4494 // We cannot reload if we do not have any history state. This happens, for | 4510 // We cannot reload if we do not have any history state. This happens, for |
4495 // example, when recovering from a crash. | 4511 // example, when recovering from a crash. |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5112 mojo::ServiceProviderPtr service_provider; | 5128 mojo::ServiceProviderPtr service_provider; |
5113 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5129 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5114 request->url = mojo::String::From(url); | 5130 request->url = mojo::String::From(url); |
5115 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5131 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5116 nullptr, nullptr, | 5132 nullptr, nullptr, |
5117 base::Bind(&OnGotContentHandlerID)); | 5133 base::Bind(&OnGotContentHandlerID)); |
5118 return service_provider.Pass(); | 5134 return service_provider.Pass(); |
5119 } | 5135 } |
5120 | 5136 |
5121 } // namespace content | 5137 } // namespace content |
OLD | NEW |