Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/picasa_file_util.cc |
| diff --git a/chrome/browser/media_galleries/fileapi/picasa_file_util.cc b/chrome/browser/media_galleries/fileapi/picasa_file_util.cc |
| index 646f9548f4f80012cb1e4169554d97736c05e655..e4d402953e9573e2adc210ad9bf0057e3775f0b0 100644 |
| --- a/chrome/browser/media_galleries/fileapi/picasa_file_util.cc |
| +++ b/chrome/browser/media_galleries/fileapi/picasa_file_util.cc |
| @@ -49,11 +49,24 @@ base::File::Error FindAlbumInfo(const std::string& key, |
| return base::File::FILE_OK; |
| } |
| -PicasaDataProvider::DataType GetDataTypeForURL( |
| +std::vector<std::string> GetVirtualPathComponents( |
| const fileapi::FileSystemURL& url) { |
| - std::vector<std::string> components; |
| - fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| + ImportedMediaGalleryRegistry* imported_registry = |
| + ImportedMediaGalleryRegistry::GetInstance(); |
| + base::FilePath root = imported_registry->ImportedRoot().Append("picasa"); |
|
Lei Zhang
2014/03/27 02:27:20
Append -> AppendASCII, ditto elsewhere.
vandebo (ex-Chrome)
2014/03/27 05:39:09
Done x3.
|
| + |
| + DCHECK(root.IsParent(url.path()) || root == url.path()); |
| + base::FilePath virtual_path; |
| + root.AppendRelativePath(url.path(), &virtual_path); |
| + |
| + std::vector<std::string> result; |
| + fileapi::VirtualPath::GetComponentsUTF8Unsafe(virtual_path, &result); |
| + return result; |
| +} |
| +PicasaDataProvider::DataType GetDataTypeForURL( |
| + const fileapi::FileSystemURL& url) { |
| + std::vector<std::string> components = GetVirtualPathComponents(url); |
| if (components.size() >= 2 && components[0] == kPicasaDirAlbums) |
| return PicasaDataProvider::ALBUMS_IMAGES_DATA; |
| @@ -107,8 +120,7 @@ base::File::Error PicasaFileUtil::GetFileInfoSync( |
| if (platform_path) |
| *platform_path = base::FilePath(); |
| - std::vector<std::string> components; |
| - fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| + std::vector<std::string> components = GetVirtualPathComponents(url); |
| switch (components.size()) { |
| case 0: |
| @@ -176,9 +188,7 @@ base::File::Error PicasaFileUtil::ReadDirectorySync( |
| if (!file_info.is_directory) |
| return base::File::FILE_ERROR_NOT_A_DIRECTORY; |
| - std::vector<std::string> components; |
| - fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| - |
| + std::vector<std::string> components = GetVirtualPathComponents(url); |
| switch (components.size()) { |
| case 0: { |
| // Root directory. |
| @@ -283,8 +293,7 @@ base::File::Error PicasaFileUtil::GetLocalFilePath( |
| base::FilePath* local_file_path) { |
| DCHECK(local_file_path); |
| DCHECK(url.is_valid()); |
| - std::vector<std::string> components; |
| - fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| + std::vector<std::string> components = GetVirtualPathComponents(url); |
| switch (components.size()) { |
| case 2: |
| @@ -331,7 +340,7 @@ base::File::Error PicasaFileUtil::GetLocalFilePath( |
| return error; |
| // Not part of this class's mandate to check that it actually exists. |
| - *local_file_path = album_info.path.Append(url.path().BaseName()); |
| + *local_file_path = album_info.path.Append(components[2]); |
| return base::File::FILE_OK; |
| } |