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 c7a84de7ff38c08f8db23c1c33af7a462c4c7cd5..2d8b7bb062b1034c8a8d234b05ac03a96dc57594 100644 |
--- a/content/browser/frame_host/navigation_entry_impl.cc |
+++ b/content/browser/frame_host/navigation_entry_impl.cc |
@@ -25,8 +25,12 @@ namespace content { |
int NavigationEntryImpl::kInvalidBindings = -1; |
-NavigationEntryImpl::TreeNode::TreeNode(FrameNavigationEntry* frame_entry) |
- : frame_entry(frame_entry) { |
+NavigationEntryImpl::TreeNode::TreeNode(NavigationEntryImpl* entry, |
+ FrameNavigationEntry* frame_entry) |
+ : entry(entry), |
+ frame_entry(nullptr) { |
+ if (frame_entry) |
+ SetFrameEntry(frame_entry); |
} |
NavigationEntryImpl::TreeNode::~TreeNode() { |
@@ -34,13 +38,24 @@ NavigationEntryImpl::TreeNode::~TreeNode() { |
NavigationEntryImpl::TreeNode* NavigationEntryImpl::TreeNode::Clone() const { |
// Clone the tree using a copy of the FrameNavigationEntry, without sharing. |
+ // TODO(creis): Should not have an |entry| in TreeNode. Currently sharing |
+ // it, which is very wrong. |
NavigationEntryImpl::TreeNode* copy = |
- new NavigationEntryImpl::TreeNode(frame_entry->Clone()); |
+ new NavigationEntryImpl::TreeNode(entry, frame_entry->Clone()); |
// TODO(creis): Clone children once we add them. |
return copy; |
} |
+void NavigationEntryImpl::TreeNode::SetFrameEntry( |
+ FrameNavigationEntry* new_frame_entry) { |
+ frame_entry = new_frame_entry; |
+ entry->frames_to_items_[new_frame_entry->frame_tree_node_id()] = this; |
+ |
+ // TODO(creis): Move NE::frame_to_target_ to FNE::target_. |
+ //entry->unique_names_to_items_[frame_entry->target()] = this; |
+} |
+ |
NavigationEntry* NavigationEntry::Create() { |
return new NavigationEntryImpl(); |
} |
@@ -62,8 +77,8 @@ NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, |
const base::string16& title, |
ui::PageTransition transition_type, |
bool is_renderer_initiated) |
- : frame_tree_( |
- new TreeNode(new FrameNavigationEntry(instance, url, referrer))), |
+ : frame_tree_(new TreeNode( |
+ this, new FrameNavigationEntry(instance, url, referrer))), |
unique_id_(GetUniqueIDInConstructor()), |
bindings_(kInvalidBindings), |
page_type_(PAGE_TYPE_NORMAL), |
@@ -79,8 +94,7 @@ NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, |
is_renderer_initiated_(is_renderer_initiated), |
should_replace_entry_(false), |
should_clear_history_list_(false), |
- can_load_local_resources_(false), |
- frame_tree_node_id_(-1) { |
+ can_load_local_resources_(false) { |
} |
NavigationEntryImpl::~NavigationEntryImpl() { |
@@ -138,11 +152,12 @@ const base::string16& NavigationEntryImpl::GetTitle() const { |
} |
void NavigationEntryImpl::SetPageState(const PageState& state) { |
- page_state_ = state; |
+ CHECK(state.ToEncodedData().empty() || state.IsValid()); |
+ frame_tree_->frame_entry->set_page_state(state); |
} |
const PageState& NavigationEntryImpl::GetPageState() const { |
- return page_state_; |
+ return frame_tree_->frame_entry->page_state(); |
} |
void NavigationEntryImpl::SetPageID(int page_id) { |
@@ -341,6 +356,31 @@ void NavigationEntryImpl::ClearExtraData(const std::string& key) { |
extra_data_.erase(key); |
} |
+void NavigationEntryImpl::ResetFrameTree() { |
+ frame_tree_.reset(new TreeNode(this, nullptr)); |
+} |
+ |
+NavigationEntryImpl::TreeNode* NavigationEntryImpl::GetTreeNodeForFrame( |
+ FrameTreeNode* frame_tree_node) { |
+ // Search based on FTN ID and unique name. |
+ // TODO(creis): We had been using a map of routing ID to frame sequence num. |
+ // Is that useful here? |
+ if (TreeNode* node = frames_to_items_[frame_tree_node->frame_tree_node_id()]) |
+ return node; |
+ // TODO(creis): Move NE::frame_to_target_ to FNE::target_. |
+ //if (TreeNode* node = unique_names_to_items_[frame_tree_node->name()]) |
+ // return node; |
+ return nullptr; |
+} |
+ |
+FrameNavigationEntry* NavigationEntryImpl::GetFrameEntryForFrame( |
+ FrameTreeNode* frame_tree_node) { |
+ TreeNode* node = GetTreeNodeForFrame(frame_tree_node); |
+ if (node) |
+ return node->frame_entry.get(); |
+ return nullptr; |
+} |
+ |
NavigationEntryImpl* NavigationEntryImpl::Clone() const { |
NavigationEntryImpl* copy = new NavigationEntryImpl(); |
@@ -356,7 +396,6 @@ NavigationEntryImpl* NavigationEntryImpl::Clone() const { |
copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; |
copy->title_ = title_; |
copy->favicon_ = favicon_; |
- copy->page_state_ = page_state_; |
copy->page_id_ = page_id_; |
copy->ssl_ = ssl_; |
copy->transition_type_ = transition_type_; |
@@ -399,7 +438,6 @@ void NavigationEntryImpl::ResetForCommit() { |
set_should_replace_entry(false); |
set_should_clear_history_list(false); |
- set_frame_tree_node_id(-1); |
#if defined(OS_ANDROID) |
// Reset the time stamp so that the metrics are not reported if this entry is |
@@ -420,6 +458,7 @@ GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { |
} |
CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( |
+ const FrameNavigationEntry& frame_entry, |
FrameMsg_Navigate_Type::Value navigation_type) const { |
FrameMsg_UILoadMetricsReportType::Value report_type = |
FrameMsg_UILoadMetricsReportType::NO_REPORT; |
@@ -431,9 +470,9 @@ CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( |
#endif |
return CommonNavigationParams( |
- GetURL(), GetReferrer(), GetTransitionType(), navigation_type, |
- !IsViewSourceMode(), ui_timestamp, report_type, GetBaseURLForDataURL(), |
- GetHistoryURLForDataURL()); |
+ frame_entry.url(), frame_entry.referrer(), GetTransitionType(), |
+ navigation_type, !IsViewSourceMode(), ui_timestamp, report_type, |
+ GetBaseURLForDataURL(), GetHistoryURLForDataURL()); |
} |
CommitNavigationParams NavigationEntryImpl::ConstructCommitNavigationParams( |
@@ -451,6 +490,7 @@ CommitNavigationParams NavigationEntryImpl::ConstructCommitNavigationParams( |
} |
HistoryNavigationParams NavigationEntryImpl::ConstructHistoryNavigationParams( |
+ const FrameNavigationEntry& frame_entry, |
NavigationControllerImpl* controller) const { |
int pending_history_list_offset = controller->GetIndexOfEntry(this); |
int current_history_list_offset = controller->GetLastCommittedEntryIndex(); |
@@ -464,7 +504,7 @@ HistoryNavigationParams NavigationEntryImpl::ConstructHistoryNavigationParams( |
current_history_list_length = 0; |
} |
return HistoryNavigationParams( |
- GetPageState(), GetPageID(), pending_history_list_offset, |
+ frame_entry.page_state(), GetPageID(), pending_history_list_offset, |
current_history_list_offset, current_history_list_length, |
should_clear_history_list()); |
} |