Chromium Code Reviews| 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_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERY_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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 | 58 |
| 59 // The root of the gallery, relative to the root of the device. | 59 // The root of the gallery, relative to the root of the device. |
| 60 FilePath path; | 60 FilePath path; |
| 61 | 61 |
| 62 // The type of gallery. | 62 // The type of gallery. |
| 63 Type type; | 63 Type type; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 typedef std::map<MediaGalleryPrefId, MediaGalleryPrefInfo> | 66 typedef std::map<MediaGalleryPrefId, MediaGalleryPrefInfo> |
| 67 MediaGalleriesPrefInfoMap; | 67 MediaGalleriesPrefInfoMap; |
| 68 typedef std::set<MediaGalleryPrefId> MediaGalleryPrefIdSet; | |
| 68 | 69 |
| 69 // A class to manage the media gallery preferences. There is one instance per | 70 // A class to manage the media gallery preferences. There is one instance per |
| 70 // user profile. | 71 // user profile. |
| 71 class MediaGalleriesPreferences : public ProfileKeyedService { | 72 class MediaGalleriesPreferences : public ProfileKeyedService { |
| 72 public: | 73 public: |
| 73 | 74 |
| 74 explicit MediaGalleriesPreferences(Profile* profile); | 75 explicit MediaGalleriesPreferences(Profile* profile); |
| 75 virtual ~MediaGalleriesPreferences(); | 76 virtual ~MediaGalleriesPreferences(); |
| 76 | 77 |
| 77 // Builds |remembered_galleries_| from the persistent store. | 78 // Builds |remembered_galleries_| from the persistent store. |
| 78 void InitFromPrefs(); | 79 void InitFromPrefs(); |
| 79 | 80 |
| 80 // Lookup a media gallery and fill in information about it and return true. | 81 // Lookup a media gallery and fill in information about it and return true. |
| 81 // If the media gallery does not already exist, fill in as much of the | 82 // If the media gallery does not already exist, fill in as much of the |
| 82 // MediaGalleryPrefInfo struct as we can and return false. | 83 // MediaGalleryPrefInfo struct as we can and return false. |
| 83 // TODO(vandebo) figure out if we want this to be async, in which case: | 84 // TODO(vandebo) figure out if we want this to be async, in which case: |
| 84 // void LookUpGalleryByPath(FilePath&path, callback(const MediaGalleryInfo&)) | 85 // void LookUpGalleryByPath(FilePath&path, callback(const MediaGalleryInfo&)) |
| 85 bool LookUpGalleryByPath(const FilePath& path, | 86 bool LookUpGalleryByPath(const FilePath& path, |
| 86 MediaGalleryPrefInfo* gallery) const; | 87 MediaGalleryPrefInfo* gallery) const; |
| 87 | 88 |
| 89 MediaGalleryPrefIdSet LookUpGalleriesByDeviceId( | |
| 90 const std::string& device_id) const; | |
| 91 | |
| 88 // Teaches the registry about a new gallery. | 92 // Teaches the registry about a new gallery. |
| 89 MediaGalleryPrefId AddGallery(const std::string& device_id, | 93 MediaGalleryPrefId AddGallery(const std::string& device_id, |
| 90 const string16& display_name, | 94 const string16& display_name, |
| 91 const FilePath& path, | 95 const FilePath& path, |
| 92 bool user_added); | 96 bool user_added); |
| 93 | 97 |
| 94 // Deprecated: Teach the registry about a user added registry simply from | 98 // Deprecated: Teach the registry about a user added registry simply from |
| 95 // the path. | 99 // the path. |
| 96 // TODO(vandebo) remove once webui/options doesn't use this anymore. | 100 // TODO(vandebo) remove once webui/options doesn't use this anymore. |
| 97 MediaGalleryPrefId AddGalleryByPath(const FilePath& path); | 101 MediaGalleryPrefId AddGalleryByPath(const FilePath& path); |
| 98 | 102 |
| 99 // Removes the gallery identified by |id| from the store. | 103 // Removes the gallery identified by |id| from the store. |
| 100 void ForgetGalleryById(MediaGalleryPrefId id); | 104 void ForgetGalleryById(MediaGalleryPrefId id); |
| 101 | 105 |
| 102 std::set<MediaGalleryPrefId> GalleriesForExtension( | 106 MediaGalleryPrefIdSet GalleriesForExtension( |
|
Evan Stade
2012/08/11 00:07:14
you should update the controller to use this new t
vandebo (ex-Chrome)
2012/08/11 00:45:34
Done.
| |
| 103 const extensions::Extension& extension) const; | 107 const extensions::Extension& extension) const; |
| 104 | 108 |
| 105 void SetGalleryPermissionForExtension(const extensions::Extension& extension, | 109 void SetGalleryPermissionForExtension(const extensions::Extension& extension, |
| 106 MediaGalleryPrefId pref_id, | 110 MediaGalleryPrefId pref_id, |
| 107 bool has_permission); | 111 bool has_permission); |
| 108 | 112 |
| 109 const MediaGalleriesPrefInfoMap& known_galleries() const { | 113 const MediaGalleriesPrefInfoMap& known_galleries() const { |
| 110 return known_galleries_; | 114 return known_galleries_; |
| 111 } | 115 } |
| 112 | 116 |
| 113 // ProfileKeyedService implementation: | 117 // ProfileKeyedService implementation: |
| 114 virtual void Shutdown() OVERRIDE; | 118 virtual void Shutdown() OVERRIDE; |
| 115 | 119 |
| 116 static void RegisterUserPrefs(PrefService* prefs); | 120 static void RegisterUserPrefs(PrefService* prefs); |
| 117 | 121 |
| 118 // Returns true if the media gallery UI is turned on. | 122 // Returns true if the media gallery UI is turned on. |
| 119 static bool UserInteractionIsEnabled(); | 123 static bool UserInteractionIsEnabled(); |
| 120 | 124 |
| 121 protected: | 125 protected: |
| 122 // For testing. | 126 // For testing. |
| 123 static string16 ComputeDisplayName(const FilePath& path); | 127 static string16 ComputeDisplayName(const FilePath& path); |
| 124 | 128 |
| 125 private: | 129 private: |
| 130 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> | |
|
Evan Stade
2012/08/11 00:07:14
spaces inside *
vandebo (ex-Chrome)
2012/08/11 00:45:34
Actually, I tried changing this, but it looked fun
| |
| 131 DeviceIdPrefIdsMap; | |
| 132 | |
| 126 // The profile that owns |this|. | 133 // The profile that owns |this|. |
| 127 Profile* profile_; | 134 Profile* profile_; |
| 128 | 135 |
| 129 // An in-memory cache of known galleries. | 136 // An in-memory cache of known galleries. |
| 130 MediaGalleriesPrefInfoMap known_galleries_; | 137 MediaGalleriesPrefInfoMap known_galleries_; |
| 138 DeviceIdPrefIdsMap device_map_; | |
|
Evan Stade
2012/08/11 00:07:14
docs
vandebo (ex-Chrome)
2012/08/11 00:45:34
Done.
| |
| 131 | 139 |
| 132 extensions::ExtensionPrefs* GetExtensionPrefs() const; | 140 extensions::ExtensionPrefs* GetExtensionPrefs() const; |
| 133 | 141 |
| 134 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); | 142 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); |
| 135 }; | 143 }; |
| 136 | 144 |
| 137 } // namespace chrome | 145 } // namespace chrome |
| 138 | 146 |
| 139 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ | 147 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ |
| OLD | NEW |