| 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 has_user_gesture(), | 684 has_user_gesture(), |
| 685 #endif | 685 #endif |
| 686 transferred_global_request_id().child_id, | 686 transferred_global_request_id().child_id, |
| 687 transferred_global_request_id().request_id); | 687 transferred_global_request_id().request_id); |
| 688 } | 688 } |
| 689 | 689 |
| 690 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( | 690 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( |
| 691 const FrameNavigationEntry& frame_entry, | 691 const FrameNavigationEntry& frame_entry, |
| 692 bool is_same_document_history_load, | 692 bool is_same_document_history_load, |
| 693 bool is_history_navigation_in_new_child, | 693 bool is_history_navigation_in_new_child, |
| 694 bool has_subtree_history_items, | 694 const std::set<std::string>& subframe_unique_names, |
| 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 = GetRedirectChain(); |
| 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; |
| 715 current_offset_to_send = -1; | 715 current_offset_to_send = -1; |
| 716 current_length_to_send = 0; | 716 current_length_to_send = 0; |
| 717 } | 717 } |
| 718 | 718 |
| 719 RequestNavigationParams request_params( | 719 RequestNavigationParams request_params( |
| 720 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), | 720 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), |
| 721 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), | 721 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), |
| 722 is_same_document_history_load, is_history_navigation_in_new_child, | 722 is_same_document_history_load, is_history_navigation_in_new_child, |
| 723 has_subtree_history_items, has_committed_real_load, intended_as_new_entry, | 723 subframe_unique_names, has_committed_real_load, intended_as_new_entry, |
| 724 pending_offset_to_send, current_offset_to_send, current_length_to_send, | 724 pending_offset_to_send, current_offset_to_send, current_length_to_send, |
| 725 IsViewSourceMode(), should_clear_history_list()); | 725 IsViewSourceMode(), should_clear_history_list()); |
| 726 #if defined(OS_ANDROID) | 726 #if defined(OS_ANDROID) |
| 727 if (GetDataURLAsString() && | 727 if (GetDataURLAsString() && |
| 728 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { | 728 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { |
| 729 // The number of characters that is enough for validating a data: URI. From | 729 // The number of characters that is enough for validating a data: URI. From |
| 730 // the GURL's POV, the only important part here is scheme, it doesn't check | 730 // the GURL's POV, the only important part here is scheme, it doesn't check |
| 731 // the actual content. Thus we can take only the prefix of the url, to avoid | 731 // the actual content. Thus we can take only the prefix of the url, to avoid |
| 732 // unneeded copying of a potentially long string. | 732 // unneeded copying of a potentially long string. |
| 733 const size_t kDataUriPrefixMaxLen = 64; | 733 const size_t kDataUriPrefixMaxLen = 64; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 parent_node->children.push_back( | 840 parent_node->children.push_back( |
| 841 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); | 841 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); |
| 842 } | 842 } |
| 843 | 843 |
| 844 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( | 844 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( |
| 845 FrameTreeNode* frame_tree_node) const { | 845 FrameTreeNode* frame_tree_node) const { |
| 846 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); | 846 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); |
| 847 return tree_node ? tree_node->frame_entry.get() : nullptr; | 847 return tree_node ? tree_node->frame_entry.get() : nullptr; |
| 848 } | 848 } |
| 849 | 849 |
| 850 bool NavigationEntryImpl::HasSubtreeHistoryItems( | 850 std::set<std::string> NavigationEntryImpl::GetSubframeUniqueNames( |
| 851 FrameTreeNode* frame_tree_node) const { | 851 FrameTreeNode* frame_tree_node) const { |
| 852 std::set<std::string> names; |
| 852 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); | 853 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); |
| 853 return tree_node && !tree_node->children.empty(); | 854 if (tree_node) { |
| 855 // Return the names of all immediate children. |
| 856 for (TreeNode* child : tree_node->children) |
| 857 names.insert(child->frame_entry->frame_unique_name()); |
| 858 } |
| 859 return names; |
| 854 } | 860 } |
| 855 | 861 |
| 856 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( | 862 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( |
| 857 FrameTreeNode* frame_tree_node) { | 863 FrameTreeNode* frame_tree_node) { |
| 858 DCHECK(!frame_tree_node->IsMainFrame()); | 864 DCHECK(!frame_tree_node->IsMainFrame()); |
| 859 | 865 |
| 860 NavigationEntryImpl::TreeNode* node = nullptr; | 866 NavigationEntryImpl::TreeNode* node = nullptr; |
| 861 std::queue<NavigationEntryImpl::TreeNode*> work_queue; | 867 std::queue<NavigationEntryImpl::TreeNode*> work_queue; |
| 862 int count = 0; | 868 int count = 0; |
| 863 | 869 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 return node; | 919 return node; |
| 914 | 920 |
| 915 // Enqueue any children and keep looking. | 921 // Enqueue any children and keep looking. |
| 916 for (auto* child : node->children) | 922 for (auto* child : node->children) |
| 917 work_queue.push(child); | 923 work_queue.push(child); |
| 918 } | 924 } |
| 919 return nullptr; | 925 return nullptr; |
| 920 } | 926 } |
| 921 | 927 |
| 922 } // namespace content | 928 } // namespace content |
| OLD | NEW |