| 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 = |
| 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)) |
| 679 continue; |
| 680 |
| 681 if (device_type == StorageInfo::Type::IPHOTO || |
| 682 device_type == StorageInfo::Type::ITUNES) { |
| 683 if (iapps::PathWithinIAppsLibrary(unique_id, path)) { |
| 684 *gallery_info = it->second; |
| 685 return true; |
| 686 } |
| 687 } |
| 688 } |
| 689 |
| 671 StorageInfo info; | 690 StorageInfo info; |
| 672 base::FilePath relative_path; | 691 base::FilePath relative_path; |
| 673 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { | 692 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { |
| 674 if (gallery_info) | 693 if (gallery_info) |
| 675 *gallery_info = MediaGalleryPrefInfo(); | 694 *gallery_info = MediaGalleryPrefInfo(); |
| 676 return false; | 695 return false; |
| 677 } | 696 } |
| 678 | 697 |
| 679 relative_path = relative_path.NormalizePathSeparators(); | 698 relative_path = relative_path.NormalizePathSeparators(); |
| 680 MediaGalleryPrefIdSet galleries_on_device = | 699 MediaGalleryPrefIdSet galleries_on_device = |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 if (extension_prefs_for_testing_) | 1257 if (extension_prefs_for_testing_) |
| 1239 return extension_prefs_for_testing_; | 1258 return extension_prefs_for_testing_; |
| 1240 return extensions::ExtensionPrefs::Get(profile_); | 1259 return extensions::ExtensionPrefs::Get(profile_); |
| 1241 } | 1260 } |
| 1242 | 1261 |
| 1243 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1262 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
| 1244 extensions::ExtensionPrefs* extension_prefs) { | 1263 extensions::ExtensionPrefs* extension_prefs) { |
| 1245 DCHECK(IsInitialized()); | 1264 DCHECK(IsInitialized()); |
| 1246 extension_prefs_for_testing_ = extension_prefs; | 1265 extension_prefs_for_testing_ = extension_prefs; |
| 1247 } | 1266 } |
| OLD | NEW |