Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/media_galleries/media_galleries_preferences.cc

Issue 329643002: Media Galleries: Allow readding blacklisted iApps libraries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a short unittest for the preferences lookup Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
vandebo (ex-Chrome) 2014/06/11 18:36:46 If PathIndicates... checks the device type instead
tommycli 2014/06/11 19:26:39 Done.
676 bool match = false;
677 if (StorageInfo::IsIPhotoDevice(device_id)) {
678 match = iapps::PathIndicatesIPhotoLibrary(device_id, path);
679 } else if (StorageInfo::IsITunesDevice(device_id)) {
680 match = iapps::PathIndicatesITunesLibrary(device_id, path);
681 }
682
683 if (match) {
684 *gallery_info = it->second;
685 return true;
686 }
687 }
688
671 StorageInfo info; 689 StorageInfo info;
672 base::FilePath relative_path; 690 base::FilePath relative_path;
673 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) { 691 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) {
674 if (gallery_info) 692 if (gallery_info)
675 *gallery_info = MediaGalleryPrefInfo(); 693 *gallery_info = MediaGalleryPrefInfo();
676 return false; 694 return false;
677 } 695 }
678 696
679 relative_path = relative_path.NormalizePathSeparators(); 697 relative_path = relative_path.NormalizePathSeparators();
680 MediaGalleryPrefIdSet galleries_on_device = 698 MediaGalleryPrefIdSet galleries_on_device =
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 if (extension_prefs_for_testing_) 1256 if (extension_prefs_for_testing_)
1239 return extension_prefs_for_testing_; 1257 return extension_prefs_for_testing_;
1240 return extensions::ExtensionPrefs::Get(profile_); 1258 return extensions::ExtensionPrefs::Get(profile_);
1241 } 1259 }
1242 1260
1243 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( 1261 void MediaGalleriesPreferences::SetExtensionPrefsForTesting(
1244 extensions::ExtensionPrefs* extension_prefs) { 1262 extensions::ExtensionPrefs* extension_prefs) {
1245 DCHECK(IsInitialized()); 1263 DCHECK(IsInitialized());
1246 extension_prefs_for_testing_ = extension_prefs; 1264 extension_prefs_for_testing_ = extension_prefs;
1247 } 1265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698