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/public/common/content_constants.h" | 10 #include "content/public/common/content_constants.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 should_replace_entry_(false), | 53 should_replace_entry_(false), |
54 should_clear_history_list_(false), | 54 should_clear_history_list_(false), |
55 can_load_local_resources_(false), | 55 can_load_local_resources_(false), |
56 frame_tree_node_id_(-1) { | 56 frame_tree_node_id_(-1) { |
57 } | 57 } |
58 | 58 |
59 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, | 59 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, |
60 int page_id, | 60 int page_id, |
61 const GURL& url, | 61 const GURL& url, |
62 const Referrer& referrer, | 62 const Referrer& referrer, |
63 const string16& title, | 63 const base::string16& title, |
64 PageTransition transition_type, | 64 PageTransition transition_type, |
65 bool is_renderer_initiated) | 65 bool is_renderer_initiated) |
66 : unique_id_(GetUniqueIDInConstructor()), | 66 : unique_id_(GetUniqueIDInConstructor()), |
67 site_instance_(instance), | 67 site_instance_(instance), |
68 bindings_(kInvalidBindings), | 68 bindings_(kInvalidBindings), |
69 page_type_(PAGE_TYPE_NORMAL), | 69 page_type_(PAGE_TYPE_NORMAL), |
70 url_(url), | 70 url_(url), |
71 referrer_(referrer), | 71 referrer_(referrer), |
72 update_virtual_url_with_url_(false), | 72 update_virtual_url_with_url_(false), |
73 title_(title), | 73 title_(title), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { | 124 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { |
125 virtual_url_ = (url == url_) ? GURL() : url; | 125 virtual_url_ = (url == url_) ? GURL() : url; |
126 cached_display_title_.clear(); | 126 cached_display_title_.clear(); |
127 } | 127 } |
128 | 128 |
129 const GURL& NavigationEntryImpl::GetVirtualURL() const { | 129 const GURL& NavigationEntryImpl::GetVirtualURL() const { |
130 return virtual_url_.is_empty() ? url_ : virtual_url_; | 130 return virtual_url_.is_empty() ? url_ : virtual_url_; |
131 } | 131 } |
132 | 132 |
133 void NavigationEntryImpl::SetTitle(const string16& title) { | 133 void NavigationEntryImpl::SetTitle(const base::string16& title) { |
134 title_ = title; | 134 title_ = title; |
135 cached_display_title_.clear(); | 135 cached_display_title_.clear(); |
136 } | 136 } |
137 | 137 |
138 const string16& NavigationEntryImpl::GetTitle() const { | 138 const base::string16& NavigationEntryImpl::GetTitle() const { |
139 return title_; | 139 return title_; |
140 } | 140 } |
141 | 141 |
142 void NavigationEntryImpl::SetPageState(const PageState& state) { | 142 void NavigationEntryImpl::SetPageState(const PageState& state) { |
143 page_state_ = state; | 143 page_state_ = state; |
144 } | 144 } |
145 | 145 |
146 const PageState& NavigationEntryImpl::GetPageState() const { | 146 const PageState& NavigationEntryImpl::GetPageState() const { |
147 return page_state_; | 147 return page_state_; |
148 } | 148 } |
(...skipping 10 matching lines...) Expand all Loading... |
159 site_instance_ = site_instance; | 159 site_instance_ = site_instance; |
160 } | 160 } |
161 | 161 |
162 void NavigationEntryImpl::SetBindings(int bindings) { | 162 void NavigationEntryImpl::SetBindings(int bindings) { |
163 // Ensure this is set to a valid value, and that it stays the same once set. | 163 // Ensure this is set to a valid value, and that it stays the same once set. |
164 CHECK_NE(bindings, kInvalidBindings); | 164 CHECK_NE(bindings, kInvalidBindings); |
165 CHECK(bindings_ == kInvalidBindings || bindings_ == bindings); | 165 CHECK(bindings_ == kInvalidBindings || bindings_ == bindings); |
166 bindings_ = bindings; | 166 bindings_ = bindings; |
167 } | 167 } |
168 | 168 |
169 const string16& NavigationEntryImpl::GetTitleForDisplay( | 169 const base::string16& NavigationEntryImpl::GetTitleForDisplay( |
170 const std::string& languages) const { | 170 const std::string& languages) const { |
171 // Most pages have real titles. Don't even bother caching anything if this is | 171 // Most pages have real titles. Don't even bother caching anything if this is |
172 // the case. | 172 // the case. |
173 if (!title_.empty()) | 173 if (!title_.empty()) |
174 return title_; | 174 return title_; |
175 | 175 |
176 // More complicated cases will use the URLs as the title. This result we will | 176 // More complicated cases will use the URLs as the title. This result we will |
177 // cache since it's more complicated to compute. | 177 // cache since it's more complicated to compute. |
178 if (!cached_display_title_.empty()) | 178 if (!cached_display_title_.empty()) |
179 return cached_display_title_; | 179 return cached_display_title_; |
180 | 180 |
181 // Use the virtual URL first if any, and fall back on using the real URL. | 181 // Use the virtual URL first if any, and fall back on using the real URL. |
182 string16 title; | 182 base::string16 title; |
183 if (!virtual_url_.is_empty()) { | 183 if (!virtual_url_.is_empty()) { |
184 title = net::FormatUrl(virtual_url_, languages); | 184 title = net::FormatUrl(virtual_url_, languages); |
185 } else if (!url_.is_empty()) { | 185 } else if (!url_.is_empty()) { |
186 title = net::FormatUrl(url_, languages); | 186 title = net::FormatUrl(url_, languages); |
187 } | 187 } |
188 | 188 |
189 // For file:// URLs use the filename as the title, not the full path. | 189 // For file:// URLs use the filename as the title, not the full path. |
190 if (url_.SchemeIsFile()) { | 190 if (url_.SchemeIsFile()) { |
191 string16::size_type slashpos = title.rfind('/'); | 191 base::string16::size_type slashpos = title.rfind('/'); |
192 if (slashpos != string16::npos) | 192 if (slashpos != base::string16::npos) |
193 title = title.substr(slashpos + 1); | 193 title = title.substr(slashpos + 1); |
194 } | 194 } |
195 | 195 |
196 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_); | 196 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_); |
197 return cached_display_title_; | 197 return cached_display_title_; |
198 } | 198 } |
199 | 199 |
200 bool NavigationEntryImpl::IsViewSourceMode() const { | 200 bool NavigationEntryImpl::IsViewSourceMode() const { |
201 return virtual_url_.SchemeIs(kViewSourceScheme); | 201 return virtual_url_.SchemeIs(kViewSourceScheme); |
202 } | 202 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 void NavigationEntryImpl::SetFrameToNavigate(const std::string& frame_name) { | 300 void NavigationEntryImpl::SetFrameToNavigate(const std::string& frame_name) { |
301 frame_to_navigate_ = frame_name; | 301 frame_to_navigate_ = frame_name; |
302 } | 302 } |
303 | 303 |
304 const std::string& NavigationEntryImpl::GetFrameToNavigate() const { | 304 const std::string& NavigationEntryImpl::GetFrameToNavigate() const { |
305 return frame_to_navigate_; | 305 return frame_to_navigate_; |
306 } | 306 } |
307 | 307 |
308 void NavigationEntryImpl::SetExtraData(const std::string& key, | 308 void NavigationEntryImpl::SetExtraData(const std::string& key, |
309 const string16& data) { | 309 const base::string16& data) { |
310 extra_data_[key] = data; | 310 extra_data_[key] = data; |
311 } | 311 } |
312 | 312 |
313 bool NavigationEntryImpl::GetExtraData(const std::string& key, | 313 bool NavigationEntryImpl::GetExtraData(const std::string& key, |
314 string16* data) const { | 314 base::string16* data) const { |
315 std::map<std::string, string16>::const_iterator iter = extra_data_.find(key); | 315 std::map<std::string, base::string16>::const_iterator iter = |
| 316 extra_data_.find(key); |
316 if (iter == extra_data_.end()) | 317 if (iter == extra_data_.end()) |
317 return false; | 318 return false; |
318 *data = iter->second; | 319 *data = iter->second; |
319 return true; | 320 return true; |
320 } | 321 } |
321 | 322 |
322 void NavigationEntryImpl::ClearExtraData(const std::string& key) { | 323 void NavigationEntryImpl::ClearExtraData(const std::string& key) { |
323 extra_data_.erase(key); | 324 extra_data_.erase(key); |
324 } | 325 } |
325 | 326 |
(...skipping 10 matching lines...) Expand all Loading... |
336 } | 337 } |
337 | 338 |
338 void NavigationEntryImpl::SetScreenshotPNGData( | 339 void NavigationEntryImpl::SetScreenshotPNGData( |
339 scoped_refptr<base::RefCountedBytes> png_data) { | 340 scoped_refptr<base::RefCountedBytes> png_data) { |
340 screenshot_ = png_data; | 341 screenshot_ = png_data; |
341 if (screenshot_.get()) | 342 if (screenshot_.get()) |
342 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); | 343 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); |
343 } | 344 } |
344 | 345 |
345 } // namespace content | 346 } // namespace content |
OLD | NEW |