| 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 934885c95a21dfcda409671264ce68d02bce7aaa..61c6aaa931a2af797e982acb7db6a05e427c5af8 100644
|
| --- a/content/browser/frame_host/navigation_entry_impl.cc
|
| +++ b/content/browser/frame_host/navigation_entry_impl.cc
|
| @@ -47,22 +47,25 @@ bool NavigationEntryImpl::TreeNode::MatchesFrame(
|
| scoped_ptr<NavigationEntryImpl::TreeNode>
|
| NavigationEntryImpl::TreeNode::CloneAndReplace(
|
| FrameTreeNode* frame_tree_node,
|
| - FrameNavigationEntry* frame_navigation_entry) const {
|
| - if (frame_tree_node && MatchesFrame(frame_tree_node)) {
|
| - // Replace this node in the cloned tree and prune its children.
|
| - return make_scoped_ptr(
|
| - new NavigationEntryImpl::TreeNode(frame_navigation_entry));
|
| - }
|
| + FrameNavigationEntry* frame_navigation_entry,
|
| + bool clone_children_of_target) const {
|
| + bool is_target = frame_tree_node && MatchesFrame(frame_tree_node);
|
|
|
| - // Clone the tree using a copy of the FrameNavigationEntry, without sharing.
|
| + // Clone the tree using either the target entry or a copy of the current
|
| + // FrameNavigationEntry, without sharing.
|
| // TODO(creis): Share FNEs unless it's for another tab.
|
| scoped_ptr<NavigationEntryImpl::TreeNode> copy(
|
| - new NavigationEntryImpl::TreeNode(frame_entry->Clone()));
|
| -
|
| - // Recursively clone the children.
|
| - for (auto& child : children) {
|
| - copy->children.push_back(
|
| - child->CloneAndReplace(frame_tree_node, frame_navigation_entry));
|
| + new NavigationEntryImpl::TreeNode(is_target ? frame_navigation_entry :
|
| + frame_entry->Clone()));
|
| +
|
| + // Recursively clone the children if this wasn't the target or if we were told
|
| + // to clone the target's children.
|
| + if (!is_target || clone_children_of_target) {
|
| + for (auto& child : children) {
|
| + copy->children.push_back(
|
| + child->CloneAndReplace(frame_tree_node, frame_navigation_entry,
|
| + clone_children_of_target));
|
| + }
|
| }
|
|
|
| return copy.Pass();
|
| @@ -386,19 +389,21 @@ void NavigationEntryImpl::ClearExtraData(const std::string& key) {
|
| }
|
|
|
| scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::Clone() const {
|
| - return NavigationEntryImpl::CloneAndReplace(nullptr, nullptr);
|
| + return NavigationEntryImpl::CloneAndReplace(nullptr, nullptr, true);
|
| }
|
|
|
| scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::CloneAndReplace(
|
| FrameTreeNode* frame_tree_node,
|
| - FrameNavigationEntry* frame_navigation_entry) const {
|
| + FrameNavigationEntry* frame_navigation_entry,
|
| + bool clone_children_of_target) const {
|
| scoped_ptr<NavigationEntryImpl> copy =
|
| make_scoped_ptr(new NavigationEntryImpl());
|
|
|
| // TODO(creis): Only share the same FrameNavigationEntries if cloning within
|
| // the same tab.
|
| copy->frame_tree_ =
|
| - frame_tree_->CloneAndReplace(frame_tree_node, frame_navigation_entry);
|
| + frame_tree_->CloneAndReplace(frame_tree_node, frame_navigation_entry,
|
| + clone_children_of_target);
|
|
|
| // Copy most state over, unless cleared in ResetForCommit.
|
| // Don't copy unique_id_, otherwise it won't be unique.
|
|
|