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> |
11 | 11 |
12 #include "base/base_paths_posix.h" | 12 #include "base/base_paths_posix.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/media_galleries/fileapi/iapps_finder.h" | 25 #include "chrome/browser/media_galleries/fileapi/iapps_finder.h" |
25 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h" | 26 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 out_gallery_info->model_name = model_name; | 278 out_gallery_info->model_name = model_name; |
278 out_gallery_info->total_size_in_bytes = total_size_in_bytes; | 279 out_gallery_info->total_size_in_bytes = total_size_in_bytes; |
279 out_gallery_info->last_attach_time = | 280 out_gallery_info->last_attach_time = |
280 base::Time::FromInternalValue(last_attach_time); | 281 base::Time::FromInternalValue(last_attach_time); |
281 out_gallery_info->volume_metadata_valid = volume_metadata_valid; | 282 out_gallery_info->volume_metadata_valid = volume_metadata_valid; |
282 out_gallery_info->prefs_version = prefs_version; | 283 out_gallery_info->prefs_version = prefs_version; |
283 out_gallery_info->default_gallery_type = GetDefaultGalleryType(dict); | 284 out_gallery_info->default_gallery_type = GetDefaultGalleryType(dict); |
284 return true; | 285 return true; |
285 } | 286 } |
286 | 287 |
287 base::DictionaryValue* CreateGalleryPrefInfoDictionary( | 288 std::unique_ptr<base::DictionaryValue> CreateGalleryPrefInfoDictionary( |
288 const MediaGalleryPrefInfo& gallery) { | 289 const MediaGalleryPrefInfo& gallery) { |
289 base::DictionaryValue* dict = new base::DictionaryValue(); | 290 auto dict = base::MakeUnique<base::DictionaryValue>(); |
290 dict->SetString(kMediaGalleriesPrefIdKey, | 291 dict->SetString(kMediaGalleriesPrefIdKey, |
291 base::Uint64ToString(gallery.pref_id)); | 292 base::Uint64ToString(gallery.pref_id)); |
292 dict->SetString(kMediaGalleriesDeviceIdKey, gallery.device_id); | 293 dict->SetString(kMediaGalleriesDeviceIdKey, gallery.device_id); |
293 dict->SetString(kMediaGalleriesPathKey, gallery.path.value()); | 294 dict->SetString(kMediaGalleriesPathKey, gallery.path.value()); |
294 dict->SetString(kMediaGalleriesTypeKey, TypeToStringValue(gallery.type)); | 295 dict->SetString(kMediaGalleriesTypeKey, TypeToStringValue(gallery.type)); |
295 | 296 |
296 if (gallery.default_gallery_type != MediaGalleryPrefInfo::kNotDefault) { | 297 if (gallery.default_gallery_type != MediaGalleryPrefInfo::kNotDefault) { |
297 dict->SetString(kMediaGalleriesDefaultGalleryTypeKey, | 298 dict->SetString(kMediaGalleriesDefaultGalleryTypeKey, |
298 DefaultGalleryTypeToStringValue( | 299 DefaultGalleryTypeToStringValue( |
299 gallery.default_gallery_type)); | 300 gallery.default_gallery_type)); |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 if (extension_prefs_for_testing_) | 1438 if (extension_prefs_for_testing_) |
1438 return extension_prefs_for_testing_; | 1439 return extension_prefs_for_testing_; |
1439 return extensions::ExtensionPrefs::Get(profile_); | 1440 return extensions::ExtensionPrefs::Get(profile_); |
1440 } | 1441 } |
1441 | 1442 |
1442 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1443 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1443 extensions::ExtensionPrefs* extension_prefs) { | 1444 extensions::ExtensionPrefs* extension_prefs) { |
1444 DCHECK(IsInitialized()); | 1445 DCHECK(IsInitialized()); |
1445 extension_prefs_for_testing_ = extension_prefs; | 1446 extension_prefs_for_testing_ = extension_prefs; |
1446 } | 1447 } |
OLD | NEW |