11320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Copyright 2013 The Chromium Authors. All rights reserved. 21320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Use of this source code is governed by a BSD-style license that can be 31320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// found in the LICENSE file. 41320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IPHOTO_FILE_UTIL_H_ 61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IPHOTO_FILE_UTIL_H_ 71320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/memory/scoped_ptr.h" 91320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/memory/weak_ptr.h" 101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" 111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass ImportedMediaGalleryRegistry; 131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace iphoto { 151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass IPhotoDataProvider; 171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Presents a virtual file system containing iPhoto contents in the 191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// following organization: 201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// / = virtual root 211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- /Albums 221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- /AlbumName = An album entry by name. 231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- pic1.jpg = Entries for photos in the album. 241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- pic2.jpg 251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- /AnotherAlbum 261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- pic3.jpg 271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- /originals = A directory for originals. 281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// |- pic3.jpg = Original picture. Same name as album photo. 291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciextern const char kIPhotoAlbumsDir[]; 311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass IPhotoFileUtil : public NativeMediaFileUtil { 331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci public: 341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci explicit IPhotoFileUtil(MediaPathFilter* media_path_filter); 351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual ~IPhotoFileUtil(); 36 37 protected: 38 // NativeMediaFileUtil overrides. 39 virtual void GetFileInfoOnTaskRunnerThread( 40 scoped_ptr<storage::FileSystemOperationContext> context, 41 const storage::FileSystemURL& url, 42 const GetFileInfoCallback& callback) OVERRIDE; 43 virtual void ReadDirectoryOnTaskRunnerThread( 44 scoped_ptr<storage::FileSystemOperationContext> context, 45 const storage::FileSystemURL& url, 46 const ReadDirectoryCallback& callback) OVERRIDE; 47 virtual void CreateSnapshotFileOnTaskRunnerThread( 48 scoped_ptr<storage::FileSystemOperationContext> context, 49 const storage::FileSystemURL& url, 50 const CreateSnapshotFileCallback& callback) OVERRIDE; 51 virtual base::File::Error GetFileInfoSync( 52 storage::FileSystemOperationContext* context, 53 const storage::FileSystemURL& url, 54 base::File::Info* file_info, 55 base::FilePath* platform_path) OVERRIDE; 56 virtual base::File::Error ReadDirectorySync( 57 storage::FileSystemOperationContext* context, 58 const storage::FileSystemURL& url, 59 EntryList* file_list) OVERRIDE; 60 virtual base::File::Error DeleteDirectorySync( 61 storage::FileSystemOperationContext* context, 62 const storage::FileSystemURL& url) OVERRIDE; 63 virtual base::File::Error DeleteFileSync( 64 storage::FileSystemOperationContext* context, 65 const storage::FileSystemURL& url) OVERRIDE; 66 virtual base::File::Error GetLocalFilePath( 67 storage::FileSystemOperationContext* context, 68 const storage::FileSystemURL& url, 69 base::FilePath* local_file_path) OVERRIDE; 70 71 private: 72 void GetFileInfoWithFreshDataProvider( 73 scoped_ptr<storage::FileSystemOperationContext> context, 74 const storage::FileSystemURL& url, 75 const GetFileInfoCallback& callback, 76 bool valid_parse); 77 void ReadDirectoryWithFreshDataProvider( 78 scoped_ptr<storage::FileSystemOperationContext> context, 79 const storage::FileSystemURL& url, 80 const ReadDirectoryCallback& callback, 81 bool valid_parse); 82 virtual void CreateSnapshotFileWithFreshDataProvider( 83 scoped_ptr<storage::FileSystemOperationContext> context, 84 const storage::FileSystemURL& url, 85 const CreateSnapshotFileCallback& callback, 86 bool valid_parse); 87 88 virtual IPhotoDataProvider* GetDataProvider(); 89 90 base::WeakPtrFactory<IPhotoFileUtil> weak_factory_; 91 92 ImportedMediaGalleryRegistry* imported_registry_; 93 94 DISALLOW_COPY_AND_ASSIGN(IPhotoFileUtil); 95}; 96 97} // namespace iphoto 98 99#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IPHOTO_FILE_UTIL_H_ 100