| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 19 #include "webkit/chromeos/fileapi/file_access_permissions.h" | 19 #include "webkit/chromeos/fileapi/file_access_permissions.h" |
| 20 #include "webkit/fileapi/file_system_file_util.h" |
| 20 #include "webkit/fileapi/file_system_path_manager.h" | 21 #include "webkit/fileapi/file_system_path_manager.h" |
| 21 #include "webkit/fileapi/file_system_util.h" | 22 #include "webkit/fileapi/file_system_util.h" |
| 22 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
| 23 | 24 |
| 24 namespace chromeos { | 25 namespace chromeos { |
| 25 | 26 |
| 26 typedef struct { | 27 typedef struct { |
| 27 const char* local_root_path; | 28 const char* local_root_path; |
| 28 const char* web_root_path; | 29 const char* web_root_path; |
| 29 } FixedExposedPaths; | 30 } FixedExposedPaths; |
| 30 | 31 |
| 31 const char kChromeUIScheme[] = "chrome"; | 32 const char kChromeUIScheme[] = "chrome"; |
| 32 | 33 |
| 33 // Top level file system elements exposed in FileAPI in ChromeOS: | 34 // Top level file system elements exposed in FileAPI in ChromeOS: |
| 34 FixedExposedPaths fixed_exposed_paths[] = { | 35 FixedExposedPaths fixed_exposed_paths[] = { |
| 35 {"/home/chronos/user/", "Downloads"}, | 36 {"/home/chronos/user/", "Downloads"}, |
| 36 {"/", "media"}, | 37 {"/", "media"}, |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 CrosMountPointProvider::CrosMountPointProvider( | 40 CrosMountPointProvider::CrosMountPointProvider( |
| 40 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) | 41 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) |
| 41 : special_storage_policy_(special_storage_policy), | 42 : special_storage_policy_(special_storage_policy), |
| 42 file_access_permissions_(new FileAccessPermissions()) { | 43 file_access_permissions_(new FileAccessPermissions()), |
| 44 local_file_util_(new fileapi::LocalFileSystemFileUtil( |
| 45 fileapi::FileSystemFileUtil::GetInstance())) { |
| 43 for (size_t i = 0; i < arraysize(fixed_exposed_paths); i++) { | 46 for (size_t i = 0; i < arraysize(fixed_exposed_paths); i++) { |
| 44 mount_point_map_.insert(std::pair<std::string, FilePath>( | 47 mount_point_map_.insert(std::pair<std::string, FilePath>( |
| 45 std::string(fixed_exposed_paths[i].web_root_path), | 48 std::string(fixed_exposed_paths[i].web_root_path), |
| 46 FilePath(std::string(fixed_exposed_paths[i].local_root_path)))); | 49 FilePath(std::string(fixed_exposed_paths[i].local_root_path)))); |
| 47 } | 50 } |
| 48 } | 51 } |
| 49 | 52 |
| 50 CrosMountPointProvider::~CrosMountPointProvider() { | 53 CrosMountPointProvider::~CrosMountPointProvider() { |
| 51 } | 54 } |
| 52 | 55 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const { | 170 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const { |
| 168 std::vector<FilePath> root_dirs; | 171 std::vector<FilePath> root_dirs; |
| 169 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 172 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
| 170 iter != mount_point_map_.end(); | 173 iter != mount_point_map_.end(); |
| 171 ++iter) { | 174 ++iter) { |
| 172 root_dirs.push_back(iter->second.Append(iter->first)); | 175 root_dirs.push_back(iter->second.Append(iter->first)); |
| 173 } | 176 } |
| 174 return root_dirs; | 177 return root_dirs; |
| 175 } | 178 } |
| 176 | 179 |
| 180 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileSystemFileUtil() { |
| 181 return local_file_util_.get(); |
| 182 } |
| 183 |
| 177 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 184 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
| 178 FilePath* virtual_path) { | 185 FilePath* virtual_path) { |
| 179 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 186 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
| 180 iter != mount_point_map_.end(); | 187 iter != mount_point_map_.end(); |
| 181 ++iter) { | 188 ++iter) { |
| 182 FilePath mount_prefix = iter->second.Append(iter->first); | 189 FilePath mount_prefix = iter->second.Append(iter->first); |
| 183 *virtual_path = FilePath(iter->first); | 190 *virtual_path = FilePath(iter->first); |
| 184 if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 191 if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
| 185 return true; | 192 return true; |
| 186 } | 193 } |
| 187 } | 194 } |
| 188 return false; | 195 return false; |
| 189 } | 196 } |
| 190 | 197 |
| 191 } // namespace chromeos | 198 } // namespace chromeos |
| OLD | NEW |