Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2149)

Unified Diff: chrome/browser/media_galleries/fileapi/picasa_file_util.cc

Issue 185393012: Change media galleries to external file system type to add toURL support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6b3ca1ff32d91fdefa7b8b2ed719297d43833d07 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().AppendASCII("picasa");
+
+ 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:

Powered by Google App Engine
This is Rietveld 408576698