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 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3313 bool is_potentially_trustworthy_unique_origin) { | 3322 bool is_potentially_trustworthy_unique_origin) { |
3314 Send(new FrameHostMsg_UpdateToUniqueOrigin( | 3323 Send(new FrameHostMsg_UpdateToUniqueOrigin( |
3315 routing_id_, is_potentially_trustworthy_unique_origin)); | 3324 routing_id_, is_potentially_trustworthy_unique_origin)); |
3316 } | 3325 } |
3317 | 3326 |
3318 void RenderFrameImpl::DidChangeFramePolicy( | 3327 void RenderFrameImpl::DidChangeFramePolicy( |
3319 blink::WebFrame* child_frame, | 3328 blink::WebFrame* child_frame, |
3320 blink::WebSandboxFlags flags, | 3329 blink::WebSandboxFlags flags, |
3321 const blink::WebParsedFeaturePolicy& container_policy) { | 3330 const blink::WebParsedFeaturePolicy& container_policy) { |
3322 Send(new FrameHostMsg_DidChangeFramePolicy( | 3331 Send(new FrameHostMsg_DidChangeFramePolicy( |
3323 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), flags, | 3332 routing_id_, RenderFrame::GetRoutingIdForWebFrame(child_frame), flags, |
3324 FeaturePolicyHeaderFromWeb(container_policy))); | 3333 FeaturePolicyHeaderFromWeb(container_policy))); |
3325 } | 3334 } |
3326 | 3335 |
3327 void RenderFrameImpl::DidSetFeaturePolicyHeader( | 3336 void RenderFrameImpl::DidSetFeaturePolicyHeader( |
3328 const blink::WebParsedFeaturePolicy& parsed_header) { | 3337 const blink::WebParsedFeaturePolicy& parsed_header) { |
3329 Send(new FrameHostMsg_DidSetFeaturePolicyHeader( | 3338 Send(new FrameHostMsg_DidSetFeaturePolicyHeader( |
3330 routing_id_, FeaturePolicyHeaderFromWeb(parsed_header))); | 3339 routing_id_, FeaturePolicyHeaderFromWeb(parsed_header))); |
3331 } | 3340 } |
3332 | 3341 |
3333 void RenderFrameImpl::DidAddContentSecurityPolicies( | 3342 void RenderFrameImpl::DidAddContentSecurityPolicies( |
3334 const blink::WebVector<blink::WebContentSecurityPolicy>& policies) { | 3343 const blink::WebVector<blink::WebContentSecurityPolicy>& policies) { |
3335 std::vector<ContentSecurityPolicy> content_policies; | 3344 std::vector<ContentSecurityPolicy> content_policies; |
3336 for (const auto& policy : policies) | 3345 for (const auto& policy : policies) |
3337 content_policies.push_back(BuildContentSecurityPolicy(policy)); | 3346 content_policies.push_back(BuildContentSecurityPolicy(policy)); |
3338 | 3347 |
3339 Send(new FrameHostMsg_DidAddContentSecurityPolicies(routing_id_, | 3348 Send(new FrameHostMsg_DidAddContentSecurityPolicies(routing_id_, |
3340 content_policies)); | 3349 content_policies)); |
3341 } | 3350 } |
3342 | 3351 |
3343 void RenderFrameImpl::DidChangeFrameOwnerProperties( | 3352 void RenderFrameImpl::DidChangeFrameOwnerProperties( |
3344 blink::WebFrame* child_frame, | 3353 blink::WebFrame* child_frame, |
3345 const blink::WebFrameOwnerProperties& frame_owner_properties) { | 3354 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
3346 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( | 3355 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( |
3347 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), | 3356 routing_id_, RenderFrame::GetRoutingIdForWebFrame(child_frame), |
3348 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( | 3357 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( |
3349 frame_owner_properties))); | 3358 frame_owner_properties))); |
3350 } | 3359 } |
3351 | 3360 |
3352 void RenderFrameImpl::DidMatchCSS( | 3361 void RenderFrameImpl::DidMatchCSS( |
3353 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 3362 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
3354 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 3363 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { |
3355 for (auto& observer : observers_) | 3364 for (auto& observer : observers_) |
3356 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors); | 3365 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors); |
3357 } | 3366 } |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4407 // Add an empty HTTP origin header for non GET methods if none is currently | 4416 // Add an empty HTTP origin header for non GET methods if none is currently |
4408 // present. | 4417 // present. |
4409 request.AddHTTPOriginIfNeeded(WebSecurityOrigin::CreateUnique()); | 4418 request.AddHTTPOriginIfNeeded(WebSecurityOrigin::CreateUnique()); |
4410 | 4419 |
4411 // Attach |should_replace_current_entry| state to requests so that, should | 4420 // Attach |should_replace_current_entry| state to requests so that, should |
4412 // this navigation later require a request transfer, all state is preserved | 4421 // this navigation later require a request transfer, all state is preserved |
4413 // when it is re-created in the new process. | 4422 // when it is re-created in the new process. |
4414 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); | 4423 bool should_replace_current_entry = data_source->ReplacesCurrentHistoryItem(); |
4415 | 4424 |
4416 WebFrame* parent = frame_->Parent(); | 4425 WebFrame* parent = frame_->Parent(); |
4417 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 4426 int parent_routing_id = |
| 4427 parent ? RenderFrame::GetRoutingIdForWebFrame(parent) : -1; |
4418 | 4428 |
4419 RequestExtraData* extra_data = | 4429 RequestExtraData* extra_data = |
4420 static_cast<RequestExtraData*>(request.GetExtraData()); | 4430 static_cast<RequestExtraData*>(request.GetExtraData()); |
4421 if (!extra_data) | 4431 if (!extra_data) |
4422 extra_data = new RequestExtraData(); | 4432 extra_data = new RequestExtraData(); |
4423 extra_data->set_visibility_state(VisibilityState()); | 4433 extra_data->set_visibility_state(VisibilityState()); |
4424 extra_data->set_custom_user_agent(custom_user_agent); | 4434 extra_data->set_custom_user_agent(custom_user_agent); |
4425 extra_data->set_requested_with(requested_with); | 4435 extra_data->set_requested_with(requested_with); |
4426 extra_data->set_render_frame_id(routing_id_); | 4436 extra_data->set_render_frame_id(routing_id_); |
4427 extra_data->set_is_main_frame(!parent); | 4437 extra_data->set_is_main_frame(!parent); |
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7063 policy(info.default_policy), | 7073 policy(info.default_policy), |
7064 replaces_current_history_item(info.replaces_current_history_item), | 7074 replaces_current_history_item(info.replaces_current_history_item), |
7065 history_navigation_in_new_child_frame( | 7075 history_navigation_in_new_child_frame( |
7066 info.is_history_navigation_in_new_child_frame), | 7076 info.is_history_navigation_in_new_child_frame), |
7067 client_redirect(info.is_client_redirect), | 7077 client_redirect(info.is_client_redirect), |
7068 cache_disabled(info.is_cache_disabled), | 7078 cache_disabled(info.is_cache_disabled), |
7069 form(info.form), | 7079 form(info.form), |
7070 source_location(info.source_location) {} | 7080 source_location(info.source_location) {} |
7071 | 7081 |
7072 } // namespace content | 7082 } // namespace content |
OLD | NEW |