OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/url_data_manager_backend.h" | 5 #include "content/browser/webui/url_data_manager_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 673 |
674 bool URLDataManagerBackend::StartRequest(const net::URLRequest* request, | 674 bool URLDataManagerBackend::StartRequest(const net::URLRequest* request, |
675 URLRequestChromeJob* job) { | 675 URLRequestChromeJob* job) { |
676 if (!CheckURLIsValid(request->url())) | 676 if (!CheckURLIsValid(request->url())) |
677 return false; | 677 return false; |
678 | 678 |
679 URLDataSourceImpl* source = GetDataSourceFromURL(request->url()); | 679 URLDataSourceImpl* source = GetDataSourceFromURL(request->url()); |
680 if (!source) | 680 if (!source) |
681 return false; | 681 return false; |
682 | 682 |
683 if (!source->source()->ShouldServiceRequest(request)) | 683 const content::ResourceRequestInfo* info = |
| 684 content::ResourceRequestInfo::ForRequest(request); |
| 685 if (!source->source()->ShouldServiceRequest( |
| 686 request->url(), info ? info->GetContext() : nullptr, |
| 687 info ? info->GetChildID() : -1)) { |
684 return false; | 688 return false; |
| 689 } |
685 | 690 |
686 std::string path; | 691 std::string path; |
687 URLToRequestPath(request->url(), &path); | 692 URLToRequestPath(request->url(), &path); |
688 source->source()->WillServiceRequest(request, &path); | |
689 | 693 |
690 // Save this request so we know where to send the data. | 694 // Save this request so we know where to send the data. |
691 RequestID request_id = next_request_id_++; | 695 RequestID request_id = next_request_id_++; |
692 pending_requests_.insert(std::make_pair(request_id, job)); | 696 pending_requests_.insert(std::make_pair(request_id, job)); |
693 | 697 |
694 job->set_allow_caching(source->source()->AllowCaching()); | 698 job->set_allow_caching(source->source()->AllowCaching()); |
695 job->set_add_content_security_policy( | 699 job->set_add_content_security_policy( |
696 source->source()->ShouldAddContentSecurityPolicy()); | 700 source->source()->ShouldAddContentSecurityPolicy()); |
697 job->set_content_security_policy_script_source( | 701 job->set_content_security_policy_script_source( |
698 source->source()->GetContentSecurityPolicyScriptSrc()); | 702 source->source()->GetContentSecurityPolicyScriptSrc()); |
(...skipping 24 matching lines...) Expand all Loading... |
723 DCHECK(header.empty() || header == origin || header == "*" || | 727 DCHECK(header.empty() || header == origin || header == "*" || |
724 header == "null"); | 728 header == "null"); |
725 job->set_access_control_allow_origin(header); | 729 job->set_access_control_allow_origin(header); |
726 } | 730 } |
727 | 731 |
728 // Also notifies that the headers are complete. | 732 // Also notifies that the headers are complete. |
729 job->MimeTypeAvailable(mime_type); | 733 job->MimeTypeAvailable(mime_type); |
730 | 734 |
731 // Look up additional request info to pass down. | 735 // Look up additional request info to pass down. |
732 ResourceRequestInfo::WebContentsGetter wc_getter; | 736 ResourceRequestInfo::WebContentsGetter wc_getter; |
733 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | |
734 if (info) | 737 if (info) |
735 wc_getter = info->GetWebContentsGetterForRequest(); | 738 wc_getter = info->GetWebContentsGetterForRequest(); |
736 | 739 |
737 // Forward along the request to the data source. | 740 // Forward along the request to the data source. |
738 scoped_refptr<base::SingleThreadTaskRunner> target_runner = | 741 scoped_refptr<base::SingleThreadTaskRunner> target_runner = |
739 source->source()->TaskRunnerForRequestPath(path); | 742 source->source()->TaskRunnerForRequestPath(path); |
740 if (!target_runner) { | 743 if (!target_runner) { |
741 // The DataSource is agnostic to which thread StartDataRequest is called | 744 // The DataSource is agnostic to which thread StartDataRequest is called |
742 // on for this path. Call directly into it from this thread, the IO | 745 // on for this path. Call directly into it from this thread, the IO |
743 // thread. | 746 // thread. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 853 |
851 } // namespace | 854 } // namespace |
852 | 855 |
853 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( | 856 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( |
854 ResourceContext* resource_context, | 857 ResourceContext* resource_context, |
855 bool is_incognito) { | 858 bool is_incognito) { |
856 return new DevToolsJobFactory(resource_context, is_incognito); | 859 return new DevToolsJobFactory(resource_context, is_incognito); |
857 } | 860 } |
858 | 861 |
859 } // namespace content | 862 } // namespace content |
OLD | NEW |