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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "content/child/appcache_dispatcher.h" | 9 #include "content/child/appcache_dispatcher.h" |
10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 // notification before sending message to the browser process. | 483 // notification before sending message to the browser process. |
484 render_view_->didNavigateWithinPage(frame, is_new_navigation); | 484 render_view_->didNavigateWithinPage(frame, is_new_navigation); |
485 } | 485 } |
486 | 486 |
487 void RenderFrameImpl::didUpdateCurrentHistoryItem(WebKit::WebFrame* frame) { | 487 void RenderFrameImpl::didUpdateCurrentHistoryItem(WebKit::WebFrame* frame) { |
488 // TODO(nasko): Move implementation here. Needed methods: | 488 // TODO(nasko): Move implementation here. Needed methods: |
489 // * StartNavStateSyncTimerIfNecessary | 489 // * StartNavStateSyncTimerIfNecessary |
490 render_view_->didUpdateCurrentHistoryItem(frame); | 490 render_view_->didUpdateCurrentHistoryItem(frame); |
491 } | 491 } |
492 | 492 |
493 void RenderFrameImpl::willRequestAfterPreconnect( | |
494 WebKit::WebFrame* frame, | |
495 WebKit::WebURLRequest& request) { | |
496 WebKit::WebReferrerPolicy referrer_policy = WebKit::WebReferrerPolicyDefault; | |
jochen (gone - plz use gerrit)
2013/12/20 09:02:25
this should be frame->document().referrerPolicy();
| |
497 WebString custom_user_agent; | |
jochen (gone - plz use gerrit)
2013/12/20 09:02:25
this will never be a non-empty string, so we alway
| |
498 | |
499 if (request.extraData()) { | |
500 // This will only be called before willSendRequest, so only ExtraData | |
jochen (gone - plz use gerrit)
2013/12/20 09:02:25
only willSendRequest() ever sets extra data, so th
kouhei (in TOK)
2013/12/20 09:33:34
Pepper also sets this? custom_user_agent only seem
| |
501 // members we have to copy here is on WebURLRequestExtraDataImpl. | |
502 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = | |
503 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( | |
504 request.extraData()); | |
505 | |
506 referrer_policy = old_extra_data->referrer_policy(); | |
507 custom_user_agent = old_extra_data->custom_user_agent(); | |
508 } | |
509 | |
510 bool was_after_preconnect_request = true; | |
511 // The args after |was_after_preconnect_request| are not used, and set to | |
512 // correct values at |willSendRequest|. | |
513 request.setExtraData(new webkit_glue::WebURLRequestExtraDataImpl( | |
514 referrer_policy, custom_user_agent, was_after_preconnect_request)); | |
jochen (gone - plz use gerrit)
2013/12/20 09:02:25
the request is inspected in RenderFrameImpl::decid
| |
515 } | |
516 | |
493 void RenderFrameImpl::willSendRequest( | 517 void RenderFrameImpl::willSendRequest( |
494 WebKit::WebFrame* frame, | 518 WebKit::WebFrame* frame, |
495 unsigned identifier, | 519 unsigned identifier, |
496 WebKit::WebURLRequest& request, | 520 WebKit::WebURLRequest& request, |
497 const WebKit::WebURLResponse& redirect_response) { | 521 const WebKit::WebURLResponse& redirect_response) { |
498 // The request my be empty during tests. | 522 // The request my be empty during tests. |
499 if (request.url().isEmpty()) | 523 if (request.url().isEmpty()) |
500 return; | 524 return; |
501 | 525 |
502 WebFrame* top_frame = frame->top(); | 526 WebFrame* top_frame = frame->top(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 referrer_policy = internal_data->referrer_policy(); | 558 referrer_policy = internal_data->referrer_policy(); |
535 internal_data->clear_referrer_policy(); | 559 internal_data->clear_referrer_policy(); |
536 } else { | 560 } else { |
537 referrer_policy = frame->document().referrerPolicy(); | 561 referrer_policy = frame->document().referrerPolicy(); |
538 } | 562 } |
539 | 563 |
540 // The request's extra data may indicate that we should set a custom user | 564 // The request's extra data may indicate that we should set a custom user |
541 // agent. This needs to be done here, after WebKit is through with setting the | 565 // agent. This needs to be done here, after WebKit is through with setting the |
542 // user agent on its own. | 566 // user agent on its own. |
543 WebString custom_user_agent; | 567 WebString custom_user_agent; |
568 bool was_after_preconnect_request = false; | |
544 if (request.extraData()) { | 569 if (request.extraData()) { |
545 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = | 570 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = |
546 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( | 571 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( |
547 request.extraData()); | 572 request.extraData()); |
548 custom_user_agent = old_extra_data->custom_user_agent(); | 573 custom_user_agent = old_extra_data->custom_user_agent(); |
574 was_after_preconnect_request = | |
575 old_extra_data->was_after_preconnect_request(); | |
549 | 576 |
550 if (!custom_user_agent.isNull()) { | 577 if (!custom_user_agent.isNull()) { |
551 if (custom_user_agent.isEmpty()) | 578 if (custom_user_agent.isEmpty()) |
552 request.clearHTTPHeaderField("User-Agent"); | 579 request.clearHTTPHeaderField("User-Agent"); |
553 else | 580 else |
554 request.setHTTPHeaderField("User-Agent", custom_user_agent); | 581 request.setHTTPHeaderField("User-Agent", custom_user_agent); |
555 } | 582 } |
556 } | 583 } |
557 | 584 |
558 request.setExtraData( | 585 request.setExtraData( |
559 new RequestExtraData(referrer_policy, | 586 new RequestExtraData(referrer_policy, |
560 custom_user_agent, | 587 custom_user_agent, |
588 was_after_preconnect_request, | |
561 (frame == top_frame), | 589 (frame == top_frame), |
562 frame->identifier(), | 590 frame->identifier(), |
563 frame->parent() == top_frame, | 591 frame->parent() == top_frame, |
564 frame->parent() ? frame->parent()->identifier() : -1, | 592 frame->parent() ? frame->parent()->identifier() : -1, |
565 navigation_state->allow_download(), | 593 navigation_state->allow_download(), |
566 transition_type, | 594 transition_type, |
567 navigation_state->transferred_request_child_id(), | 595 navigation_state->transferred_request_child_id(), |
568 navigation_state->transferred_request_request_id())); | 596 navigation_state->transferred_request_request_id())); |
569 | 597 |
570 DocumentState* top_document_state = | 598 DocumentState* top_document_state = |
571 DocumentState::FromDataSource(top_data_source); | 599 DocumentState::FromDataSource(top_data_source); |
572 // TODO(gavinp): separate out prefetching and prerender field trials | 600 if (top_document_state) { |
573 // if the rel=prerender rel type is sticking around. | 601 // TODO(gavinp): separate out prefetching and prerender field trials |
574 if (top_document_state && | 602 // if the rel=prerender rel type is sticking around. |
575 request.targetType() == WebURLRequest::TargetIsPrefetch) | 603 if (request.targetType() == WebURLRequest::TargetIsPrefetch) |
576 top_document_state->set_was_prefetcher(true); | 604 top_document_state->set_was_prefetcher(true); |
605 | |
606 if (was_after_preconnect_request) | |
607 top_document_state->set_was_after_preconnect_request(true); | |
608 } | |
577 | 609 |
578 // This is an instance where we embed a copy of the routing id | 610 // This is an instance where we embed a copy of the routing id |
579 // into the data portion of the message. This can cause problems if we | 611 // into the data portion of the message. This can cause problems if we |
580 // don't register this id on the browser side, since the download manager | 612 // don't register this id on the browser side, since the download manager |
581 // expects to find a RenderViewHost based off the id. | 613 // expects to find a RenderViewHost based off the id. |
582 request.setRequestorID(GetRoutingID()); | 614 request.setRequestorID(GetRoutingID()); |
583 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 615 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
584 | 616 |
585 if (!navigation_state->extra_headers().empty()) { | 617 if (!navigation_state->extra_headers().empty()) { |
586 for (net::HttpUtil::HeadersIterator i( | 618 for (net::HttpUtil::HeadersIterator i( |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 | 936 |
905 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, | 937 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, |
906 int arb_robustness_status_code) { | 938 int arb_robustness_status_code) { |
907 Send(new ViewHostMsg_DidLose3DContext( | 939 Send(new ViewHostMsg_DidLose3DContext( |
908 GURL(frame->top()->document().securityOrigin().toString()), | 940 GURL(frame->top()->document().securityOrigin().toString()), |
909 THREE_D_API_TYPE_WEBGL, | 941 THREE_D_API_TYPE_WEBGL, |
910 arb_robustness_status_code)); | 942 arb_robustness_status_code)); |
911 } | 943 } |
912 | 944 |
913 } // namespace content | 945 } // namespace content |
OLD | NEW |