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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "content/common/view_messages.h" | 72 #include "content/common/view_messages.h" |
73 #include "content/common/worker_url_loader_factory_provider.mojom.h" | 73 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
74 #include "content/public/common/appcache_info.h" | 74 #include "content/public/common/appcache_info.h" |
75 #include "content/public/common/associated_interface_provider.h" | 75 #include "content/public/common/associated_interface_provider.h" |
76 #include "content/public/common/bindings_policy.h" | 76 #include "content/public/common/bindings_policy.h" |
77 #include "content/public/common/browser_side_navigation_policy.h" | 77 #include "content/public/common/browser_side_navigation_policy.h" |
78 #include "content/public/common/content_constants.h" | 78 #include "content/public/common/content_constants.h" |
79 #include "content/public/common/content_features.h" | 79 #include "content/public/common/content_features.h" |
80 #include "content/public/common/content_switches.h" | 80 #include "content/public/common/content_switches.h" |
81 #include "content/public/common/context_menu_params.h" | 81 #include "content/public/common/context_menu_params.h" |
| 82 #include "content/public/common/favicon_url.h" |
82 #include "content/public/common/file_chooser_file_info.h" | 83 #include "content/public/common/file_chooser_file_info.h" |
83 #include "content/public/common/file_chooser_params.h" | 84 #include "content/public/common/file_chooser_params.h" |
84 #include "content/public/common/isolated_world_ids.h" | 85 #include "content/public/common/isolated_world_ids.h" |
85 #include "content/public/common/page_state.h" | 86 #include "content/public/common/page_state.h" |
86 #include "content/public/common/resource_response.h" | 87 #include "content/public/common/resource_response.h" |
87 #include "content/public/common/service_manager_connection.h" | 88 #include "content/public/common/service_manager_connection.h" |
88 #include "content/public/common/url_constants.h" | 89 #include "content/public/common/url_constants.h" |
89 #include "content/public/common/url_loader_throttle.h" | 90 #include "content/public/common/url_loader_throttle.h" |
90 #include "content/public/common/url_utils.h" | 91 #include "content/public/common/url_utils.h" |
91 #include "content/public/renderer/browser_plugin_delegate.h" | 92 #include "content/public/renderer/browser_plugin_delegate.h" |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // Explicitly close |file| here to make sure to include any flush operations | 671 // Explicitly close |file| here to make sure to include any flush operations |
671 // in the UMA metric. | 672 // in the UMA metric. |
672 file.Close(); | 673 file.Close(); |
673 return save_status; | 674 return save_status; |
674 } | 675 } |
675 | 676 |
676 double ConvertToBlinkTime(const base::TimeTicks& time_ticks) { | 677 double ConvertToBlinkTime(const base::TimeTicks& time_ticks) { |
677 return (time_ticks - base::TimeTicks()).InSecondsF(); | 678 return (time_ticks - base::TimeTicks()).InSecondsF(); |
678 } | 679 } |
679 | 680 |
| 681 FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
| 682 switch (type) { |
| 683 case blink::WebIconURL::kTypeFavicon: |
| 684 return FaviconURL::IconType::kFavicon; |
| 685 case blink::WebIconURL::kTypeTouch: |
| 686 return FaviconURL::IconType::kTouchIcon; |
| 687 case blink::WebIconURL::kTypeTouchPrecomposed: |
| 688 return FaviconURL::IconType::kTouchPrecomposedIcon; |
| 689 case blink::WebIconURL::kTypeInvalid: |
| 690 return FaviconURL::IconType::kInvalid; |
| 691 } |
| 692 NOTREACHED(); |
| 693 return FaviconURL::IconType::kInvalid; |
| 694 } |
| 695 |
| 696 std::vector<gfx::Size> ConvertToFaviconSizes( |
| 697 const blink::WebVector<blink::WebSize>& web_sizes) { |
| 698 std::vector<gfx::Size> result; |
| 699 result.reserve(web_sizes.size()); |
| 700 for (const blink::WebSize& web_size : web_sizes) |
| 701 result.push_back(gfx::Size(web_size)); |
| 702 return result; |
| 703 } |
| 704 |
680 } // namespace | 705 } // namespace |
681 | 706 |
682 // The following methods are outside of the anonymous namespace to ensure that | 707 // The following methods are outside of the anonymous namespace to ensure that |
683 // the corresponding symbols get emmitted even on symbol_level 1. | 708 // the corresponding symbols get emmitted even on symbol_level 1. |
684 NOINLINE void ExhaustMemory() { | 709 NOINLINE void ExhaustMemory() { |
685 volatile void* ptr = nullptr; | 710 volatile void* ptr = nullptr; |
686 do { | 711 do { |
687 ptr = malloc(0x10000000); | 712 ptr = malloc(0x10000000); |
688 base::debug::Alias(&ptr); | 713 base::debug::Alias(&ptr); |
689 } while (ptr); | 714 } while (ptr); |
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3780 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); | 3805 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); |
3781 Send(new FrameHostMsg_UpdateTitle(routing_id_, | 3806 Send(new FrameHostMsg_UpdateTitle(routing_id_, |
3782 shortened_title, direction)); | 3807 shortened_title, direction)); |
3783 } | 3808 } |
3784 | 3809 |
3785 // Also check whether we have new encoding name. | 3810 // Also check whether we have new encoding name. |
3786 UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8()); | 3811 UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8()); |
3787 } | 3812 } |
3788 | 3813 |
3789 void RenderFrameImpl::DidChangeIcon(blink::WebIconURL::Type icon_type) { | 3814 void RenderFrameImpl::DidChangeIcon(blink::WebIconURL::Type icon_type) { |
3790 // TODO(nasko): Investigate wheather implementation should move here. | 3815 SendUpdateFaviconURL(icon_type); |
3791 render_view_->didChangeIcon(frame_, icon_type); | 3816 } |
| 3817 |
| 3818 void RenderFrameImpl::SendUpdateFaviconURL( |
| 3819 blink::WebIconURL::Type icon_types_mask) { |
| 3820 if (frame_->Parent()) |
| 3821 return; |
| 3822 |
| 3823 WebVector<blink::WebIconURL> icon_urls = frame_->IconURLs(icon_types_mask); |
| 3824 if (icon_urls.empty()) |
| 3825 return; |
| 3826 |
| 3827 std::vector<FaviconURL> urls; |
| 3828 urls.reserve(icon_urls.size()); |
| 3829 for (const blink::WebIconURL& icon_url : icon_urls) { |
| 3830 urls.push_back(FaviconURL(icon_url.GetIconURL(), |
| 3831 ToFaviconType(icon_url.IconType()), |
| 3832 ConvertToFaviconSizes(icon_url.Sizes()))); |
| 3833 } |
| 3834 DCHECK_EQ(icon_urls.size(), urls.size()); |
| 3835 |
| 3836 Send(new FrameHostMsg_UpdateFaviconURL(GetRoutingID(), urls)); |
3792 } | 3837 } |
3793 | 3838 |
3794 void RenderFrameImpl::DidFinishDocumentLoad() { | 3839 void RenderFrameImpl::DidFinishDocumentLoad() { |
3795 TRACE_EVENT1("navigation,benchmark,rail", | 3840 TRACE_EVENT1("navigation,benchmark,rail", |
3796 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_); | 3841 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_); |
3797 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); | 3842 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); |
3798 | 3843 |
3799 for (auto& observer : observers_) | 3844 for (auto& observer : observers_) |
3800 observer.DidFinishDocumentLoad(); | 3845 observer.DidFinishDocumentLoad(); |
3801 | 3846 |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5036 | 5081 |
5037 void RenderFrameImpl::DidStopLoading() { | 5082 void RenderFrameImpl::DidStopLoading() { |
5038 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", | 5083 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", |
5039 "id", routing_id_); | 5084 "id", routing_id_); |
5040 | 5085 |
5041 // Any subframes created after this point won't be considered part of the | 5086 // Any subframes created after this point won't be considered part of the |
5042 // current history navigation (if this was one), so we don't need to track | 5087 // current history navigation (if this was one), so we don't need to track |
5043 // this state anymore. | 5088 // this state anymore. |
5044 history_subframe_unique_names_.clear(); | 5089 history_subframe_unique_names_.clear(); |
5045 | 5090 |
| 5091 blink::WebIconURL::Type icon_types_mask = |
| 5092 static_cast<blink::WebIconURL::Type>( |
| 5093 blink::WebIconURL::kTypeFavicon | |
| 5094 blink::WebIconURL::kTypeTouchPrecomposed | |
| 5095 blink::WebIconURL::kTypeTouch); |
| 5096 SendUpdateFaviconURL(icon_types_mask); |
| 5097 |
5046 render_view_->FrameDidStopLoading(frame_); | 5098 render_view_->FrameDidStopLoading(frame_); |
5047 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 5099 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
5048 } | 5100 } |
5049 | 5101 |
5050 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) { | 5102 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) { |
5051 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 5103 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
5052 } | 5104 } |
5053 | 5105 |
5054 void RenderFrameImpl::HandleWebAccessibilityEvent( | 5106 void RenderFrameImpl::HandleWebAccessibilityEvent( |
5055 const blink::WebAXObject& obj, blink::WebAXEvent event) { | 5107 const blink::WebAXObject& obj, blink::WebAXEvent event) { |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6814 policy(info.default_policy), | 6866 policy(info.default_policy), |
6815 replaces_current_history_item(info.replaces_current_history_item), | 6867 replaces_current_history_item(info.replaces_current_history_item), |
6816 history_navigation_in_new_child_frame( | 6868 history_navigation_in_new_child_frame( |
6817 info.is_history_navigation_in_new_child_frame), | 6869 info.is_history_navigation_in_new_child_frame), |
6818 client_redirect(info.is_client_redirect), | 6870 client_redirect(info.is_client_redirect), |
6819 cache_disabled(info.is_cache_disabled), | 6871 cache_disabled(info.is_cache_disabled), |
6820 form(info.form), | 6872 form(info.form), |
6821 source_location(info.source_location) {} | 6873 source_location(info.source_location) {} |
6822 | 6874 |
6823 } // namespace content | 6875 } // namespace content |
OLD | NEW |