| 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 | 53 | 
| 55 namespace { | 54 namespace { | 
| 56 | 55 | 
| 57 // Helper class that we pass to SocketStreamDispatcherHost so that it can find | 56 // Helper class that we pass to SocketStreamDispatcherHost so that it can find | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 190       id(), render_process_id); | 189       id(), render_process_id); | 
| 191   if (!CommandLine::ForCurrentProcess()->HasSwitch( | 190   if (!CommandLine::ForCurrentProcess()->HasSwitch( | 
| 192           switches::kDisableFileSystem)) { | 191           switches::kDisableFileSystem)) { | 
| 193     // Grant most file permissions to this worker. | 192     // Grant most file permissions to this worker. | 
| 194     // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 193     // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 
| 195     // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 194     // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 
| 196     // requests them. | 195     // requests them. | 
| 197     // This is for the filesystem sandbox. | 196     // This is for the filesystem sandbox. | 
| 198     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 197     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 
| 199         id(), resource_context_->file_system_context()-> | 198         id(), resource_context_->file_system_context()-> | 
| 200           path_manager()->sandbox_provider()->new_base_path(), | 199           sandbox_provider()->new_base_path(), | 
| 201         base::PLATFORM_FILE_OPEN | | 200         base::PLATFORM_FILE_OPEN | | 
| 202         base::PLATFORM_FILE_CREATE | | 201         base::PLATFORM_FILE_CREATE | | 
| 203         base::PLATFORM_FILE_OPEN_ALWAYS | | 202         base::PLATFORM_FILE_OPEN_ALWAYS | | 
| 204         base::PLATFORM_FILE_CREATE_ALWAYS | | 203         base::PLATFORM_FILE_CREATE_ALWAYS | | 
| 205         base::PLATFORM_FILE_OPEN_TRUNCATED | | 204         base::PLATFORM_FILE_OPEN_TRUNCATED | | 
| 206         base::PLATFORM_FILE_READ | | 205         base::PLATFORM_FILE_READ | | 
| 207         base::PLATFORM_FILE_WRITE | | 206         base::PLATFORM_FILE_WRITE | | 
| 208         base::PLATFORM_FILE_EXCLUSIVE_READ | | 207         base::PLATFORM_FILE_EXCLUSIVE_READ | | 
| 209         base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 208         base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 
| 210         base::PLATFORM_FILE_ASYNC | | 209         base::PLATFORM_FILE_ASYNC | | 
| 211         base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 210         base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 
| 212         base::PLATFORM_FILE_ENUMERATE); | 211         base::PLATFORM_FILE_ENUMERATE); | 
| 213     // This is so that we can read and move stuff out of the old filesystem | 212     // This is so that we can read and move stuff out of the old filesystem | 
| 214     // sandbox. | 213     // sandbox. | 
| 215     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 214     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 
| 216         id(), resource_context_->file_system_context()-> | 215         id(), resource_context_->file_system_context()-> | 
| 217           path_manager()->sandbox_provider()->old_base_path(), | 216           sandbox_provider()->old_base_path(), | 
| 218         base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | | 217         base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | | 
| 219             base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 218             base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 
| 220             base::PLATFORM_FILE_ENUMERATE); | 219             base::PLATFORM_FILE_ENUMERATE); | 
| 221     // This is so that we can rename the old sandbox out of the way so that | 220     // This is so that we can rename the old sandbox out of the way so that | 
| 222     // we know we've taken care of it. | 221     // we know we've taken care of it. | 
| 223     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 222     ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 
| 224         id(), resource_context_->file_system_context()-> | 223         id(), resource_context_->file_system_context()-> | 
| 225           path_manager()->sandbox_provider()->renamed_old_base_path(), | 224           sandbox_provider()->renamed_old_base_path(), | 
| 226         base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | | 225         base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | | 
| 227             base::PLATFORM_FILE_WRITE); | 226             base::PLATFORM_FILE_WRITE); | 
| 228   } | 227   } | 
| 229 | 228 | 
| 230   CreateMessageFilters(render_process_id); | 229   CreateMessageFilters(render_process_id); | 
| 231 | 230 | 
| 232   return true; | 231   return true; | 
| 233 } | 232 } | 
| 234 | 233 | 
| 235 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { | 234 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { | 
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 628     } | 627     } | 
| 629   } | 628   } | 
| 630   return false; | 629   return false; | 
| 631 } | 630 } | 
| 632 | 631 | 
| 633 WorkerProcessHost::WorkerInstance::FilterInfo | 632 WorkerProcessHost::WorkerInstance::FilterInfo | 
| 634 WorkerProcessHost::WorkerInstance::GetFilter() const { | 633 WorkerProcessHost::WorkerInstance::GetFilter() const { | 
| 635   DCHECK(NumFilters() == 1); | 634   DCHECK(NumFilters() == 1); | 
| 636   return *filters_.begin(); | 635   return *filters_.begin(); | 
| 637 } | 636 } | 
| OLD | NEW | 
|---|