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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 #include "media/blink/webencryptedmediaclient_impl.h" | 143 #include "media/blink/webencryptedmediaclient_impl.h" |
144 #include "media/blink/webmediaplayer_impl.h" | 144 #include "media/blink/webmediaplayer_impl.h" |
145 #include "media/renderers/gpu_video_accelerator_factories.h" | 145 #include "media/renderers/gpu_video_accelerator_factories.h" |
146 #include "mojo/common/url_type_converters.h" | 146 #include "mojo/common/url_type_converters.h" |
147 #include "mojo/edk/js/core.h" | 147 #include "mojo/edk/js/core.h" |
148 #include "mojo/edk/js/support.h" | 148 #include "mojo/edk/js/support.h" |
149 #include "net/base/data_url.h" | 149 #include "net/base/data_url.h" |
150 #include "net/base/net_errors.h" | 150 #include "net/base/net_errors.h" |
151 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 151 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
152 #include "net/http/http_util.h" | 152 #include "net/http/http_util.h" |
153 #include "storage/common/data_element.h" | |
153 #include "third_party/WebKit/public/platform/URLConversion.h" | 154 #include "third_party/WebKit/public/platform/URLConversion.h" |
154 #include "third_party/WebKit/public/platform/WebCachePolicy.h" | 155 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
155 #include "third_party/WebKit/public/platform/WebData.h" | 156 #include "third_party/WebKit/public/platform/WebData.h" |
156 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 157 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
157 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 158 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
158 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 159 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
159 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 160 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
160 #include "third_party/WebKit/public/platform/WebString.h" | 161 #include "third_party/WebKit/public/platform/WebString.h" |
161 #include "third_party/WebKit/public/platform/WebURL.h" | 162 #include "third_party/WebKit/public/platform/WebURL.h" |
162 #include "third_party/WebKit/public/platform/WebURLError.h" | 163 #include "third_party/WebKit/public/platform/WebURLError.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 // passed back to the browser in the DidCommitProvisionalLoad and the | 533 // passed back to the browser in the DidCommitProvisionalLoad and the |
533 // DocumentLoadComplete IPCs. | 534 // DocumentLoadComplete IPCs. |
534 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 535 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
535 request.setUiStartTime(ui_timestamp.InSecondsF()); | 536 request.setUiStartTime(ui_timestamp.InSecondsF()); |
536 request.setInputPerfMetricReportPolicy( | 537 request.setInputPerfMetricReportPolicy( |
537 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( | 538 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( |
538 common_params.report_type)); | 539 common_params.report_type)); |
539 return request; | 540 return request; |
540 } | 541 } |
541 | 542 |
543 // Converts the HTTP body data stored in ResourceRequestBody format to a | |
544 // WebHTTPBody, which is then added to the WebURLRequest. | |
545 // PlzNavigate: used to add the POST data sent by the renderer at commit time | |
546 // to the WebURLRequest used to commit the navigation. This ensures that the | |
547 // POST data will be in the PageState sent to the browser on commit. | |
548 void AddHTTPBodyToRequest(WebURLRequest* request, | |
549 const scoped_refptr<ResourceRequestBody>& body) { | |
Łukasz Anforowicz
2016/05/17 23:52:56
This function is more-or-less copy&pasted from htt
| |
550 WebHTTPBody http_body; | |
551 http_body.initialize(); | |
552 http_body.setIdentifier(body->identifier()); | |
553 for (const ResourceRequestBody::Element& element : *(body->elements())) { | |
554 long long length = -1; | |
555 switch (element.type()) { | |
556 case storage::DataElement::TYPE_BYTES: | |
557 http_body.appendData(WebData(element.bytes(), element.length())); | |
558 break; | |
559 case storage::DataElement::TYPE_FILE: | |
560 if (element.length() != std::numeric_limits<uint64_t>::max()) | |
561 length = element.length(); | |
562 http_body.appendFileRange( | |
563 element.path().AsUTF16Unsafe(), element.offset(), length, | |
564 element.expected_modification_time().ToDoubleT()); | |
565 break; | |
566 case storage::DataElement::TYPE_FILE_FILESYSTEM: | |
567 http_body.appendFileSystemURLRange( | |
568 element.filesystem_url(), element.offset(), element.length(), | |
569 element.expected_modification_time().ToDoubleT()); | |
570 break; | |
571 case storage::DataElement::TYPE_BLOB: | |
572 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); | |
573 break; | |
574 default: | |
575 // TYPE_BYTES_DESCRIPTION and TYPE_DISK_CACHE_ENTRY should not be | |
576 // encountered. | |
577 NOTREACHED(); | |
578 break; | |
579 } | |
580 } | |
581 request->setHTTPBody(http_body); | |
582 } | |
583 | |
542 // Sanitizes the navigation_start timestamp for browser-initiated navigations, | 584 // Sanitizes the navigation_start timestamp for browser-initiated navigations, |
543 // where the browser possibly has a better notion of start time than the | 585 // where the browser possibly has a better notion of start time than the |
544 // renderer. In the case of cross-process navigations, this carries over the | 586 // renderer. In the case of cross-process navigations, this carries over the |
545 // time of finishing the onbeforeunload handler of the previous page. | 587 // time of finishing the onbeforeunload handler of the previous page. |
546 // TimeTicks is sometimes not monotonic across processes, and because | 588 // TimeTicks is sometimes not monotonic across processes, and because |
547 // |browser_navigation_start| is likely before this process existed, | 589 // |browser_navigation_start| is likely before this process existed, |
548 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by | 590 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by |
549 // clamping it to renderer_navigation_start, initialized earlier in the call | 591 // clamping it to renderer_navigation_start, initialized earlier in the call |
550 // stack. | 592 // stack. |
551 base::TimeTicks SanitizeNavigationTiming( | 593 base::TimeTicks SanitizeNavigationTiming( |
(...skipping 4820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5372 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 5414 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
5373 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 5415 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
5374 start_params.extra_headers.end(), | 5416 start_params.extra_headers.end(), |
5375 "\n"); | 5417 "\n"); |
5376 i.GetNext();) { | 5418 i.GetNext();) { |
5377 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 5419 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
5378 WebString::fromUTF8(i.values())); | 5420 WebString::fromUTF8(i.values())); |
5379 } | 5421 } |
5380 } | 5422 } |
5381 | 5423 |
5382 if (common_params.method == "POST" && !browser_side_navigation) { | 5424 if (common_params.method == "POST" && !browser_side_navigation && |
5383 // Set post data. | 5425 start_params.post_data) { |
5384 WebHTTPBody http_body; | 5426 AddHTTPBodyToRequest(&request, start_params.post_data); |
5385 http_body.initialize(); | |
5386 const char* data = nullptr; | |
5387 if (start_params.browser_initiated_post_data.size()) { | |
5388 data = reinterpret_cast<const char*>( | |
5389 &start_params.browser_initiated_post_data.front()); | |
5390 } | |
5391 http_body.appendData( | |
5392 WebData(data, start_params.browser_initiated_post_data.size())); | |
5393 request.setHTTPBody(http_body); | |
5394 } | 5427 } |
5395 | 5428 |
5396 // A session history navigation should have been accompanied by state. | 5429 // A session history navigation should have been accompanied by state. |
5397 CHECK_EQ(request_params.page_id, -1); | 5430 CHECK_EQ(request_params.page_id, -1); |
5398 | 5431 |
5399 should_load_request = true; | 5432 should_load_request = true; |
5400 } | 5433 } |
5401 | 5434 |
5402 if (should_load_request) { | 5435 if (should_load_request) { |
5403 // Sanitize navigation start now that we know the load_type. | 5436 // Sanitize navigation start now that we know the load_type. |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6094 // event target. Potentially a Pepper plugin will receive the event. | 6127 // event target. Potentially a Pepper plugin will receive the event. |
6095 // In order to tell whether a plugin gets the last mouse event and which it | 6128 // In order to tell whether a plugin gets the last mouse event and which it |
6096 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6129 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6097 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6130 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6098 // |pepper_last_mouse_event_target_|. | 6131 // |pepper_last_mouse_event_target_|. |
6099 pepper_last_mouse_event_target_ = nullptr; | 6132 pepper_last_mouse_event_target_ = nullptr; |
6100 #endif | 6133 #endif |
6101 } | 6134 } |
6102 | 6135 |
6103 } // namespace content | 6136 } // namespace content |
OLD | NEW |