Chromium Code Reviews| 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 bool has_committed_real_load, | 695 bool has_committed_real_load, |
| 695 bool intended_as_new_entry, | 696 bool intended_as_new_entry, |
| 696 int pending_history_list_offset, | 697 int pending_history_list_offset, |
| 697 int current_history_list_offset, | 698 int current_history_list_offset, |
| 698 int current_history_list_length) const { | 699 int current_history_list_length) const { |
| 699 // 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 |
| 700 // completed navigation (whose previous redirects don't apply). | 701 // completed navigation (whose previous redirects don't apply). |
| 701 std::vector<GURL> redirects; | 702 std::vector<GURL> redirects; |
| 702 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { | 703 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { |
| 703 redirects = GetRedirectChain(); | 704 redirects = GetRedirectChain(); |
| 704 } | 705 } |
| 705 | 706 |
| 706 int pending_offset_to_send = pending_history_list_offset; | 707 int pending_offset_to_send = pending_history_list_offset; |
| 707 int current_offset_to_send = current_history_list_offset; | 708 int current_offset_to_send = current_history_list_offset; |
| 708 int current_length_to_send = current_history_list_length; | 709 int current_length_to_send = current_history_list_length; |
| 709 if (should_clear_history_list()) { | 710 if (should_clear_history_list()) { |
| 710 // Set the history list related parameters to the same values a | 711 // Set the history list related parameters to the same values a |
| 711 // NavigationController would return before its first navigation. This will | 712 // NavigationController would return before its first navigation. This will |
| 712 // fully clear the RenderView's view of the session history. | 713 // fully clear the RenderView's view of the session history. |
| 713 pending_offset_to_send = -1; | 714 pending_offset_to_send = -1; |
| 714 current_offset_to_send = -1; | 715 current_offset_to_send = -1; |
| 715 current_length_to_send = 0; | 716 current_length_to_send = 0; |
| 716 } | 717 } |
| 717 | 718 |
| 718 RequestNavigationParams request_params( | 719 RequestNavigationParams request_params( |
| 719 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), | 720 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), |
| 720 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), | 721 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), |
| 721 is_same_document_history_load, is_history_navigation_in_new_child, | 722 is_same_document_history_load, is_history_navigation_in_new_child, |
| 722 has_committed_real_load, intended_as_new_entry, pending_offset_to_send, | 723 has_subtree_history_items, has_committed_real_load, intended_as_new_entry, |
| 723 current_offset_to_send, current_length_to_send, IsViewSourceMode(), | 724 pending_offset_to_send, current_offset_to_send, current_length_to_send, |
| 724 should_clear_history_list()); | 725 IsViewSourceMode(), should_clear_history_list()); |
| 725 #if defined(OS_ANDROID) | 726 #if defined(OS_ANDROID) |
| 726 if (GetDataURLAsString() && | 727 if (GetDataURLAsString() && |
| 727 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { | 728 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { |
| 728 // 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 |
| 729 // 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 |
| 730 // 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 |
| 731 // unneeded copying of a potentially long string. | 732 // unneeded copying of a potentially long string. |
| 732 const size_t kDataUriPrefixMaxLen = 64; | 733 const size_t kDataUriPrefixMaxLen = 64; |
| 733 GURL data_url(std::string( | 734 GURL data_url(std::string( |
| 734 GetDataURLAsString()->front_as<char>(), | 735 GetDataURLAsString()->front_as<char>(), |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 parent_node->children.push_back( | 840 parent_node->children.push_back( |
| 840 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); | 841 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); |
| 841 } | 842 } |
| 842 | 843 |
| 843 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( | 844 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( |
| 844 FrameTreeNode* frame_tree_node) const { | 845 FrameTreeNode* frame_tree_node) const { |
| 845 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); | 846 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); |
| 846 return tree_node ? tree_node->frame_entry.get() : nullptr; | 847 return tree_node ? tree_node->frame_entry.get() : nullptr; |
| 847 } | 848 } |
| 848 | 849 |
| 850 bool NavigationEntryImpl::HasSubtreeHistoryItems( | |
| 851 FrameTreeNode* frame_tree_node) const { | |
| 852 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); | |
| 853 return tree_node ? !tree_node->children.empty() : false; | |
|
alexmos
2016/09/22 01:44:06
nit: just tree_node && !tree_node->children.empty(
Charlie Reis
2016/09/22 21:00:37
Done.
| |
| 854 } | |
| 855 | |
| 849 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( | 856 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( |
| 850 FrameTreeNode* frame_tree_node) { | 857 FrameTreeNode* frame_tree_node) { |
| 851 DCHECK(!frame_tree_node->IsMainFrame()); | 858 DCHECK(!frame_tree_node->IsMainFrame()); |
| 852 | 859 |
| 853 NavigationEntryImpl::TreeNode* node = nullptr; | 860 NavigationEntryImpl::TreeNode* node = nullptr; |
| 854 std::queue<NavigationEntryImpl::TreeNode*> work_queue; | 861 std::queue<NavigationEntryImpl::TreeNode*> work_queue; |
| 855 int count = 0; | 862 int count = 0; |
| 856 | 863 |
| 857 work_queue.push(root_node()); | 864 work_queue.push(root_node()); |
| 858 while (!work_queue.empty()) { | 865 while (!work_queue.empty()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 return node; | 913 return node; |
| 907 | 914 |
| 908 // Enqueue any children and keep looking. | 915 // Enqueue any children and keep looking. |
| 909 for (auto* child : node->children) | 916 for (auto* child : node->children) |
| 910 work_queue.push(child); | 917 work_queue.push(child); |
| 911 } | 918 } |
| 912 return nullptr; | 919 return nullptr; |
| 913 } | 920 } |
| 914 | 921 |
| 915 } // namespace content | 922 } // namespace content |
| OLD | NEW |