Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: content/browser/fileapi/browser_file_system_helper.cc

Issue 13415006: Do not refer "chrome" in content/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/content_browser_client.h"
16 #include "content/public/common/content_client.h"
15 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #include "content/public/common/url_constants.h"
16 #include "webkit/fileapi/external_mount_points.h" 19 #include "webkit/fileapi/external_mount_points.h"
17 #include "webkit/fileapi/file_permission_policy.h" 20 #include "webkit/fileapi/file_permission_policy.h"
18 #include "webkit/fileapi/file_system_options.h" 21 #include "webkit/fileapi/file_system_options.h"
19 #include "webkit/fileapi/file_system_task_runners.h" 22 #include "webkit/fileapi/file_system_task_runners.h"
20 #include "webkit/fileapi/local_file_system_operation.h" 23 #include "webkit/fileapi/local_file_system_operation.h"
21 #include "webkit/fileapi/sandbox_mount_point_provider.h" 24 #include "webkit/fileapi/sandbox_mount_point_provider.h"
22 #include "webkit/quota/quota_manager.h" 25 #include "webkit/quota/quota_manager.h"
23 26
24 namespace content { 27 namespace content {
28
25 namespace { 29 namespace {
26 30
27 const char kChromeScheme[] = "chrome";
28 const char kExtensionScheme[] = "chrome-extension";
29
30 using fileapi::FileSystemOptions; 31 using fileapi::FileSystemOptions;
31 32
32 FileSystemOptions CreateBrowserFileSystemOptions(bool is_incognito) { 33 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 = 34 FileSystemOptions::ProfileMode profile_mode =
41 is_incognito ? FileSystemOptions::PROFILE_MODE_INCOGNITO 35 is_incognito ? FileSystemOptions::PROFILE_MODE_INCOGNITO
42 : FileSystemOptions::PROFILE_MODE_NORMAL; 36 : FileSystemOptions::PROFILE_MODE_NORMAL;
37 std::vector<std::string> additional_allowed_schemes;
38 GetContentClient()->browser()->GetAdditionalAllowedSchemesForFileSystem(
39 &additional_allowed_schemes);
40 if (CommandLine::ForCurrentProcess()->HasSwitch(
41 switches::kAllowFileAccessFromFiles)) {
42 additional_allowed_schemes.push_back(chrome::kFileScheme);
43 }
43 return FileSystemOptions(profile_mode, additional_allowed_schemes); 44 return FileSystemOptions(profile_mode, additional_allowed_schemes);
44 } 45 }
45 46
46 } // anonymous namespace 47 } // namespace
47 48
48 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext( 49 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext(
49 const base::FilePath& profile_path, bool is_incognito, 50 const base::FilePath& profile_path, bool is_incognito,
50 fileapi::ExternalMountPoints* external_mount_points, 51 fileapi::ExternalMountPoints* external_mount_points,
51 quota::SpecialStoragePolicy* special_storage_policy, 52 quota::SpecialStoragePolicy* special_storage_policy,
52 quota::QuotaManagerProxy* quota_manager_proxy) { 53 quota::QuotaManagerProxy* quota_manager_proxy) {
53 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 54 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
54 base::SequencedWorkerPool::SequenceToken media_sequence_token = 55 base::SequencedWorkerPool::SequenceToken media_sequence_token =
55 pool->GetNamedSequenceToken(fileapi::kMediaTaskRunnerName); 56 pool->GetNamedSequenceToken(fileapi::kMediaTaskRunnerName);
56 57
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // for the file. (We first need to check if it can already be read not to 157 // for the file. (We first need to check if it can already be read not to
157 // overwrite existing permissions) 158 // overwrite existing permissions)
158 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 159 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
159 process_id, *platform_path)) { 160 process_id, *platform_path)) {
160 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( 161 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
161 process_id, *platform_path); 162 process_id, *platform_path);
162 } 163 }
163 } 164 }
164 165
165 } // namespace content 166 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698