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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // based on the payload of FrameMsg_GetSerializedHtmlWithLocalLinks. | 611 // based on the payload of FrameMsg_GetSerializedHtmlWithLocalLinks. |
612 class LinkRewritingDelegate : public WebFrameSerializer::LinkRewritingDelegate { | 612 class LinkRewritingDelegate : public WebFrameSerializer::LinkRewritingDelegate { |
613 public: | 613 public: |
614 LinkRewritingDelegate( | 614 LinkRewritingDelegate( |
615 const std::map<GURL, base::FilePath>& url_to_local_path, | 615 const std::map<GURL, base::FilePath>& url_to_local_path, |
616 const std::map<int, base::FilePath>& frame_routing_id_to_local_path) | 616 const std::map<int, base::FilePath>& frame_routing_id_to_local_path) |
617 : url_to_local_path_(url_to_local_path), | 617 : url_to_local_path_(url_to_local_path), |
618 frame_routing_id_to_local_path_(frame_routing_id_to_local_path) {} | 618 frame_routing_id_to_local_path_(frame_routing_id_to_local_path) {} |
619 | 619 |
620 bool RewriteFrameSource(WebFrame* frame, WebString* rewritten_link) override { | 620 bool RewriteFrameSource(WebFrame* frame, WebString* rewritten_link) override { |
621 int routing_id = GetRoutingIdForFrameOrProxy(frame); | 621 int routing_id = RenderFrame::GetRoutingIdForWebFrame(frame); |
622 auto it = frame_routing_id_to_local_path_.find(routing_id); | 622 auto it = frame_routing_id_to_local_path_.find(routing_id); |
623 if (it == frame_routing_id_to_local_path_.end()) | 623 if (it == frame_routing_id_to_local_path_.end()) |
624 return false; // This can happen because of https://crbug.com/541354. | 624 return false; // This can happen because of https://crbug.com/541354. |
625 | 625 |
626 const base::FilePath& local_path = it->second; | 626 const base::FilePath& local_path = it->second; |
627 *rewritten_link = ConvertRelativePathToHtmlAttribute(local_path); | 627 *rewritten_link = ConvertRelativePathToHtmlAttribute(local_path); |
628 return true; | 628 return true; |
629 } | 629 } |
630 | 630 |
631 bool RewriteLink(const WebURL& url, WebString* rewritten_link) override { | 631 bool RewriteLink(const WebURL& url, WebString* rewritten_link) override { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 670 |
671 // Let's record |url| as being serialized for the *current* frame. | 671 // Let's record |url| as being serialized for the *current* frame. |
672 auto pair = serialized_resources_uri_digests_->insert(digest); | 672 auto pair = serialized_resources_uri_digests_->insert(digest); |
673 bool insertion_took_place = pair.second; | 673 bool insertion_took_place = pair.second; |
674 DCHECK(insertion_took_place); // Blink should dedupe within a frame. | 674 DCHECK(insertion_took_place); // Blink should dedupe within a frame. |
675 | 675 |
676 return false; | 676 return false; |
677 } | 677 } |
678 | 678 |
679 WebString GetContentID(WebFrame* frame) override { | 679 WebString GetContentID(WebFrame* frame) override { |
680 int routing_id = GetRoutingIdForFrameOrProxy(frame); | 680 int routing_id = RenderFrame::GetRoutingIdForWebFrame(frame); |
681 | 681 |
682 auto it = params_.frame_routing_id_to_content_id.find(routing_id); | 682 auto it = params_.frame_routing_id_to_content_id.find(routing_id); |
683 if (it == params_.frame_routing_id_to_content_id.end()) | 683 if (it == params_.frame_routing_id_to_content_id.end()) |
684 return WebString(); | 684 return WebString(); |
685 | 685 |
686 const std::string& content_id = it->second; | 686 const std::string& content_id = it->second; |
687 return WebString::FromUTF8(content_id); | 687 return WebString::FromUTF8(content_id); |
688 } | 688 } |
689 | 689 |
690 blink::WebFrameSerializerCacheControlPolicy CacheControlPolicy() override { | 690 blink::WebFrameSerializerCacheControlPolicy CacheControlPolicy() override { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 // static | 1056 // static |
1057 void RenderFrame::ForEach(RenderFrameVisitor* visitor) { | 1057 void RenderFrame::ForEach(RenderFrameVisitor* visitor) { |
1058 FrameMap* frames = g_frame_map.Pointer(); | 1058 FrameMap* frames = g_frame_map.Pointer(); |
1059 for (FrameMap::iterator it = frames->begin(); it != frames->end(); ++it) { | 1059 for (FrameMap::iterator it = frames->begin(); it != frames->end(); ++it) { |
1060 if (!visitor->Visit(it->second)) | 1060 if (!visitor->Visit(it->second)) |
1061 return; | 1061 return; |
1062 } | 1062 } |
1063 } | 1063 } |
1064 | 1064 |
1065 // static | 1065 // static |
| 1066 int RenderFrame::GetRoutingIdForWebFrame(blink::WebFrame* web_frame) { |
| 1067 if (!web_frame) |
| 1068 return MSG_ROUTING_NONE; |
| 1069 if (web_frame->IsWebRemoteFrame()) |
| 1070 return RenderFrameProxy::FromWebFrame(web_frame)->routing_id(); |
| 1071 return RenderFrameImpl::FromWebFrame(web_frame)->GetRoutingID(); |
| 1072 } |
| 1073 |
| 1074 // static |
1066 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { | 1075 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { |
1067 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 1076 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); |
1068 if (iter != g_frame_map.Get().end()) | 1077 if (iter != g_frame_map.Get().end()) |
1069 return iter->second; | 1078 return iter->second; |
1070 return NULL; | 1079 return NULL; |
1071 } | 1080 } |
1072 | 1081 |
1073 // static | 1082 // static |
1074 void RenderFrameImpl::InstallCreateHook( | 1083 void RenderFrameImpl::InstallCreateHook( |
1075 CreateRenderFrameImplFunction create_render_frame_impl) { | 1084 CreateRenderFrameImplFunction create_render_frame_impl) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 if (parent_frame) { | 1263 if (parent_frame) { |
1255 previews_state_ = parent_frame->GetPreviewsState(); | 1264 previews_state_ = parent_frame->GetPreviewsState(); |
1256 effective_connection_type_ = parent_frame->GetEffectiveConnectionType(); | 1265 effective_connection_type_ = parent_frame->GetEffectiveConnectionType(); |
1257 } | 1266 } |
1258 | 1267 |
1259 bool is_tracing_rail = false; | 1268 bool is_tracing_rail = false; |
1260 bool is_tracing_navigation = false; | 1269 bool is_tracing_navigation = false; |
1261 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1270 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1262 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1271 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1263 if (is_tracing_rail || is_tracing_navigation) { | 1272 if (is_tracing_rail || is_tracing_navigation) { |
1264 int parent_id = GetRoutingIdForFrameOrProxy(frame_->Parent()); | 1273 int parent_id = RenderFrame::GetRoutingIdForWebFrame(frame_->Parent()); |
1265 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1274 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
1266 "id", routing_id_, | 1275 "id", routing_id_, |
1267 "parent", parent_id); | 1276 "parent", parent_id); |
1268 } | 1277 } |
1269 | 1278 |
1270 #if BUILDFLAG(ENABLE_PLUGINS) | 1279 #if BUILDFLAG(ENABLE_PLUGINS) |
1271 new PepperBrowserConnection(this); | 1280 new PepperBrowserConnection(this); |
1272 #endif | 1281 #endif |
1273 shared_worker_repository_ = base::MakeUnique<SharedWorkerRepository>(this); | 1282 shared_worker_repository_ = base::MakeUnique<SharedWorkerRepository>(this); |
1274 GetWebFrame()->SetSharedWorkerRepositoryClient( | 1283 GetWebFrame()->SetSharedWorkerRepositoryClient( |
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3306 bool is_potentially_trustworthy_unique_origin) { | 3315 bool is_potentially_trustworthy_unique_origin) { |
3307 Send(new FrameHostMsg_UpdateToUniqueOrigin( | 3316 Send(new FrameHostMsg_UpdateToUniqueOrigin( |
3308 routing_id_, is_potentially_trustworthy_unique_origin)); | 3317 routing_id_, is_potentially_trustworthy_unique_origin)); |
3309 } | 3318 } |
3310 | 3319 |
3311 void RenderFrameImpl::DidChangeFramePolicy( | 3320 void RenderFrameImpl::DidChangeFramePolicy( |
3312 blink::WebFrame* child_frame, | 3321 blink::WebFrame* child_frame, |
3313 blink::WebSandboxFlags flags, | 3322 blink::WebSandboxFlags flags, |
3314 const blink::WebParsedFeaturePolicy& container_policy) { | 3323 const blink::WebParsedFeaturePolicy& container_policy) { |
3315 Send(new FrameHostMsg_DidChangeFramePolicy( | 3324 Send(new FrameHostMsg_DidChangeFramePolicy( |
3316 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), flags, | 3325 routing_id_, RenderFrame::GetRoutingIdForWebFrame(child_frame), flags, |
3317 FeaturePolicyHeaderFromWeb(container_policy))); | 3326 FeaturePolicyHeaderFromWeb(container_policy))); |
3318 } | 3327 } |
3319 | 3328 |
3320 void RenderFrameImpl::DidSetFeaturePolicyHeader( | 3329 void RenderFrameImpl::DidSetFeaturePolicyHeader( |
3321 const blink::WebParsedFeaturePolicy& parsed_header) { | 3330 const blink::WebParsedFeaturePolicy& parsed_header) { |
3322 Send(new FrameHostMsg_DidSetFeaturePolicyHeader( | 3331 Send(new FrameHostMsg_DidSetFeaturePolicyHeader( |
3323 routing_id_, FeaturePolicyHeaderFromWeb(parsed_header))); | 3332 routing_id_, FeaturePolicyHeaderFromWeb(parsed_header))); |
3324 } | 3333 } |
3325 | 3334 |
3326 void RenderFrameImpl::DidAddContentSecurityPolicies( | 3335 void RenderFrameImpl::DidAddContentSecurityPolicies( |
3327 const blink::WebVector<blink::WebContentSecurityPolicy>& policies) { | 3336 const blink::WebVector<blink::WebContentSecurityPolicy>& policies) { |
3328 std::vector<ContentSecurityPolicy> content_policies; | 3337 std::vector<ContentSecurityPolicy> content_policies; |
3329 for (const auto& policy : policies) | 3338 for (const auto& policy : policies) |
3330 content_policies.push_back(BuildContentSecurityPolicy(policy)); | 3339 content_policies.push_back(BuildContentSecurityPolicy(policy)); |
3331 | 3340 |
3332 Send(new FrameHostMsg_DidAddContentSecurityPolicies(routing_id_, | 3341 Send(new FrameHostMsg_DidAddContentSecurityPolicies(routing_id_, |
3333 content_policies)); | 3342 content_policies)); |
3334 } | 3343 } |
3335 | 3344 |
3336 void RenderFrameImpl::DidChangeFrameOwnerProperties( | 3345 void RenderFrameImpl::DidChangeFrameOwnerProperties( |
3337 blink::WebFrame* child_frame, | 3346 blink::WebFrame* child_frame, |
3338 const blink::WebFrameOwnerProperties& frame_owner_properties) { | 3347 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
3339 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( | 3348 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( |
3340 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), | 3349 routing_id_, RenderFrame::GetRoutingIdForWebFrame(child_frame), |
3341 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( | 3350 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( |
3342 frame_owner_properties))); | 3351 frame_owner_properties))); |
3343 } | 3352 } |
3344 | 3353 |
3345 void RenderFrameImpl::DidMatchCSS( | 3354 void RenderFrameImpl::DidMatchCSS( |
3346 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 3355 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
3347 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 3356 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { |
3348 for (auto& observer : observers_) | 3357 for (auto& observer : observers_) |
3349 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors); | 3358 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors); |
3350 } | 3359 } |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4402 // Add an empty HTTP origin header for non GET methods if none is currently | 4411 // Add an empty HTTP origin header for non GET methods if none is currently |
4403 // present. | 4412 // present. |
4404 request.AddHTTPOriginIfNeeded(WebSecurityOrigin::CreateUnique()); | 4413 request.AddHTTPOriginIfNeeded(WebSecurityOrigin::CreateUnique()); |
4405 | 4414 |
4406 // Attach |should_replace_current_entry| state to requests so that, should | 4415 // Attach |should_replace_current_entry| state to requests so that, should |
4407 // this navigation later require a request transfer, all state is preserved | 4416 // this navigation later require a request transfer, all state is preserved |
4408 // when it is re-created in the new process. | 4417 // when it is re-created in the new process. |
4409 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); | 4418 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); |
4410 | 4419 |
4411 WebFrame* parent = frame_->Parent(); | 4420 WebFrame* parent = frame_->Parent(); |
4412 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 4421 int parent_routing_id = |
| 4422 parent ? RenderFrame::GetRoutingIdForWebFrame(parent) : -1; |
4413 | 4423 |
4414 RequestExtraData* extra_data = | 4424 RequestExtraData* extra_data = |
4415 static_cast<RequestExtraData*>(request.GetExtraData()); | 4425 static_cast<RequestExtraData*>(request.GetExtraData()); |
4416 if (!extra_data) | 4426 if (!extra_data) |
4417 extra_data = new RequestExtraData(); | 4427 extra_data = new RequestExtraData(); |
4418 extra_data->set_visibility_state(VisibilityState()); | 4428 extra_data->set_visibility_state(VisibilityState()); |
4419 extra_data->set_custom_user_agent(custom_user_agent); | 4429 extra_data->set_custom_user_agent(custom_user_agent); |
4420 extra_data->set_requested_with(requested_with); | 4430 extra_data->set_requested_with(requested_with); |
4421 extra_data->set_render_frame_id(routing_id_); | 4431 extra_data->set_render_frame_id(routing_id_); |
4422 extra_data->set_is_main_frame(!parent); | 4432 extra_data->set_is_main_frame(!parent); |
(...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7053 policy(info.default_policy), | 7063 policy(info.default_policy), |
7054 replaces_current_history_item(info.replaces_current_history_item), | 7064 replaces_current_history_item(info.replaces_current_history_item), |
7055 history_navigation_in_new_child_frame( | 7065 history_navigation_in_new_child_frame( |
7056 info.is_history_navigation_in_new_child_frame), | 7066 info.is_history_navigation_in_new_child_frame), |
7057 client_redirect(info.is_client_redirect), | 7067 client_redirect(info.is_client_redirect), |
7058 cache_disabled(info.is_cache_disabled), | 7068 cache_disabled(info.is_cache_disabled), |
7059 form(info.form), | 7069 form(info.form), |
7060 source_location(info.source_location) {} | 7070 source_location(info.source_location) {} |
7061 | 7071 |
7062 } // namespace content | 7072 } // namespace content |
OLD | NEW |