| 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/fileapi/browser_file_system_helper.h" | 5 #include "content/browser/fileapi/browser_file_system_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "content/browser/child_process_security_policy_impl.h" | 13 #include "content/browser/child_process_security_policy_impl.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/browser/content_browser_client.h" |
| 16 #include "content/public/common/content_client.h" |
| 16 #include "webkit/fileapi/external_mount_points.h" | 17 #include "webkit/fileapi/external_mount_points.h" |
| 17 #include "webkit/fileapi/file_permission_policy.h" | 18 #include "webkit/fileapi/file_permission_policy.h" |
| 18 #include "webkit/fileapi/file_system_options.h" | 19 #include "webkit/fileapi/file_system_options.h" |
| 19 #include "webkit/fileapi/file_system_task_runners.h" | 20 #include "webkit/fileapi/file_system_task_runners.h" |
| 20 #include "webkit/fileapi/local_file_system_operation.h" | 21 #include "webkit/fileapi/local_file_system_operation.h" |
| 21 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 22 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 22 #include "webkit/quota/quota_manager.h" | 23 #include "webkit/quota/quota_manager.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 const char kChromeScheme[] = "chrome"; | |
| 28 const char kExtensionScheme[] = "chrome-extension"; | |
| 29 | |
| 30 using fileapi::FileSystemOptions; | 29 using fileapi::FileSystemOptions; |
| 31 | 30 |
| 32 FileSystemOptions CreateBrowserFileSystemOptions(bool is_incognito) { | 31 FileSystemOptions CreateBrowserFileSystemOptions(bool is_incognito) { |
| 33 std::vector<std::string> additional_allowed_schemes; | |
| 34 additional_allowed_schemes.push_back(kChromeScheme); | |
| 35 additional_allowed_schemes.push_back(kExtensionScheme); | |
| 36 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 37 switches::kAllowFileAccessFromFiles)) { | |
| 38 additional_allowed_schemes.push_back("file"); | |
| 39 } | |
| 40 FileSystemOptions::ProfileMode profile_mode = | 32 FileSystemOptions::ProfileMode profile_mode = |
| 41 is_incognito ? FileSystemOptions::PROFILE_MODE_INCOGNITO | 33 is_incognito ? FileSystemOptions::PROFILE_MODE_INCOGNITO |
| 42 : FileSystemOptions::PROFILE_MODE_NORMAL; | 34 : FileSystemOptions::PROFILE_MODE_NORMAL; |
| 43 return FileSystemOptions(profile_mode, additional_allowed_schemes); | 35 return FileSystemOptions( |
| 36 profile_mode, |
| 37 GetContentClient()->browser()-> |
| 38 GetAdditionalAllowedSchemesForFileSystem()); |
| 44 } | 39 } |
| 45 | 40 |
| 46 } // anonymous namespace | 41 } // namespace |
| 47 | 42 |
| 48 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext( | 43 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext( |
| 49 const base::FilePath& profile_path, bool is_incognito, | 44 const base::FilePath& profile_path, bool is_incognito, |
| 50 fileapi::ExternalMountPoints* external_mount_points, | 45 fileapi::ExternalMountPoints* external_mount_points, |
| 51 quota::SpecialStoragePolicy* special_storage_policy, | 46 quota::SpecialStoragePolicy* special_storage_policy, |
| 52 quota::QuotaManagerProxy* quota_manager_proxy) { | 47 quota::QuotaManagerProxy* quota_manager_proxy) { |
| 53 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 48 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 54 base::SequencedWorkerPool::SequenceToken media_sequence_token = | 49 base::SequencedWorkerPool::SequenceToken media_sequence_token = |
| 55 pool->GetNamedSequenceToken(fileapi::kMediaTaskRunnerName); | 50 pool->GetNamedSequenceToken(fileapi::kMediaTaskRunnerName); |
| 56 | 51 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // for the file. (We first need to check if it can already be read not to | 151 // for the file. (We first need to check if it can already be read not to |
| 157 // overwrite existing permissions) | 152 // overwrite existing permissions) |
| 158 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | 153 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
| 159 process_id, *platform_path)) { | 154 process_id, *platform_path)) { |
| 160 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 155 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 161 process_id, *platform_path); | 156 process_id, *platform_path); |
| 162 } | 157 } |
| 163 } | 158 } |
| 164 | 159 |
| 165 } // namespace content | 160 } // namespace content |
| OLD | NEW |