| 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 539 } |
| 540 | 540 |
| 541 void NavigationEntryImpl::SetHttpStatusCode(int http_status_code) { | 541 void NavigationEntryImpl::SetHttpStatusCode(int http_status_code) { |
| 542 http_status_code_ = http_status_code; | 542 http_status_code_ = http_status_code; |
| 543 } | 543 } |
| 544 | 544 |
| 545 int NavigationEntryImpl::GetHttpStatusCode() const { | 545 int NavigationEntryImpl::GetHttpStatusCode() const { |
| 546 return http_status_code_; | 546 return http_status_code_; |
| 547 } | 547 } |
| 548 | 548 |
| 549 void NavigationEntryImpl::SetRedirectChain( | 549 void NavigationEntryImpl::SetMainFrameRedirectChain( |
| 550 const std::vector<GURL>& redirect_chain) { | 550 const std::vector<GURL>& redirect_chain) { |
| 551 redirect_chain_ = redirect_chain; | 551 root_node()->frame_entry->set_redirect_chain(redirect_chain); |
| 552 } | 552 } |
| 553 | 553 |
| 554 const std::vector<GURL>& NavigationEntryImpl::GetRedirectChain() const { | 554 const std::vector<GURL>& NavigationEntryImpl::GetMainFrameRedirectChain() |
| 555 return redirect_chain_; | 555 const { |
| 556 return root_node()->frame_entry->redirect_chain(); |
| 556 } | 557 } |
| 557 | 558 |
| 558 bool NavigationEntryImpl::IsRestored() const { | 559 bool NavigationEntryImpl::IsRestored() const { |
| 559 return restore_type_ != RestoreType::NONE; | 560 return restore_type_ != RestoreType::NONE; |
| 560 } | 561 } |
| 561 | 562 |
| 562 void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) { | 563 void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) { |
| 563 can_load_local_resources_ = allow; | 564 can_load_local_resources_ = allow; |
| 564 } | 565 } |
| 565 | 566 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 copy->screenshot_ = screenshot_; | 626 copy->screenshot_ = screenshot_; |
| 626 copy->extra_headers_ = extra_headers_; | 627 copy->extra_headers_ = extra_headers_; |
| 627 copy->base_url_for_data_url_ = base_url_for_data_url_; | 628 copy->base_url_for_data_url_ = base_url_for_data_url_; |
| 628 #if defined(OS_ANDROID) | 629 #if defined(OS_ANDROID) |
| 629 copy->data_url_as_string_ = data_url_as_string_; | 630 copy->data_url_as_string_ = data_url_as_string_; |
| 630 #endif | 631 #endif |
| 631 // ResetForCommit: is_renderer_initiated_ | 632 // ResetForCommit: is_renderer_initiated_ |
| 632 copy->cached_display_title_ = cached_display_title_; | 633 copy->cached_display_title_ = cached_display_title_; |
| 633 // ResetForCommit: transferred_global_request_id_ | 634 // ResetForCommit: transferred_global_request_id_ |
| 634 // ResetForCommit: should_replace_entry_ | 635 // ResetForCommit: should_replace_entry_ |
| 635 copy->redirect_chain_ = redirect_chain_; | |
| 636 // ResetForCommit: should_clear_history_list_ | 636 // ResetForCommit: should_clear_history_list_ |
| 637 // ResetForCommit: frame_tree_node_id_ | 637 // ResetForCommit: frame_tree_node_id_ |
| 638 // ResetForCommit: intent_received_timestamp_ | 638 // ResetForCommit: intent_received_timestamp_ |
| 639 #if defined(OS_ANDROID) | 639 #if defined(OS_ANDROID) |
| 640 copy->has_user_gesture_ = has_user_gesture_; | 640 copy->has_user_gesture_ = has_user_gesture_; |
| 641 #endif | 641 #endif |
| 642 copy->extra_data_ = extra_data_; | 642 copy->extra_data_ = extra_data_; |
| 643 | 643 |
| 644 return copy; | 644 return copy; |
| 645 } | 645 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 bool has_subtree_history_items, | 694 bool has_subtree_history_items, |
| 695 bool has_committed_real_load, | 695 bool has_committed_real_load, |
| 696 bool intended_as_new_entry, | 696 bool intended_as_new_entry, |
| 697 int pending_history_list_offset, | 697 int pending_history_list_offset, |
| 698 int current_history_list_offset, | 698 int current_history_list_offset, |
| 699 int current_history_list_length) const { | 699 int current_history_list_length) const { |
| 700 // Set the redirect chain to the navigation's redirects, unless returning to a | 700 // Set the redirect chain to the navigation's redirects, unless returning to a |
| 701 // completed navigation (whose previous redirects don't apply). | 701 // completed navigation (whose previous redirects don't apply). |
| 702 std::vector<GURL> redirects; | 702 std::vector<GURL> redirects; |
| 703 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { | 703 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { |
| 704 redirects = GetRedirectChain(); | 704 redirects = frame_entry.redirect_chain(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 int pending_offset_to_send = pending_history_list_offset; | 707 int pending_offset_to_send = pending_history_list_offset; |
| 708 int current_offset_to_send = current_history_list_offset; | 708 int current_offset_to_send = current_history_list_offset; |
| 709 int current_length_to_send = current_history_list_length; | 709 int current_length_to_send = current_history_list_length; |
| 710 if (should_clear_history_list()) { | 710 if (should_clear_history_list()) { |
| 711 // Set the history list related parameters to the same values a | 711 // Set the history list related parameters to the same values a |
| 712 // NavigationController would return before its first navigation. This will | 712 // NavigationController would return before its first navigation. This will |
| 713 // fully clear the RenderView's view of the session history. | 713 // fully clear the RenderView's view of the session history. |
| 714 pending_offset_to_send = -1; | 714 pending_offset_to_send = -1; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 set_intent_received_timestamp(base::TimeTicks()); | 763 set_intent_received_timestamp(base::TimeTicks()); |
| 764 #endif | 764 #endif |
| 765 } | 765 } |
| 766 | 766 |
| 767 void NavigationEntryImpl::AddOrUpdateFrameEntry( | 767 void NavigationEntryImpl::AddOrUpdateFrameEntry( |
| 768 FrameTreeNode* frame_tree_node, | 768 FrameTreeNode* frame_tree_node, |
| 769 int64_t item_sequence_number, | 769 int64_t item_sequence_number, |
| 770 int64_t document_sequence_number, | 770 int64_t document_sequence_number, |
| 771 SiteInstanceImpl* site_instance, | 771 SiteInstanceImpl* site_instance, |
| 772 scoped_refptr<SiteInstanceImpl> source_site_instance, | 772 scoped_refptr<SiteInstanceImpl> source_site_instance, |
| 773 const std::vector<GURL>& redirect_chain, |
| 773 const GURL& url, | 774 const GURL& url, |
| 774 const Referrer& referrer, | 775 const Referrer& referrer, |
| 775 const PageState& page_state, | 776 const PageState& page_state, |
| 776 const std::string& method, | 777 const std::string& method, |
| 777 int64_t post_id) { | 778 int64_t post_id) { |
| 778 // We should only have an empty PageState if the navigation is new, and thus | 779 // We should only have an empty PageState if the navigation is new, and thus |
| 779 // page ID is -1. | 780 // page ID is -1. |
| 780 if (!page_state.IsValid() && GetPageID() != -1) { | 781 if (!page_state.IsValid() && GetPageID() != -1) { |
| 781 // Temporarily generate a minidump to diagnose https://crbug.com/568703. | 782 // Temporarily generate a minidump to diagnose https://crbug.com/568703. |
| 782 base::debug::DumpWithoutCrashing(); | 783 base::debug::DumpWithoutCrashing(); |
| 783 NOTREACHED() << "Shouldn't set an empty PageState."; | 784 NOTREACHED() << "Shouldn't set an empty PageState."; |
| 784 } | 785 } |
| 785 | 786 |
| 786 // If this is called for the main frame, the FrameNavigationEntry is | 787 // If this is called for the main frame, the FrameNavigationEntry is |
| 787 // guaranteed to exist, so just update it directly and return. | 788 // guaranteed to exist, so just update it directly and return. |
| 788 if (frame_tree_node->IsMainFrame()) { | 789 if (frame_tree_node->IsMainFrame()) { |
| 789 // If the document of the FrameNavigationEntry is changing, we must clear | 790 // If the document of the FrameNavigationEntry is changing, we must clear |
| 790 // any child FrameNavigationEntries. | 791 // any child FrameNavigationEntries. |
| 791 if (root_node()->frame_entry->document_sequence_number() != | 792 if (root_node()->frame_entry->document_sequence_number() != |
| 792 document_sequence_number) | 793 document_sequence_number) |
| 793 root_node()->children.clear(); | 794 root_node()->children.clear(); |
| 794 | 795 |
| 795 root_node()->frame_entry->UpdateEntry( | 796 root_node()->frame_entry->UpdateEntry( |
| 796 frame_tree_node->unique_name(), item_sequence_number, | 797 frame_tree_node->unique_name(), item_sequence_number, |
| 797 document_sequence_number, site_instance, | 798 document_sequence_number, site_instance, |
| 798 std::move(source_site_instance), url, referrer, page_state, method, | 799 std::move(source_site_instance), redirect_chain, url, referrer, |
| 799 post_id); | 800 page_state, method, post_id); |
| 800 return; | 801 return; |
| 801 } | 802 } |
| 802 | 803 |
| 803 // We should already have a TreeNode for the parent node by the time this node | 804 // We should already have a TreeNode for the parent node by the time this node |
| 804 // commits. Find it first. | 805 // commits. Find it first. |
| 805 NavigationEntryImpl::TreeNode* parent_node = | 806 NavigationEntryImpl::TreeNode* parent_node = |
| 806 FindFrameEntry(frame_tree_node->parent()); | 807 FindFrameEntry(frame_tree_node->parent()); |
| 807 if (!parent_node) { | 808 if (!parent_node) { |
| 808 // The renderer should not send a commit for a subframe before its parent. | 809 // The renderer should not send a commit for a subframe before its parent. |
| 809 // TODO(creis): Kill the renderer if we get here. | 810 // TODO(creis): Kill the renderer if we get here. |
| 810 return; | 811 return; |
| 811 } | 812 } |
| 812 | 813 |
| 813 // Now check whether we have a TreeNode for the node itself. | 814 // Now check whether we have a TreeNode for the node itself. |
| 814 const std::string& unique_name = frame_tree_node->unique_name(); | 815 const std::string& unique_name = frame_tree_node->unique_name(); |
| 815 for (TreeNode* child : parent_node->children) { | 816 for (TreeNode* child : parent_node->children) { |
| 816 if (child->frame_entry->frame_unique_name() == unique_name) { | 817 if (child->frame_entry->frame_unique_name() == unique_name) { |
| 817 // If the document of the FrameNavigationEntry is changing, we must clear | 818 // If the document of the FrameNavigationEntry is changing, we must clear |
| 818 // any child FrameNavigationEntries. | 819 // any child FrameNavigationEntries. |
| 819 if (child->frame_entry->document_sequence_number() != | 820 if (child->frame_entry->document_sequence_number() != |
| 820 document_sequence_number) | 821 document_sequence_number) |
| 821 child->children.clear(); | 822 child->children.clear(); |
| 822 | 823 |
| 823 // Update the existing FrameNavigationEntry (e.g., for replaceState). | 824 // Update the existing FrameNavigationEntry (e.g., for replaceState). |
| 824 child->frame_entry->UpdateEntry(unique_name, item_sequence_number, | 825 child->frame_entry->UpdateEntry( |
| 825 document_sequence_number, site_instance, | 826 unique_name, item_sequence_number, document_sequence_number, |
| 826 std::move(source_site_instance), url, | 827 site_instance, std::move(source_site_instance), redirect_chain, url, |
| 827 referrer, page_state, method, post_id); | 828 referrer, page_state, method, post_id); |
| 828 return; | 829 return; |
| 829 } | 830 } |
| 830 } | 831 } |
| 831 | 832 |
| 832 // No entry exists yet, so create a new one. | 833 // No entry exists yet, so create a new one. |
| 833 // Unordered list, since we expect to look up entries by frame sequence number | 834 // Unordered list, since we expect to look up entries by frame sequence number |
| 834 // or unique name. | 835 // or unique name. |
| 835 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 836 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
| 836 unique_name, item_sequence_number, document_sequence_number, | 837 unique_name, item_sequence_number, document_sequence_number, |
| 837 site_instance, std::move(source_site_instance), url, referrer, method, | 838 site_instance, std::move(source_site_instance), url, referrer, method, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 return node; | 914 return node; |
| 914 | 915 |
| 915 // Enqueue any children and keep looking. | 916 // Enqueue any children and keep looking. |
| 916 for (auto* child : node->children) | 917 for (auto* child : node->children) |
| 917 work_queue.push(child); | 918 work_queue.push(child); |
| 918 } | 919 } |
| 919 return nullptr; | 920 return nullptr; |
| 920 } | 921 } |
| 921 | 922 |
| 922 } // namespace content | 923 } // namespace content |
| OLD | NEW |