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

Unified Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 2191543003: Remove existing FrameNavigationEntry when new named frame is added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New implementation of FNE clearing. More work needed. Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_entry_impl.cc
diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc
index 9250e6811a31745d126c71bf78b67cae448382cd..a19d154613a1bd23b6d744a45ab0fbc6c2cb7018 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -788,6 +788,61 @@ void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
tree_node->children.clear();
}
+void NavigationEntryImpl::ClearMatchingFrameEntries(
+ FrameTreeNode* frame_tree_node) {
+ DCHECK(!frame_tree_node->IsMainFrame());
+
+ bool match_found = false;
+ NavigationEntryImpl::TreeNode* node = nullptr;
+ NavigationEntryImpl::TreeNode* parent_node = nullptr;
+ std::map<NavigationEntryImpl::TreeNode*, NavigationEntryImpl::TreeNode*>
+ parenting_map;
+ std::queue<NavigationEntryImpl::TreeNode*> work_queue;
+ work_queue.push(root_node());
+ parenting_map.insert(std::make_pair(root_node(), nullptr));
+
+ while (!work_queue.empty()) {
+ node = work_queue.front();
+ parent_node = parenting_map.find(node)->second;
+ work_queue.pop();
+
+ if (node->MatchesFrame(frame_tree_node, node == root_node())) {
+ match_found = true;
+ break;
Charlie Reis 2016/07/28 22:57:01 It's a little unfortunate that we stop after the f
nasko 2016/07/29 15:52:22 Done.
+ }
+
+ // Enqueue any children and keep looking.
+ for (auto* child : node->children) {
+ work_queue.push(child);
+ parenting_map.insert(std::make_pair(child, node));
+ }
+ }
+
+ if (!match_found)
+ return;
+
+ // Walk the ancestor chain for both the FrameTreeNode and the
+ // FrameNavigationEntry. If a mismatch in unique name is detected, the
+ // matched FrameNavigationEntry needs to be removed.
+ // The FTN and FNE are a match, guaranteed by the while loop above.
+ // Start with the parent nodes.
+ FrameTreeNode* ftn = frame_tree_node->parent();
+ TreeNode* current_node = parent_node;
+ while (ftn && current_node) {
+ if (!current_node->MatchesFrame(ftn, current_node == root_node())) {
+ auto it = std::find(parent_node->children.begin(),
+ parent_node->children.end(), node);
+ DCHECK(it != parent_node->children.end());
+ parent_node->children.erase(it);
+ break;
+ }
+ ftn = ftn->parent();
+ auto it = parenting_map.find(current_node);
+ if (it != parenting_map.end())
+ current_node = it->second;
Charlie Reis 2016/07/28 22:57:01 Need to handle the else branch, right? (If the FT
nasko 2016/07/29 15:52:22 Done.
+ }
+}
+
void NavigationEntryImpl::SetScreenshotPNGData(
scoped_refptr<base::RefCountedBytes> png_data) {
screenshot_ = png_data;
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698