| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/media_galleries/fileapi/picasa_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/picasa_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return error; | 200 return error; |
| 201 | 201 |
| 202 if (!file_info.is_directory) | 202 if (!file_info.is_directory) |
| 203 return base::File::FILE_ERROR_NOT_A_DIRECTORY; | 203 return base::File::FILE_ERROR_NOT_A_DIRECTORY; |
| 204 | 204 |
| 205 std::vector<std::string> components = GetVirtualPathComponents(url); | 205 std::vector<std::string> components = GetVirtualPathComponents(url); |
| 206 switch (components.size()) { | 206 switch (components.size()) { |
| 207 case 0: { | 207 case 0: { |
| 208 // Root directory. | 208 // Root directory. |
| 209 file_list->push_back( | 209 file_list->push_back( |
| 210 DirectoryEntry(kPicasaDirAlbums, DirectoryEntry::DIRECTORY, 0, | 210 DirectoryEntry(kPicasaDirAlbums, DirectoryEntry::DIRECTORY)); |
| 211 base::Time())); | |
| 212 file_list->push_back( | 211 file_list->push_back( |
| 213 DirectoryEntry(kPicasaDirFolders, DirectoryEntry::DIRECTORY, 0, | 212 DirectoryEntry(kPicasaDirFolders, DirectoryEntry::DIRECTORY)); |
| 214 base::Time())); | |
| 215 break; | 213 break; |
| 216 } | 214 } |
| 217 case 1: | 215 case 1: |
| 218 if (components[0] == kPicasaDirAlbums) { | 216 if (components[0] == kPicasaDirAlbums) { |
| 219 scoped_ptr<AlbumMap> albums = GetDataProvider()->GetAlbums(); | 217 scoped_ptr<AlbumMap> albums = GetDataProvider()->GetAlbums(); |
| 220 if (!albums) | 218 if (!albums) |
| 221 return base::File::FILE_ERROR_NOT_FOUND; | 219 return base::File::FILE_ERROR_NOT_FOUND; |
| 222 | 220 |
| 223 for (AlbumMap::const_iterator it = albums->begin(); | 221 for (AlbumMap::const_iterator it = albums->begin(); |
| 224 it != albums->end(); ++it) { | 222 it != albums->end(); ++it) { |
| 225 file_list->push_back( | 223 file_list->push_back( |
| 226 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, | 224 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY)); |
| 227 it->second.timestamp)); | |
| 228 } | 225 } |
| 229 } else if (components[0] == kPicasaDirFolders) { | 226 } else if (components[0] == kPicasaDirFolders) { |
| 230 scoped_ptr<AlbumMap> folders = GetDataProvider()->GetFolders(); | 227 scoped_ptr<AlbumMap> folders = GetDataProvider()->GetFolders(); |
| 231 if (!folders) | 228 if (!folders) |
| 232 return base::File::FILE_ERROR_NOT_FOUND; | 229 return base::File::FILE_ERROR_NOT_FOUND; |
| 233 | 230 |
| 234 for (AlbumMap::const_iterator it = folders->begin(); | 231 for (AlbumMap::const_iterator it = folders->begin(); |
| 235 it != folders->end(); ++it) { | 232 it != folders->end(); ++it) { |
| 236 file_list->push_back( | 233 file_list->push_back( |
| 237 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, | 234 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY)); |
| 238 it->second.timestamp)); | |
| 239 } | 235 } |
| 240 } | 236 } |
| 241 break; | 237 break; |
| 242 case 2: | 238 case 2: |
| 243 if (components[0] == kPicasaDirAlbums) { | 239 if (components[0] == kPicasaDirAlbums) { |
| 244 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); | 240 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); |
| 245 AlbumInfo album_info; | 241 AlbumInfo album_info; |
| 246 base::File::Error error = | 242 base::File::Error error = |
| 247 FindAlbumInfo(components[1], album_map.get(), &album_info); | 243 FindAlbumInfo(components[1], album_map.get(), &album_info); |
| 248 if (error != base::File::FILE_OK) | 244 if (error != base::File::FILE_OK) |
| 249 return error; | 245 return error; |
| 250 | 246 |
| 251 scoped_ptr<AlbumImages> album_images = | 247 scoped_ptr<AlbumImages> album_images = |
| 252 GetDataProvider()->FindAlbumImages(album_info.uid, &error); | 248 GetDataProvider()->FindAlbumImages(album_info.uid, &error); |
| 253 if (error != base::File::FILE_OK) | 249 if (error != base::File::FILE_OK) |
| 254 return error; | 250 return error; |
| 255 | 251 |
| 256 for (AlbumImages::const_iterator it = album_images->begin(); | 252 for (AlbumImages::const_iterator it = album_images->begin(); |
| 257 it != album_images->end(); | 253 it != album_images->end(); |
| 258 ++it) { | 254 ++it) { |
| 259 storage::DirectoryEntry entry; | 255 storage::DirectoryEntry entry; |
| 260 base::File::Info info; | 256 base::File::Info info; |
| 261 | 257 |
| 262 // Simply skip files that we can't get info on. | 258 // Simply skip files that we can't get info on. |
| 263 if (storage::NativeFileUtil::GetFileInfo(it->second, &info) != | 259 if (storage::NativeFileUtil::GetFileInfo(it->second, &info) != |
| 264 base::File::FILE_OK) { | 260 base::File::FILE_OK) { |
| 265 continue; | 261 continue; |
| 266 } | 262 } |
| 267 | 263 |
| 268 file_list->push_back(DirectoryEntry( | 264 file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE)); |
| 269 it->first, DirectoryEntry::FILE, info.size, info.last_modified)); | |
| 270 } | 265 } |
| 271 } | 266 } |
| 272 | 267 |
| 273 if (components[0] == kPicasaDirFolders) { | 268 if (components[0] == kPicasaDirFolders) { |
| 274 EntryList super_list; | 269 EntryList super_list; |
| 275 base::File::Error error = | 270 base::File::Error error = |
| 276 NativeMediaFileUtil::ReadDirectorySync(context, url, &super_list); | 271 NativeMediaFileUtil::ReadDirectorySync(context, url, &super_list); |
| 277 if (error != base::File::FILE_OK) | 272 if (error != base::File::FILE_OK) |
| 278 return error; | 273 return error; |
| 279 | 274 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 393 } |
| 399 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread( | 394 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread( |
| 400 context.Pass(), url, callback); | 395 context.Pass(), url, callback); |
| 401 } | 396 } |
| 402 | 397 |
| 403 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { | 398 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { |
| 404 return ImportedMediaGalleryRegistry::PicasaDataProvider(); | 399 return ImportedMediaGalleryRegistry::PicasaDataProvider(); |
| 405 } | 400 } |
| 406 | 401 |
| 407 } // namespace picasa | 402 } // namespace picasa |
| OLD | NEW |