Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2918903002: Move IconURLs method from WebFrame to WebLocalFrame (Closed)
Patch Set: Simplify unit test changes to avoid UaF from previous patchset. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/child/url_loader_throttle.h" 74 #include "content/public/child/url_loader_throttle.h"
75 #include "content/public/common/appcache_info.h" 75 #include "content/public/common/appcache_info.h"
76 #include "content/public/common/associated_interface_provider.h" 76 #include "content/public/common/associated_interface_provider.h"
77 #include "content/public/common/bindings_policy.h" 77 #include "content/public/common/bindings_policy.h"
78 #include "content/public/common/browser_side_navigation_policy.h" 78 #include "content/public/common/browser_side_navigation_policy.h"
79 #include "content/public/common/content_constants.h" 79 #include "content/public/common/content_constants.h"
80 #include "content/public/common/content_features.h" 80 #include "content/public/common/content_features.h"
81 #include "content/public/common/content_switches.h" 81 #include "content/public/common/content_switches.h"
82 #include "content/public/common/context_menu_params.h" 82 #include "content/public/common/context_menu_params.h"
83 #include "content/public/common/favicon_url.h"
83 #include "content/public/common/file_chooser_file_info.h" 84 #include "content/public/common/file_chooser_file_info.h"
84 #include "content/public/common/file_chooser_params.h" 85 #include "content/public/common/file_chooser_params.h"
85 #include "content/public/common/isolated_world_ids.h" 86 #include "content/public/common/isolated_world_ids.h"
86 #include "content/public/common/page_state.h" 87 #include "content/public/common/page_state.h"
87 #include "content/public/common/resource_response.h" 88 #include "content/public/common/resource_response.h"
88 #include "content/public/common/service_manager_connection.h" 89 #include "content/public/common/service_manager_connection.h"
89 #include "content/public/common/url_constants.h" 90 #include "content/public/common/url_constants.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"
92 #include "content/public/renderer/content_renderer_client.h" 93 #include "content/public/renderer/content_renderer_client.h"
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::FAVICON;
685 case blink::WebIconURL::kTypeTouch:
686 return FaviconURL::TOUCH_ICON;
687 case blink::WebIconURL::kTypeTouchPrecomposed:
688 return FaviconURL::TOUCH_PRECOMPOSED_ICON;
689 case blink::WebIconURL::kTypeInvalid:
690 return FaviconURL::INVALID_ICON;
691 }
692 return FaviconURL::INVALID_ICON;
693 }
694
695 void ConvertToFaviconSizes(const blink::WebVector<blink::WebSize>& web_sizes,
696 std::vector<gfx::Size>* sizes) {
697 DCHECK(sizes->empty());
698 sizes->reserve(web_sizes.size());
699 for (size_t i = 0; i < web_sizes.size(); ++i)
700 sizes->push_back(gfx::Size(web_sizes[i]));
701 }
702
680 } // namespace 703 } // namespace
681 704
682 // The following methods are outside of the anonymous namespace to ensure that 705 // The following methods are outside of the anonymous namespace to ensure that
683 // the corresponding symbols get emmitted even on symbol_level 1. 706 // the corresponding symbols get emmitted even on symbol_level 1.
684 NOINLINE void ExhaustMemory() { 707 NOINLINE void ExhaustMemory() {
685 volatile void* ptr = nullptr; 708 volatile void* ptr = nullptr;
686 do { 709 do {
687 ptr = malloc(0x10000000); 710 ptr = malloc(0x10000000);
688 base::debug::Alias(&ptr); 711 base::debug::Alias(&ptr);
689 } while (ptr); 712 } while (ptr);
(...skipping 3070 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); 3783 base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
3761 Send(new FrameHostMsg_UpdateTitle(routing_id_, 3784 Send(new FrameHostMsg_UpdateTitle(routing_id_,
3762 shortened_title, direction)); 3785 shortened_title, direction));
3763 } 3786 }
3764 3787
3765 // Also check whether we have new encoding name. 3788 // Also check whether we have new encoding name.
3766 UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8()); 3789 UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8());
3767 } 3790 }
3768 3791
3769 void RenderFrameImpl::DidChangeIcon(blink::WebIconURL::Type icon_type) { 3792 void RenderFrameImpl::DidChangeIcon(blink::WebIconURL::Type icon_type) {
3770 // TODO(nasko): Investigate wheather implementation should move here. 3793 SendUpdateFaviconURL(icon_type);
3771 render_view_->didChangeIcon(frame_, icon_type); 3794 }
3795
3796 void RenderFrameImpl::SendUpdateFaviconURL(blink::WebIconURL::Type icon_type) {
3797 if (frame_->Parent())
3798 return;
3799
3800 WebVector<blink::WebIconURL> icon_urls = frame_->IconURLs(icon_type);
3801 std::vector<FaviconURL> urls;
3802 for (size_t i = 0; i < icon_urls.size(); i++) {
3803 std::vector<gfx::Size> sizes;
3804 ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes);
3805 urls.push_back(FaviconURL(icon_urls[i].GetIconURL(),
3806 ToFaviconType(icon_urls[i].IconType()), sizes));
3807 }
3808
3809 if (!urls.empty())
dcheng 2017/06/06 20:01:30 Maybe we can short-circuit this at line 3801? I gu
Łukasz Anforowicz 2017/06/06 20:55:00 Done.
3810 Send(new FrameHostMsg_UpdateFaviconURL(GetRoutingID(), urls));
3772 } 3811 }
3773 3812
3774 void RenderFrameImpl::DidFinishDocumentLoad() { 3813 void RenderFrameImpl::DidFinishDocumentLoad() {
3775 TRACE_EVENT1("navigation,benchmark,rail", 3814 TRACE_EVENT1("navigation,benchmark,rail",
3776 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_); 3815 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_);
3777 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); 3816 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_));
3778 3817
3779 for (auto& observer : observers_) 3818 for (auto& observer : observers_)
3780 observer.DidFinishDocumentLoad(); 3819 observer.DidFinishDocumentLoad();
3781 3820
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5004 5043
5005 void RenderFrameImpl::DidStopLoading() { 5044 void RenderFrameImpl::DidStopLoading() {
5006 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", 5045 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading",
5007 "id", routing_id_); 5046 "id", routing_id_);
5008 5047
5009 // Any subframes created after this point won't be considered part of the 5048 // Any subframes created after this point won't be considered part of the
5010 // current history navigation (if this was one), so we don't need to track 5049 // current history navigation (if this was one), so we don't need to track
5011 // this state anymore. 5050 // this state anymore.
5012 history_subframe_unique_names_.clear(); 5051 history_subframe_unique_names_.clear();
5013 5052
5053 blink::WebIconURL::Type icon_types = static_cast<blink::WebIconURL::Type>(
5054 blink::WebIconURL::kTypeFavicon |
5055 blink::WebIconURL::kTypeTouchPrecomposed | blink::WebIconURL::kTypeTouch);
5056 SendUpdateFaviconURL(icon_types);
5057
5014 render_view_->FrameDidStopLoading(frame_); 5058 render_view_->FrameDidStopLoading(frame_);
5015 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 5059 Send(new FrameHostMsg_DidStopLoading(routing_id_));
5016 } 5060 }
5017 5061
5018 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) { 5062 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) {
5019 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); 5063 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress));
5020 } 5064 }
5021 5065
5022 void RenderFrameImpl::HandleWebAccessibilityEvent( 5066 void RenderFrameImpl::HandleWebAccessibilityEvent(
5023 const blink::WebAXObject& obj, blink::WebAXEvent event) { 5067 const blink::WebAXObject& obj, blink::WebAXEvent event) {
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
6782 policy(info.default_policy), 6826 policy(info.default_policy),
6783 replaces_current_history_item(info.replaces_current_history_item), 6827 replaces_current_history_item(info.replaces_current_history_item),
6784 history_navigation_in_new_child_frame( 6828 history_navigation_in_new_child_frame(
6785 info.is_history_navigation_in_new_child_frame), 6829 info.is_history_navigation_in_new_child_frame),
6786 client_redirect(info.is_client_redirect), 6830 client_redirect(info.is_client_redirect),
6787 cache_disabled(info.is_cache_disabled), 6831 cache_disabled(info.is_cache_disabled),
6788 form(info.form), 6832 form(info.form),
6789 source_location(info.source_location) {} 6833 source_location(info.source_location) {}
6790 6834
6791 } // namespace content 6835 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698