Skip to content

Commit

Permalink
Media Galleries Partial Deprecation: Remove iPhoto support.
Browse files Browse the repository at this point in the history
Axes about 2900 SLOC and iPhoto support. Affects Mac OSX only.

BUG=542912

Review URL: https://codereview.chromium.org/1805203002

Cr-Commit-Position: refs/heads/master@{#382034}
  • Loading branch information
tommycli authored and Commit bot committed Mar 18, 2016
1 parent 02158c8 commit a239a38
Show file tree
Hide file tree
Showing 51 changed files with 12 additions and 2,922 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ TEST_F(VolumeManagerTest, MTPPlugAndUnplug) {

storage_monitor::StorageInfo non_mtp_info(
storage_monitor::StorageInfo::MakeDeviceId(
storage_monitor::StorageInfo::IPHOTO, "dummy-device-id2"),
storage_monitor::StorageInfo::FIXED_MASS_STORAGE, "dummy-device-id2"),
FILE_PATH_LITERAL("/dummy/device/location2"),
base::UTF8ToUTF16("label2"),
base::UTF8ToUTF16("vendor2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,106 +234,6 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
}
#endif // defined(OS_WIN) || defined(OS_MACOSX)

#if defined(OS_MACOSX)
void PopulateIPhotoTestData(const base::FilePath& iphoto_data_root) {
std::string xml_contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<plist version=\"1.0\">"
"<dict>\n"

" <key>List of Albums</key>"
" <array>\n"

" <dict>\n"
" <key>AlbumId</key>"
" <integer>1</integer>"
" <key>AlbumName</key>"
" <string>Album1</string>"
" <key>KeyList</key>\n"
" <array>"
" <string>1</string>"
" <string>2</string>"
" </array>\n"
" </dict>\n"

" <dict>\n"
" <key>AlbumId</key>"
" <integer>2</integer>"
" <key>AlbumName</key>"
" <string>Album2</string>"
" <key>KeyList</key>\n"
" <array>"
" <string>2</string>"
" </array>\n"
" </dict>\n"

" </array>\n"

" <key>Master Image List</key>\n"
" <dict>\n"

" <key>1</key>"
" <dict>\n"
" <key>MediaType</key>"
" <string>Image</string>"
" <key>Caption</key>"
" <string>caption 1</string>"
" <key>GUID</key>"
" <string>1</string>"
" <key>ModDateAsTimerInterval</key>"
" <string>386221543.0000</string>"
" <key>DateAsTimerInterval</key>"
" <string>386221543.0000</string>"
" <key>DateAsTimerIntervalGMT</key>"
" <string>385123456.00</string>"
" <key>ImagePath</key>"
" <string>$path1</string>"
" <key>ThumbPath</key>"
" <string>/thumb/path</string>\n"
" </dict>\n"

" <key>2</key>\n"
" <dict>\n"
" <key>MediaType</key>"
" <string>Image</string>"
" <key>Caption</key>"
" <string>caption 2</string>"
" <key>GUID</key>"
" <string>2</string>"
" <key>ModDateAsTimerInterval</key>"
" <string>386221543.0000</string>"
" <key>DateAsTimerInterval</key>"
" <string>386221543.0000</string>"
" <key>DateAsTimerIntervalGMT</key>"
" <string>385123456.00</string>"
" <key>ImagePath</key>"
" <string>$path2</string>"
" <key>ThumbPath</key>"
" <string>/thumb/path2</string>\n"
" </dict>\n"

" </dict>\n" // Master Image List

"</dict>\n"
"</plist>";

base::FilePath test_jpg_path = GetCommonDataDir().AppendASCII("test.jpg");
ASSERT_TRUE(base::CreateDirectory(iphoto_data_root));
base::FilePath first_only_jpg =
iphoto_data_root.AppendASCII("InFirstAlbumOnly.jpg");
base::FilePath in_both_jpg = iphoto_data_root.AppendASCII("InBoth.jpg");
ASSERT_TRUE(base::CopyFile(test_jpg_path, first_only_jpg));
ASSERT_TRUE(base::CopyFile(test_jpg_path, in_both_jpg));
base::ReplaceFirstSubstringAfterOffset(
&xml_contents, 0, "$path1", first_only_jpg.value());
base::ReplaceFirstSubstringAfterOffset(
&xml_contents, 0, "$path2", in_both_jpg.value());

base::FilePath album_xml = iphoto_data_root.AppendASCII("AlbumData.xml");
ASSERT_NE(-1, base::WriteFile(album_xml,
xml_contents.c_str(), xml_contents.size()));
}
#endif // defined(OS_MACOSX)

base::FilePath GetCommonDataDir() const {
return test_data_dir_.AppendASCII("api_test")
.AppendASCII("media_galleries")
Expand Down Expand Up @@ -534,20 +434,6 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
}
#endif // defined(OS_WIN) || defined(OS_MACOSX)

#if defined(OS_MACOSX)
IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
IPhotoTest) {
PopulateIPhotoTestData(
ensure_media_directories_exists()->GetFakeIPhotoRootPath());

base::ListValue custom_args;
custom_args.AppendInteger(test_jpg_size());
ASSERT_TRUE(RunMediaGalleriesTestWithArg("iphoto", custom_args)) << message_;

iapps::SetMacPreferencesForTesting(NULL);
}
#endif // defined(OS_MACOSX)

IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, ToURL) {
RemoveAllGalleries();
MediaGalleryPrefId pref_id;
Expand Down
11 changes: 3 additions & 8 deletions chrome/browser/media_galleries/fileapi/iapps_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ namespace iapps {

typedef base::Callback<void(const std::string&)> IAppsFinderCallback;

// These methods look for the iTunes/iPhoto library in in an asynchronous
// These methods look for the iTunes library in in an asynchronous
// manner and call |callback| on the UI thread as soon as the result is known.
// If a library exists, |callback| gets the device id for the library. If a
// library does not exist, or the OS does not support iTunes/iPhoto, then
// |callback| gets an empty string.

void FindIPhotoLibrary(const IAppsFinderCallback& callback);
// library does not exist, or the OS does not support iTunes, then |callback|
// gets an empty string.

void FindITunesLibrary(const IAppsFinderCallback& callback);

// These methods returns true if |path| should be interpreted as the device
// indicated by |device_id|.

bool PathIndicatesIPhotoLibrary(const std::string& device_id,
const base::FilePath& path);

bool PathIndicatesITunesLibrary(const std::string& device_id,
const base::FilePath& path);

Expand Down
25 changes: 0 additions & 25 deletions chrome/browser/media_galleries/fileapi/iapps_finder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,13 @@ void FindIAppsOnFileThread(storage_monitor::StorageInfo::Type type,
base::Bind(task, base::Bind(PostResultToUIThread, type, callback)));
}

// iPhoto is only supported on OSX.
#if !defined(OS_MACOSX)
void FindIPhotoLibrary(const IAppsFinderCallback& callback) {
callback.Run(std::string());
}
#endif // !defined(OS_MACOSX)

// iTunes is only support on OSX and Windows.
#if !defined(OS_MACOSX) && !defined(OS_WIN)
void FindITunesLibrary(const IAppsFinderCallback& callback) {
callback.Run(std::string());
}
#endif

bool PathIndicatesIPhotoLibrary(const std::string& device_id,
const base::FilePath& path) {
storage_monitor::StorageInfo::Type device_type;
std::string unique_id;
storage_monitor::StorageInfo::CrackDeviceId(
device_id, &device_type, &unique_id);
if (device_type != storage_monitor::StorageInfo::IPHOTO)
return false;

// |unique_id| is the path to the library XML file at the library root.
base::FilePath library_root =
base::FilePath::FromUTF8Unsafe(unique_id).DirName();
return (path == library_root) ||
(path == library_root.AppendASCII("Data")) ||
(path == library_root.AppendASCII("Originals")) ||
(path == library_root.AppendASCII("Masters"));
}

bool PathIndicatesITunesLibrary(const std::string& device_id,
const base::FilePath& path) {
storage_monitor::StorageInfo::Type device_type;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/media_galleries/fileapi/iapps_finder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace iapps {

#if defined(OS_MACOSX)

extern NSString* const kIPhotoRecentDatabasesKey;
extern NSString* const kITunesRecentDatabasePathsKey;

// Set the mac preferences to use for testing. The caller continues to own
Expand Down
19 changes: 0 additions & 19 deletions chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,15 @@ void FindMostRecentDatabase(
callback.Run(most_recent_db_path.value());
}

base::FilePath ExtractIPhotoPath(NSString* path_ns) {
NSURL* url = [NSURL URLWithString:path_ns];
if (![url isFileURL])
return base::FilePath();

NSString* expanded_path_ns = [url path];
return base::mac::NSStringToFilePath(expanded_path_ns);
}

base::FilePath ExtractITunesPath(NSString* path_ns) {
NSString* expanded_path_ns = [path_ns stringByExpandingTildeInPath];
return base::mac::NSStringToFilePath(expanded_path_ns);
};

} // namespace

NSString* const kIPhotoRecentDatabasesKey = @"iPhotoRecentDatabases";
NSString* const kITunesRecentDatabasePathsKey = @"iTunesRecentDatabasePaths";

void FindIPhotoLibrary(const IAppsFinderCallback& callback) {
FindIAppsOnFileThread(
storage_monitor::StorageInfo::IPHOTO,
base::Bind(&FindMostRecentDatabase,
base::scoped_nsobject<NSString>(kIPhotoRecentDatabasesKey),
base::Bind(&ExtractIPhotoPath)),
callback);
}

void FindITunesLibrary(const IAppsFinderCallback& callback) {
FindIAppsOnFileThread(
storage_monitor::StorageInfo::ITUNES,
Expand Down
Loading

0 comments on commit a239a38

Please sign in to comment.