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

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

Issue 2445053002: Fix history nav to a script-injected about:blank frame. (Closed)
Patch Set: Created 4 years, 1 month 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 const { 696 const {
697 return StartNavigationParams(extra_headers(), 697 return StartNavigationParams(extra_headers(),
698 transferred_global_request_id().child_id, 698 transferred_global_request_id().child_id,
699 transferred_global_request_id().request_id); 699 transferred_global_request_id().request_id);
700 } 700 }
701 701
702 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams( 702 RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams(
703 const FrameNavigationEntry& frame_entry, 703 const FrameNavigationEntry& frame_entry,
704 bool is_same_document_history_load, 704 bool is_same_document_history_load,
705 bool is_history_navigation_in_new_child, 705 bool is_history_navigation_in_new_child,
706 const std::set<std::string>& subframe_unique_names, 706 const std::map<std::string, bool>& subframe_unique_names,
707 bool has_committed_real_load, 707 bool has_committed_real_load,
708 bool intended_as_new_entry, 708 bool intended_as_new_entry,
709 int pending_history_list_offset, 709 int pending_history_list_offset,
710 int current_history_list_offset, 710 int current_history_list_offset,
711 int current_history_list_length) const { 711 int current_history_list_length) const {
712 // Set the redirect chain to the navigation's redirects, unless returning to a 712 // Set the redirect chain to the navigation's redirects, unless returning to a
713 // completed navigation (whose previous redirects don't apply). 713 // completed navigation (whose previous redirects don't apply).
714 std::vector<GURL> redirects; 714 std::vector<GURL> redirects;
715 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { 715 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) {
716 redirects = frame_entry.redirect_chain(); 716 redirects = frame_entry.redirect_chain();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 parent_node->children.push_back( 859 parent_node->children.push_back(
860 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); 860 new NavigationEntryImpl::TreeNode(parent_node, frame_entry));
861 } 861 }
862 862
863 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 863 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
864 FrameTreeNode* frame_tree_node) const { 864 FrameTreeNode* frame_tree_node) const {
865 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 865 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
866 return tree_node ? tree_node->frame_entry.get() : nullptr; 866 return tree_node ? tree_node->frame_entry.get() : nullptr;
867 } 867 }
868 868
869 std::set<std::string> NavigationEntryImpl::GetSubframeUniqueNames( 869 std::map<std::string, bool> NavigationEntryImpl::GetSubframeUniqueNames(
870 FrameTreeNode* frame_tree_node) const { 870 FrameTreeNode* frame_tree_node) const {
871 std::set<std::string> names; 871 std::map<std::string, bool> names;
872 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 872 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
873 if (tree_node) { 873 if (tree_node) {
874 // Return the names of all immediate children. 874 // Return the names of all immediate children.
875 for (TreeNode* child : tree_node->children) 875 for (TreeNode* child : tree_node->children) {
876 names.insert(child->frame_entry->frame_unique_name()); 876 // Keep track of whether we would be loading about:blank, since the
877 // renderer should be allowed to just commit the initial blank frame if
878 // that was the default URL. PageState doesn't matter there, because
879 // content injected into about:blank frames doesn't use it.
880 //
881 // Be careful not to include iframe srcdoc URLs in this check, which do
882 // need their PageState. The committed URL in that case gets rewritten to
883 // about:blank, but we can detect it via the PageState's URL.
884 //
885 // See https://crbug.com/657896 for details.
886 bool is_about_blank = false;
887 ExplodedPageState exploded_page_state;
888 if (DecodePageState(child->frame_entry->page_state().ToEncodedData(),
889 &exploded_page_state)) {
890 ExplodedFrameState frame_state = exploded_page_state.top;
891 if (UTF16ToUTF8(frame_state.url_string.string()) == url::kAboutBlankURL)
892 is_about_blank = true;
893 }
894
895 names[child->frame_entry->frame_unique_name()] = is_about_blank;
896 }
877 } 897 }
878 return names; 898 return names;
879 } 899 }
880 900
881 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( 901 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame(
882 FrameTreeNode* frame_tree_node) { 902 FrameTreeNode* frame_tree_node) {
883 DCHECK(!frame_tree_node->IsMainFrame()); 903 DCHECK(!frame_tree_node->IsMainFrame());
884 904
885 NavigationEntryImpl::TreeNode* node = nullptr; 905 NavigationEntryImpl::TreeNode* node = nullptr;
886 std::queue<NavigationEntryImpl::TreeNode*> work_queue; 906 std::queue<NavigationEntryImpl::TreeNode*> work_queue;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return node; 958 return node;
939 959
940 // Enqueue any children and keep looking. 960 // Enqueue any children and keep looking.
941 for (auto* child : node->children) 961 for (auto* child : node->children)
942 work_queue.push(child); 962 work_queue.push(child);
943 } 963 }
944 return nullptr; 964 return nullptr;
945 } 965 }
946 966
947 } // 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