Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h" | |
| 10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" | |
| 11 #include "webkit/browser/fileapi/file_system_operation.h" | |
| 12 | |
| 13 namespace local_discovery { | |
| 14 | |
| 15 PrivetFileSystemBackend::PrivetFileSystemBackend( | |
| 16 fileapi::ExternalMountPoints* mount_points) | |
| 17 : mount_points_(mount_points), | |
| 18 async_util_(new PrivetFileSystemAsyncUtil()) { | |
| 19 } | |
| 20 | |
| 21 PrivetFileSystemBackend::~PrivetFileSystemBackend() { | |
| 22 } | |
| 23 | |
| 24 bool PrivetFileSystemBackend::CanHandleType( | |
| 25 fileapi::FileSystemType type) const { | |
| 26 return (type == fileapi::kFileSystemTypePrivet); | |
| 27 } | |
| 28 | |
| 29 void PrivetFileSystemBackend::Initialize(fileapi::FileSystemContext* context) { | |
| 30 mount_points_->RegisterFileSystem( | |
| 31 "privet", | |
| 32 fileapi::kFileSystemTypePrivet, | |
| 33 fileapi::FileSystemMountOption(), | |
| 34 base::FilePath(kPrivetFilePath)); | |
| 35 } | |
| 36 | |
| 37 void PrivetFileSystemBackend::OpenFileSystem( | |
| 38 const GURL& origin_url, | |
| 39 fileapi::FileSystemType type, | |
| 40 fileapi::OpenFileSystemMode mode, | |
| 41 const OpenFileSystemCallback& callback) { | |
| 42 // Copied from src/chrome/browser/chromeos/fileapi/file_system_backend.cc | |
| 43 // This is deprecated for non-sandboxed filesystems. | |
| 44 NOTREACHED(); | |
| 45 callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY); | |
| 46 } | |
| 47 | |
| 48 fileapi::FileSystemQuotaUtil* PrivetFileSystemBackend::GetQuotaUtil() { | |
| 49 // No quota support. | |
| 50 return NULL; | |
| 51 } | |
| 52 | |
| 53 // TODO(noamsml): Any access controls | |
| 54 | |
| 55 bool PrivetFileSystemBackend::IsAccessAllowed( | |
| 56 const fileapi::FileSystemURL& url) const { | |
| 57 // TODO(noamsml) | |
|
Vitaly Buka (NO REVIEWS)
2014/01/07 21:08:49
it could be usefull to have bug ID to find context
Noam Samuel
2014/01/07 22:10:59
Done.
| |
| 58 return true; | |
| 59 } | |
| 60 | |
| 61 void PrivetFileSystemBackend::GrantFullAccessToExtension( | |
| 62 const std::string& extension_id) { | |
| 63 // TODO(noamsml) | |
| 64 } | |
| 65 | |
| 66 void PrivetFileSystemBackend::GrantFileAccessToExtension( | |
| 67 const std::string& extension_id, const base::FilePath& virtual_path) { | |
| 68 // TODO(noamsml) | |
| 69 } | |
| 70 | |
| 71 void PrivetFileSystemBackend::RevokeAccessForExtension( | |
| 72 const std::string& extension_id) { | |
| 73 // TODO(noamsml) | |
| 74 } | |
| 75 | |
| 76 // Copied from file_system_backend.cc:193 | |
| 77 std::vector<base::FilePath> | |
| 78 PrivetFileSystemBackend::GetRootDirectories() const { | |
| 79 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; | |
| 80 mount_points_->AddMountPointInfosTo(&mount_points); | |
| 81 // System mount pints | |
|
Vitaly Buka (NO REVIEWS)
2014/01/07 21:08:49
The line addressed by this comment is not clear.
a
Noam Samuel
2014/01/07 22:10:59
Removed.
| |
| 82 | |
| 83 std::vector<base::FilePath> root_dirs; | |
| 84 for (size_t i = 0; i < mount_points.size(); ++i) | |
| 85 root_dirs.push_back(mount_points[i].path); | |
| 86 return root_dirs; | |
| 87 } | |
| 88 | |
| 89 fileapi::AsyncFileUtil* PrivetFileSystemBackend::GetAsyncFileUtil( | |
| 90 fileapi::FileSystemType type) { | |
| 91 return async_util_.get(); | |
| 92 } | |
| 93 | |
| 94 fileapi::CopyOrMoveFileValidatorFactory* | |
| 95 PrivetFileSystemBackend::GetCopyOrMoveFileValidatorFactory( | |
| 96 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | |
| 97 DCHECK(error_code); | |
| 98 *error_code = base::PLATFORM_FILE_OK; | |
| 99 return NULL; | |
| 100 } | |
| 101 | |
| 102 fileapi::FileSystemOperation* | |
| 103 PrivetFileSystemBackend::CreateFileSystemOperation( | |
| 104 const fileapi::FileSystemURL& url, | |
| 105 fileapi::FileSystemContext* context, | |
| 106 base::PlatformFileError* error_code) const { | |
| 107 return fileapi::FileSystemOperation::Create( | |
| 108 url, context, | |
| 109 make_scoped_ptr(new fileapi::FileSystemOperationContext(context))); | |
| 110 } | |
| 111 | |
| 112 scoped_ptr<webkit_blob::FileStreamReader> | |
| 113 PrivetFileSystemBackend::CreateFileStreamReader( | |
| 114 const fileapi::FileSystemURL& url, | |
| 115 int64 offset, | |
| 116 const base::Time& expected_modification_time, | |
| 117 fileapi::FileSystemContext* context) const { | |
| 118 return scoped_ptr<webkit_blob::FileStreamReader>(); | |
| 119 } | |
| 120 | |
| 121 | |
| 122 scoped_ptr<fileapi::FileStreamWriter> | |
| 123 PrivetFileSystemBackend::CreateFileStreamWriter( | |
| 124 const fileapi::FileSystemURL& url, | |
| 125 int64 offset, | |
| 126 fileapi::FileSystemContext* context) const { | |
| 127 return scoped_ptr<fileapi::FileStreamWriter>(); | |
| 128 } | |
| 129 | |
| 130 bool PrivetFileSystemBackend::GetVirtualPath( | |
| 131 const base::FilePath& filesystem_path, | |
| 132 base::FilePath* virtual_path) { | |
| 133 return mount_points_->GetVirtualPath(filesystem_path, virtual_path); | |
| 134 } | |
| 135 | |
| 136 } // namespace local_discovery | |
| OLD | NEW |