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

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

Issue 1305293002: Clone the subframe FrameNavigationEntries for in-page navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <queue> 7 #include <queue>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 29 matching lines...) Expand all
40 return true; 40 return true;
41 41
42 // For now, we set the root FNE's FrameTreeNode ID to -1. 42 // For now, we set the root FNE's FrameTreeNode ID to -1.
43 return frame_tree_node->IsMainFrame() && 43 return frame_tree_node->IsMainFrame() &&
44 frame_entry->frame_tree_node_id() == -1; 44 frame_entry->frame_tree_node_id() == -1;
45 } 45 }
46 46
47 scoped_ptr<NavigationEntryImpl::TreeNode> 47 scoped_ptr<NavigationEntryImpl::TreeNode>
48 NavigationEntryImpl::TreeNode::CloneAndReplace( 48 NavigationEntryImpl::TreeNode::CloneAndReplace(
49 FrameTreeNode* frame_tree_node, 49 FrameTreeNode* frame_tree_node,
50 FrameNavigationEntry* frame_navigation_entry) const { 50 FrameNavigationEntry* frame_navigation_entry,
51 if (frame_tree_node && MatchesFrame(frame_tree_node)) { 51 bool clone_children_of_target) const {
52 // Replace this node in the cloned tree and prune its children. 52 bool is_target = frame_tree_node && MatchesFrame(frame_tree_node);
53 return make_scoped_ptr(
54 new NavigationEntryImpl::TreeNode(frame_navigation_entry));
55 }
56 53
57 // Clone the tree using a copy of the FrameNavigationEntry, without sharing. 54 // Clone the tree using either the target entry or a copy of the current
55 // FrameNavigationEntry, without sharing.
58 // TODO(creis): Share FNEs unless it's for another tab. 56 // TODO(creis): Share FNEs unless it's for another tab.
59 scoped_ptr<NavigationEntryImpl::TreeNode> copy( 57 scoped_ptr<NavigationEntryImpl::TreeNode> copy(
60 new NavigationEntryImpl::TreeNode(frame_entry->Clone())); 58 new NavigationEntryImpl::TreeNode(is_target ? frame_navigation_entry :
59 frame_entry->Clone()));
61 60
62 // Recursively clone the children. 61 // Recursively clone the children if this wasn't the target or if we were told
63 for (auto& child : children) { 62 // to clone the target's children.
64 copy->children.push_back( 63 if (!is_target || clone_children_of_target) {
65 child->CloneAndReplace(frame_tree_node, frame_navigation_entry)); 64 for (auto& child : children) {
65 copy->children.push_back(
66 child->CloneAndReplace(frame_tree_node, frame_navigation_entry,
67 clone_children_of_target));
68 }
66 } 69 }
67 70
68 return copy.Pass(); 71 return copy.Pass();
69 } 72 }
70 73
71 scoped_ptr<NavigationEntry> NavigationEntry::Create() { 74 scoped_ptr<NavigationEntry> NavigationEntry::Create() {
72 return make_scoped_ptr(new NavigationEntryImpl()).Pass(); 75 return make_scoped_ptr(new NavigationEntryImpl()).Pass();
73 } 76 }
74 77
75 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( 78 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return false; 382 return false;
380 *data = iter->second; 383 *data = iter->second;
381 return true; 384 return true;
382 } 385 }
383 386
384 void NavigationEntryImpl::ClearExtraData(const std::string& key) { 387 void NavigationEntryImpl::ClearExtraData(const std::string& key) {
385 extra_data_.erase(key); 388 extra_data_.erase(key);
386 } 389 }
387 390
388 scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::Clone() const { 391 scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::Clone() const {
389 return NavigationEntryImpl::CloneAndReplace(nullptr, nullptr); 392 return NavigationEntryImpl::CloneAndReplace(nullptr, nullptr, true);
390 } 393 }
391 394
392 scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::CloneAndReplace( 395 scoped_ptr<NavigationEntryImpl> NavigationEntryImpl::CloneAndReplace(
393 FrameTreeNode* frame_tree_node, 396 FrameTreeNode* frame_tree_node,
394 FrameNavigationEntry* frame_navigation_entry) const { 397 FrameNavigationEntry* frame_navigation_entry,
398 bool clone_children_of_target) const {
395 scoped_ptr<NavigationEntryImpl> copy = 399 scoped_ptr<NavigationEntryImpl> copy =
396 make_scoped_ptr(new NavigationEntryImpl()); 400 make_scoped_ptr(new NavigationEntryImpl());
397 401
398 // TODO(creis): Only share the same FrameNavigationEntries if cloning within 402 // TODO(creis): Only share the same FrameNavigationEntries if cloning within
399 // the same tab. 403 // the same tab.
400 copy->frame_tree_ = 404 copy->frame_tree_ =
401 frame_tree_->CloneAndReplace(frame_tree_node, frame_navigation_entry); 405 frame_tree_->CloneAndReplace(frame_tree_node, frame_navigation_entry,
406 clone_children_of_target);
402 407
403 // Copy most state over, unless cleared in ResetForCommit. 408 // Copy most state over, unless cleared in ResetForCommit.
404 // Don't copy unique_id_, otherwise it won't be unique. 409 // Don't copy unique_id_, otherwise it won't be unique.
405 copy->bindings_ = bindings_; 410 copy->bindings_ = bindings_;
406 copy->page_type_ = page_type_; 411 copy->page_type_ = page_type_;
407 copy->virtual_url_ = virtual_url_; 412 copy->virtual_url_ = virtual_url_;
408 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; 413 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_;
409 copy->title_ = title_; 414 copy->title_ = title_;
410 copy->favicon_ = favicon_; 415 copy->favicon_ = favicon_;
411 copy->page_id_ = page_id_; 416 copy->page_id_ = page_id_;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 return node; 613 return node;
609 } 614 }
610 // Enqueue any children and keep looking. 615 // Enqueue any children and keep looking.
611 for (auto& child : node->children) 616 for (auto& child : node->children)
612 work_queue.push(child); 617 work_queue.push(child);
613 } 618 }
614 return nullptr; 619 return nullptr;
615 } 620 }
616 621
617 } // namespace content 622 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698