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

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: 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..692d119e7b21788c346016e37f9fb6b67b342b06 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -788,6 +788,40 @@ void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
tree_node->children.clear();
}
+void NavigationEntryImpl::ClearNamedFrameEntries(
+ const std::string& frame_unique_name) {
+ NavigationEntryImpl::TreeNode* node = nullptr;
+ NavigationEntryImpl::TreeNode* parent = nullptr;
+ std::queue<
+ std::pair<NavigationEntryImpl::TreeNode*, NavigationEntryImpl::TreeNode*>>
Charlie Reis 2016/07/27 22:48:28 I suppose that's what we get for not having a pare
nasko 2016/07/29 15:52:21 Acknowledged.
+ work_queue;
+ work_queue.push(std::make_pair(root_node(), nullptr));
+ int count = 0;
+
+ while (!work_queue.empty()) {
+ node = work_queue.front().first;
+ parent = work_queue.front().second;
+ work_queue.pop();
+
+ if (parent && node->frame_entry->frame_unique_name() == frame_unique_name) {
Charlie Reis 2016/07/27 22:48:28 I'm curious if it would be better to use MatchesFr
nasko 2016/07/29 15:52:22 Done.
+ auto it =
+ std::find(parent->children.begin(), parent->children.end(), node);
+ if (it != parent->children.end()) {
Charlie Reis 2016/07/27 22:48:27 This shouldn't ever fail, should it?
nasko 2016/07/29 15:52:21 No.
+ parent->children.erase(it);
+ ++count;
+ }
+ continue;
+ }
+
+ // Enqueue any children and keep looking.
+ for (auto* child : node->children)
+ work_queue.push(std::make_pair(child, node));
+ }
+
+ // There should be at most one frame matching the |frame_unique_name|.
+ DCHECK_GE(1, count);
+}
+
void NavigationEntryImpl::SetScreenshotPNGData(
scoped_refptr<base::RefCountedBytes> png_data) {
screenshot_ = png_data;

Powered by Google App Engine
This is Rietveld 408576698