OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/cert_store.h" | 15 #include "chrome/browser/cert_store.h" |
| 16 #include "chrome/browser/child_process_security_policy.h" |
16 #include "chrome/browser/cross_site_request_manager.h" | 17 #include "chrome/browser/cross_site_request_manager.h" |
17 #include "chrome/browser/download/download_file.h" | 18 #include "chrome/browser/download/download_file.h" |
18 #include "chrome/browser/download/download_manager.h" | 19 #include "chrome/browser/download/download_manager.h" |
19 #include "chrome/browser/download/download_request_manager.h" | 20 #include "chrome/browser/download/download_request_manager.h" |
20 #include "chrome/browser/download/save_file_manager.h" | 21 #include "chrome/browser/download/save_file_manager.h" |
21 #include "chrome/browser/external_protocol_handler.h" | 22 #include "chrome/browser/external_protocol_handler.h" |
22 #include "chrome/browser/plugin_service.h" | 23 #include "chrome/browser/plugin_service.h" |
23 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
24 #include "chrome/browser/renderer_host/async_resource_handler.h" | 25 #include "chrome/browser/renderer_host/async_resource_handler.h" |
25 #include "chrome/browser/renderer_host/buffered_resource_handler.h" | 26 #include "chrome/browser/renderer_host/buffered_resource_handler.h" |
26 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" | 27 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" |
27 #include "chrome/browser/renderer_host/download_resource_handler.h" | 28 #include "chrome/browser/renderer_host/download_resource_handler.h" |
28 #include "chrome/browser/renderer_host/media_resource_handler.h" | 29 #include "chrome/browser/renderer_host/media_resource_handler.h" |
29 #include "chrome/browser/renderer_host/render_view_host.h" | 30 #include "chrome/browser/renderer_host/render_view_host.h" |
30 #include "chrome/browser/renderer_host/renderer_security_policy.h" | |
31 #include "chrome/browser/renderer_host/resource_request_details.h" | 31 #include "chrome/browser/renderer_host/resource_request_details.h" |
32 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" | 32 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" |
33 #include "chrome/browser/renderer_host/save_file_resource_handler.h" | 33 #include "chrome/browser/renderer_host/save_file_resource_handler.h" |
34 #include "chrome/browser/renderer_host/sync_resource_handler.h" | 34 #include "chrome/browser/renderer_host/sync_resource_handler.h" |
35 #include "chrome/browser/tab_contents/tab_util.h" | 35 #include "chrome/browser/tab_contents/tab_util.h" |
36 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
37 #include "chrome/common/notification_service.h" | 37 #include "chrome/common/notification_service.h" |
38 #include "chrome/common/render_messages.h" | 38 #include "chrome/common/render_messages.h" |
39 #include "net/base/auth.h" | 39 #include "net/base/auth.h" |
40 #include "net/base/cert_status_flags.h" | 40 #include "net/base/cert_status_flags.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Consults the RendererSecurity policy to determine whether the | 102 // Consults the RendererSecurity policy to determine whether the |
103 // ResourceDispatcherHost should service this request. A request might be | 103 // ResourceDispatcherHost should service this request. A request might be |
104 // disallowed if the renderer is not authorized to restrive the request URL or | 104 // disallowed if the renderer is not authorized to restrive the request URL or |
105 // if the renderer is attempting to upload an unauthorized file. | 105 // if the renderer is attempting to upload an unauthorized file. |
106 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, | 106 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, |
107 int process_id, | 107 int process_id, |
108 const ViewHostMsg_Resource_Request& request_data) { | 108 const ViewHostMsg_Resource_Request& request_data) { |
109 if (process_type != ChildProcessInfo::RENDER_PROCESS) | 109 if (process_type != ChildProcessInfo::RENDER_PROCESS) |
110 return true; | 110 return true; |
111 | 111 |
112 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); | 112 ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance()
; |
113 | 113 |
114 // Check if the renderer is permitted to request the requested URL. | 114 // Check if the renderer is permitted to request the requested URL. |
115 if (!policy->CanRequestURL(process_id, request_data.url)) { | 115 if (!policy->CanRequestURL(process_id, request_data.url)) { |
116 LOG(INFO) << "Denied unauthorized request for " << | 116 LOG(INFO) << "Denied unauthorized request for " << |
117 request_data.url.possibly_invalid_spec(); | 117 request_data.url.possibly_invalid_spec(); |
118 return false; | 118 return false; |
119 } | 119 } |
120 | 120 |
121 // Check if the renderer is permitted to upload the requested files. | 121 // Check if the renderer is permitted to upload the requested files. |
122 if (request_data.upload_data) { | 122 if (request_data.upload_data) { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // We are explicitly forcing the download of 'url'. | 477 // We are explicitly forcing the download of 'url'. |
478 void ResourceDispatcherHost::BeginDownload(const GURL& url, | 478 void ResourceDispatcherHost::BeginDownload(const GURL& url, |
479 const GURL& referrer, | 479 const GURL& referrer, |
480 int process_id, | 480 int process_id, |
481 int route_id, | 481 int route_id, |
482 URLRequestContext* request_context) { | 482 URLRequestContext* request_context) { |
483 if (is_shutdown_) | 483 if (is_shutdown_) |
484 return; | 484 return; |
485 | 485 |
486 // Check if the renderer is permitted to request the requested URL. | 486 // Check if the renderer is permitted to request the requested URL. |
487 if (!RendererSecurityPolicy::GetInstance()-> | 487 if (!ChildProcessSecurityPolicy::GetInstance()-> |
488 CanRequestURL(process_id, url)) { | 488 CanRequestURL(process_id, url)) { |
489 LOG(INFO) << "Denied unauthorized download request for " << | 489 LOG(INFO) << "Denied unauthorized download request for " << |
490 url.possibly_invalid_spec(); | 490 url.possibly_invalid_spec(); |
491 return; | 491 return; |
492 } | 492 } |
493 | 493 |
494 // Ensure the Chrome plugins are loaded, as they may intercept network | 494 // Ensure the Chrome plugins are loaded, as they may intercept network |
495 // requests. Does nothing if they are already loaded. | 495 // requests. Does nothing if they are already loaded. |
496 plugin_service_->LoadChromePlugins(this); | 496 plugin_service_->LoadChromePlugins(this); |
497 URLRequest* request = new URLRequest(url, this); | 497 URLRequest* request = new URLRequest(url, this); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // URLRequest::Delegate ------------------------------------------------------- | 814 // URLRequest::Delegate ------------------------------------------------------- |
815 | 815 |
816 void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, | 816 void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, |
817 const GURL& new_url) { | 817 const GURL& new_url) { |
818 RESOURCE_LOG("OnReceivedRedirect: " << request->url().spec()); | 818 RESOURCE_LOG("OnReceivedRedirect: " << request->url().spec()); |
819 ExtraRequestInfo* info = ExtraInfoForRequest(request); | 819 ExtraRequestInfo* info = ExtraInfoForRequest(request); |
820 | 820 |
821 DCHECK(request->status().is_success()); | 821 DCHECK(request->status().is_success()); |
822 | 822 |
823 if (info->process_type == ChildProcessInfo::RENDER_PROCESS && | 823 if (info->process_type == ChildProcessInfo::RENDER_PROCESS && |
824 !RendererSecurityPolicy::GetInstance()-> | 824 !ChildProcessSecurityPolicy::GetInstance()-> |
825 CanRequestURL(info->process_id, new_url)) { | 825 CanRequestURL(info->process_id, new_url)) { |
826 LOG(INFO) << "Denied unauthorized request for " << | 826 LOG(INFO) << "Denied unauthorized request for " << |
827 new_url.possibly_invalid_spec(); | 827 new_url.possibly_invalid_spec(); |
828 | 828 |
829 // Tell the renderer that this request was disallowed. | 829 // Tell the renderer that this request was disallowed. |
830 CancelRequest(info->process_id, info->request_id, false); | 830 CancelRequest(info->process_id, info->request_id, false); |
831 return; | 831 return; |
832 } | 832 } |
833 | 833 |
834 NofityReceivedRedirect(request, info->process_id, new_url); | 834 NofityReceivedRedirect(request, info->process_id, new_url); |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 case ViewHostMsg_UploadProgress_ACK::ID: | 1558 case ViewHostMsg_UploadProgress_ACK::ID: |
1559 case ViewHostMsg_SyncLoad::ID: | 1559 case ViewHostMsg_SyncLoad::ID: |
1560 return true; | 1560 return true; |
1561 | 1561 |
1562 default: | 1562 default: |
1563 break; | 1563 break; |
1564 } | 1564 } |
1565 | 1565 |
1566 return false; | 1566 return false; |
1567 } | 1567 } |
OLD | NEW |