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

Unified Diff: chrome/browser/media_galleries/fileapi/iphoto_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/iphoto_file_util.cc
diff --git a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc
index f35595720bd872d3cacf83abd4a41e353d5fc614..38ae639b92c30026bff59bffe3221fc57f7fbde8 100644
--- a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc
+++ b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc
@@ -47,6 +47,21 @@ bool ContainsElement(const std::vector<T>& collection, const T& key) {
return false;
}
+std::vector<std::string> GetVirtualPathComponents(
+ const fileapi::FileSystemURL& url) {
+ ImportedMediaGalleryRegistry* imported_registry =
+ ImportedMediaGalleryRegistry::GetInstance();
+ base::FilePath root = imported_registry->ImportedRoot().AppendASCII("iphoto");
+
+ 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;
+}
+
} // namespace
const char kIPhotoAlbumsDir[] = "Albums";
@@ -156,8 +171,7 @@ base::File::Error IPhotoFileUtil::GetFileInfoSync(
const fileapi::FileSystemURL& url,
base::File::Info* file_info,
base::FilePath* platform_path) {
- std::vector<std::string> components;
- fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
+ std::vector<std::string> components = GetVirtualPathComponents(url);
if (components.size() == 0) {
return MakeDirectoryFileInfo(file_info);
@@ -206,8 +220,7 @@ base::File::Error IPhotoFileUtil::ReadDirectorySync(
const fileapi::FileSystemURL& url,
EntryList* file_list) {
DCHECK(file_list->empty());
- std::vector<std::string> components;
- fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
+ std::vector<std::string> components = GetVirtualPathComponents(url);
// Root directory. Child is the /Albums dir.
if (components.size() == 0) {
@@ -290,8 +303,7 @@ base::File::Error IPhotoFileUtil::GetLocalFilePath(
fileapi::FileSystemOperationContext* context,
const fileapi::FileSystemURL& url,
base::FilePath* local_file_path) {
- std::vector<std::string> components;
- fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
+ std::vector<std::string> components = GetVirtualPathComponents(url);
if (components.size() == 3 && components[0] == kIPhotoAlbumsDir) {
base::FilePath location = GetDataProvider()->GetPhotoLocationInAlbum(

Powered by Google App Engine
This is Rietveld 408576698