OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_galleries_preferences.h" | 5 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
6 | 6 |
7 #include "base/base_paths_posix.h" | 7 #include "base/base_paths_posix.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 AddGallery(info.device_id(), base::FilePath(), | 661 AddGallery(info.device_id(), base::FilePath(), |
662 MediaGalleryPrefInfo::kAutoDetected, info.storage_label(), | 662 MediaGalleryPrefInfo::kAutoDetected, info.storage_label(), |
663 info.vendor_name(), info.model_name(), info.total_size_in_bytes(), | 663 info.vendor_name(), info.model_name(), info.total_size_in_bytes(), |
664 base::Time::Now(), 0, 0, 0); | 664 base::Time::Now(), 0, 0, 0); |
665 } | 665 } |
666 | 666 |
667 bool MediaGalleriesPreferences::LookUpGalleryByPath( | 667 bool MediaGalleriesPreferences::LookUpGalleryByPath( |
668 const base::FilePath& path, | 668 const base::FilePath& path, |
669 MediaGalleryPrefInfo* gallery_info) const { | 669 MediaGalleryPrefInfo* gallery_info) const { |
670 DCHECK(IsInitialized()); | 670 DCHECK(IsInitialized()); |
671 | |
672 // First check if the path matches an imported gallery. | |
673 for (MediaGalleriesPrefInfoMap::const_iterator it = | |
vandebo (ex-Chrome)
2014/06/11 16:40:56
This is where cheating on the iTunes/iPhoto device
tommycli
2014/06/11 18:17:56
Yeah... it's true...
| |
674 known_galleries_.begin(); it != known_galleries_.end(); ++it) { | |
675 const std::string& device_id = it->second.device_id; | |
676 StorageInfo::Type device_type; | |
677 std::string unique_id; | |
678 if (!StorageInfo::CrackDeviceId(device_id, &device_type, &unique_id)) | |
vandebo (ex-Chrome)
2014/06/11 16:40:56
Instead of cracking it here, use StorageInfo::IsIT
tommycli
2014/06/11 18:17:56
Done.
| |
679 continue; | |
680 | |
681 bool match = false; | |
682 switch (device_type) { | |
683 case StorageInfo::Type::IPHOTO: | |
684 match = iapps::PathIndicatesIPhotoLibrary(unique_id, path); | |
685 break; | |
686 case StorageInfo::Type::ITUNES: | |
687 match = iapps::PathIndicatesITunesLibrary(unique_id, path); | |
688 break; | |
689 default: | |
690 break; | |
691 } | |
692 | |
693 if (match) { | |
694 *gallery_info = it->second; | |
695 return true; | |
696 } | |
697 } | |
698 | |
671 StorageInfo info; | 699 StorageInfo info; |
672 base::FilePath relative_path; | 700 base::FilePath relative_path; |
673 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { | 701 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { |
674 if (gallery_info) | 702 if (gallery_info) |
675 *gallery_info = MediaGalleryPrefInfo(); | 703 *gallery_info = MediaGalleryPrefInfo(); |
676 return false; | 704 return false; |
677 } | 705 } |
678 | 706 |
679 relative_path = relative_path.NormalizePathSeparators(); | 707 relative_path = relative_path.NormalizePathSeparators(); |
680 MediaGalleryPrefIdSet galleries_on_device = | 708 MediaGalleryPrefIdSet galleries_on_device = |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1238 if (extension_prefs_for_testing_) | 1266 if (extension_prefs_for_testing_) |
1239 return extension_prefs_for_testing_; | 1267 return extension_prefs_for_testing_; |
1240 return extensions::ExtensionPrefs::Get(profile_); | 1268 return extensions::ExtensionPrefs::Get(profile_); |
1241 } | 1269 } |
1242 | 1270 |
1243 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1271 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1244 extensions::ExtensionPrefs* extension_prefs) { | 1272 extensions::ExtensionPrefs* extension_prefs) { |
1245 DCHECK(IsInitialized()); | 1273 DCHECK(IsInitialized()); |
1246 extension_prefs_for_testing_ = extension_prefs; | 1274 extension_prefs_for_testing_ = extension_prefs; |
1247 } | 1275 } |
OLD | NEW |