| 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/content_constants.h" | 23 #include "content/public/common/content_constants.h" |
| 23 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 24 #include "ui/gfx/text_elider.h" | 25 #include "ui/gfx/text_elider.h" |
| 25 | 26 |
| 26 using base::UTF16ToUTF8; | 27 using base::UTF16ToUTF8; |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 // ResetForCommit: should_replace_entry_ | 562 // ResetForCommit: should_replace_entry_ |
| 562 copy->redirect_chain_ = redirect_chain_; | 563 copy->redirect_chain_ = redirect_chain_; |
| 563 // ResetForCommit: should_clear_history_list_ | 564 // ResetForCommit: should_clear_history_list_ |
| 564 // ResetForCommit: frame_tree_node_id_ | 565 // ResetForCommit: frame_tree_node_id_ |
| 565 // ResetForCommit: intent_received_timestamp_ | 566 // ResetForCommit: intent_received_timestamp_ |
| 566 copy->extra_data_ = extra_data_; | 567 copy->extra_data_ = extra_data_; |
| 567 | 568 |
| 568 return copy; | 569 return copy; |
| 569 } | 570 } |
| 570 | 571 |
| 572 scoped_refptr<ResourceRequestBody> |
| 573 NavigationEntryImpl::ConstructResourceRequestBody() const { |
| 574 scoped_refptr<ResourceRequestBody> browser_initiated_post_body; |
| 575 if (GetHasPostData()) { |
| 576 if (const base::RefCountedMemory* memory = GetBrowserInitiatedPostData()) { |
| 577 browser_initiated_post_body = new ResourceRequestBody(); |
| 578 browser_initiated_post_body->AppendBytes(memory->front_as<char>(), |
| 579 memory->size()); |
| 580 } |
| 581 } |
| 582 return browser_initiated_post_body; |
| 583 } |
| 584 |
| 571 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( | 585 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( |
| 586 const std::string& method, |
| 572 const GURL& dest_url, | 587 const GURL& dest_url, |
| 573 const Referrer& dest_referrer, | 588 const Referrer& dest_referrer, |
| 574 FrameMsg_Navigate_Type::Value navigation_type, | 589 FrameMsg_Navigate_Type::Value navigation_type, |
| 575 LoFiState lofi_state, | 590 LoFiState lofi_state, |
| 576 const base::TimeTicks& navigation_start) const { | 591 const base::TimeTicks& navigation_start) const { |
| 577 FrameMsg_UILoadMetricsReportType::Value report_type = | 592 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 578 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 593 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 579 base::TimeTicks ui_timestamp = base::TimeTicks(); | 594 base::TimeTicks ui_timestamp = base::TimeTicks(); |
| 580 #if defined(OS_ANDROID) | 595 #if defined(OS_ANDROID) |
| 581 if (!intent_received_timestamp().is_null()) | 596 if (!intent_received_timestamp().is_null()) |
| 582 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | 597 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; |
| 583 ui_timestamp = intent_received_timestamp(); | 598 ui_timestamp = intent_received_timestamp(); |
| 584 #endif | 599 #endif |
| 585 | 600 |
| 601 if (GetHasPostData()) |
| 602 DCHECK_EQ("POST", method); |
| 603 |
| 586 return CommonNavigationParams( | 604 return CommonNavigationParams( |
| 587 dest_url, dest_referrer, GetTransitionType(), navigation_type, | 605 dest_url, dest_referrer, GetTransitionType(), navigation_type, |
| 588 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, | 606 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, |
| 589 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, | 607 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, |
| 590 navigation_start, GetHasPostData() ? "POST" : "GET"); | 608 navigation_start, method); |
| 591 } | 609 } |
| 592 | 610 |
| 593 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() | 611 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams( |
| 594 const { | 612 const scoped_refptr<ResourceRequestBody>& post_body) const { |
| 595 std::vector<unsigned char> browser_initiated_post_data; | 613 return StartNavigationParams( |
| 596 if (GetBrowserInitiatedPostData()) { | 614 extra_headers(), post_body ? post_body : ConstructResourceRequestBody(), |
| 597 browser_initiated_post_data.assign( | |
| 598 GetBrowserInitiatedPostData()->front(), | |
| 599 GetBrowserInitiatedPostData()->front() + | |
| 600 GetBrowserInitiatedPostData()->size()); | |
| 601 } | |
| 602 | |
| 603 return StartNavigationParams(extra_headers(), browser_initiated_post_data, | |
| 604 #if defined(OS_ANDROID) | 615 #if defined(OS_ANDROID) |
| 605 has_user_gesture(), | 616 has_user_gesture(), |
| 606 #endif | 617 #endif |
| 607 transferred_global_request_id().child_id, | 618 transferred_global_request_id().child_id, |
| 608 transferred_global_request_id().request_id); | 619 transferred_global_request_id().request_id); |
| 609 } | 620 } |
| 610 | 621 |
| 611 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( | 622 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( |
| 612 const FrameNavigationEntry& frame_entry, | 623 const FrameNavigationEntry& frame_entry, |
| 613 bool is_same_document_history_load, | 624 bool is_same_document_history_load, |
| 614 bool has_committed_real_load, | 625 bool has_committed_real_load, |
| 615 bool intended_as_new_entry, | 626 bool intended_as_new_entry, |
| 616 int pending_history_list_offset, | 627 int pending_history_list_offset, |
| 617 int current_history_list_offset, | 628 int current_history_list_offset, |
| 618 int current_history_list_length) const { | 629 int current_history_list_length) const { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 return node; | 769 return node; |
| 759 | 770 |
| 760 // Enqueue any children and keep looking. | 771 // Enqueue any children and keep looking. |
| 761 for (auto& child : node->children) | 772 for (auto& child : node->children) |
| 762 work_queue.push(child); | 773 work_queue.push(child); |
| 763 } | 774 } |
| 764 return nullptr; | 775 return nullptr; |
| 765 } | 776 } |
| 766 | 777 |
| 767 } // namespace content | 778 } // namespace content |
| OLD | NEW |