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