| Index: chrome/browser/media_gallery/media_galleries_preferences.h
|
| diff --git a/chrome/browser/media_gallery/media_galleries_preferences.h b/chrome/browser/media_gallery/media_galleries_preferences.h
|
| index 076606ec792be90e2f2f6a065ee8929bbd53c501..1e6efc62900e6ec6b1eb8fe5d5b45714d48ea343 100644
|
| --- a/chrome/browser/media_gallery/media_galleries_preferences.h
|
| +++ b/chrome/browser/media_gallery/media_galleries_preferences.h
|
| @@ -5,8 +5,9 @@
|
| #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
|
| #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
|
|
|
| -#include <list>
|
| +#include <map>
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/file_path.h"
|
| @@ -20,6 +21,13 @@ namespace base {
|
| class DictionaryValue;
|
| }
|
|
|
| +namespace extensions {
|
| +class Extension;
|
| +class ExtensionPrefs;
|
| +}
|
| +
|
| +namespace chrome {
|
| +
|
| typedef uint64 MediaGalleryPrefId;
|
|
|
| struct MediaGalleryPermission {
|
| @@ -27,33 +35,42 @@ struct MediaGalleryPermission {
|
| bool has_permission;
|
| };
|
|
|
| -struct MediaGallery {
|
| - MediaGallery();
|
| - ~MediaGallery();
|
| +struct MediaGalleryPrefInfo {
|
| + enum Type {
|
| + kAutoDetected, // Auto added to the list of galleries.
|
| + kUserAdded, // Explicitly added by the user.
|
| + kBlackListed, // Auto added but then removed by the user.
|
| + };
|
|
|
| - // The ID that uniquely, persistently identifies the gallery.
|
| - uint64 id;
|
| -
|
| - // The directory where the gallery is located, relative to the base path
|
| - // for the device.
|
| - FilePath path;
|
| + static const MediaGalleryPrefId kInvalidPrefId = 0;
|
|
|
| - // The base path of the device.
|
| - FilePath base_path;
|
| + MediaGalleryPrefInfo();
|
| + ~MediaGalleryPrefInfo();
|
|
|
| - // A string which identifies the device that the gallery lives on.
|
| - std::string identifier;
|
| + // The ID that identifies this gallery in this Profile.
|
| + MediaGalleryPrefId pref_id;
|
|
|
| // The user-visible name of this gallery.
|
| string16 display_name;
|
| +
|
| + // A string which uniquely and persistently identifies the device that the
|
| + // gallery lives on.
|
| + std::string device_id;
|
| +
|
| + // The root of the gallery, relative to the root of the device.
|
| + FilePath path;
|
| +
|
| + // The type of gallery.
|
| + Type type;
|
| };
|
|
|
| -// A class to manage the media galleries that the user has added, explicitly or
|
| -// otherwise. There is one registry per user profile.
|
| -// TODO(estade): should MediaFileSystemRegistry be merged into this class?
|
| +typedef std::map<MediaGalleryPrefId, MediaGalleryPrefInfo>
|
| + MediaGalleriesPrefInfoMap;
|
| +
|
| +// A class to manage the media gallery preferences. There is one registry per
|
| +// user profile.
|
| class MediaGalleriesPreferences : public ProfileKeyedService {
|
| public:
|
| - typedef std::list<MediaGallery> MediaGalleries;
|
|
|
| explicit MediaGalleriesPreferences(Profile* profile);
|
| virtual ~MediaGalleriesPreferences();
|
| @@ -61,15 +78,35 @@ class MediaGalleriesPreferences : public ProfileKeyedService {
|
| // Builds |remembered_galleries_| from the persistent store.
|
| void InitFromPrefs();
|
|
|
| - // Teaches the registry about a new gallery defined by |path| (which should
|
| - // be a directory).
|
| - void AddGalleryByPath(const FilePath& path);
|
| + // Lookup a media gallery and fill in information about it and return true.
|
| + // If the media gallery does not already exist, fill in as much of the
|
| + // MediaGalleryPrefInfo struct as we can and return false.
|
| + // TODO(vandebo) figure out if we want this to be async, in which case:
|
| + // void LookUpGalleryByPath(FilePath&path, callback(const MediaGalleryInfo&))
|
| + bool LookUpGalleryByPath(const FilePath& path,
|
| + MediaGalleryPrefInfo* gallery) const;
|
| +
|
| + // Teaches the registry about a new gallery.
|
| + MediaGalleryPrefId AddGallery(const std::string& device_id,
|
| + const string16& display_name,
|
| + const FilePath& path,
|
| + bool user_added);
|
| +
|
| + // Teach the registry about a user added registry simply from the path.
|
| + MediaGalleryPrefId AddGalleryByPath(const FilePath& path);
|
|
|
| // Removes the gallery identified by |id| from the store.
|
| - void ForgetGalleryById(uint64 id);
|
| + void ForgetGalleryById(MediaGalleryPrefId id);
|
|
|
| - const MediaGalleries& remembered_galleries() const {
|
| - return remembered_galleries_;
|
| + std::vector<MediaGalleryPrefId> GalleriesForExtension(
|
| + const extensions::Extension& extension) const;
|
| +
|
| + void SetGalleryPermissionForExtension(const extensions::Extension& extension,
|
| + MediaGalleryPrefId pref_id,
|
| + bool has_permission);
|
| +
|
| + const MediaGalleriesPrefInfoMap& known_galleries() const {
|
| + return known_galleries_;
|
| }
|
|
|
| // ProfileKeyedService implementation:
|
| @@ -85,10 +122,13 @@ class MediaGalleriesPreferences : public ProfileKeyedService {
|
| Profile* profile_;
|
|
|
| // An in-memory cache of known galleries.
|
| - // TODO(estade): either actually use this, or remove it.
|
| - MediaGalleries remembered_galleries_;
|
| + MediaGalleriesPrefInfoMap known_galleries_;
|
| +
|
| + extensions::ExtensionPrefs* GetExtensionPrefs() const;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences);
|
| };
|
|
|
| +} // namespace chrome
|
| +
|
| #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
|
|
|