Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 1956383003: Forwarding POST body into renderer after a cross-site transfer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempting to rebase on top of clamy@'s other CL. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bool force_post_method,
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 = (force_post_method || 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);
602 } 617 }
603 618
604 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() 619 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams(
605 const { 620 const scoped_refptr<ResourceRequestBody>& post_body) const {
606 std::vector<unsigned char> browser_initiated_post_data; 621 return StartNavigationParams(
607 if (GetBrowserInitiatedPostData()) { 622 extra_headers(),
608 browser_initiated_post_data.assign( 623 post_body ? post_body : ConstructBodyFromBrowserInitiatedPostData(),
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) 624 #if defined(OS_ANDROID)
616 has_user_gesture(), 625 has_user_gesture(),
617 #endif 626 #endif
618 transferred_global_request_id().child_id, 627 transferred_global_request_id().child_id,
619 transferred_global_request_id().request_id); 628 transferred_global_request_id().request_id);
620 } 629 }
621 630
622 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( 631 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams(
623 const FrameNavigationEntry& frame_entry, 632 const FrameNavigationEntry& frame_entry,
624 bool is_same_document_history_load, 633 bool is_same_document_history_load,
625 bool has_committed_real_load, 634 bool has_committed_real_load,
626 bool intended_as_new_entry, 635 bool intended_as_new_entry,
627 int pending_history_list_offset, 636 int pending_history_list_offset,
628 int current_history_list_offset, 637 int current_history_list_offset,
629 int current_history_list_length) const { 638 int current_history_list_length) const {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return node; 778 return node;
770 779
771 // Enqueue any children and keep looking. 780 // Enqueue any children and keep looking.
772 for (auto& child : node->children) 781 for (auto& child : node->children)
773 work_queue.push(child); 782 work_queue.push(child);
774 } 783 }
775 return nullptr; 784 return nullptr;
776 } 785 }
777 786
778 } // namespace content 787 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698