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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 return found->second; | 819 return found->second; |
820 } | 820 } |
821 | 821 |
822 base::FilePath MediaGalleriesPreferences::LookUpGalleryPathForExtension( | 822 base::FilePath MediaGalleriesPreferences::LookUpGalleryPathForExtension( |
823 MediaGalleryPrefId gallery_id, | 823 MediaGalleryPrefId gallery_id, |
824 const extensions::Extension* extension, | 824 const extensions::Extension* extension, |
825 bool include_unpermitted_galleries) { | 825 bool include_unpermitted_galleries) { |
826 DCHECK(IsInitialized()); | 826 DCHECK(IsInitialized()); |
827 DCHECK(extension); | 827 DCHECK(extension); |
828 if (!include_unpermitted_galleries && | 828 if (!include_unpermitted_galleries && |
829 !ContainsKey(GalleriesForExtension(*extension), gallery_id)) | 829 !base::ContainsKey(GalleriesForExtension(*extension), gallery_id)) |
830 return base::FilePath(); | 830 return base::FilePath(); |
831 | 831 |
832 MediaGalleriesPrefInfoMap::const_iterator it = | 832 MediaGalleriesPrefInfoMap::const_iterator it = |
833 known_galleries_.find(gallery_id); | 833 known_galleries_.find(gallery_id); |
834 if (it == known_galleries_.end()) | 834 if (it == known_galleries_.end()) |
835 return base::FilePath(); | 835 return base::FilePath(); |
836 | 836 |
837 // This seems wrong: it just returns the absolute path to the device, which | 837 // This seems wrong: it just returns the absolute path to the device, which |
838 // is not necessarily the gallery path. | 838 // is not necessarily the gallery path. |
839 return MediaStorageUtil::FindDevicePathById(it->second.device_id); | 839 return MediaStorageUtil::FindDevicePathById(it->second.device_id); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 } | 1143 } |
1144 | 1144 |
1145 void MediaGalleriesPreferences::EraseOrBlacklistGalleryById( | 1145 void MediaGalleriesPreferences::EraseOrBlacklistGalleryById( |
1146 MediaGalleryPrefId id, bool erase) { | 1146 MediaGalleryPrefId id, bool erase) { |
1147 DCHECK(IsInitialized()); | 1147 DCHECK(IsInitialized()); |
1148 PrefService* prefs = profile_->GetPrefs(); | 1148 PrefService* prefs = profile_->GetPrefs(); |
1149 std::unique_ptr<ListPrefUpdate> update( | 1149 std::unique_ptr<ListPrefUpdate> update( |
1150 new ListPrefUpdate(prefs, prefs::kMediaGalleriesRememberedGalleries)); | 1150 new ListPrefUpdate(prefs, prefs::kMediaGalleriesRememberedGalleries)); |
1151 base::ListValue* list = update->Get(); | 1151 base::ListValue* list = update->Get(); |
1152 | 1152 |
1153 if (!ContainsKey(known_galleries_, id)) | 1153 if (!base::ContainsKey(known_galleries_, id)) |
1154 return; | 1154 return; |
1155 | 1155 |
1156 for (base::ListValue::iterator iter = list->begin(); | 1156 for (base::ListValue::iterator iter = list->begin(); |
1157 iter != list->end(); ++iter) { | 1157 iter != list->end(); ++iter) { |
1158 base::DictionaryValue* dict; | 1158 base::DictionaryValue* dict; |
1159 MediaGalleryPrefId iter_id; | 1159 MediaGalleryPrefId iter_id; |
1160 if ((*iter)->GetAsDictionary(&dict) && GetPrefId(*dict, &iter_id) && | 1160 if ((*iter)->GetAsDictionary(&dict) && GetPrefId(*dict, &iter_id) && |
1161 id == iter_id) { | 1161 id == iter_id) { |
1162 RemoveGalleryPermissionsFromPrefs(id); | 1162 RemoveGalleryPermissionsFromPrefs(id); |
1163 MediaGalleryPrefInfo::Type type; | 1163 MediaGalleryPrefInfo::Type type; |
(...skipping 20 matching lines...) Expand all Loading... |
1184 gallery_change_observers_, | 1184 gallery_change_observers_, |
1185 OnGalleryRemoved(this, id)); | 1185 OnGalleryRemoved(this, id)); |
1186 return; | 1186 return; |
1187 } | 1187 } |
1188 } | 1188 } |
1189 } | 1189 } |
1190 | 1190 |
1191 bool MediaGalleriesPreferences::NonAutoGalleryHasPermission( | 1191 bool MediaGalleriesPreferences::NonAutoGalleryHasPermission( |
1192 MediaGalleryPrefId id) const { | 1192 MediaGalleryPrefId id) const { |
1193 DCHECK(IsInitialized()); | 1193 DCHECK(IsInitialized()); |
1194 DCHECK(!ContainsKey(known_galleries_, id) || | 1194 DCHECK(!base::ContainsKey(known_galleries_, id) || |
1195 known_galleries_.find(id)->second.type != | 1195 known_galleries_.find(id)->second.type != |
1196 MediaGalleryPrefInfo::kAutoDetected); | 1196 MediaGalleryPrefInfo::kAutoDetected); |
1197 ExtensionPrefs* prefs = GetExtensionPrefs(); | 1197 ExtensionPrefs* prefs = GetExtensionPrefs(); |
1198 const base::DictionaryValue* extensions = | 1198 const base::DictionaryValue* extensions = |
1199 prefs->pref_service()->GetDictionary(extensions::pref_names::kExtensions); | 1199 prefs->pref_service()->GetDictionary(extensions::pref_names::kExtensions); |
1200 if (!extensions) | 1200 if (!extensions) |
1201 return true; | 1201 return true; |
1202 | 1202 |
1203 for (base::DictionaryValue::Iterator iter(*extensions); !iter.IsAtEnd(); | 1203 for (base::DictionaryValue::Iterator iter(*extensions); !iter.IsAtEnd(); |
1204 iter.Advance()) { | 1204 iter.Advance()) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 if (extension_prefs_for_testing_) | 1437 if (extension_prefs_for_testing_) |
1438 return extension_prefs_for_testing_; | 1438 return extension_prefs_for_testing_; |
1439 return extensions::ExtensionPrefs::Get(profile_); | 1439 return extensions::ExtensionPrefs::Get(profile_); |
1440 } | 1440 } |
1441 | 1441 |
1442 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1442 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1443 extensions::ExtensionPrefs* extension_prefs) { | 1443 extensions::ExtensionPrefs* extension_prefs) { |
1444 DCHECK(IsInitialized()); | 1444 DCHECK(IsInitialized()); |
1445 extension_prefs_for_testing_ = extension_prefs; | 1445 extension_prefs_for_testing_ = extension_prefs; |
1446 } | 1446 } |
OLD | NEW |