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> |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 412 } |
413 | 413 |
414 void NavigationEntryImpl::SetPostID(int64_t post_id) { | 414 void NavigationEntryImpl::SetPostID(int64_t post_id) { |
415 frame_tree_->frame_entry->set_post_id(post_id); | 415 frame_tree_->frame_entry->set_post_id(post_id); |
416 } | 416 } |
417 | 417 |
418 int64_t NavigationEntryImpl::GetPostID() const { | 418 int64_t NavigationEntryImpl::GetPostID() const { |
419 return frame_tree_->frame_entry->post_id(); | 419 return frame_tree_->frame_entry->post_id(); |
420 } | 420 } |
421 | 421 |
422 void NavigationEntryImpl::SetBrowserInitiatedPostData( | 422 void NavigationEntryImpl::SetPostData( |
423 const base::RefCountedMemory* data) { | 423 const scoped_refptr<ResourceRequestBody>& data) { |
424 browser_initiated_post_data_ = data; | 424 post_data_ = static_cast<ResourceRequestBodyImpl*>(data.get()); |
425 } | 425 } |
426 | 426 |
427 const base::RefCountedMemory* | 427 scoped_refptr<ResourceRequestBody> NavigationEntryImpl::GetPostData() const { |
428 NavigationEntryImpl::GetBrowserInitiatedPostData() const { | 428 return post_data_.get(); |
429 return browser_initiated_post_data_.get(); | |
430 } | 429 } |
431 | 430 |
432 | 431 |
433 const FaviconStatus& NavigationEntryImpl::GetFavicon() const { | 432 const FaviconStatus& NavigationEntryImpl::GetFavicon() const { |
434 return favicon_; | 433 return favicon_; |
435 } | 434 } |
436 | 435 |
437 FaviconStatus& NavigationEntryImpl::GetFavicon() { | 436 FaviconStatus& NavigationEntryImpl::GetFavicon() { |
438 return favicon_; | 437 return favicon_; |
439 } | 438 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 copy->favicon_ = favicon_; | 542 copy->favicon_ = favicon_; |
544 copy->page_id_ = page_id_; | 543 copy->page_id_ = page_id_; |
545 copy->ssl_ = ssl_; | 544 copy->ssl_ = ssl_; |
546 copy->transition_type_ = transition_type_; | 545 copy->transition_type_ = transition_type_; |
547 copy->user_typed_url_ = user_typed_url_; | 546 copy->user_typed_url_ = user_typed_url_; |
548 copy->restore_type_ = restore_type_; | 547 copy->restore_type_ = restore_type_; |
549 copy->original_request_url_ = original_request_url_; | 548 copy->original_request_url_ = original_request_url_; |
550 copy->is_overriding_user_agent_ = is_overriding_user_agent_; | 549 copy->is_overriding_user_agent_ = is_overriding_user_agent_; |
551 copy->timestamp_ = timestamp_; | 550 copy->timestamp_ = timestamp_; |
552 copy->http_status_code_ = http_status_code_; | 551 copy->http_status_code_ = http_status_code_; |
553 // ResetForCommit: browser_initiated_post_data_ | 552 // ResetForCommit: post_data_ |
554 copy->screenshot_ = screenshot_; | 553 copy->screenshot_ = screenshot_; |
555 copy->extra_headers_ = extra_headers_; | 554 copy->extra_headers_ = extra_headers_; |
556 copy->base_url_for_data_url_ = base_url_for_data_url_; | 555 copy->base_url_for_data_url_ = base_url_for_data_url_; |
557 #if defined(OS_ANDROID) | 556 #if defined(OS_ANDROID) |
558 copy->data_url_as_string_ = data_url_as_string_; | 557 copy->data_url_as_string_ = data_url_as_string_; |
559 #endif | 558 #endif |
560 // ResetForCommit: is_renderer_initiated_ | 559 // ResetForCommit: is_renderer_initiated_ |
561 copy->cached_display_title_ = cached_display_title_; | 560 copy->cached_display_title_ = cached_display_title_; |
562 // ResetForCommit: transferred_global_request_id_ | 561 // ResetForCommit: transferred_global_request_id_ |
563 // ResetForCommit: should_replace_entry_ | 562 // ResetForCommit: should_replace_entry_ |
564 copy->redirect_chain_ = redirect_chain_; | 563 copy->redirect_chain_ = redirect_chain_; |
565 // ResetForCommit: should_clear_history_list_ | 564 // ResetForCommit: should_clear_history_list_ |
566 // ResetForCommit: frame_tree_node_id_ | 565 // ResetForCommit: frame_tree_node_id_ |
567 // ResetForCommit: intent_received_timestamp_ | 566 // ResetForCommit: intent_received_timestamp_ |
568 copy->extra_data_ = extra_data_; | 567 copy->extra_data_ = extra_data_; |
569 | 568 |
570 return copy; | 569 return copy; |
571 } | 570 } |
572 | 571 |
573 scoped_refptr<ResourceRequestBodyImpl> | |
574 NavigationEntryImpl::ConstructBodyFromBrowserInitiatedPostData() const { | |
575 scoped_refptr<ResourceRequestBodyImpl> browser_initiated_post_body; | |
576 if (GetHasPostData()) { | |
577 if (const base::RefCountedMemory* memory = GetBrowserInitiatedPostData()) { | |
578 browser_initiated_post_body = new ResourceRequestBodyImpl(); | |
579 browser_initiated_post_body->AppendBytes(memory->front_as<char>(), | |
580 memory->size()); | |
581 } | |
582 } | |
583 return browser_initiated_post_body; | |
584 } | |
585 | |
586 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( | 572 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( |
587 const FrameNavigationEntry& frame_entry, | 573 const FrameNavigationEntry& frame_entry, |
588 const scoped_refptr<ResourceRequestBodyImpl>& post_body, | 574 const scoped_refptr<ResourceRequestBodyImpl>& post_body, |
589 const GURL& dest_url, | 575 const GURL& dest_url, |
590 const Referrer& dest_referrer, | 576 const Referrer& dest_referrer, |
591 FrameMsg_Navigate_Type::Value navigation_type, | 577 FrameMsg_Navigate_Type::Value navigation_type, |
592 LoFiState lofi_state, | 578 LoFiState lofi_state, |
593 const base::TimeTicks& navigation_start) const { | 579 const base::TimeTicks& navigation_start) const { |
594 FrameMsg_UILoadMetricsReportType::Value report_type = | 580 FrameMsg_UILoadMetricsReportType::Value report_type = |
595 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 581 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
(...skipping 10 matching lines...) Expand all Loading... |
606 // subframe navigation entries. | 592 // subframe navigation entries. |
607 if (IsBrowserSideNavigationEnabled()) | 593 if (IsBrowserSideNavigationEnabled()) |
608 method = frame_entry.method(); | 594 method = frame_entry.method(); |
609 else | 595 else |
610 method = (post_body.get() || GetHasPostData()) ? "POST" : "GET"; | 596 method = (post_body.get() || GetHasPostData()) ? "POST" : "GET"; |
611 | 597 |
612 return CommonNavigationParams( | 598 return CommonNavigationParams( |
613 dest_url, dest_referrer, GetTransitionType(), navigation_type, | 599 dest_url, dest_referrer, GetTransitionType(), navigation_type, |
614 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, | 600 !IsViewSourceMode(), should_replace_entry(), ui_timestamp, report_type, |
615 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, | 601 GetBaseURLForDataURL(), GetHistoryURLForDataURL(), lofi_state, |
616 navigation_start, method, | 602 navigation_start, method, post_body ? post_body : post_data_); |
617 post_body ? post_body : ConstructBodyFromBrowserInitiatedPostData()); | |
618 } | 603 } |
619 | 604 |
620 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() | 605 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() |
621 const { | 606 const { |
622 return StartNavigationParams(extra_headers(), | 607 return StartNavigationParams(extra_headers(), |
623 #if defined(OS_ANDROID) | 608 #if defined(OS_ANDROID) |
624 has_user_gesture(), | 609 has_user_gesture(), |
625 #endif | 610 #endif |
626 transferred_global_request_id().child_id, | 611 transferred_global_request_id().child_id, |
627 transferred_global_request_id().request_id); | 612 transferred_global_request_id().request_id); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 661 } |
677 #endif | 662 #endif |
678 return request_params; | 663 return request_params; |
679 } | 664 } |
680 | 665 |
681 void NavigationEntryImpl::ResetForCommit(FrameNavigationEntry* frame_entry) { | 666 void NavigationEntryImpl::ResetForCommit(FrameNavigationEntry* frame_entry) { |
682 // Any state that only matters when a navigation entry is pending should be | 667 // Any state that only matters when a navigation entry is pending should be |
683 // cleared here. | 668 // cleared here. |
684 // TODO(creis): This state should be moved to NavigationRequest once | 669 // TODO(creis): This state should be moved to NavigationRequest once |
685 // PlzNavigate is enabled. | 670 // PlzNavigate is enabled. |
686 SetBrowserInitiatedPostData(nullptr); | 671 SetPostData(nullptr); |
687 set_is_renderer_initiated(false); | 672 set_is_renderer_initiated(false); |
688 set_transferred_global_request_id(GlobalRequestID()); | 673 set_transferred_global_request_id(GlobalRequestID()); |
689 set_should_replace_entry(false); | 674 set_should_replace_entry(false); |
690 | 675 |
691 set_should_clear_history_list(false); | 676 set_should_clear_history_list(false); |
692 set_frame_tree_node_id(-1); | 677 set_frame_tree_node_id(-1); |
693 | 678 |
694 if (frame_entry) | 679 if (frame_entry) |
695 frame_entry->set_source_site_instance(nullptr); | 680 frame_entry->set_source_site_instance(nullptr); |
696 | 681 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 return node; | 762 return node; |
778 | 763 |
779 // Enqueue any children and keep looking. | 764 // Enqueue any children and keep looking. |
780 for (auto& child : node->children) | 765 for (auto& child : node->children) |
781 work_queue.push(child); | 766 work_queue.push(child); |
782 } | 767 } |
783 return nullptr; | 768 return nullptr; |
784 } | 769 } |
785 | 770 |
786 } // namespace content | 771 } // namespace content |
OLD | NEW |