OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
39 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
41 #include "content/public/common/result_codes.h" | 41 #include "content/public/common/result_codes.h" |
42 #include "ipc/ipc_switches.h" | 42 #include "ipc/ipc_switches.h" |
43 #include "net/base/mime_util.h" | 43 #include "net/base/mime_util.h" |
44 #include "net/base/registry_controlled_domain.h" | 44 #include "net/base/registry_controlled_domain.h" |
45 #include "ui/base/ui_base_switches.h" | 45 #include "ui/base/ui_base_switches.h" |
46 #include "webkit/fileapi/file_system_context.h" | 46 #include "webkit/fileapi/file_system_context.h" |
47 #include "webkit/fileapi/file_system_path_manager.h" | |
48 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 47 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
49 #include "webkit/glue/resource_type.h" | 48 #include "webkit/glue/resource_type.h" |
50 | 49 |
51 using content::BrowserThread; | 50 using content::BrowserThread; |
52 using content::ChildProcessHost; | 51 using content::ChildProcessHost; |
53 using content::UserMetricsAction; | 52 using content::UserMetricsAction; |
54 using content::WorkerServiceImpl; | 53 using content::WorkerServiceImpl; |
55 | 54 |
56 namespace { | 55 namespace { |
57 | 56 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 id(), render_process_id); | 190 id(), render_process_id); |
192 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 191 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
193 switches::kDisableFileSystem)) { | 192 switches::kDisableFileSystem)) { |
194 // Grant most file permissions to this worker. | 193 // Grant most file permissions to this worker. |
195 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 194 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and |
196 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 195 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API |
197 // requests them. | 196 // requests them. |
198 // This is for the filesystem sandbox. | 197 // This is for the filesystem sandbox. |
199 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 198 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
200 id(), resource_context_->file_system_context()-> | 199 id(), resource_context_->file_system_context()-> |
201 path_manager()->sandbox_provider()->new_base_path(), | 200 sandbox_provider()->new_base_path(), |
202 base::PLATFORM_FILE_OPEN | | 201 base::PLATFORM_FILE_OPEN | |
203 base::PLATFORM_FILE_CREATE | | 202 base::PLATFORM_FILE_CREATE | |
204 base::PLATFORM_FILE_OPEN_ALWAYS | | 203 base::PLATFORM_FILE_OPEN_ALWAYS | |
205 base::PLATFORM_FILE_CREATE_ALWAYS | | 204 base::PLATFORM_FILE_CREATE_ALWAYS | |
206 base::PLATFORM_FILE_OPEN_TRUNCATED | | 205 base::PLATFORM_FILE_OPEN_TRUNCATED | |
207 base::PLATFORM_FILE_READ | | 206 base::PLATFORM_FILE_READ | |
208 base::PLATFORM_FILE_WRITE | | 207 base::PLATFORM_FILE_WRITE | |
209 base::PLATFORM_FILE_EXCLUSIVE_READ | | 208 base::PLATFORM_FILE_EXCLUSIVE_READ | |
210 base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 209 base::PLATFORM_FILE_EXCLUSIVE_WRITE | |
211 base::PLATFORM_FILE_ASYNC | | 210 base::PLATFORM_FILE_ASYNC | |
212 base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 211 base::PLATFORM_FILE_WRITE_ATTRIBUTES | |
213 base::PLATFORM_FILE_ENUMERATE); | 212 base::PLATFORM_FILE_ENUMERATE); |
214 // This is so that we can read and move stuff out of the old filesystem | 213 // This is so that we can read and move stuff out of the old filesystem |
215 // sandbox. | 214 // sandbox. |
216 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 215 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
217 id(), resource_context_->file_system_context()-> | 216 id(), resource_context_->file_system_context()-> |
218 path_manager()->sandbox_provider()->old_base_path(), | 217 sandbox_provider()->old_base_path(), |
219 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | | 218 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | |
220 base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 219 base::PLATFORM_FILE_WRITE_ATTRIBUTES | |
221 base::PLATFORM_FILE_ENUMERATE); | 220 base::PLATFORM_FILE_ENUMERATE); |
222 // This is so that we can rename the old sandbox out of the way so that | 221 // This is so that we can rename the old sandbox out of the way so that |
223 // we know we've taken care of it. | 222 // we know we've taken care of it. |
224 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 223 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
225 id(), resource_context_->file_system_context()-> | 224 id(), resource_context_->file_system_context()-> |
226 path_manager()->sandbox_provider()->renamed_old_base_path(), | 225 sandbox_provider()->renamed_old_base_path(), |
227 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | | 226 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | |
228 base::PLATFORM_FILE_WRITE); | 227 base::PLATFORM_FILE_WRITE); |
229 } | 228 } |
230 | 229 |
231 CreateMessageFilters(render_process_id); | 230 CreateMessageFilters(render_process_id); |
232 | 231 |
233 return true; | 232 return true; |
234 } | 233 } |
235 | 234 |
236 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { | 235 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 630 } |
632 } | 631 } |
633 return false; | 632 return false; |
634 } | 633 } |
635 | 634 |
636 WorkerProcessHost::WorkerInstance::FilterInfo | 635 WorkerProcessHost::WorkerInstance::FilterInfo |
637 WorkerProcessHost::WorkerInstance::GetFilter() const { | 636 WorkerProcessHost::WorkerInstance::GetFilter() const { |
638 DCHECK(NumFilters() == 1); | 637 DCHECK(NumFilters() == 1); |
639 return *filters_.begin(); | 638 return *filters_.begin(); |
640 } | 639 } |
OLD | NEW |