| 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/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.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/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 18 #include "webkit/chromeos/fileapi/file_access_permissions.h" | 18 #include "webkit/chromeos/fileapi/file_access_permissions.h" |
| 19 #include "webkit/chromeos/fileapi/remote_file_stream_writer.h" |
| 19 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" | 20 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" |
| 20 #include "webkit/fileapi/file_system_file_stream_reader.h" | 21 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 21 #include "webkit/fileapi/file_system_operation.h" | 22 #include "webkit/fileapi/file_system_operation.h" |
| 22 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
| 23 #include "webkit/fileapi/local_file_stream_writer.h" | 24 #include "webkit/fileapi/local_file_stream_writer.h" |
| 24 #include "webkit/glue/webkit_glue.h" | 25 #include "webkit/glue/webkit_glue.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const char kChromeUIScheme[] = "chrome"; | 29 const char kChromeUIScheme[] = "chrome"; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 const GURL& url, | 270 const GURL& url, |
| 270 int64 offset, | 271 int64 offset, |
| 271 fileapi::FileSystemContext* context) const { | 272 fileapi::FileSystemContext* context) const { |
| 272 FilePath virtual_path; | 273 FilePath virtual_path; |
| 273 if (!fileapi::CrackFileSystemURL(url, NULL, NULL, &virtual_path)) | 274 if (!fileapi::CrackFileSystemURL(url, NULL, NULL, &virtual_path)) |
| 274 return NULL; | 275 return NULL; |
| 275 const MountPoint* mount_point = GetMountPoint(virtual_path); | 276 const MountPoint* mount_point = GetMountPoint(virtual_path); |
| 276 if (!mount_point) | 277 if (!mount_point) |
| 277 return NULL; | 278 return NULL; |
| 278 if (mount_point->location == REMOTE) { | 279 if (mount_point->location == REMOTE) { |
| 279 // TODO(kinaba): return a gdata writer for remote file system. | 280 return new fileapi::RemoteFileStreamWriter(mount_point->remote_proxy, |
| 280 return NULL; | 281 url, |
| 282 offset); |
| 281 } | 283 } |
| 282 FilePath root_path = mount_point->local_root_path; | 284 FilePath root_path = mount_point->local_root_path; |
| 283 return new fileapi::LocalFileStreamWriter( | 285 return new fileapi::LocalFileStreamWriter( |
| 284 root_path.Append(virtual_path), offset); | 286 root_path.Append(virtual_path), offset); |
| 285 } | 287 } |
| 286 | 288 |
| 287 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, | 289 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, |
| 288 FilePath* virtual_path) { | 290 FilePath* virtual_path) { |
| 289 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); | 291 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); |
| 290 iter != mount_point_map_.end(); | 292 iter != mount_point_map_.end(); |
| 291 ++iter) { | 293 ++iter) { |
| 292 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); | 294 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); |
| 293 *virtual_path = FilePath(iter->first); | 295 *virtual_path = FilePath(iter->first); |
| 294 if (mount_prefix == filesystem_path) { | 296 if (mount_prefix == filesystem_path) { |
| 295 return true; | 297 return true; |
| 296 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 298 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
| 297 return true; | 299 return true; |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 return false; | 302 return false; |
| 301 } | 303 } |
| 302 | 304 |
| 303 } // namespace chromeos | 305 } // namespace chromeos |
| OLD | NEW |