Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Unified Diff: chrome/browser/media_gallery/media_galleries_preferences.h

Issue 10821077: Add gallery permissions to Media Galleries Preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compiles Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d9a3c71dced2c08ad9b9e39f2e2927f44e45cd2f 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,40 @@ 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;
+ MediaGalleryPrefInfo();
+ ~MediaGalleryPrefInfo();
- // The base path of the device.
- FilePath base_path;
-
- // 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 +76,34 @@ 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 gallery and fill in information about it, or 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,
Evan Stade 2012/08/02 17:47:31 I thought we said that this would never fail, rath
vandebo (ex-Chrome) 2012/08/02 17:51:38 Oops... right, I'll fix that.
vandebo (ex-Chrome) 2012/08/02 18:26:02 Done.
+ MediaGalleryPrefInfo* gallery) const;
+
+ // Teaches the registry about a new gallery.
+ MediaGalleryPrefId AddMediaGallery(const std::string& device_id,
+ const string16& display_name,
+ const FilePath& path,
Evan Stade 2012/08/02 17:47:31 why take 3 of the members of a MediaGalleryPrefInf
vandebo (ex-Chrome) 2012/08/02 17:51:38 Because not all the fields can be valid and becaus
Evan Stade 2012/08/02 18:00:54 are these "some callers" real or hypothetical?
vandebo (ex-Chrome) 2012/08/02 18:26:02 Doesn't matter, my point is that I think it's bad
Evan Stade 2012/08/02 18:36:35 Technically, you could get rid of the AddMediaGall
+ bool user_added);
+
+ // Teach the registry about a user added registry simply from the path.
+ MediaGalleryPrefId AddMediaGalleryByPath(const FilePath& path);
// Removes the gallery identified by |id| from the store.
- void ForgetGalleryById(uint64 id);
+ void ForgetMediaGalleryById(MediaGalleryPrefId id);
- const MediaGalleries& remembered_galleries() const {
- return remembered_galleries_;
+ std::vector<MediaGalleryPrefId> MediaGalleriesForExtension(
+ const extensions::Extension& extension) const;
+
+ void SetMediaGalleryPermissionForExtension(
+ const extensions::Extension& extension,
+ MediaGalleryPrefId pref_id,
+ bool has_permission);
+
+ const MediaGalleriesPrefInfoMap& known_galleries() const {
+ return known_galleries_;
}
// ProfileKeyedService implementation:
@@ -85,10 +119,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_

Powered by Google App Engine
This is Rietveld 408576698