| 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 if (iapps::PathIndicatesIPhotoLibrary(device_id, path) || |
| 677 iapps::PathIndicatesITunesLibrary(device_id, path)) { |
| 678 *gallery_info = it->second; |
| 679 return true; |
| 680 } |
| 681 } |
| 682 |
| 671 StorageInfo info; | 683 StorageInfo info; |
| 672 base::FilePath relative_path; | 684 base::FilePath relative_path; |
| 673 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { | 685 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { |
| 674 if (gallery_info) | 686 if (gallery_info) |
| 675 *gallery_info = MediaGalleryPrefInfo(); | 687 *gallery_info = MediaGalleryPrefInfo(); |
| 676 return false; | 688 return false; |
| 677 } | 689 } |
| 678 | 690 |
| 679 relative_path = relative_path.NormalizePathSeparators(); | 691 relative_path = relative_path.NormalizePathSeparators(); |
| 680 MediaGalleryPrefIdSet galleries_on_device = | 692 MediaGalleryPrefIdSet galleries_on_device = |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 if (extension_prefs_for_testing_) | 1250 if (extension_prefs_for_testing_) |
| 1239 return extension_prefs_for_testing_; | 1251 return extension_prefs_for_testing_; |
| 1240 return extensions::ExtensionPrefs::Get(profile_); | 1252 return extensions::ExtensionPrefs::Get(profile_); |
| 1241 } | 1253 } |
| 1242 | 1254 |
| 1243 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1255 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
| 1244 extensions::ExtensionPrefs* extension_prefs) { | 1256 extensions::ExtensionPrefs* extension_prefs) { |
| 1245 DCHECK(IsInitialized()); | 1257 DCHECK(IsInitialized()); |
| 1246 extension_prefs_for_testing_ = extension_prefs; | 1258 extension_prefs_for_testing_ = extension_prefs; |
| 1247 } | 1259 } |
| OLD | NEW |