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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 MediaGalleryPrefId pref_id) {} | 172 MediaGalleryPrefId pref_id) {} |
173 | 173 |
174 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, | 174 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, |
175 MediaGalleryPrefId pref_id) {} | 175 MediaGalleryPrefId pref_id) {} |
176 | 176 |
177 protected: | 177 protected: |
178 virtual ~GalleryChangeObserver(); | 178 virtual ~GalleryChangeObserver(); |
179 }; | 179 }; |
180 | 180 |
181 explicit MediaGalleriesPreferences(Profile* profile); | 181 explicit MediaGalleriesPreferences(Profile* profile); |
182 virtual ~MediaGalleriesPreferences(); | 182 ~MediaGalleriesPreferences() override; |
183 | 183 |
184 // Ensures that the preferences is initialized. The provided callback, if | 184 // Ensures that the preferences is initialized. The provided callback, if |
185 // non-null, will be called when initialization is complete. If initialization | 185 // non-null, will be called when initialization is complete. If initialization |
186 // has already completed, this callback will be invoked in the calling stack. | 186 // has already completed, this callback will be invoked in the calling stack. |
187 // Before the callback is run, other calls may not return the correct results. | 187 // Before the callback is run, other calls may not return the correct results. |
188 // Should be invoked on the UI thread; callbacks will be run on the UI thread. | 188 // Should be invoked on the UI thread; callbacks will be run on the UI thread. |
189 // This call also ensures that the StorageMonitor is initialized. | 189 // This call also ensures that the StorageMonitor is initialized. |
190 // Note for unit tests: This requires an active FILE thread and | 190 // Note for unit tests: This requires an active FILE thread and |
191 // EnsureMediaDirectoriesExists instance to complete reliably. | 191 // EnsureMediaDirectoriesExists instance to complete reliably. |
192 void EnsureInitialized(base::Closure callback); | 192 void EnsureInitialized(base::Closure callback); |
193 | 193 |
194 // Return true if the storage monitor has already been initialized. | 194 // Return true if the storage monitor has already been initialized. |
195 bool IsInitialized() const; | 195 bool IsInitialized() const; |
196 | 196 |
197 Profile* profile(); | 197 Profile* profile(); |
198 | 198 |
199 void AddGalleryChangeObserver(GalleryChangeObserver* observer); | 199 void AddGalleryChangeObserver(GalleryChangeObserver* observer); |
200 void RemoveGalleryChangeObserver(GalleryChangeObserver* observer); | 200 void RemoveGalleryChangeObserver(GalleryChangeObserver* observer); |
201 | 201 |
202 // RemovableStorageObserver implementation. | 202 // RemovableStorageObserver implementation. |
203 virtual void OnRemovableStorageAttached( | 203 void OnRemovableStorageAttached( |
204 const storage_monitor::StorageInfo& info) override; | 204 const storage_monitor::StorageInfo& info) override; |
205 | 205 |
206 // Lookup a media gallery and fill in information about it and return true if | 206 // Lookup a media gallery and fill in information about it and return true if |
207 // it exists. Return false if it does not, filling in default information. | 207 // it exists. Return false if it does not, filling in default information. |
208 bool LookUpGalleryByPath(const base::FilePath& path, | 208 bool LookUpGalleryByPath(const base::FilePath& path, |
209 MediaGalleryPrefInfo* gallery) const; | 209 MediaGalleryPrefInfo* gallery) const; |
210 | 210 |
211 MediaGalleryPrefIdSet LookUpGalleriesByDeviceId( | 211 MediaGalleryPrefIdSet LookUpGalleriesByDeviceId( |
212 const std::string& device_id) const; | 212 const std::string& device_id) const; |
213 | 213 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 bool has_permission); | 270 bool has_permission); |
271 | 271 |
272 const MediaGalleriesPrefInfoMap& known_galleries() const; | 272 const MediaGalleriesPrefInfoMap& known_galleries() const; |
273 | 273 |
274 // These keep track of when we last successfully completed a media scan. | 274 // These keep track of when we last successfully completed a media scan. |
275 // This is used to provide cached results when appropriate. | 275 // This is used to provide cached results when appropriate. |
276 base::Time GetLastScanCompletionTime() const; | 276 base::Time GetLastScanCompletionTime() const; |
277 void SetLastScanCompletionTime(const base::Time& time); | 277 void SetLastScanCompletionTime(const base::Time& time); |
278 | 278 |
279 // KeyedService implementation: | 279 // KeyedService implementation: |
280 virtual void Shutdown() override; | 280 void Shutdown() override; |
281 | 281 |
282 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 282 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
283 | 283 |
284 // Returns true if the media gallery preferences system has ever been used | 284 // Returns true if the media gallery preferences system has ever been used |
285 // for this profile. To be exact, it checks if a gallery has ever been added | 285 // for this profile. To be exact, it checks if a gallery has ever been added |
286 // (including defaults). | 286 // (including defaults). |
287 static bool APIHasBeenUsed(Profile* profile); | 287 static bool APIHasBeenUsed(Profile* profile); |
288 | 288 |
289 private: | 289 private: |
290 friend class MediaGalleriesPreferencesTest; | 290 friend class MediaGalleriesPreferencesTest; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 DeviceIdPrefIdsMap device_map_; | 395 DeviceIdPrefIdsMap device_map_; |
396 | 396 |
397 ObserverList<GalleryChangeObserver> gallery_change_observers_; | 397 ObserverList<GalleryChangeObserver> gallery_change_observers_; |
398 | 398 |
399 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_; | 399 base::WeakPtrFactory<MediaGalleriesPreferences> weak_factory_; |
400 | 400 |
401 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); | 401 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); |
402 }; | 402 }; |
403 | 403 |
404 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ | 404 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PREFERENCES_H_ |
OLD | NEW |