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 "webkit/fileapi/test_mount_point_provider.h" | 5 #include "webkit/fileapi/test_mount_point_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 private: | 65 private: |
66 int64 usage_; | 66 int64 usage_; |
67 }; | 67 }; |
68 | 68 |
69 TestMountPointProvider::TestMountPointProvider( | 69 TestMountPointProvider::TestMountPointProvider( |
70 base::SequencedTaskRunner* task_runner, | 70 base::SequencedTaskRunner* task_runner, |
71 const base::FilePath& base_path) | 71 const base::FilePath& base_path) |
72 : base_path_(base_path), | 72 : base_path_(base_path), |
73 task_runner_(task_runner), | 73 task_runner_(task_runner), |
74 local_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())), | 74 local_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())), |
75 quota_util_(new QuotaUtil) { | 75 quota_util_(new QuotaUtil), |
| 76 require_copy_or_move_validator_(false) { |
76 UpdateObserverList::Source source; | 77 UpdateObserverList::Source source; |
77 source.AddObserver(quota_util_.get(), task_runner_); | 78 source.AddObserver(quota_util_.get(), task_runner_); |
78 observers_ = UpdateObserverList(source); | 79 observers_ = UpdateObserverList(source); |
79 } | 80 } |
80 | 81 |
81 TestMountPointProvider::~TestMountPointProvider() { | 82 TestMountPointProvider::~TestMountPointProvider() { |
82 } | 83 } |
83 | 84 |
84 bool TestMountPointProvider::CanHandleType(FileSystemType type) const { | 85 bool TestMountPointProvider::CanHandleType(FileSystemType type) const { |
85 return (type == kFileSystemTypeTest); | 86 return (type == kFileSystemTypeTest); |
(...skipping 28 matching lines...) Expand all Loading... |
114 | 115 |
115 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { | 116 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { |
116 return local_file_util_.get(); | 117 return local_file_util_.get(); |
117 } | 118 } |
118 | 119 |
119 CopyOrMoveFileValidatorFactory* | 120 CopyOrMoveFileValidatorFactory* |
120 TestMountPointProvider::GetCopyOrMoveFileValidatorFactory( | 121 TestMountPointProvider::GetCopyOrMoveFileValidatorFactory( |
121 FileSystemType type, base::PlatformFileError* error_code) { | 122 FileSystemType type, base::PlatformFileError* error_code) { |
122 DCHECK(error_code); | 123 DCHECK(error_code); |
123 *error_code = base::PLATFORM_FILE_OK; | 124 *error_code = base::PLATFORM_FILE_OK; |
| 125 if (require_copy_or_move_validator_) { |
| 126 if (!copy_or_move_file_validator_factory_) |
| 127 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; |
| 128 return copy_or_move_file_validator_factory_.get(); |
| 129 } |
124 return NULL; | 130 return NULL; |
125 } | 131 } |
126 | 132 |
127 void TestMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( | 133 void TestMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( |
128 FileSystemType type, scoped_ptr<CopyOrMoveFileValidatorFactory> factory) { | 134 FileSystemType type, scoped_ptr<CopyOrMoveFileValidatorFactory> factory) { |
129 DCHECK(!factory); | 135 if (!require_copy_or_move_validator_) { |
| 136 DCHECK(!factory); |
| 137 return; |
| 138 } |
| 139 if (!copy_or_move_file_validator_factory_) |
| 140 copy_or_move_file_validator_factory_ = factory.Pass(); |
130 } | 141 } |
131 | 142 |
132 FilePermissionPolicy TestMountPointProvider::GetPermissionPolicy( | 143 FilePermissionPolicy TestMountPointProvider::GetPermissionPolicy( |
133 const FileSystemURL& url, int permissions) const { | 144 const FileSystemURL& url, int permissions) const { |
134 return FILE_PERMISSION_ALWAYS_DENY; | 145 return FILE_PERMISSION_ALWAYS_DENY; |
135 } | 146 } |
136 | 147 |
137 FileSystemOperation* TestMountPointProvider::CreateFileSystemOperation( | 148 FileSystemOperation* TestMountPointProvider::CreateFileSystemOperation( |
138 const FileSystemURL& url, | 149 const FileSystemURL& url, |
139 FileSystemContext* context, | 150 FileSystemContext* context, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 NOTREACHED(); | 189 NOTREACHED(); |
179 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 190 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
180 } | 191 } |
181 | 192 |
182 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( | 193 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( |
183 FileSystemType type) const { | 194 FileSystemType type) const { |
184 return &observers_; | 195 return &observers_; |
185 } | 196 } |
186 | 197 |
187 } // namespace fileapi | 198 } // namespace fileapi |
OLD | NEW |