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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { | 744 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { |
746 DCHECK(!frame_); | 745 DCHECK(!frame_); |
747 | 746 |
748 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( | 747 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( |
749 std::make_pair(web_frame, this)); | 748 std::make_pair(web_frame, this)); |
750 CHECK(result.second) << "Inserting a duplicate item."; | 749 CHECK(result.second) << "Inserting a duplicate item."; |
751 | 750 |
752 frame_ = web_frame; | 751 frame_ = web_frame; |
753 } | 752 } |
754 | 753 |
755 void RenderFrameImpl::Initialize() { | 754 void RenderFrameImpl::Initialize(LoFiState lofi_state) { |
756 is_subframe_ = !!frame_->parent(); | 755 is_subframe_ = !!frame_->parent(); |
757 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); | 756 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); |
757 lofi_state_ = lofi_state; | |
758 | 758 |
759 #if defined(ENABLE_PLUGINS) | 759 #if defined(ENABLE_PLUGINS) |
760 new PepperBrowserConnection(this); | 760 new PepperBrowserConnection(this); |
761 #endif | 761 #endif |
762 new SharedWorkerRepository(this); | 762 new SharedWorkerRepository(this); |
763 | 763 |
764 if (is_local_root_ && !render_frame_proxy_) { | 764 if (is_local_root_ && !render_frame_proxy_) { |
765 // DevToolsAgent is a RenderFrameObserver, and will destruct itself | 765 // DevToolsAgent is a RenderFrameObserver, and will destruct itself |
766 // when |this| is deleted. | 766 // when |this| is deleted. |
767 devtools_agent_ = new DevToolsAgent(this); | 767 devtools_agent_ = new DevToolsAgent(this); |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2171 | 2171 |
2172 // Create the RenderFrame and WebLocalFrame, linking the two. | 2172 // Create the RenderFrame and WebLocalFrame, linking the two. |
2173 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( | 2173 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( |
2174 render_view_.get(), child_routing_id); | 2174 render_view_.get(), child_routing_id); |
2175 blink::WebLocalFrame* web_frame = | 2175 blink::WebLocalFrame* web_frame = |
2176 WebLocalFrame::create(scope, child_render_frame); | 2176 WebLocalFrame::create(scope, child_render_frame); |
2177 child_render_frame->SetWebFrame(web_frame); | 2177 child_render_frame->SetWebFrame(web_frame); |
2178 | 2178 |
2179 // Add the frame to the frame tree and initialize it. | 2179 // Add the frame to the frame tree and initialize it. |
2180 parent->appendChild(web_frame); | 2180 parent->appendChild(web_frame); |
2181 child_render_frame->Initialize(); | 2181 child_render_frame->Initialize(lofi_state_); |
2182 | 2182 |
2183 return web_frame; | 2183 return web_frame; |
2184 } | 2184 } |
2185 | 2185 |
2186 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) { | 2186 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) { |
2187 DCHECK(!frame_ || frame_ == frame); | 2187 DCHECK(!frame_ || frame_ == frame); |
2188 // We only need to notify the browser if the active, top-level frame clears | 2188 // We only need to notify the browser if the active, top-level frame clears |
2189 // its opener. We can ignore cases where a swapped out frame clears its | 2189 // its opener. We can ignore cases where a swapped out frame clears its |
2190 // opener after hearing about it from the browser, and the browser does not | 2190 // opener after hearing about it from the browser, and the browser does not |
2191 // (yet) care about subframe openers. | 2191 // (yet) care about subframe openers. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2250 | 2250 |
2251 void RenderFrameImpl::frameFocused() { | 2251 void RenderFrameImpl::frameFocused() { |
2252 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 2252 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
2253 } | 2253 } |
2254 | 2254 |
2255 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 2255 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
2256 DCHECK(!frame_ || frame_ == frame); | 2256 DCHECK(!frame_ || frame_ == frame); |
2257 | 2257 |
2258 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); | 2258 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); |
2259 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2259 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
2260 FrameWillClose(frame)); | 2260 FrameWillClose(frame, lofi_state_ == LOFI_ON)); |
2261 } | 2261 } |
2262 | 2262 |
2263 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame, | 2263 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame, |
2264 const blink::WebString& name) { | 2264 const blink::WebString& name) { |
2265 DCHECK(!frame_ || frame_ == frame); | 2265 DCHECK(!frame_ || frame_ == frame); |
2266 | 2266 |
2267 // TODO(alexmos): According to https://crbug.com/169110, sending window.name | 2267 // TODO(alexmos): According to https://crbug.com/169110, sending window.name |
2268 // updates may have performance implications for benchmarks like SunSpider. | 2268 // updates may have performance implications for benchmarks like SunSpider. |
2269 // For now, send these updates only for --site-per-process, which needs to | 2269 // For now, send these updates only for --site-per-process, which needs to |
2270 // replicate frame names to frame proxies, and when | 2270 // replicate frame names to frame proxies, and when |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2641 const blink::WebHistoryItem& item, | 2641 const blink::WebHistoryItem& item, |
2642 blink::WebHistoryCommitType commit_type) { | 2642 blink::WebHistoryCommitType commit_type) { |
2643 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", | 2643 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", |
2644 "id", routing_id_, | 2644 "id", routing_id_, |
2645 "url", GetLoadingUrl().possibly_invalid_spec()); | 2645 "url", GetLoadingUrl().possibly_invalid_spec()); |
2646 DCHECK(!frame_ || frame_ == frame); | 2646 DCHECK(!frame_ || frame_ == frame); |
2647 DocumentState* document_state = | 2647 DocumentState* document_state = |
2648 DocumentState::FromDataSource(frame->dataSource()); | 2648 DocumentState::FromDataSource(frame->dataSource()); |
2649 NavigationStateImpl* navigation_state = | 2649 NavigationStateImpl* navigation_state = |
2650 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2650 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2651 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse( | |
2652 frame->dataSource()->response()); | |
2653 if (extra_data) | |
2654 lofi_state_ = extra_data->is_lofi() ? LOFI_ON : LOFI_OFF; | |
bengr
2015/08/25 00:00:02
What is lofi_state_ if !extra_data? Maybe do:
lof
megjablon
2015/08/25 20:29:47
Done.
| |
2651 | 2655 |
2652 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2656 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2653 RenderFrameProxy* proxy = | 2657 RenderFrameProxy* proxy = |
2654 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2658 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2655 CHECK(proxy); | 2659 CHECK(proxy); |
2656 proxy->web_frame()->swap(frame_); | 2660 proxy->web_frame()->swap(frame_); |
2657 proxy_routing_id_ = MSG_ROUTING_NONE; | 2661 proxy_routing_id_ = MSG_ROUTING_NONE; |
2658 | 2662 |
2659 // If this is the main frame going from a remote frame to a local frame, | 2663 // If this is the main frame going from a remote frame to a local frame, |
2660 // it needs to set RenderViewImpl's pointer for the main frame to itself | 2664 // 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... | |
3295 extra_data->set_allow_download( | 3299 extra_data->set_allow_download( |
3296 navigation_state->common_params().allow_download); | 3300 navigation_state->common_params().allow_download); |
3297 extra_data->set_transition_type(transition_type); | 3301 extra_data->set_transition_type(transition_type); |
3298 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3302 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
3299 extra_data->set_transferred_request_child_id( | 3303 extra_data->set_transferred_request_child_id( |
3300 navigation_state->start_params().transferred_request_child_id); | 3304 navigation_state->start_params().transferred_request_child_id); |
3301 extra_data->set_transferred_request_request_id( | 3305 extra_data->set_transferred_request_request_id( |
3302 navigation_state->start_params().transferred_request_request_id); | 3306 navigation_state->start_params().transferred_request_request_id); |
3303 extra_data->set_service_worker_provider_id(provider_id); | 3307 extra_data->set_service_worker_provider_id(provider_id); |
3304 extra_data->set_stream_override(stream_override.Pass()); | 3308 extra_data->set_stream_override(stream_override.Pass()); |
3309 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache) | |
3310 extra_data->set_lofi_state(LOFI_OFF); | |
3311 else | |
3312 extra_data->set_lofi_state(lofi_state_); | |
3305 request.setExtraData(extra_data); | 3313 request.setExtraData(extra_data); |
3314 LOG(WARNING) << "willSendRequest " << request.url() << ": " << lofi_state_; | |
3306 | 3315 |
3307 // TODO(creis): Update prefetching to work with out-of-process iframes. | 3316 // TODO(creis): Update prefetching to work with out-of-process iframes. |
3308 WebFrame* top_frame = frame->top(); | 3317 WebFrame* top_frame = frame->top(); |
3309 if (top_frame && top_frame->isWebLocalFrame()) { | 3318 if (top_frame && top_frame->isWebLocalFrame()) { |
3310 DocumentState* top_document_state = | 3319 DocumentState* top_document_state = |
3311 DocumentState::FromDataSource(top_frame->dataSource()); | 3320 DocumentState::FromDataSource(top_frame->dataSource()); |
3312 if (top_document_state) { | 3321 if (top_document_state) { |
3313 // TODO(gavinp): separate out prefetching and prerender field trials | 3322 // TODO(gavinp): separate out prefetching and prerender field trials |
3314 // if the rel=prerender rel type is sticking around. | 3323 // if the rel=prerender rel type is sticking around. |
3315 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) | 3324 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3381 document_state->set_connection_info( | 3390 document_state->set_connection_info( |
3382 extra_data->connection_info()); | 3391 extra_data->connection_info()); |
3383 document_state->set_was_fetched_via_proxy( | 3392 document_state->set_was_fetched_via_proxy( |
3384 extra_data->was_fetched_via_proxy()); | 3393 extra_data->was_fetched_via_proxy()); |
3385 document_state->set_proxy_server( | 3394 document_state->set_proxy_server( |
3386 extra_data->proxy_server()); | 3395 extra_data->proxy_server()); |
3387 } | 3396 } |
3388 InternalDocumentStateData* internal_data = | 3397 InternalDocumentStateData* internal_data = |
3389 InternalDocumentStateData::FromDocumentState(document_state); | 3398 InternalDocumentStateData::FromDocumentState(document_state); |
3390 internal_data->set_http_status_code(http_status_code); | 3399 internal_data->set_http_status_code(http_status_code); |
3400 | |
3401 | |
bengr
2015/08/25 00:00:02
Remove these blank lines.
| |
3391 } | 3402 } |
3392 | 3403 |
3393 void RenderFrameImpl::didLoadResourceFromMemoryCache( | 3404 void RenderFrameImpl::didLoadResourceFromMemoryCache( |
3394 blink::WebLocalFrame* frame, | 3405 blink::WebLocalFrame* frame, |
3395 const blink::WebURLRequest& request, | 3406 const blink::WebURLRequest& request, |
3396 const blink::WebURLResponse& response) { | 3407 const blink::WebURLResponse& response) { |
3397 DCHECK(!frame_ || frame_ == frame); | 3408 DCHECK(!frame_ || frame_ == frame); |
3398 // The recipients of this message have no use for data: URLs: they don't | 3409 // The recipients of this message have no use for data: URLs: they don't |
3399 // affect the page's insecure content list and are not in the disk cache. To | 3410 // affect the page's insecure content list and are not in the disk cache. To |
3400 // prevent large (1M+) data: URLs from crashing in the IPC system, we simply | 3411 // prevent large (1M+) data: URLs from crashing in the IPC system, we simply |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4430 switches::kEnableBrowserSideNavigation); | 4441 switches::kEnableBrowserSideNavigation); |
4431 bool is_reload = IsReload(common_params.navigation_type); | 4442 bool is_reload = IsReload(common_params.navigation_type); |
4432 bool is_history_navigation = request_params.page_state.IsValid(); | 4443 bool is_history_navigation = request_params.page_state.IsValid(); |
4433 WebURLRequest::CachePolicy cache_policy = | 4444 WebURLRequest::CachePolicy cache_policy = |
4434 WebURLRequest::UseProtocolCachePolicy; | 4445 WebURLRequest::UseProtocolCachePolicy; |
4435 RenderFrameImpl::PrepareRenderViewForNavigation( | 4446 RenderFrameImpl::PrepareRenderViewForNavigation( |
4436 common_params.url, request_params, &is_reload, &cache_policy); | 4447 common_params.url, request_params, &is_reload, &cache_policy); |
4437 | 4448 |
4438 GetContentClient()->SetActiveURL(common_params.url); | 4449 GetContentClient()->SetActiveURL(common_params.url); |
4439 | 4450 |
4451 LOG(WARNING) << common_params.url << ": " << request_params.lofi_state; | |
bengr
2015/08/25 00:00:02
Remove the warning.
megjablon
2015/08/25 20:29:47
Done.
| |
4452 lofi_state_ = (LoFiState) request_params.lofi_state; | |
4453 | |
4440 // If this frame isn't in the same process as the main frame, it may naively | 4454 // If this frame isn't in the same process as the main frame, it may naively |
4441 // assume that this is the first navigation in the iframe, but this may not | 4455 // assume that this is the first navigation in the iframe, but this may not |
4442 // actually be the case. Inform the frame's state machine if this frame has | 4456 // actually be the case. Inform the frame's state machine if this frame has |
4443 // already committed other loads. | 4457 // already committed other loads. |
4444 if (request_params.has_committed_real_load && frame_->parent()) | 4458 if (request_params.has_committed_real_load && frame_->parent()) |
4445 frame_->setCommittedFirstRealLoad(); | 4459 frame_->setCommittedFirstRealLoad(); |
4446 | 4460 |
4447 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4461 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
4448 // We cannot reload if we do not have any history state. This happens, for | 4462 // We cannot reload if we do not have any history state. This happens, for |
4449 // example, when recovering from a crash. | 4463 // example, when recovering from a crash. |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5070 void RenderFrameImpl::RegisterMojoServices() { | 5084 void RenderFrameImpl::RegisterMojoServices() { |
5071 // Only main frame have ImageDownloader service. | 5085 // Only main frame have ImageDownloader service. |
5072 if (!frame_->parent()) { | 5086 if (!frame_->parent()) { |
5073 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 5087 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
5074 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 5088 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
5075 base::Unretained(this))); | 5089 base::Unretained(this))); |
5076 } | 5090 } |
5077 } | 5091 } |
5078 | 5092 |
5079 } // namespace content | 5093 } // namespace content |
OLD | NEW |