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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 #include "media/blink/webmediaplayer_impl.h" | 142 #include "media/blink/webmediaplayer_impl.h" |
143 #include "media/renderers/gpu_video_accelerator_factories.h" | 143 #include "media/renderers/gpu_video_accelerator_factories.h" |
144 #include "mojo/common/url_type_converters.h" | 144 #include "mojo/common/url_type_converters.h" |
145 #include "mojo/edk/js/core.h" | 145 #include "mojo/edk/js/core.h" |
146 #include "mojo/edk/js/support.h" | 146 #include "mojo/edk/js/support.h" |
147 #include "net/base/data_url.h" | 147 #include "net/base/data_url.h" |
148 #include "net/base/net_errors.h" | 148 #include "net/base/net_errors.h" |
149 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 149 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
150 #include "net/http/http_util.h" | 150 #include "net/http/http_util.h" |
151 #include "third_party/WebKit/public/platform/URLConversion.h" | 151 #include "third_party/WebKit/public/platform/URLConversion.h" |
152 #include "third_party/WebKit/public/platform/WebCachePolicy.h" | |
152 #include "third_party/WebKit/public/platform/WebData.h" | 153 #include "third_party/WebKit/public/platform/WebData.h" |
153 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 154 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
154 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 155 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
155 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 156 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
156 #include "third_party/WebKit/public/platform/WebString.h" | 157 #include "third_party/WebKit/public/platform/WebString.h" |
157 #include "third_party/WebKit/public/platform/WebURL.h" | 158 #include "third_party/WebKit/public/platform/WebURL.h" |
158 #include "third_party/WebKit/public/platform/WebURLError.h" | 159 #include "third_party/WebKit/public/platform/WebURLError.h" |
159 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 160 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
160 #include "third_party/WebKit/public/platform/WebVector.h" | 161 #include "third_party/WebKit/public/platform/WebVector.h" |
161 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" | 162 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 #endif | 238 #endif |
238 | 239 |
239 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) | 240 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) |
240 #include "media/mojo/services/mojo_decoder_factory.h" // nogncheck | 241 #include "media/mojo/services/mojo_decoder_factory.h" // nogncheck |
241 #endif | 242 #endif |
242 | 243 |
243 #if defined(ENABLE_WEBVR) | 244 #if defined(ENABLE_WEBVR) |
244 #include "content/renderer/vr/vr_dispatcher.h" | 245 #include "content/renderer/vr/vr_dispatcher.h" |
245 #endif | 246 #endif |
246 | 247 |
248 using blink::WebCachePolicy; | |
247 using blink::WebContentDecryptionModule; | 249 using blink::WebContentDecryptionModule; |
248 using blink::WebContextMenuData; | 250 using blink::WebContextMenuData; |
249 using blink::WebCString; | 251 using blink::WebCString; |
250 using blink::WebData; | 252 using blink::WebData; |
251 using blink::WebDataSource; | 253 using blink::WebDataSource; |
252 using blink::WebDocument; | 254 using blink::WebDocument; |
253 using blink::WebDOMEvent; | 255 using blink::WebDOMEvent; |
254 using blink::WebDOMMessageEvent; | 256 using blink::WebDOMMessageEvent; |
255 using blink::WebElement; | 257 using blink::WebElement; |
256 using blink::WebExternalPopupMenu; | 258 using blink::WebExternalPopupMenu; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 bool IsTopLevelNavigation(WebFrame* frame) { | 508 bool IsTopLevelNavigation(WebFrame* frame) { |
507 return frame->parent() == NULL; | 509 return frame->parent() == NULL; |
508 } | 510 } |
509 | 511 |
510 WebURLRequest CreateURLRequestForNavigation( | 512 WebURLRequest CreateURLRequestForNavigation( |
511 const CommonNavigationParams& common_params, | 513 const CommonNavigationParams& common_params, |
512 scoped_ptr<StreamOverrideParameters> stream_override, | 514 scoped_ptr<StreamOverrideParameters> stream_override, |
513 bool is_view_source_mode_enabled) { | 515 bool is_view_source_mode_enabled) { |
514 WebURLRequest request(common_params.url); | 516 WebURLRequest request(common_params.url); |
515 if (is_view_source_mode_enabled) | 517 if (is_view_source_mode_enabled) |
516 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); | 518 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); |
517 | 519 |
518 if (common_params.referrer.url.is_valid()) { | 520 if (common_params.referrer.url.is_valid()) { |
519 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 521 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
520 common_params.referrer.policy, | 522 common_params.referrer.policy, |
521 common_params.url, | 523 common_params.url, |
522 WebString::fromUTF8(common_params.referrer.url.spec())); | 524 WebString::fromUTF8(common_params.referrer.url.spec())); |
523 if (!web_referrer.isEmpty()) | 525 if (!web_referrer.isEmpty()) |
524 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 526 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
525 } | 527 } |
526 | 528 |
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2926 break; | 2928 break; |
2927 } | 2929 } |
2928 } | 2930 } |
2929 } | 2931 } |
2930 } | 2932 } |
2931 } | 2933 } |
2932 | 2934 |
2933 if (content_initiated) { | 2935 if (content_initiated) { |
2934 const WebURLRequest& request = datasource->request(); | 2936 const WebURLRequest& request = datasource->request(); |
2935 switch (request.getCachePolicy()) { | 2937 switch (request.getCachePolicy()) { |
2936 case WebURLRequest::UseProtocolCachePolicy: // normal load. | 2938 case WebCachePolicy::UseProtocolCachePolicy: // normal load. |
2937 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); | 2939 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
2938 break; | 2940 break; |
2939 case WebURLRequest::ValidatingCacheData: // reload. | 2941 case WebCachePolicy::ValidatingCacheData: // reload. |
2940 case WebURLRequest::BypassingCache: // end-to-end reload. | 2942 case WebCachePolicy::BypassingCache: // end-to-end reload. |
2941 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); | 2943 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
2942 break; | 2944 break; |
2943 case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. | 2945 case WebCachePolicy::ReturnCacheDataElseLoad: // allow stale data. |
2944 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); | 2946 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); |
2945 break; | 2947 break; |
2946 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. | 2948 case WebCachePolicy::ReturnCacheDataDontLoad: // Don't re-post. |
2947 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); | 2949 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
2948 break; | 2950 break; |
2949 default: | 2951 default: |
2950 NOTREACHED(); | 2952 NOTREACHED(); |
2951 } | 2953 } |
2952 } | 2954 } |
2953 | 2955 |
2954 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | 2956 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( |
2955 document_state->navigation_state()); | 2957 document_state->navigation_state()); |
2956 | 2958 |
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4635 } | 4637 } |
4636 | 4638 |
4637 // PlzNavigate | 4639 // PlzNavigate |
4638 void RenderFrameImpl::OnFailedNavigation( | 4640 void RenderFrameImpl::OnFailedNavigation( |
4639 const CommonNavigationParams& common_params, | 4641 const CommonNavigationParams& common_params, |
4640 const RequestNavigationParams& request_params, | 4642 const RequestNavigationParams& request_params, |
4641 bool has_stale_copy_in_cache, | 4643 bool has_stale_copy_in_cache, |
4642 int error_code) { | 4644 int error_code) { |
4643 DCHECK(IsBrowserSideNavigationEnabled()); | 4645 DCHECK(IsBrowserSideNavigationEnabled()); |
4644 bool is_reload = IsReload(common_params.navigation_type); | 4646 bool is_reload = IsReload(common_params.navigation_type); |
4645 WebURLRequest::CachePolicy cache_policy = | 4647 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
4646 WebURLRequest::UseProtocolCachePolicy; | |
4647 RenderFrameImpl::PrepareRenderViewForNavigation( | 4648 RenderFrameImpl::PrepareRenderViewForNavigation( |
4648 common_params.url, request_params, &is_reload, &cache_policy); | 4649 common_params.url, request_params, is_reload, cache_policy); |
4649 | 4650 |
4650 GetContentClient()->SetActiveURL(common_params.url); | 4651 GetContentClient()->SetActiveURL(common_params.url); |
4651 | 4652 |
4652 // If this frame isn't in the same process as the main frame, it may naively | 4653 // If this frame isn't in the same process as the main frame, it may naively |
4653 // assume that this is the first navigation in the iframe, but this may not | 4654 // assume that this is the first navigation in the iframe, but this may not |
4654 // actually be the case. Inform the frame's state machine if this frame has | 4655 // actually be the case. Inform the frame's state machine if this frame has |
4655 // already committed other loads. | 4656 // already committed other loads. |
4656 if (request_params.has_committed_real_load && frame_->parent()) | 4657 if (request_params.has_committed_real_load && frame_->parent()) |
4657 frame_->setCommittedFirstRealLoad(); | 4658 frame_->setCommittedFirstRealLoad(); |
4658 | 4659 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5225 const CommonNavigationParams& common_params, | 5226 const CommonNavigationParams& common_params, |
5226 const StartNavigationParams& start_params, | 5227 const StartNavigationParams& start_params, |
5227 const RequestNavigationParams& request_params, | 5228 const RequestNavigationParams& request_params, |
5228 scoped_ptr<StreamOverrideParameters> stream_params) { | 5229 scoped_ptr<StreamOverrideParameters> stream_params) { |
5229 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5230 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
5230 | 5231 |
5231 // Lower bound for browser initiated navigation start time. | 5232 // Lower bound for browser initiated navigation start time. |
5232 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5233 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
5233 bool is_reload = IsReload(common_params.navigation_type); | 5234 bool is_reload = IsReload(common_params.navigation_type); |
5234 bool is_history_navigation = request_params.page_state.IsValid(); | 5235 bool is_history_navigation = request_params.page_state.IsValid(); |
5235 WebURLRequest::CachePolicy cache_policy = | 5236 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
5236 WebURLRequest::UseProtocolCachePolicy; | |
5237 RenderFrameImpl::PrepareRenderViewForNavigation( | 5237 RenderFrameImpl::PrepareRenderViewForNavigation( |
5238 common_params.url, request_params, &is_reload, &cache_policy); | 5238 common_params.url, request_params, is_reload, cache_policy); |
5239 | 5239 |
5240 GetContentClient()->SetActiveURL(common_params.url); | 5240 GetContentClient()->SetActiveURL(common_params.url); |
5241 | 5241 |
5242 // If this frame isn't in the same process as the main frame, it may naively | 5242 // If this frame isn't in the same process as the main frame, it may naively |
5243 // assume that this is the first navigation in the iframe, but this may not | 5243 // assume that this is the first navigation in the iframe, but this may not |
5244 // actually be the case. Inform the frame's state machine if this frame has | 5244 // actually be the case. Inform the frame's state machine if this frame has |
5245 // already committed other loads. | 5245 // already committed other loads. |
5246 if (request_params.has_committed_real_load && frame_->parent()) | 5246 if (request_params.has_committed_real_load && frame_->parent()) |
5247 frame_->setCommittedFirstRealLoad(); | 5247 frame_->setCommittedFirstRealLoad(); |
5248 | 5248 |
5249 bool no_current_entry = | 5249 bool no_current_entry = |
5250 SiteIsolationPolicy::UseSubframeNavigationEntries() | 5250 SiteIsolationPolicy::UseSubframeNavigationEntries() |
5251 ? current_history_item_.isNull() | 5251 ? current_history_item_.isNull() |
5252 : !render_view_->history_controller()->GetCurrentEntry(); | 5252 : !render_view_->history_controller()->GetCurrentEntry(); |
5253 if (is_reload && no_current_entry) { | 5253 if (is_reload && no_current_entry) { |
5254 // We cannot reload if we do not have any history state. This happens, for | 5254 // We cannot reload if we do not have any history state. This happens, for |
5255 // example, when recovering from a crash. | 5255 // example, when recovering from a crash. |
5256 is_reload = false; | 5256 is_reload = false; |
5257 cache_policy = WebURLRequest::ValidatingCacheData; | 5257 cache_policy = WebCachePolicy::ValidatingCacheData; |
5258 } | 5258 } |
5259 | 5259 |
5260 // If the navigation is for "view source", the WebLocalFrame needs to be put | 5260 // If the navigation is for "view source", the WebLocalFrame needs to be put |
5261 // in a special mode. | 5261 // in a special mode. |
5262 if (request_params.is_view_source) | 5262 if (request_params.is_view_source) |
5263 frame_->enableViewSourceMode(true); | 5263 frame_->enableViewSourceMode(true); |
5264 | 5264 |
5265 pending_navigation_params_.reset( | 5265 pending_navigation_params_.reset( |
5266 new NavigationParams(common_params, start_params, request_params)); | 5266 new NavigationParams(common_params, start_params, request_params)); |
5267 | 5267 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5569 new MediaStreamRendererFactoryImpl()); | 5569 new MediaStreamRendererFactoryImpl()); |
5570 #else | 5570 #else |
5571 return scoped_ptr<MediaStreamRendererFactory>( | 5571 return scoped_ptr<MediaStreamRendererFactory>( |
5572 static_cast<MediaStreamRendererFactory*>(NULL)); | 5572 static_cast<MediaStreamRendererFactory*>(NULL)); |
5573 #endif | 5573 #endif |
5574 } | 5574 } |
5575 | 5575 |
5576 void RenderFrameImpl::PrepareRenderViewForNavigation( | 5576 void RenderFrameImpl::PrepareRenderViewForNavigation( |
5577 const GURL& url, | 5577 const GURL& url, |
5578 const RequestNavigationParams& request_params, | 5578 const RequestNavigationParams& request_params, |
5579 bool* is_reload, | 5579 bool is_reload, |
5580 WebURLRequest::CachePolicy* cache_policy) { | 5580 WebCachePolicy cache_policy) { |
hiroshige
2016/04/07 06:30:32
Can we remove |is_reload| and |cache_policy| if th
Takashi Toyoshima
2016/04/08 04:41:48
I think it's WebKit style, but we usually do not r
hiroshige
2016/04/08 05:50:40
Sorry, I meant: can we remove the two parameters f
Takashi Toyoshima
2016/04/08 06:12:07
Oops, I see. You are right. I can just remove thes
| |
5581 DCHECK(render_view_->webview()); | 5581 DCHECK(render_view_->webview()); |
5582 | 5582 |
5583 MaybeHandleDebugURL(url); | 5583 MaybeHandleDebugURL(url); |
5584 | 5584 |
5585 FOR_EACH_OBSERVER( | 5585 FOR_EACH_OBSERVER( |
5586 RenderViewObserver, render_view_->observers_, Navigate(url)); | 5586 RenderViewObserver, render_view_->observers_, Navigate(url)); |
5587 | 5587 |
5588 render_view_->history_list_offset_ = | 5588 render_view_->history_list_offset_ = |
5589 request_params.current_history_list_offset; | 5589 request_params.current_history_list_offset; |
5590 render_view_->history_list_length_ = | 5590 render_view_->history_list_length_ = |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5801 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 5801 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
5802 // can result in stale data for pages that are set to expire. We explicitly | 5802 // can result in stale data for pages that are set to expire. We explicitly |
5803 // override that by setting the policy here so that as necessary we load | 5803 // override that by setting the policy here so that as necessary we load |
5804 // from the network. | 5804 // from the network. |
5805 // | 5805 // |
5806 // TODO(davidben): Remove this in favor of passing a cache policy to the | 5806 // TODO(davidben): Remove this in favor of passing a cache policy to the |
5807 // loadHistoryItem call in OnNavigate. That requires not overloading | 5807 // loadHistoryItem call in OnNavigate. That requires not overloading |
5808 // UseProtocolCachePolicy to mean both "normal load" and "determine cache | 5808 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
5809 // policy based on load type, etc". | 5809 // policy based on load type, etc". |
5810 internal_data->set_cache_policy_override( | 5810 internal_data->set_cache_policy_override( |
5811 WebURLRequest::UseProtocolCachePolicy); | 5811 WebCachePolicy::UseProtocolCachePolicy); |
5812 } | 5812 } |
5813 | 5813 |
5814 if (IsReload(pending_navigation_params_->common_params.navigation_type)) | 5814 if (IsReload(pending_navigation_params_->common_params.navigation_type)) |
5815 document_state->set_load_type(DocumentState::RELOAD); | 5815 document_state->set_load_type(DocumentState::RELOAD); |
5816 else if (pending_navigation_params_->request_params.page_state.IsValid()) | 5816 else if (pending_navigation_params_->request_params.page_state.IsValid()) |
5817 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 5817 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
5818 else | 5818 else |
5819 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 5819 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
5820 | 5820 |
5821 internal_data->set_is_overriding_user_agent( | 5821 internal_data->set_is_overriding_user_agent( |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6032 int match_count, | 6032 int match_count, |
6033 int ordinal, | 6033 int ordinal, |
6034 const WebRect& selection_rect, | 6034 const WebRect& selection_rect, |
6035 bool final_status_update) { | 6035 bool final_status_update) { |
6036 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6036 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6037 selection_rect, ordinal, | 6037 selection_rect, ordinal, |
6038 final_status_update)); | 6038 final_status_update)); |
6039 } | 6039 } |
6040 | 6040 |
6041 } // namespace content | 6041 } // namespace content |
OLD | NEW |