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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 dict->SetString(kMediaGalleriesVolumeLabelKey, gallery.volume_label); | 245 dict->SetString(kMediaGalleriesVolumeLabelKey, gallery.volume_label); |
246 dict->SetString(kMediaGalleriesVendorNameKey, gallery.vendor_name); | 246 dict->SetString(kMediaGalleriesVendorNameKey, gallery.vendor_name); |
247 dict->SetString(kMediaGalleriesModelNameKey, gallery.model_name); | 247 dict->SetString(kMediaGalleriesModelNameKey, gallery.model_name); |
248 dict->SetDouble(kMediaGalleriesSizeKey, gallery.total_size_in_bytes); | 248 dict->SetDouble(kMediaGalleriesSizeKey, gallery.total_size_in_bytes); |
249 dict->SetDouble(kMediaGalleriesLastAttachTimeKey, | 249 dict->SetDouble(kMediaGalleriesLastAttachTimeKey, |
250 gallery.last_attach_time.ToInternalValue()); | 250 gallery.last_attach_time.ToInternalValue()); |
251 } else { | 251 } else { |
252 dict->SetString(kMediaGalleriesDisplayNameKey, gallery.display_name); | 252 dict->SetString(kMediaGalleriesDisplayNameKey, gallery.display_name); |
253 } | 253 } |
254 | 254 |
255 dict->SetInteger(kMediaGalleriesScanAudioCountKey, gallery.audio_count); | 255 if (gallery.audio_count || gallery.image_count || gallery.video_count) { |
256 dict->SetInteger(kMediaGalleriesScanImageCountKey, gallery.image_count); | 256 dict->SetInteger(kMediaGalleriesScanAudioCountKey, gallery.audio_count); |
257 dict->SetInteger(kMediaGalleriesScanVideoCountKey, gallery.video_count); | 257 dict->SetInteger(kMediaGalleriesScanImageCountKey, gallery.image_count); |
| 258 dict->SetInteger(kMediaGalleriesScanVideoCountKey, gallery.video_count); |
| 259 } |
258 | 260 |
259 // Version 0 of the prefs format was that the display_name was always | 261 // Version 0 of the prefs format was that the display_name was always |
260 // used to show the user-visible name of the gallery. Version 1 means | 262 // used to show the user-visible name of the gallery. Version 1 means |
261 // that there is an optional display_name, and when it is present, it | 263 // that there is an optional display_name, and when it is present, it |
262 // overrides the name that would be built from the volume metadata, path, | 264 // overrides the name that would be built from the volume metadata, path, |
263 // or whatever other data. So if we see a display_name with version 0, it | 265 // or whatever other data. So if we see a display_name with version 0, it |
264 // means it may be overwritten simply by getting new volume metadata. | 266 // means it may be overwritten simply by getting new volume metadata. |
265 // A display_name with version 1 should not be overwritten. | 267 // A display_name with version 1 should not be overwritten. |
266 dict->SetInteger(kMediaGalleriesPrefsVersionKey, gallery.prefs_version); | 268 dict->SetInteger(kMediaGalleriesPrefsVersionKey, gallery.prefs_version); |
267 | 269 |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 if (extension_prefs_for_testing_) | 1245 if (extension_prefs_for_testing_) |
1244 return extension_prefs_for_testing_; | 1246 return extension_prefs_for_testing_; |
1245 return extensions::ExtensionPrefs::Get(profile_); | 1247 return extensions::ExtensionPrefs::Get(profile_); |
1246 } | 1248 } |
1247 | 1249 |
1248 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1250 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1249 extensions::ExtensionPrefs* extension_prefs) { | 1251 extensions::ExtensionPrefs* extension_prefs) { |
1250 DCHECK(IsInitialized()); | 1252 DCHECK(IsInitialized()); |
1251 extension_prefs_for_testing_ = extension_prefs; | 1253 extension_prefs_for_testing_ = extension_prefs; |
1252 } | 1254 } |
OLD | NEW |