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 data_url_as_string_ = data_url; | |
Charlie Reis
2015/12/15 19:22:07
I had an earlier comment about adding a safety che
mnaganov (inactive)
2015/12/15 20:30:49
Really sorry about missing that one! Thanks for po
| |
219 } | |
220 | |
221 const scoped_refptr<const base::RefCountedString> | |
222 NavigationEntryImpl::GetDataURLAsString() const { | |
223 return data_url_as_string_; | |
224 } | |
225 #endif | |
226 | |
214 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { | 227 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { |
215 frame_tree_->frame_entry->set_referrer(referrer); | 228 frame_tree_->frame_entry->set_referrer(referrer); |
216 } | 229 } |
217 | 230 |
218 const Referrer& NavigationEntryImpl::GetReferrer() const { | 231 const Referrer& NavigationEntryImpl::GetReferrer() const { |
219 return frame_tree_->frame_entry->referrer(); | 232 return frame_tree_->frame_entry->referrer(); |
220 } | 233 } |
221 | 234 |
222 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { | 235 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { |
223 virtual_url_ = (url == GetURL()) ? GURL() : url; | 236 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_; | 526 copy->restore_type_ = restore_type_; |
514 copy->original_request_url_ = original_request_url_; | 527 copy->original_request_url_ = original_request_url_; |
515 copy->is_overriding_user_agent_ = is_overriding_user_agent_; | 528 copy->is_overriding_user_agent_ = is_overriding_user_agent_; |
516 copy->timestamp_ = timestamp_; | 529 copy->timestamp_ = timestamp_; |
517 copy->http_status_code_ = http_status_code_; | 530 copy->http_status_code_ = http_status_code_; |
518 // ResetForCommit: browser_initiated_post_data_ | 531 // ResetForCommit: browser_initiated_post_data_ |
519 copy->screenshot_ = screenshot_; | 532 copy->screenshot_ = screenshot_; |
520 copy->extra_headers_ = extra_headers_; | 533 copy->extra_headers_ = extra_headers_; |
521 // ResetForCommit: source_site_instance_ | 534 // ResetForCommit: source_site_instance_ |
522 copy->base_url_for_data_url_ = base_url_for_data_url_; | 535 copy->base_url_for_data_url_ = base_url_for_data_url_; |
536 #if defined(OS_ANDROID) | |
537 copy->data_url_as_string_ = data_url_as_string_; | |
538 #endif | |
523 // ResetForCommit: is_renderer_initiated_ | 539 // ResetForCommit: is_renderer_initiated_ |
524 copy->cached_display_title_ = cached_display_title_; | 540 copy->cached_display_title_ = cached_display_title_; |
525 // ResetForCommit: transferred_global_request_id_ | 541 // ResetForCommit: transferred_global_request_id_ |
526 // ResetForCommit: should_replace_entry_ | 542 // ResetForCommit: should_replace_entry_ |
527 copy->redirect_chain_ = redirect_chain_; | 543 copy->redirect_chain_ = redirect_chain_; |
528 // ResetForCommit: should_clear_history_list_ | 544 // ResetForCommit: should_clear_history_list_ |
529 // ResetForCommit: frame_tree_node_id_ | 545 // ResetForCommit: frame_tree_node_id_ |
530 // ResetForCommit: intent_received_timestamp_ | 546 // ResetForCommit: intent_received_timestamp_ |
531 copy->extra_data_ = extra_data_; | 547 copy->extra_data_ = extra_data_; |
532 | 548 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 int current_length_to_send = current_history_list_length; | 611 int current_length_to_send = current_history_list_length; |
596 if (should_clear_history_list()) { | 612 if (should_clear_history_list()) { |
597 // Set the history list related parameters to the same values a | 613 // Set the history list related parameters to the same values a |
598 // NavigationController would return before its first navigation. This will | 614 // NavigationController would return before its first navigation. This will |
599 // fully clear the RenderView's view of the session history. | 615 // fully clear the RenderView's view of the session history. |
600 pending_offset_to_send = -1; | 616 pending_offset_to_send = -1; |
601 current_offset_to_send = -1; | 617 current_offset_to_send = -1; |
602 current_length_to_send = 0; | 618 current_length_to_send = 0; |
603 } | 619 } |
604 | 620 |
605 return RequestNavigationParams( | 621 RequestNavigationParams request_params( |
606 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), | 622 GetIsOverridingUserAgent(), redirects, GetCanLoadLocalResources(), |
607 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), | 623 base::Time::Now(), frame_entry.page_state(), GetPageID(), GetUniqueID(), |
608 is_same_document_history_load, has_committed_real_load, | 624 is_same_document_history_load, has_committed_real_load, |
609 intended_as_new_entry, pending_offset_to_send, current_offset_to_send, | 625 intended_as_new_entry, pending_offset_to_send, current_offset_to_send, |
610 current_length_to_send, IsViewSourceMode(), should_clear_history_list()); | 626 current_length_to_send, IsViewSourceMode(), should_clear_history_list()); |
627 #if defined(OS_ANDROID) | |
628 if (GetDataURLAsString() && | |
629 GetDataURLAsString()->size() <= kMaxLengthOfDataURLString) { | |
630 // The number of characters that is enough for validating a data: URI. From | |
631 // the GURL's POV, the only important part here is scheme, it doesn't check | |
632 // the actual content. Thus we can take only the prefix of the url, to avoid | |
633 // unneeded copying of a potentially long string. | |
634 const size_t kDataUriPrefixMaxLen = 64; | |
635 GURL data_url(std::string( | |
636 GetDataURLAsString()->front_as<char>(), | |
637 std::min(GetDataURLAsString()->size(), kDataUriPrefixMaxLen))); | |
638 if (data_url.is_valid() && data_url.SchemeIs(url::kDataScheme)) | |
639 request_params.data_url_as_string = GetDataURLAsString()->data(); | |
640 } | |
641 #endif | |
642 return request_params; | |
611 } | 643 } |
612 | 644 |
613 void NavigationEntryImpl::ResetForCommit() { | 645 void NavigationEntryImpl::ResetForCommit() { |
614 // Any state that only matters when a navigation entry is pending should be | 646 // Any state that only matters when a navigation entry is pending should be |
615 // cleared here. | 647 // cleared here. |
616 // TODO(creis): This state should be moved to NavigationRequest once | 648 // TODO(creis): This state should be moved to NavigationRequest once |
617 // PlzNavigate is enabled. | 649 // PlzNavigate is enabled. |
618 SetBrowserInitiatedPostData(nullptr); | 650 SetBrowserInitiatedPostData(nullptr); |
619 set_source_site_instance(nullptr); | 651 set_source_site_instance(nullptr); |
620 set_is_renderer_initiated(false); | 652 set_is_renderer_initiated(false); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 return node; | 756 return node; |
725 } | 757 } |
726 // Enqueue any children and keep looking. | 758 // Enqueue any children and keep looking. |
727 for (auto& child : node->children) | 759 for (auto& child : node->children) |
728 work_queue.push(child); | 760 work_queue.push(child); |
729 } | 761 } |
730 return nullptr; | 762 return nullptr; |
731 } | 763 } |
732 | 764 |
733 } // namespace content | 765 } // namespace content |
OLD | NEW |