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/browser/frame_host/navigation_entry_impl.h" | 5 #include "content/browser/frame_host/navigation_entry_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "components/url_formatter/url_formatter.h" | 17 #include "components/url_formatter/url_formatter.h" |
18 #include "content/common/content_constants_internal.h" | 18 #include "content/common/content_constants_internal.h" |
19 #include "content/common/navigation_params.h" | 19 #include "content/common/navigation_params.h" |
20 #include "content/common/page_state_serialization.h" | 20 #include "content/common/page_state_serialization.h" |
| 21 #include "content/common/resource_request_body.h" |
21 #include "content/common/site_isolation_policy.h" | 22 #include "content/common/site_isolation_policy.h" |
22 #include "content/public/common/browser_side_navigation_policy.h" | 23 #include "content/public/common/browser_side_navigation_policy.h" |
23 #include "content/public/common/content_constants.h" | 24 #include "content/public/common/content_constants.h" |
24 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
25 #include "ui/gfx/text_elider.h" | 26 #include "ui/gfx/text_elider.h" |
26 | 27 |
27 using base::UTF16ToUTF8; | 28 using base::UTF16ToUTF8; |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 // ResetForCommit: should_replace_entry_ | 563 // ResetForCommit: should_replace_entry_ |
563 copy->redirect_chain_ = redirect_chain_; | 564 copy->redirect_chain_ = redirect_chain_; |
564 // ResetForCommit: should_clear_history_list_ | 565 // ResetForCommit: should_clear_history_list_ |
565 // ResetForCommit: frame_tree_node_id_ | 566 // ResetForCommit: frame_tree_node_id_ |
566 // ResetForCommit: intent_received_timestamp_ | 567 // ResetForCommit: intent_received_timestamp_ |
567 copy->extra_data_ = extra_data_; | 568 copy->extra_data_ = extra_data_; |
568 | 569 |
569 return copy; | 570 return copy; |
570 } | 571 } |
571 | 572 |
| 573 scoped_refptr<ResourceRequestBody> |
| 574 NavigationEntryImpl::ConstructBodyFromBrowserInitiatedPostData() const { |
| 575 scoped_refptr<ResourceRequestBody> browser_initiated_post_body; |
| 576 if (GetHasPostData()) { |
| 577 if (const base::RefCountedMemory* memory = GetBrowserInitiatedPostData()) { |
| 578 browser_initiated_post_body = new ResourceRequestBody(); |
| 579 browser_initiated_post_body->AppendBytes(memory->front_as<char>(), |
| 580 memory->size()); |
| 581 } |
| 582 } |
| 583 return browser_initiated_post_body; |
| 584 } |
| 585 |
572 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( | 586 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( |
573 const FrameNavigationEntry& frame_entry, | 587 const FrameNavigationEntry& frame_entry, |
| 588 const scoped_refptr<ResourceRequestBody>& post_body, |
574 const GURL& dest_url, | 589 const GURL& dest_url, |
575 const Referrer& dest_referrer, | 590 const Referrer& dest_referrer, |
576 FrameMsg_Navigate_Type::Value navigation_type, | 591 FrameMsg_Navigate_Type::Value navigation_type, |
577 LoFiState lofi_state, | 592 LoFiState lofi_state, |
578 const base::TimeTicks& navigation_start) const { | 593 const base::TimeTicks& navigation_start) const { |
579 FrameMsg_UILoadMetricsReportType::Value report_type = | 594 FrameMsg_UILoadMetricsReportType::Value report_type = |
580 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 595 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
581 base::TimeTicks ui_timestamp = base::TimeTicks(); | 596 base::TimeTicks ui_timestamp = base::TimeTicks(); |
582 #if defined(OS_ANDROID) | 597 #if defined(OS_ANDROID) |
583 if (!intent_received_timestamp().is_null()) | 598 if (!intent_received_timestamp().is_null()) |
584 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | 599 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; |
585 ui_timestamp = intent_received_timestamp(); | 600 ui_timestamp = intent_received_timestamp(); |
586 #endif | 601 #endif |
587 | 602 |
588 std::string method; | 603 std::string method; |
589 | 604 |
590 // TODO(clamy): Consult the FrameNavigationEntry in all modes that use | 605 // TODO(clamy): Consult the FrameNavigationEntry in all modes that use |
591 // subframe navigation entries. | 606 // subframe navigation entries. |
592 if (IsBrowserSideNavigationEnabled()) | 607 if (IsBrowserSideNavigationEnabled()) |
593 method = frame_entry.method(); | 608 method = frame_entry.method(); |
594 else | 609 else |
595 method = GetHasPostData() ? "POST" : "GET"; | 610 method = (post_body.get() || GetHasPostData()) ? "POST" : "GET"; |
596 | 611 |
597 return CommonNavigationParams( | 612 return CommonNavigationParams( |
598 dest_url, dest_referrer, GetTransitionType(), navigation_type, | 613 dest_url, dest_referrer, GetTransitionType(), navigation_type, |
599 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, | 614 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, |
600 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, | 615 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, |
601 navigation_start, method); | 616 navigation_start, method, |
| 617 post_body ? post_body : ConstructBodyFromBrowserInitiatedPostData()); |
602 } | 618 } |
603 | 619 |
604 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() | 620 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() |
605 const { | 621 const { |
606 std::vector<unsigned char> browser_initiated_post_data; | 622 return StartNavigationParams(extra_headers(), |
607 if (GetBrowserInitiatedPostData()) { | |
608 browser_initiated_post_data.assign( | |
609 GetBrowserInitiatedPostData()->front(), | |
610 GetBrowserInitiatedPostData()->front() + | |
611 GetBrowserInitiatedPostData()->size()); | |
612 } | |
613 | |
614 return StartNavigationParams(extra_headers(), browser_initiated_post_data, | |
615 #if defined(OS_ANDROID) | 623 #if defined(OS_ANDROID) |
616 has_user_gesture(), | 624 has_user_gesture(), |
617 #endif | 625 #endif |
618 transferred_global_request_id().child_id, | 626 transferred_global_request_id().child_id, |
619 transferred_global_request_id().request_id); | 627 transferred_global_request_id().request_id); |
620 } | 628 } |
621 | 629 |
622 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( | 630 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( |
623 const FrameNavigationEntry& frame_entry, | 631 const FrameNavigationEntry& frame_entry, |
624 bool is_same_document_history_load, | 632 bool is_same_document_history_load, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 return node; | 777 return node; |
770 | 778 |
771 // Enqueue any children and keep looking. | 779 // Enqueue any children and keep looking. |
772 for (auto& child : node->children) | 780 for (auto& child : node->children) |
773 work_queue.push(child); | 781 work_queue.push(child); |
774 } | 782 } |
775 return nullptr; | 783 return nullptr; |
776 } | 784 } |
777 | 785 |
778 } // namespace content | 786 } // namespace content |
OLD | NEW |