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 4161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4172 void RenderFrameImpl::SaveImageFromDataURL(const blink::WebString& data_url) { | 4172 void RenderFrameImpl::SaveImageFromDataURL(const blink::WebString& data_url) { |
4173 // Note: We should basically send GURL but we use size-limited string instead | 4173 // Note: We should basically send GURL but we use size-limited string instead |
4174 // in order to send a larger data url to save a image for <canvas> or <img>. | 4174 // in order to send a larger data url to save a image for <canvas> or <img>. |
4175 if (data_url.length() < kMaxLengthOfDataURLString) { | 4175 if (data_url.length() < kMaxLengthOfDataURLString) { |
4176 Send(new FrameHostMsg_SaveImageFromDataURL(render_view_->GetRoutingID(), | 4176 Send(new FrameHostMsg_SaveImageFromDataURL(render_view_->GetRoutingID(), |
4177 routing_id_, data_url.Utf8())); | 4177 routing_id_, data_url.Utf8())); |
4178 } | 4178 } |
4179 } | 4179 } |
4180 | 4180 |
4181 void RenderFrameImpl::WillSendRequest(blink::WebURLRequest& request) { | 4181 void RenderFrameImpl::WillSendRequest(blink::WebURLRequest& request) { |
4182 // Set the first party for cookies url if it has not been set yet (new | |
4183 // requests). This value will be updated during redirects, consistent with | |
4184 // https://tools.ietf.org/html/draft-west-first-party-cookies-04#section-2.1.1 | |
4185 if (request.FirstPartyForCookies().IsEmpty()) { | |
4186 if (request.GetFrameType() == blink::WebURLRequest::kFrameTypeTopLevel) | |
4187 request.SetFirstPartyForCookies(request.Url()); | |
4188 else | |
4189 request.SetFirstPartyForCookies( | |
4190 frame_->GetDocument().FirstPartyForCookies()); | |
4191 } | |
4192 | |
4193 // Set the requestor origin to the same origin as the frame's document if it | |
4194 // hasn't yet been set. | |
4195 // | |
4196 // TODO(mkwst): It would be cleaner to adjust blink::ResourceRequest to | |
4197 // initialize itself with a `nullptr` initiator so that this can be a simple | |
4198 // `isNull()` check. https://crbug.com/625969 | |
tyoshino (SeeGerritForStatus)
2017/06/08 04:45:44
Add 625969 to the BUG line
kinuko
2017/06/08 04:55:30
Done.
| |
4199 WebDocument frame_document = frame_->GetDocument(); | |
4200 if (request.RequestorOrigin().IsUnique() && | |
4201 !frame_document.GetSecurityOrigin().IsUnique()) { | |
4202 request.SetRequestorOrigin(frame_document.GetSecurityOrigin()); | |
4203 } | |
4204 | |
4205 WebDataSource* provisional_data_source = frame_->ProvisionalDataSource(); | 4182 WebDataSource* provisional_data_source = frame_->ProvisionalDataSource(); |
4206 WebDataSource* data_source = | 4183 WebDataSource* data_source = |
4207 provisional_data_source ? provisional_data_source : frame_->DataSource(); | 4184 provisional_data_source ? provisional_data_source : frame_->DataSource(); |
4208 | 4185 |
4209 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 4186 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
4210 DCHECK(document_state); | 4187 DCHECK(document_state); |
4211 InternalDocumentStateData* internal_data = | 4188 InternalDocumentStateData* internal_data = |
4212 InternalDocumentStateData::FromDocumentState(document_state); | 4189 InternalDocumentStateData::FromDocumentState(document_state); |
4213 NavigationStateImpl* navigation_state = | 4190 NavigationStateImpl* navigation_state = |
4214 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4191 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4265 | 4242 |
4266 // Attach |should_replace_current_entry| state to requests so that, should | 4243 // Attach |should_replace_current_entry| state to requests so that, should |
4267 // this navigation later require a request transfer, all state is preserved | 4244 // this navigation later require a request transfer, all state is preserved |
4268 // when it is re-created in the new process. | 4245 // when it is re-created in the new process. |
4269 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); | 4246 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); |
4270 | 4247 |
4271 WebFrame* parent = frame_->Parent(); | 4248 WebFrame* parent = frame_->Parent(); |
4272 int parent_routing_id = | 4249 int parent_routing_id = |
4273 parent ? RenderFrame::GetRoutingIdForWebFrame(parent) : -1; | 4250 parent ? RenderFrame::GetRoutingIdForWebFrame(parent) : -1; |
4274 | 4251 |
4252 WebDocument frame_document = frame_->GetDocument(); | |
4275 RequestExtraData* extra_data = | 4253 RequestExtraData* extra_data = |
4276 static_cast<RequestExtraData*>(request.GetExtraData()); | 4254 static_cast<RequestExtraData*>(request.GetExtraData()); |
4277 if (!extra_data) | 4255 if (!extra_data) |
4278 extra_data = new RequestExtraData(); | 4256 extra_data = new RequestExtraData(); |
4279 extra_data->set_visibility_state(VisibilityState()); | 4257 extra_data->set_visibility_state(VisibilityState()); |
4280 extra_data->set_custom_user_agent(custom_user_agent); | 4258 extra_data->set_custom_user_agent(custom_user_agent); |
4281 extra_data->set_requested_with(requested_with); | 4259 extra_data->set_requested_with(requested_with); |
4282 extra_data->set_render_frame_id(routing_id_); | 4260 extra_data->set_render_frame_id(routing_id_); |
4283 extra_data->set_is_main_frame(!parent); | 4261 extra_data->set_is_main_frame(!parent); |
4284 extra_data->set_frame_origin(url::Origin(frame_document.GetSecurityOrigin())); | 4262 extra_data->set_frame_origin(url::Origin(frame_document.GetSecurityOrigin())); |
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6240 if (request_params.should_clear_history_list) { | 6218 if (request_params.should_clear_history_list) { |
6241 CHECK_EQ(-1, render_view_->history_list_offset_); | 6219 CHECK_EQ(-1, render_view_->history_list_offset_); |
6242 CHECK_EQ(0, render_view_->history_list_length_); | 6220 CHECK_EQ(0, render_view_->history_list_length_); |
6243 } | 6221 } |
6244 } | 6222 } |
6245 | 6223 |
6246 void RenderFrameImpl::BeginNavigation(const NavigationPolicyInfo& info) { | 6224 void RenderFrameImpl::BeginNavigation(const NavigationPolicyInfo& info) { |
6247 CHECK(IsBrowserSideNavigationEnabled()); | 6225 CHECK(IsBrowserSideNavigationEnabled()); |
6248 browser_side_navigation_pending_ = true; | 6226 browser_side_navigation_pending_ = true; |
6249 | 6227 |
6228 blink::WebURLRequest& request = info.url_request; | |
6229 | |
6250 // Note: At this stage, the goal is to apply all the modifications the | 6230 // Note: At this stage, the goal is to apply all the modifications the |
6251 // renderer wants to make to the request, and then send it to the browser, so | 6231 // renderer wants to make to the request, and then send it to the browser, so |
6252 // that the actual network request can be started. Ideally, all such | 6232 // that the actual network request can be started. Ideally, all such |
6253 // modifications should take place in willSendRequest, and in the | 6233 // modifications should take place in willSendRequest, and in the |
6254 // implementation of willSendRequest for the various InspectorAgents | 6234 // implementation of willSendRequest for the various InspectorAgents |
6255 // (devtools). | 6235 // (devtools). |
6256 // | 6236 // |
6257 // TODO(clamy): Apply devtools override. | 6237 // TODO(clamy): Apply devtools override. |
6258 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 6238 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
6259 // else in blink. | 6239 // else in blink. |
6260 WillSendRequest(info.url_request); | 6240 WillSendRequest(request); |
6241 | |
6242 // Set RequestorInfo and FirstPartyForCookies. | |
tyoshino (SeeGerritForStatus)
2017/06/08 04:45:45
RequestorInfo -> RequestorOrigin
kinuko
2017/06/08 04:55:30
Done.
| |
6243 WebDocument frame_document = frame_->GetDocument(); | |
6244 if (request.GetFrameType() == blink::WebURLRequest::kFrameTypeTopLevel) | |
6245 request.SetFirstPartyForCookies(request.Url()); | |
6246 else | |
6247 request.SetFirstPartyForCookies(frame_document.FirstPartyForCookies()); | |
6248 request.SetRequestorOrigin(frame_document.GetSecurityOrigin()); | |
6261 | 6249 |
6262 // Update the transition type of the request for client side redirects. | 6250 // Update the transition type of the request for client side redirects. |
6263 if (!info.url_request.GetExtraData()) | 6251 if (!info.url_request.GetExtraData()) |
tyoshino (SeeGerritForStatus)
2017/06/08 04:45:45
use request everywhere in this function?
kinuko
2017/06/08 04:55:30
Was a bit afraid it might make the change unnecess
| |
6264 info.url_request.SetExtraData(new RequestExtraData()); | 6252 info.url_request.SetExtraData(new RequestExtraData()); |
6265 if (info.is_client_redirect) { | 6253 if (info.is_client_redirect) { |
6266 RequestExtraData* extra_data = | 6254 RequestExtraData* extra_data = |
6267 static_cast<RequestExtraData*>(info.url_request.GetExtraData()); | 6255 static_cast<RequestExtraData*>(info.url_request.GetExtraData()); |
6268 extra_data->set_transition_type(ui::PageTransitionFromInt( | 6256 extra_data->set_transition_type(ui::PageTransitionFromInt( |
6269 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); | 6257 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); |
6270 } | 6258 } |
6271 | 6259 |
6272 // TODO(clamy): Same-document navigations should not be sent back to the | 6260 // TODO(clamy): Same-document navigations should not be sent back to the |
6273 // browser. | 6261 // browser. |
6274 // TODO(clamy): Data urls should not be sent back to the browser either. | 6262 // TODO(clamy): Data urls should not be sent back to the browser either. |
6275 // These values are assumed on the browser side for navigations. These checks | 6263 // These values are assumed on the browser side for navigations. These checks |
6276 // ensure the renderer has the correct values. | 6264 // ensure the renderer has the correct values. |
6277 DCHECK_EQ(FETCH_REQUEST_MODE_NAVIGATE, | 6265 DCHECK_EQ(FETCH_REQUEST_MODE_NAVIGATE, |
6278 GetFetchRequestModeForWebURLRequest(info.url_request)); | 6266 GetFetchRequestModeForWebURLRequest(info.url_request)); |
6279 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, | 6267 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, |
6280 GetFetchCredentialsModeForWebURLRequest(info.url_request)); | 6268 GetFetchCredentialsModeForWebURLRequest(info.url_request)); |
6281 DCHECK(GetFetchRedirectModeForWebURLRequest(info.url_request) == | 6269 DCHECK(GetFetchRedirectModeForWebURLRequest(info.url_request) == |
6282 FetchRedirectMode::MANUAL_MODE); | 6270 FetchRedirectMode::MANUAL_MODE); |
6283 DCHECK(frame_->Parent() || | 6271 DCHECK(frame_->Parent() || |
6284 GetRequestContextFrameTypeForWebURLRequest(info.url_request) == | 6272 GetRequestContextFrameTypeForWebURLRequest(info.url_request) == |
6285 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 6273 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
6286 DCHECK(!frame_->Parent() || | 6274 DCHECK(!frame_->Parent() || |
6287 GetRequestContextFrameTypeForWebURLRequest(info.url_request) == | 6275 GetRequestContextFrameTypeForWebURLRequest(info.url_request) == |
6288 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 6276 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
6289 | 6277 |
6278 DCHECK(!info.url_request.RequestorOrigin().IsNull()); | |
6290 base::Optional<url::Origin> initiator_origin = | 6279 base::Optional<url::Origin> initiator_origin = |
6291 info.url_request.RequestorOrigin().IsNull() | 6280 base::Optional<url::Origin>(info.url_request.RequestorOrigin()); |
6292 ? base::Optional<url::Origin>() | |
6293 : base::Optional<url::Origin>(info.url_request.RequestorOrigin()); | |
6294 | 6281 |
6295 int load_flags = GetLoadFlagsForWebURLRequest(info.url_request); | 6282 int load_flags = GetLoadFlagsForWebURLRequest(info.url_request); |
6296 | 6283 |
6297 // Requests initiated via devtools can have caching disabled. | 6284 // Requests initiated via devtools can have caching disabled. |
6298 if (info.is_cache_disabled) { | 6285 if (info.is_cache_disabled) { |
6299 // Turn off all caching related flags and set LOAD_BYPASS_CACHE. | 6286 // Turn off all caching related flags and set LOAD_BYPASS_CACHE. |
6300 load_flags &= ~(net::LOAD_VALIDATE_CACHE | net::LOAD_SKIP_CACHE_VALIDATION | | 6287 load_flags &= ~(net::LOAD_VALIDATE_CACHE | net::LOAD_SKIP_CACHE_VALIDATION | |
6301 net::LOAD_ONLY_FROM_CACHE | net::LOAD_DISABLE_CACHE); | 6288 net::LOAD_ONLY_FROM_CACHE | net::LOAD_DISABLE_CACHE); |
6302 load_flags |= net::LOAD_BYPASS_CACHE; | 6289 load_flags |= net::LOAD_BYPASS_CACHE; |
6303 } | 6290 } |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6814 policy(info.default_policy), | 6801 policy(info.default_policy), |
6815 replaces_current_history_item(info.replaces_current_history_item), | 6802 replaces_current_history_item(info.replaces_current_history_item), |
6816 history_navigation_in_new_child_frame( | 6803 history_navigation_in_new_child_frame( |
6817 info.is_history_navigation_in_new_child_frame), | 6804 info.is_history_navigation_in_new_child_frame), |
6818 client_redirect(info.is_client_redirect), | 6805 client_redirect(info.is_client_redirect), |
6819 cache_disabled(info.is_cache_disabled), | 6806 cache_disabled(info.is_cache_disabled), |
6820 form(info.form), | 6807 form(info.form), |
6821 source_location(info.source_location) {} | 6808 source_location(info.source_location) {} |
6822 | 6809 |
6823 } // namespace content | 6810 } // namespace content |
OLD | NEW |