Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 2550113002: Send a subtree of same-process PageStates for back/forward child frames.
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 const { 706 const {
707 return StartNavigationParams(extra_headers(), 707 return StartNavigationParams(extra_headers(),
708 transferred_global_request_id().child_id, 708 transferred_global_request_id().child_id,
709 transferred_global_request_id().request_id); 709 transferred_global_request_id().request_id);
710 } 710 }
711 711
712 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( 712 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams(
713 const FrameNavigationEntry& frame_entry, 713 const FrameNavigationEntry& frame_entry,
714 bool is_same_document_history_load, 714 bool is_same_document_history_load,
715 bool is_history_navigation_in_new_child, 715 bool is_history_navigation_in_new_child,
716 const std::map<std::string, bool>& subframe_unique_names, 716 const std::map<std::string, PageState>& subtree_page_states,
717 bool has_committed_real_load, 717 bool has_committed_real_load,
718 bool intended_as_new_entry, 718 bool intended_as_new_entry,
719 int pending_history_list_offset, 719 int pending_history_list_offset,
720 int current_history_list_offset, 720 int current_history_list_offset,
721 int current_history_list_length) const { 721 int current_history_list_length) const {
722 // Set the redirect chain to the navigation's redirects, unless returning to a 722 // Set the redirect chain to the navigation's redirects, unless returning to a
723 // completed navigation (whose previous redirects don't apply). 723 // completed navigation (whose previous redirects don't apply).
724 std::vector<GURL> redirects; 724 std::vector<GURL> redirects;
725 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { 725 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) {
726 redirects = frame_entry.redirect_chain(); 726 redirects = frame_entry.redirect_chain();
727 } 727 }
728 728
729 int pending_offset_to_send = pending_history_list_offset; 729 int pending_offset_to_send = pending_history_list_offset;
730 int current_offset_to_send = current_history_list_offset; 730 int current_offset_to_send = current_history_list_offset;
731 int current_length_to_send = current_history_list_length; 731 int current_length_to_send = current_history_list_length;
732 if (should_clear_history_list()) { 732 if (should_clear_history_list()) {
733 // Set the history list related parameters to the same values a 733 // Set the history list related parameters to the same values a
734 // NavigationController would return before its first navigation. This will 734 // NavigationController would return before its first navigation. This will
735 // fully clear the RenderView's view of the session history. 735 // fully clear the RenderView's view of the session history.
736 pending_offset_to_send = -1; 736 pending_offset_to_send = -1;
737 current_offset_to_send = -1; 737 current_offset_to_send = -1;
738 current_length_to_send = 0; 738 current_length_to_send = 0;
739 } 739 }
740 740
741 RequestNavigationParams request_params( 741 RequestNavigationParams request_params(
742 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), 742 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(),
743 frame_entry.page_state(), GetUniqueID(), is_same_document_history_load, 743 frame_entry.page_state(), GetUniqueID(), is_same_document_history_load,
744 is_history_navigation_in_new_child, subframe_unique_names, 744 is_history_navigation_in_new_child, subtree_page_states,
745 has_committed_real_load, intended_as_new_entry, pending_offset_to_send, 745 has_committed_real_load, intended_as_new_entry, pending_offset_to_send,
746 current_offset_to_send, current_length_to_send, IsViewSourceMode(), 746 current_offset_to_send, current_length_to_send, IsViewSourceMode(),
747 should_clear_history_list()); 747 should_clear_history_list());
748 #if defined(OS_ANDROID) 748 #if defined(OS_ANDROID)
749 if (GetDataURLAsString() && 749 if (GetDataURLAsString() &&
750 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { 750 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) {
751 // The number of characters that is enough for validating a data: URI. From 751 // The number of characters that is enough for validating a data: URI. From
752 // the GURL's POV, the only important part here is scheme, it doesn't check 752 // the GURL's POV, the only important part here is scheme, it doesn't check
753 // the actual content. Thus we can take only the prefix of the url, to avoid 753 // the actual content. Thus we can take only the prefix of the url, to avoid
754 // unneeded copying of a potentially long string. 754 // unneeded copying of a potentially long string.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 parent_node->children.push_back( 857 parent_node->children.push_back(
858 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); 858 new NavigationEntryImpl::TreeNode(parent_node, frame_entry));
859 } 859 }
860 860
861 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 861 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
862 FrameTreeNode* frame_tree_node) const { 862 FrameTreeNode* frame_tree_node) const {
863 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 863 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
864 return tree_node ? tree_node->frame_entry.get() : nullptr; 864 return tree_node ? tree_node->frame_entry.get() : nullptr;
865 } 865 }
866 866
867 std::map<std::string, bool> NavigationEntryImpl::GetSubframeUniqueNames( 867 std::map<std::string, PageState> NavigationEntryImpl::GetSubtreePageStates(
868 FrameTreeNode* frame_tree_node) const { 868 FrameTreeNode* frame_tree_node) const {
869 std::map<std::string, bool> names; 869 std::map<std::string, PageState> states;
870 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 870 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
871 if (tree_node) { 871 if (tree_node) {
872 // Return the names of all immediate children. 872 // Return a map of unique name to (same-process) PageStates for the subtree
873 for (TreeNode* child : tree_node->children) { 873 // rooted at |tree_node|. Use an empty PageState for any cross-process
874 // Keep track of whether we would be loading about:blank, since the 874 // PageStates, to indicate to the renderer that it should ask the browser
875 // renderer should be allowed to just commit the initial blank frame if 875 // process to handle the navigation.
876 // that was the default URL. PageState doesn't matter there, because 876 SiteInstance* site_instance = tree_node->frame_entry->site_instance();
877 // content injected into about:blank frames doesn't use it.
878 //
879 // Be careful not to rely on FrameNavigationEntry's URLs in this check,
880 // because the committed URL in the browser could be rewritten to
881 // about:blank.
882 // See RenderProcessHostImpl::FilterURL to know which URLs are rewritten.
883 // See https://crbug.com/657896 for details.
884 bool is_about_blank = false;
885 ExplodedPageState exploded_page_state;
886 if (DecodePageState(child->frame_entry->page_state().ToEncodedData(),
887 &exploded_page_state)) {
888 ExplodedFrameState frame_state = exploded_page_state.top;
889 if (UTF16ToUTF8(frame_state.url_string.string()) == url::kAboutBlankURL)
890 is_about_blank = true;
891 }
892 877
893 names[child->frame_entry->frame_unique_name()] = is_about_blank; 878 // Start with the immediate children.
879 std::queue<NavigationEntryImpl::TreeNode*> work_queue;
880 for (TreeNode* child : tree_node->children)
881 work_queue.push(child);
882 NavigationEntryImpl::TreeNode* node = nullptr;
883 while (!work_queue.empty()) {
884 node = work_queue.front();
885 work_queue.pop();
886
887 // Use an empty PageState if the FNE has a different SiteInstance.
888 states[node->frame_entry->frame_unique_name()] =
889 node->frame_entry->site_instance() == site_instance
890 ? node->frame_entry->page_state()
891 : PageState();
892
893 // Enqueue any further children and continue.
894 for (TreeNode* child : node->children)
895 work_queue.push(child);
894 } 896 }
895 } 897 }
896 return names; 898 return states;
897 } 899 }
898 900
899 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( 901 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame(
900 FrameTreeNode* frame_tree_node) { 902 FrameTreeNode* frame_tree_node) {
901 DCHECK(!frame_tree_node->IsMainFrame()); 903 DCHECK(!frame_tree_node->IsMainFrame());
902 904
903 NavigationEntryImpl::TreeNode* node = nullptr; 905 NavigationEntryImpl::TreeNode* node = nullptr;
904 std::queue<NavigationEntryImpl::TreeNode*> work_queue; 906 std::queue<NavigationEntryImpl::TreeNode*> work_queue;
905 int count = 0; 907 int count = 0;
906 908
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 return node; 958 return node;
957 959
958 // Enqueue any children and keep looking. 960 // Enqueue any children and keep looking.
959 for (auto* child : node->children) 961 for (auto* child : node->children)
960 work_queue.push(child); 962 work_queue.push(child);
961 } 963 }
962 return nullptr; 964 return nullptr;
963 } 965 }
964 966
965 } // namespace content 967 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/browser/frame_host/navigation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698