OLD | NEW |
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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
11 #include "content/common/navigation_params.h" | 11 #include "content/common/navigation_params.h" |
12 #include "content/public/common/content_constants.h" | 12 #include "content/public/common/content_constants.h" |
13 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "ui/gfx/text_elider.h" | 15 #include "ui/gfx/text_elider.h" |
16 | 16 |
17 // Use this to get a new unique ID for a NavigationEntry during construction. | 17 // Use this to get a new unique ID for a NavigationEntry during construction. |
18 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 18 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
19 static int GetUniqueIDInConstructor() { | 19 static int GetUniqueIDInConstructor() { |
20 static int unique_id_counter = 0; | 20 static int unique_id_counter = 0; |
21 return ++unique_id_counter; | 21 return ++unique_id_counter; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 int NavigationEntryImpl::kInvalidBindings = -1; | 26 int NavigationEntryImpl::kInvalidBindings = -1; |
27 | 27 |
| 28 NavigationEntryImpl::TreeNode::TreeNode(FrameNavigationEntry* frame_entry) |
| 29 : frame_entry(frame_entry) { |
| 30 } |
| 31 |
| 32 NavigationEntryImpl::TreeNode::~TreeNode() { |
| 33 } |
| 34 |
| 35 NavigationEntryImpl::TreeNode* NavigationEntryImpl::TreeNode::Clone() const { |
| 36 // Clone the tree using a copy of the FrameNavigationEntry, without sharing. |
| 37 NavigationEntryImpl::TreeNode* copy = |
| 38 new NavigationEntryImpl::TreeNode(frame_entry->Clone()); |
| 39 |
| 40 // TODO(creis): Clone children once we add them. |
| 41 return copy; |
| 42 } |
| 43 |
28 NavigationEntry* NavigationEntry::Create() { | 44 NavigationEntry* NavigationEntry::Create() { |
29 return new NavigationEntryImpl(); | 45 return new NavigationEntryImpl(); |
30 } | 46 } |
31 | 47 |
32 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( | 48 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( |
33 NavigationEntry* entry) { | 49 NavigationEntry* entry) { |
34 return static_cast<NavigationEntryImpl*>(entry); | 50 return static_cast<NavigationEntryImpl*>(entry); |
35 } | 51 } |
36 | 52 |
37 NavigationEntryImpl::NavigationEntryImpl() | 53 NavigationEntryImpl::NavigationEntryImpl() |
38 : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), | 54 : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), |
39 ui::PAGE_TRANSITION_LINK, false) { | 55 ui::PAGE_TRANSITION_LINK, false) { |
40 } | 56 } |
41 | 57 |
42 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, | 58 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, |
43 int page_id, | 59 int page_id, |
44 const GURL& url, | 60 const GURL& url, |
45 const Referrer& referrer, | 61 const Referrer& referrer, |
46 const base::string16& title, | 62 const base::string16& title, |
47 ui::PageTransition transition_type, | 63 ui::PageTransition transition_type, |
48 bool is_renderer_initiated) | 64 bool is_renderer_initiated) |
49 : frame_entry_(instance, url, referrer), | 65 : frame_tree_( |
| 66 new TreeNode(new FrameNavigationEntry(instance, url, referrer))), |
50 unique_id_(GetUniqueIDInConstructor()), | 67 unique_id_(GetUniqueIDInConstructor()), |
51 bindings_(kInvalidBindings), | 68 bindings_(kInvalidBindings), |
52 page_type_(PAGE_TYPE_NORMAL), | 69 page_type_(PAGE_TYPE_NORMAL), |
53 update_virtual_url_with_url_(false), | 70 update_virtual_url_with_url_(false), |
54 title_(title), | 71 title_(title), |
55 page_id_(page_id), | 72 page_id_(page_id), |
56 transition_type_(transition_type), | 73 transition_type_(transition_type), |
57 has_post_data_(false), | 74 has_post_data_(false), |
58 post_id_(-1), | 75 post_id_(-1), |
59 restore_type_(RESTORE_NONE), | 76 restore_type_(RESTORE_NONE), |
(...skipping 11 matching lines...) Expand all Loading... |
71 | 88 |
72 int NavigationEntryImpl::GetUniqueID() const { | 89 int NavigationEntryImpl::GetUniqueID() const { |
73 return unique_id_; | 90 return unique_id_; |
74 } | 91 } |
75 | 92 |
76 PageType NavigationEntryImpl::GetPageType() const { | 93 PageType NavigationEntryImpl::GetPageType() const { |
77 return page_type_; | 94 return page_type_; |
78 } | 95 } |
79 | 96 |
80 void NavigationEntryImpl::SetURL(const GURL& url) { | 97 void NavigationEntryImpl::SetURL(const GURL& url) { |
81 frame_entry_.set_url(url); | 98 frame_tree_->frame_entry->set_url(url); |
82 cached_display_title_.clear(); | 99 cached_display_title_.clear(); |
83 } | 100 } |
84 | 101 |
85 const GURL& NavigationEntryImpl::GetURL() const { | 102 const GURL& NavigationEntryImpl::GetURL() const { |
86 return frame_entry_.url(); | 103 return frame_tree_->frame_entry->url(); |
87 } | 104 } |
88 | 105 |
89 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) { | 106 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) { |
90 base_url_for_data_url_ = url; | 107 base_url_for_data_url_ = url; |
91 } | 108 } |
92 | 109 |
93 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const { | 110 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const { |
94 return base_url_for_data_url_; | 111 return base_url_for_data_url_; |
95 } | 112 } |
96 | 113 |
97 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { | 114 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { |
98 frame_entry_.set_referrer(referrer); | 115 frame_tree_->frame_entry->set_referrer(referrer); |
99 } | 116 } |
100 | 117 |
101 const Referrer& NavigationEntryImpl::GetReferrer() const { | 118 const Referrer& NavigationEntryImpl::GetReferrer() const { |
102 return frame_entry_.referrer(); | 119 return frame_tree_->frame_entry->referrer(); |
103 } | 120 } |
104 | 121 |
105 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { | 122 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { |
106 virtual_url_ = (url == GetURL()) ? GURL() : url; | 123 virtual_url_ = (url == GetURL()) ? GURL() : url; |
107 cached_display_title_.clear(); | 124 cached_display_title_.clear(); |
108 } | 125 } |
109 | 126 |
110 const GURL& NavigationEntryImpl::GetVirtualURL() const { | 127 const GURL& NavigationEntryImpl::GetVirtualURL() const { |
111 return virtual_url_.is_empty() ? GetURL() : virtual_url_; | 128 return virtual_url_.is_empty() ? GetURL() : virtual_url_; |
112 } | 129 } |
(...skipping 17 matching lines...) Expand all Loading... |
130 | 147 |
131 void NavigationEntryImpl::SetPageID(int page_id) { | 148 void NavigationEntryImpl::SetPageID(int page_id) { |
132 page_id_ = page_id; | 149 page_id_ = page_id; |
133 } | 150 } |
134 | 151 |
135 int32 NavigationEntryImpl::GetPageID() const { | 152 int32 NavigationEntryImpl::GetPageID() const { |
136 return page_id_; | 153 return page_id_; |
137 } | 154 } |
138 | 155 |
139 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) { | 156 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) { |
140 frame_entry_.set_site_instance(site_instance); | 157 // TODO(creis): Update all callers and remove this method. |
| 158 frame_tree_->frame_entry->set_site_instance(site_instance); |
141 } | 159 } |
142 | 160 |
143 void NavigationEntryImpl::set_source_site_instance( | 161 void NavigationEntryImpl::set_source_site_instance( |
144 SiteInstanceImpl* source_site_instance) { | 162 SiteInstanceImpl* source_site_instance) { |
145 source_site_instance_ = source_site_instance; | 163 source_site_instance_ = source_site_instance; |
146 } | 164 } |
147 | 165 |
148 void NavigationEntryImpl::SetBindings(int bindings) { | 166 void NavigationEntryImpl::SetBindings(int bindings) { |
149 // Ensure this is set to a valid value, and that it stays the same once set. | 167 // Ensure this is set to a valid value, and that it stays the same once set. |
150 CHECK_NE(bindings, kInvalidBindings); | 168 CHECK_NE(bindings, kInvalidBindings); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 return true; | 337 return true; |
320 } | 338 } |
321 | 339 |
322 void NavigationEntryImpl::ClearExtraData(const std::string& key) { | 340 void NavigationEntryImpl::ClearExtraData(const std::string& key) { |
323 extra_data_.erase(key); | 341 extra_data_.erase(key); |
324 } | 342 } |
325 | 343 |
326 NavigationEntryImpl* NavigationEntryImpl::Clone() const { | 344 NavigationEntryImpl* NavigationEntryImpl::Clone() const { |
327 NavigationEntryImpl* copy = new NavigationEntryImpl(); | 345 NavigationEntryImpl* copy = new NavigationEntryImpl(); |
328 | 346 |
329 // TODO(creis): Once we have a tree of FrameNavigationEntries, make a deep | 347 // TODO(creis): Only share the same FrameNavigationEntries if cloning within |
330 // copy. Only share the same FrameNavigationEntries if cloning within the | 348 // the same tab. |
331 // same tab. | 349 copy->frame_tree_.reset(frame_tree_->Clone()); |
332 copy->frame_entry_ = frame_entry_; | |
333 | 350 |
334 // Copy all state over, unless cleared in ResetForCommit. | 351 // Copy all state over, unless cleared in ResetForCommit. |
335 copy->unique_id_ = unique_id_; | 352 copy->unique_id_ = unique_id_; |
336 copy->bindings_ = bindings_; | 353 copy->bindings_ = bindings_; |
337 copy->page_type_ = page_type_; | 354 copy->page_type_ = page_type_; |
338 copy->virtual_url_ = virtual_url_; | 355 copy->virtual_url_ = virtual_url_; |
339 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; | 356 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; |
340 copy->title_ = title_; | 357 copy->title_ = title_; |
341 copy->favicon_ = favicon_; | 358 copy->favicon_ = favicon_; |
342 copy->page_state_ = page_state_; | 359 copy->page_state_ = page_state_; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 GetBrowserInitiatedPostData()->size()); | 479 GetBrowserInitiatedPostData()->size()); |
463 } | 480 } |
464 | 481 |
465 return StartNavigationParams( | 482 return StartNavigationParams( |
466 GetHasPostData(), extra_headers(), browser_initiated_post_data, | 483 GetHasPostData(), extra_headers(), browser_initiated_post_data, |
467 should_replace_entry(), transferred_global_request_id().child_id, | 484 should_replace_entry(), transferred_global_request_id().child_id, |
468 transferred_global_request_id().request_id); | 485 transferred_global_request_id().request_id); |
469 } | 486 } |
470 | 487 |
471 } // namespace content | 488 } // namespace content |
OLD | NEW |