| 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/sequenced_task_runner.h" |   12 #include "base/sequenced_task_runner.h" | 
|   13 #include "base/threading/sequenced_worker_pool.h" |   13 #include "base/threading/sequenced_worker_pool.h" | 
|   14 #include "content/browser/child_process_security_policy_impl.h" |   14 #include "content/browser/child_process_security_policy_impl.h" | 
|   15 #include "content/public/browser/browser_context.h" |   15 #include "content/public/browser/browser_context.h" | 
|   16 #include "content/public/browser/browser_thread.h" |   16 #include "content/public/browser/browser_thread.h" | 
|   17 #include "content/public/browser/content_browser_client.h" |   17 #include "content/public/browser/content_browser_client.h" | 
|   18 #include "content/public/common/content_client.h" |   18 #include "content/public/common/content_client.h" | 
|   19 #include "content/public/common/content_switches.h" |   19 #include "content/public/common/content_switches.h" | 
|   20 #include "content/public/common/url_constants.h" |   20 #include "content/public/common/url_constants.h" | 
|   21 #include "webkit/browser/fileapi/external_mount_points.h" |   21 #include "webkit/browser/fileapi/external_mount_points.h" | 
|   22 #include "webkit/browser/fileapi/file_permission_policy.h" |   22 #include "webkit/browser/fileapi/file_permission_policy.h" | 
|   23 #include "webkit/browser/fileapi/file_system_backend.h" |   23 #include "webkit/browser/fileapi/file_system_backend.h" | 
 |   24 #include "webkit/browser/fileapi/file_system_context.h" | 
|   24 #include "webkit/browser/fileapi/file_system_operation_runner.h" |   25 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 
|   25 #include "webkit/browser/fileapi/file_system_options.h" |   26 #include "webkit/browser/fileapi/file_system_options.h" | 
|   26 #include "webkit/browser/quota/quota_manager.h" |   27 #include "webkit/browser/quota/quota_manager.h" | 
|   27  |   28  | 
|   28 namespace content { |   29 namespace content { | 
|   29  |   30  | 
|   30 namespace { |   31 namespace { | 
|   31  |   32  | 
|   32 using fileapi::FileSystemOptions; |   33 using fileapi::FileSystemOptions; | 
|   33  |   34  | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|   59           pool->GetNamedSequenceToken("FileAPI"), |   60           pool->GetNamedSequenceToken("FileAPI"), | 
|   60           base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |   61           base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 
|   61  |   62  | 
|   62   // Setting up additional filesystem backends. |   63   // Setting up additional filesystem backends. | 
|   63   ScopedVector<fileapi::FileSystemBackend> additional_backends; |   64   ScopedVector<fileapi::FileSystemBackend> additional_backends; | 
|   64   GetContentClient()->browser()->GetAdditionalFileSystemBackends( |   65   GetContentClient()->browser()->GetAdditionalFileSystemBackends( | 
|   65       browser_context, |   66       browser_context, | 
|   66       profile_path, |   67       profile_path, | 
|   67       &additional_backends); |   68       &additional_backends); | 
|   68  |   69  | 
 |   70   // Set up the auto mount handlers for url requests. | 
 |   71   std::vector<fileapi::URLRequestAutoMountHandler> | 
 |   72       url_request_auto_mount_handlers; | 
 |   73   GetContentClient()->browser()->GetURLRequestAutoMountHandlers( | 
 |   74       &url_request_auto_mount_handlers); | 
 |   75  | 
|   69   scoped_refptr<fileapi::FileSystemContext> file_system_context = |   76   scoped_refptr<fileapi::FileSystemContext> file_system_context = | 
|   70       new fileapi::FileSystemContext( |   77       new fileapi::FileSystemContext( | 
|   71           BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), |   78           BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), | 
|   72           file_task_runner.get(), |   79           file_task_runner.get(), | 
|   73           BrowserContext::GetMountPoints(browser_context), |   80           BrowserContext::GetMountPoints(browser_context), | 
|   74           browser_context->GetSpecialStoragePolicy(), |   81           browser_context->GetSpecialStoragePolicy(), | 
|   75           quota_manager_proxy, |   82           quota_manager_proxy, | 
|   76           additional_backends.Pass(), |   83           additional_backends.Pass(), | 
 |   84           url_request_auto_mount_handlers, | 
|   77           profile_path, |   85           profile_path, | 
|   78           CreateBrowserFileSystemOptions(is_incognito)); |   86           CreateBrowserFileSystemOptions(is_incognito)); | 
|   79  |   87  | 
|   80   std::vector<fileapi::FileSystemType> types; |   88   std::vector<fileapi::FileSystemType> types; | 
|   81   file_system_context->GetFileSystemTypes(&types); |   89   file_system_context->GetFileSystemTypes(&types); | 
|   82   for (size_t i = 0; i < types.size(); ++i) { |   90   for (size_t i = 0; i < types.size(); ++i) { | 
|   83     ChildProcessSecurityPolicyImpl::GetInstance()-> |   91     ChildProcessSecurityPolicyImpl::GetInstance()-> | 
|   84         RegisterFileSystemPermissionPolicy( |   92         RegisterFileSystemPermissionPolicy( | 
|   85             types[i], |   93             types[i], | 
|   86             fileapi::FileSystemContext::GetPermissionPolicy(types[i])); |   94             fileapi::FileSystemContext::GetPermissionPolicy(types[i])); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  121   context->operation_runner()->SyncGetPlatformPath(url, platform_path); |  129   context->operation_runner()->SyncGetPlatformPath(url, platform_path); | 
|  122  |  130  | 
|  123   // The path is to be attached to URLLoader so we grant read permission |  131   // The path is to be attached to URLLoader so we grant read permission | 
|  124   // for the file. (We need to check first because a parent directory may |  132   // for the file. (We need to check first because a parent directory may | 
|  125   // already have the permissions and we don't need to grant it to the file.) |  133   // already have the permissions and we don't need to grant it to the file.) | 
|  126   if (!policy->CanReadFile(process_id, *platform_path)) |  134   if (!policy->CanReadFile(process_id, *platform_path)) | 
|  127     policy->GrantReadFile(process_id, *platform_path); |  135     policy->GrantReadFile(process_id, *platform_path); | 
|  128 } |  136 } | 
|  129  |  137  | 
|  130 }  // namespace content |  138 }  // namespace content | 
| OLD | NEW |