| 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" |
| 11 #include "content/public/common/url_constants.h" | 11 #include "content/public/common/url_constants.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 #include "ui/gfx/text_elider.h" | 13 #include "ui/gfx/text_elider.h" |
| 14 | 14 |
| 15 // Use this to get a new unique ID for a NavigationEntry during construction. | 15 // Use this to get a new unique ID for a NavigationEntry during construction. |
| 16 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 16 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
| 17 static int GetUniqueIDInConstructor() { | 17 static int GetUniqueIDInConstructor() { |
| 18 static int unique_id_counter = 0; | 18 static int unique_id_counter = 0; |
| 19 return ++unique_id_counter; | 19 return ++unique_id_counter; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 int NavigationEntryImpl::kInvalidBindings = -1; | 24 int NavigationEntryImpl::kInvalidBindings = -1; |
| 25 | 25 |
| 26 NavigationEntry* NavigationEntry::Create() { | 26 NavigationEntry* NavigationEntry::Create() { |
| 27 return new NavigationEntryImpl(); | 27 return new NavigationEntryImpl(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) { | |
| 31 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy)); | |
| 32 } | |
| 33 | |
| 34 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( | 30 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( |
| 35 NavigationEntry* entry) { | 31 NavigationEntry* entry) { |
| 36 return static_cast<NavigationEntryImpl*>(entry); | 32 return static_cast<NavigationEntryImpl*>(entry); |
| 37 } | 33 } |
| 38 | 34 |
| 39 NavigationEntryImpl::NavigationEntryImpl() | 35 NavigationEntryImpl::NavigationEntryImpl() |
| 40 : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), | 36 : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), |
| 41 ui::PAGE_TRANSITION_LINK, false) { | 37 ui::PAGE_TRANSITION_LINK, false) { |
| 42 } | 38 } |
| 43 | 39 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (iter == extra_data_.end()) | 314 if (iter == extra_data_.end()) |
| 319 return false; | 315 return false; |
| 320 *data = iter->second; | 316 *data = iter->second; |
| 321 return true; | 317 return true; |
| 322 } | 318 } |
| 323 | 319 |
| 324 void NavigationEntryImpl::ClearExtraData(const std::string& key) { | 320 void NavigationEntryImpl::ClearExtraData(const std::string& key) { |
| 325 extra_data_.erase(key); | 321 extra_data_.erase(key); |
| 326 } | 322 } |
| 327 | 323 |
| 324 NavigationEntryImpl* NavigationEntryImpl::Clone() const { |
| 325 NavigationEntryImpl* copy = new NavigationEntryImpl(); |
| 326 |
| 327 // TODO(creis): Once we have a tree of FrameNavigationEntries, make a deep |
| 328 // copy. Only share the same FrameNavigationEntries if cloning within the |
| 329 // same tab. |
| 330 copy->frame_entry_ = frame_entry_; |
| 331 |
| 332 // Copy all state over, unless cleared in ResetForCommit. |
| 333 copy->unique_id_ = unique_id_; |
| 334 copy->bindings_ = bindings_; |
| 335 copy->page_type_ = page_type_; |
| 336 copy->virtual_url_ = virtual_url_; |
| 337 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; |
| 338 copy->title_ = title_; |
| 339 copy->favicon_ = favicon_; |
| 340 copy->page_state_ = page_state_; |
| 341 copy->page_id_ = page_id_; |
| 342 copy->ssl_ = ssl_; |
| 343 copy->transition_type_ = transition_type_; |
| 344 copy->user_typed_url_ = user_typed_url_; |
| 345 copy->has_post_data_ = has_post_data_; |
| 346 copy->post_id_ = post_id_; |
| 347 copy->restore_type_ = restore_type_; |
| 348 copy->original_request_url_ = original_request_url_; |
| 349 copy->is_overriding_user_agent_ = is_overriding_user_agent_; |
| 350 copy->timestamp_ = timestamp_; |
| 351 copy->http_status_code_ = http_status_code_; |
| 352 // ResetForCommit: browser_initiated_post_data_ |
| 353 copy->screenshot_ = screenshot_; |
| 354 copy->extra_headers_ = extra_headers_; |
| 355 // ResetForCommit: source_site_instance_ |
| 356 copy->base_url_for_data_url_ = base_url_for_data_url_; |
| 357 // ResetForCommit: is_renderer_initiated_ |
| 358 copy->cached_display_title_ = cached_display_title_; |
| 359 // ResetForCommit: transferred_global_request_id_ |
| 360 // ResetForCommit: should_replace_entry_ |
| 361 copy->redirect_chain_ = redirect_chain_; |
| 362 // ResetForCommit: should_clear_history_list_ |
| 363 copy->frame_to_navigate_ = frame_to_navigate_; |
| 364 // ResetForCommit: frame_tree_node_id_ |
| 365 // ResetForCommit: intent_received_timestamp_ |
| 366 copy->extra_data_ = extra_data_; |
| 367 |
| 368 return copy; |
| 369 } |
| 370 |
| 328 void NavigationEntryImpl::ResetForCommit() { | 371 void NavigationEntryImpl::ResetForCommit() { |
| 329 // Any state that only matters when a navigation entry is pending should be | 372 // Any state that only matters when a navigation entry is pending should be |
| 330 // cleared here. | 373 // cleared here. |
| 374 // TODO(creis): This state should be moved to NavigationRequest once |
| 375 // PlzNavigate is enabled. |
| 331 SetBrowserInitiatedPostData(nullptr); | 376 SetBrowserInitiatedPostData(nullptr); |
| 377 set_source_site_instance(nullptr); |
| 332 set_is_renderer_initiated(false); | 378 set_is_renderer_initiated(false); |
| 333 set_transferred_global_request_id(GlobalRequestID()); | 379 set_transferred_global_request_id(GlobalRequestID()); |
| 334 set_should_replace_entry(false); | 380 set_should_replace_entry(false); |
| 335 | 381 |
| 336 set_should_clear_history_list(false); | 382 set_should_clear_history_list(false); |
| 337 set_frame_tree_node_id(-1); | 383 set_frame_tree_node_id(-1); |
| 338 set_source_site_instance(nullptr); | |
| 339 | 384 |
| 340 #if defined(OS_ANDROID) | 385 #if defined(OS_ANDROID) |
| 341 // Reset the time stamp so that the metrics are not reported if this entry is | 386 // Reset the time stamp so that the metrics are not reported if this entry is |
| 342 // loaded again in the future. | 387 // loaded again in the future. |
| 343 set_intent_received_timestamp(base::TimeTicks()); | 388 set_intent_received_timestamp(base::TimeTicks()); |
| 344 #endif | 389 #endif |
| 345 } | 390 } |
| 346 | 391 |
| 347 void NavigationEntryImpl::SetScreenshotPNGData( | 392 void NavigationEntryImpl::SetScreenshotPNGData( |
| 348 scoped_refptr<base::RefCountedBytes> png_data) { | 393 scoped_refptr<base::RefCountedBytes> png_data) { |
| 349 screenshot_ = png_data; | 394 screenshot_ = png_data; |
| 350 if (screenshot_.get()) | 395 if (screenshot_.get()) |
| 351 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); | 396 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); |
| 352 } | 397 } |
| 353 | 398 |
| 354 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { | 399 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { |
| 355 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); | 400 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); |
| 356 } | 401 } |
| 357 | 402 |
| 358 } // namespace content | 403 } // namespace content |
| OLD | NEW |