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/worker_host/worker_process_host.h" | 5 #include "content/browser/worker_host/worker_process_host.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/browser/renderer_host/database_message_filter.h" | 28 #include "content/browser/renderer_host/database_message_filter.h" |
29 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 29 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
30 #include "content/browser/renderer_host/render_view_host_delegate.h" | 30 #include "content/browser/renderer_host/render_view_host_delegate.h" |
31 #include "content/browser/renderer_host/render_view_host_impl.h" | 31 #include "content/browser/renderer_host/render_view_host_impl.h" |
32 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 32 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
33 #include "content/browser/resource_context_impl.h" | 33 #include "content/browser/resource_context_impl.h" |
34 #include "content/browser/worker_host/message_port_service.h" | 34 #include "content/browser/worker_host/message_port_service.h" |
35 #include "content/browser/worker_host/worker_message_filter.h" | 35 #include "content/browser/worker_host/worker_message_filter.h" |
36 #include "content/browser/worker_host/worker_service_impl.h" | 36 #include "content/browser/worker_host/worker_service_impl.h" |
37 #include "content/common/child_process_host_impl.h" | 37 #include "content/common/child_process_host_impl.h" |
38 #include "content/common/debug_flags.h" | |
39 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
40 #include "content/common/worker_messages.h" | 39 #include "content/common/worker_messages.h" |
41 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
43 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
44 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
45 #include "content/public/common/result_codes.h" | 44 #include "content/public/common/result_codes.h" |
46 #include "ipc/ipc_switches.h" | 45 #include "ipc/ipc_switches.h" |
47 #include "net/base/mime_util.h" | 46 #include "net/base/mime_util.h" |
48 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 47 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
49 #include "net/url_request/url_request_context_getter.h" | 48 #include "net/url_request/url_request_context_getter.h" |
50 #include "ui/base/ui_base_switches.h" | 49 #include "ui/base/ui_base_switches.h" |
51 #include "webkit/fileapi/file_system_context.h" | 50 #include "webkit/fileapi/file_system_context.h" |
52 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 51 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
53 #include "webkit/glue/resource_type.h" | 52 #include "webkit/glue/resource_type.h" |
54 | 53 |
| 54 #if defined(OS_WIN) |
| 55 #include "content/common/sandbox_win.h" |
| 56 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 57 #endif |
| 58 |
55 namespace content { | 59 namespace content { |
56 namespace { | 60 namespace { |
57 | 61 |
| 62 #if defined(OS_WIN) |
| 63 // NOTE: changes to this class need to be reviewed by the security team. |
| 64 class WorkerSandboxedProcessLauncherDelegate |
| 65 : public content::SandboxedProcessLauncherDelegate { |
| 66 public: |
| 67 WorkerSandboxedProcessLauncherDelegate() {} |
| 68 virtual ~WorkerSandboxedProcessLauncherDelegate() {} |
| 69 |
| 70 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, |
| 71 bool* success) { |
| 72 AddBaseHandleClosePolicy(policy); |
| 73 } |
| 74 }; |
| 75 #endif // OS_WIN |
| 76 |
58 // Helper class that we pass to SocketStreamDispatcherHost so that it can find | 77 // Helper class that we pass to SocketStreamDispatcherHost so that it can find |
59 // the right net::URLRequestContext for a request. | 78 // the right net::URLRequestContext for a request. |
60 class URLRequestContextSelector | 79 class URLRequestContextSelector |
61 : public ResourceMessageFilter::URLRequestContextSelector { | 80 : public ResourceMessageFilter::URLRequestContextSelector { |
62 public: | 81 public: |
63 explicit URLRequestContextSelector( | 82 explicit URLRequestContextSelector( |
64 net::URLRequestContextGetter* url_request_context, | 83 net::URLRequestContextGetter* url_request_context, |
65 net::URLRequestContextGetter* media_url_request_context) | 84 net::URLRequestContextGetter* media_url_request_context) |
66 : url_request_context_(url_request_context), | 85 : url_request_context_(url_request_context), |
67 media_url_request_context_(media_url_request_context) { | 86 media_url_request_context_(media_url_request_context) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // launches a new xterm, and runs the worker process in gdb, reading | 203 // launches a new xterm, and runs the worker process in gdb, reading |
185 // optional commands from gdb_chrome file in the working directory. | 204 // optional commands from gdb_chrome file in the working directory. |
186 cmd_line->PrependWrapper("xterm -e gdb -x gdb_chrome --args"); | 205 cmd_line->PrependWrapper("xterm -e gdb -x gdb_chrome --args"); |
187 use_zygote = false; | 206 use_zygote = false; |
188 } | 207 } |
189 } | 208 } |
190 #endif | 209 #endif |
191 | 210 |
192 process_->Launch( | 211 process_->Launch( |
193 #if defined(OS_WIN) | 212 #if defined(OS_WIN) |
194 base::FilePath(), | 213 new WorkerSandboxedProcessLauncherDelegate, |
195 #elif defined(OS_POSIX) | 214 #elif defined(OS_POSIX) |
196 use_zygote, | 215 use_zygote, |
197 base::EnvironmentVector(), | 216 base::EnvironmentVector(), |
198 #endif | 217 #endif |
199 cmd_line); | 218 cmd_line); |
200 | 219 |
201 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( | 220 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( |
202 process_->GetData().id, render_process_id); | 221 process_->GetData().id, render_process_id); |
203 CreateMessageFilters(render_process_id); | 222 CreateMessageFilters(render_process_id); |
204 | 223 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 return false; | 686 return false; |
668 } | 687 } |
669 | 688 |
670 WorkerProcessHost::WorkerInstance::FilterInfo | 689 WorkerProcessHost::WorkerInstance::FilterInfo |
671 WorkerProcessHost::WorkerInstance::GetFilter() const { | 690 WorkerProcessHost::WorkerInstance::GetFilter() const { |
672 DCHECK(NumFilters() == 1); | 691 DCHECK(NumFilters() == 1); |
673 return *filters_.begin(); | 692 return *filters_.begin(); |
674 } | 693 } |
675 | 694 |
676 } // namespace content | 695 } // namespace content |
OLD | NEW |