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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/basictypes.h" | |
14 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
18 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
21 #include "components/storage_monitor/removable_storage_observer.h" | 23 #include "components/storage_monitor/removable_storage_observer.h" |
22 | 24 |
23 class Profile; | 25 class Profile; |
24 | 26 |
25 namespace base { | 27 namespace base { |
26 class DictionaryValue; | 28 class DictionaryValue; |
27 } | 29 } |
28 | 30 |
29 namespace extensions { | 31 namespace extensions { |
30 class Extension; | 32 class Extension; |
31 class ExtensionPrefs; | 33 class ExtensionPrefs; |
32 } | 34 } |
33 | 35 |
34 namespace user_prefs { | 36 namespace user_prefs { |
35 class PrefRegistrySyncable; | 37 class PrefRegistrySyncable; |
36 } | 38 } |
37 | 39 |
38 typedef uint64 MediaGalleryPrefId; | 40 typedef uint64_t MediaGalleryPrefId; |
39 const MediaGalleryPrefId kInvalidMediaGalleryPrefId = 0; | 41 const MediaGalleryPrefId kInvalidMediaGalleryPrefId = 0; |
40 | 42 |
41 const char kMediaGalleriesPrefsVersionKey[] = "preferencesVersion"; | 43 const char kMediaGalleriesPrefsVersionKey[] = "preferencesVersion"; |
42 const char kMediaGalleriesDefaultGalleryTypeKey[] = "defaultGalleryType"; | 44 const char kMediaGalleriesDefaultGalleryTypeKey[] = "defaultGalleryType"; |
43 | 45 |
44 struct MediaGalleryPermission { | 46 struct MediaGalleryPermission { |
45 MediaGalleryPrefId pref_id; | 47 MediaGalleryPrefId pref_id; |
46 bool has_permission; | 48 bool has_permission; |
47 }; | 49 }; |
48 | 50 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Vendor name for the volume/device on which the gallery is located. | 98 // Vendor name for the volume/device on which the gallery is located. |
97 // Will be empty if unknown. | 99 // Will be empty if unknown. |
98 base::string16 vendor_name; | 100 base::string16 vendor_name; |
99 | 101 |
100 // Model name for the volume/device on which the gallery is located. | 102 // Model name for the volume/device on which the gallery is located. |
101 // Will be empty if unknown. | 103 // Will be empty if unknown. |
102 base::string16 model_name; | 104 base::string16 model_name; |
103 | 105 |
104 // The capacity in bytes of the volume/device on which the gallery is | 106 // The capacity in bytes of the volume/device on which the gallery is |
105 // located. Will be zero if unknown. | 107 // located. Will be zero if unknown. |
106 uint64 total_size_in_bytes; | 108 uint64_t total_size_in_bytes; |
107 | 109 |
108 // If the gallery is on a removable device, the time that device was last | 110 // If the gallery is on a removable device, the time that device was last |
109 // attached. It is stored in preferences by the base::Time internal value, | 111 // attached. It is stored in preferences by the base::Time internal value, |
110 // which is microseconds since the epoch. | 112 // which is microseconds since the epoch. |
111 base::Time last_attach_time; | 113 base::Time last_attach_time; |
112 | 114 |
113 // Set to true if the volume metadata fields (volume_label, vendor_name, | 115 // Set to true if the volume metadata fields (volume_label, vendor_name, |
114 // model_name, total_size_in_bytes) were set. False if these fields were | 116 // model_name, total_size_in_bytes) were set. False if these fields were |
115 // never written. | 117 // never written. |
116 bool volume_metadata_valid; | 118 bool volume_metadata_valid; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 228 |
227 // Teaches the registry about a new gallery. If the gallery is in a | 229 // Teaches the registry about a new gallery. If the gallery is in a |
228 // blacklisted state, it is unblacklisted. |type| should not be a blacklisted | 230 // blacklisted state, it is unblacklisted. |type| should not be a blacklisted |
229 // type. Returns the gallery's pref id. | 231 // type. Returns the gallery's pref id. |
230 MediaGalleryPrefId AddGallery(const std::string& device_id, | 232 MediaGalleryPrefId AddGallery(const std::string& device_id, |
231 const base::FilePath& relative_path, | 233 const base::FilePath& relative_path, |
232 MediaGalleryPrefInfo::Type type, | 234 MediaGalleryPrefInfo::Type type, |
233 const base::string16& volume_label, | 235 const base::string16& volume_label, |
234 const base::string16& vendor_name, | 236 const base::string16& vendor_name, |
235 const base::string16& model_name, | 237 const base::string16& model_name, |
236 uint64 total_size_in_bytes, | 238 uint64_t total_size_in_bytes, |
237 base::Time last_attach_time, | 239 base::Time last_attach_time, |
238 int audio_count, | 240 int audio_count, |
239 int image_count, | 241 int image_count, |
240 int video_count); | 242 int video_count); |
241 | 243 |
242 // Teach the registry about a gallery simply from the path. If the gallery is | 244 // Teach the registry about a gallery simply from the path. If the gallery is |
243 // in a blacklisted state, it is unblacklisted. |type| should not be a | 245 // in a blacklisted state, it is unblacklisted. |type| should not be a |
244 // blacklisted type. Returns the gallery's pref id. | 246 // blacklisted type. Returns the gallery's pref id. |
245 MediaGalleryPrefId AddGalleryByPath(const base::FilePath& path, | 247 MediaGalleryPrefId AddGalleryByPath(const base::FilePath& path, |
246 MediaGalleryPrefInfo::Type type); | 248 MediaGalleryPrefInfo::Type type); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // existing gallery with the given device_id if one exists. | 325 // existing gallery with the given device_id if one exists. |
324 // TODO(orenb): Simplify this and reduce the number of parameters. | 326 // TODO(orenb): Simplify this and reduce the number of parameters. |
325 MediaGalleryPrefId AddOrUpdateGalleryInternal( | 327 MediaGalleryPrefId AddOrUpdateGalleryInternal( |
326 const std::string& device_id, | 328 const std::string& device_id, |
327 const base::string16& display_name, | 329 const base::string16& display_name, |
328 const base::FilePath& relative_path, | 330 const base::FilePath& relative_path, |
329 MediaGalleryPrefInfo::Type type, | 331 MediaGalleryPrefInfo::Type type, |
330 const base::string16& volume_label, | 332 const base::string16& volume_label, |
331 const base::string16& vendor_name, | 333 const base::string16& vendor_name, |
332 const base::string16& model_name, | 334 const base::string16& model_name, |
333 uint64 total_size_in_bytes, | 335 uint64_t total_size_in_bytes, |
334 base::Time last_attach_time, | 336 base::Time last_attach_time, |
335 bool volume_metadata_valid, | 337 bool volume_metadata_valid, |
336 int audio_count, | 338 int audio_count, |
337 int image_count, | 339 int image_count, |
338 int video_count, | 340 int video_count, |
339 int prefs_version, | 341 int prefs_version, |
340 MediaGalleryPrefInfo::DefaultGalleryType default_gallery_type); | 342 MediaGalleryPrefInfo::DefaultGalleryType default_gallery_type); |
341 | 343 |
342 void EraseOrBlacklistGalleryById(MediaGalleryPrefId id, bool erase); | 344 void EraseOrBlacklistGalleryById(MediaGalleryPrefId id, bool erase); |
343 | 345 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 DeviceIdPrefIdsMap device_map_; | 397 DeviceIdPrefIdsMap device_map_; |
396 | 398 |
397 base::ObserverList<GalleryChangeObserver> gallery_change_observers_; | 399 base::ObserverList<GalleryChangeObserver> gallery_change_observers_; |
398 | 400 |
399 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_; | 401 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_; |
400 | 402 |
401 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); | 403 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); |
402 }; | 404 }; |
403 | 405 |
404 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ | 406 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ |
OLD | NEW |