| 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 <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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/url_formatter/url_formatter.h" | 12 #include "components/url_formatter/url_formatter.h" |
| 13 #include "content/common/content_constants_internal.h" |
| 13 #include "content/common/navigation_params.h" | 14 #include "content/common/navigation_params.h" |
| 14 #include "content/common/page_state_serialization.h" | 15 #include "content/common/page_state_serialization.h" |
| 15 #include "content/common/site_isolation_policy.h" | 16 #include "content/common/site_isolation_policy.h" |
| 16 #include "content/public/common/content_constants.h" | 17 #include "content/public/common/content_constants.h" |
| 17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 18 #include "ui/gfx/text_elider.h" | 19 #include "ui/gfx/text_elider.h" |
| 19 | 20 |
| 20 using base::UTF16ToUTF8; | 21 using base::UTF16ToUTF8; |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 205 } |
| 205 | 206 |
| 206 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) { | 207 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) { |
| 207 base_url_for_data_url_ = url; | 208 base_url_for_data_url_ = url; |
| 208 } | 209 } |
| 209 | 210 |
| 210 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const { | 211 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const { |
| 211 return base_url_for_data_url_; | 212 return base_url_for_data_url_; |
| 212 } | 213 } |
| 213 | 214 |
| 215 #if defined(OS_ANDROID) |
| 216 void NavigationEntryImpl::SetDataURLAsString( |
| 217 scoped_refptr<base::RefCountedString> data_url) { |
| 218 if (data_url) { |
| 219 // A quick check that it's actually a data URL. |
| 220 DCHECK(base::StartsWith(data_url->front_as<char>(), url::kDataScheme, |
| 221 base::CompareCase::SENSITIVE)); |
| 222 } |
| 223 data_url_as_string_ = data_url; |
| 224 } |
| 225 |
| 226 const scoped_refptr<const base::RefCountedString> |
| 227 NavigationEntryImpl::GetDataURLAsString() const { |
| 228 return data_url_as_string_; |
| 229 } |
| 230 #endif |
| 231 |
| 214 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { | 232 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { |
| 215 frame_tree_->frame_entry->set_referrer(referrer); | 233 frame_tree_->frame_entry->set_referrer(referrer); |
| 216 } | 234 } |
| 217 | 235 |
| 218 const Referrer& NavigationEntryImpl::GetReferrer() const { | 236 const Referrer& NavigationEntryImpl::GetReferrer() const { |
| 219 return frame_tree_->frame_entry->referrer(); | 237 return frame_tree_->frame_entry->referrer(); |
| 220 } | 238 } |
| 221 | 239 |
| 222 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { | 240 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { |
| 223 virtual_url_ = (url == GetURL()) ? GURL() : url; | 241 virtual_url_ = (url == GetURL()) ? GURL() : url; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 copy->restore_type_ = restore_type_; | 531 copy->restore_type_ = restore_type_; |
| 514 copy->original_request_url_ = original_request_url_; | 532 copy->original_request_url_ = original_request_url_; |
| 515 copy->is_overriding_user_agent_ = is_overriding_user_agent_; | 533 copy->is_overriding_user_agent_ = is_overriding_user_agent_; |
| 516 copy->timestamp_ = timestamp_; | 534 copy->timestamp_ = timestamp_; |
| 517 copy->http_status_code_ = http_status_code_; | 535 copy->http_status_code_ = http_status_code_; |
| 518 // ResetForCommit: browser_initiated_post_data_ | 536 // ResetForCommit: browser_initiated_post_data_ |
| 519 copy->screenshot_ = screenshot_; | 537 copy->screenshot_ = screenshot_; |
| 520 copy->extra_headers_ = extra_headers_; | 538 copy->extra_headers_ = extra_headers_; |
| 521 // ResetForCommit: source_site_instance_ | 539 // ResetForCommit: source_site_instance_ |
| 522 copy->base_url_for_data_url_ = base_url_for_data_url_; | 540 copy->base_url_for_data_url_ = base_url_for_data_url_; |
| 541 #if defined(OS_ANDROID) |
| 542 copy->data_url_as_string_ = data_url_as_string_; |
| 543 #endif |
| 523 // ResetForCommit: is_renderer_initiated_ | 544 // ResetForCommit: is_renderer_initiated_ |
| 524 copy->cached_display_title_ = cached_display_title_; | 545 copy->cached_display_title_ = cached_display_title_; |
| 525 // ResetForCommit: transferred_global_request_id_ | 546 // ResetForCommit: transferred_global_request_id_ |
| 526 // ResetForCommit: should_replace_entry_ | 547 // ResetForCommit: should_replace_entry_ |
| 527 copy->redirect_chain_ = redirect_chain_; | 548 copy->redirect_chain_ = redirect_chain_; |
| 528 // ResetForCommit: should_clear_history_list_ | 549 // ResetForCommit: should_clear_history_list_ |
| 529 // ResetForCommit: frame_tree_node_id_ | 550 // ResetForCommit: frame_tree_node_id_ |
| 530 // ResetForCommit: intent_received_timestamp_ | 551 // ResetForCommit: intent_received_timestamp_ |
| 531 copy->extra_data_ = extra_data_; | 552 copy->extra_data_ = extra_data_; |
| 532 | 553 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 int current_length_to_send = current_history_list_length; | 616 int current_length_to_send = current_history_list_length; |
| 596 if (should_clear_history_list()) { | 617 if (should_clear_history_list()) { |
| 597 // Set the history list related parameters to the same values a | 618 // Set the history list related parameters to the same values a |
| 598 // NavigationController would return before its first navigation. This will | 619 // NavigationController would return before its first navigation. This will |
| 599 // fully clear the RenderView's view of the session history. | 620 // fully clear the RenderView's view of the session history. |
| 600 pending_offset_to_send = -1; | 621 pending_offset_to_send = -1; |
| 601 current_offset_to_send = -1; | 622 current_offset_to_send = -1; |
| 602 current_length_to_send = 0; | 623 current_length_to_send = 0; |
| 603 } | 624 } |
| 604 | 625 |
| 605 return RequestNavigationParams( | 626 RequestNavigationParams request_params( |
| 606 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), | 627 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), |
| 607 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), | 628 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), |
| 608 is_same_document_history_load, has_committed_real_load, | 629 is_same_document_history_load, has_committed_real_load, |
| 609 intended_as_new_entry, pending_offset_to_send, current_offset_to_send, | 630 intended_as_new_entry, pending_offset_to_send, current_offset_to_send, |
| 610 current_length_to_send, IsViewSourceMode(), should_clear_history_list()); | 631 current_length_to_send, IsViewSourceMode(), should_clear_history_list()); |
| 632 #if defined(OS_ANDROID) |
| 633 if (GetDataURLAsString() && |
| 634 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { |
| 635 // The number of characters that is enough for validating a data: URI. From |
| 636 // the GURL's POV, the only important part here is scheme, it doesn't check |
| 637 // the actual content. Thus we can take only the prefix of the url, to avoid |
| 638 // unneeded copying of a potentially long string. |
| 639 const size_t kDataUriPrefixMaxLen = 64; |
| 640 GURL data_url(std::string( |
| 641 GetDataURLAsString()->front_as<char>(), |
| 642 std::min(GetDataURLAsString()->size(), kDataUriPrefixMaxLen))); |
| 643 if (data_url.is_valid() && data_url.SchemeIs(url::kDataScheme)) |
| 644 request_params.data_url_as_string = GetDataURLAsString()->data(); |
| 645 } |
| 646 #endif |
| 647 return request_params; |
| 611 } | 648 } |
| 612 | 649 |
| 613 void NavigationEntryImpl::ResetForCommit() { | 650 void NavigationEntryImpl::ResetForCommit() { |
| 614 // Any state that only matters when a navigation entry is pending should be | 651 // Any state that only matters when a navigation entry is pending should be |
| 615 // cleared here. | 652 // cleared here. |
| 616 // TODO(creis): This state should be moved to NavigationRequest once | 653 // TODO(creis): This state should be moved to NavigationRequest once |
| 617 // PlzNavigate is enabled. | 654 // PlzNavigate is enabled. |
| 618 SetBrowserInitiatedPostData(nullptr); | 655 SetBrowserInitiatedPostData(nullptr); |
| 619 set_source_site_instance(nullptr); | 656 set_source_site_instance(nullptr); |
| 620 set_is_renderer_initiated(false); | 657 set_is_renderer_initiated(false); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 return node; | 761 return node; |
| 725 } | 762 } |
| 726 // Enqueue any children and keep looking. | 763 // Enqueue any children and keep looking. |
| 727 for (auto& child : node->children) | 764 for (auto& child : node->children) |
| 728 work_queue.push(child); | 765 work_queue.push(child); |
| 729 } | 766 } |
| 730 return nullptr; | 767 return nullptr; |
| 731 } | 768 } |
| 732 | 769 |
| 733 } // namespace content | 770 } // namespace content |
| OLD | NEW |