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