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

Side by Side Diff: chrome/browser/media_gallery/media_galleries_preferences.h

Issue 12095074: Media Galleries: Keep media gallery permission dialogs in sync with the gallery (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix nit Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 typedef std::map<MediaGalleryPrefId, MediaGalleryPrefInfo> 71 typedef std::map<MediaGalleryPrefId, MediaGalleryPrefInfo>
72 MediaGalleriesPrefInfoMap; 72 MediaGalleriesPrefInfoMap;
73 typedef std::set<MediaGalleryPrefId> MediaGalleryPrefIdSet; 73 typedef std::set<MediaGalleryPrefId> MediaGalleryPrefIdSet;
74 74
75 // A class to manage the media gallery preferences. There is one instance per 75 // A class to manage the media gallery preferences. There is one instance per
76 // user profile. 76 // user profile.
77 class MediaGalleriesPreferences : public ProfileKeyedService { 77 class MediaGalleriesPreferences : public ProfileKeyedService {
78 public: 78 public:
79 class GalleryChangeObserver { 79 class GalleryChangeObserver {
80 public: 80 public:
81 virtual void OnGalleryChanged(MediaGalleriesPreferences* pref) {} 81 // |extension_id| specifies the extension affected by this change.
82 // It is empty if the gallery change affects all extensions.
83 virtual void OnGalleryChanged(MediaGalleriesPreferences* pref,
84 const std::string& extension_id) {}
82 85
83 protected: 86 protected:
84 virtual ~GalleryChangeObserver(); 87 virtual ~GalleryChangeObserver();
85 }; 88 };
86 89
87 explicit MediaGalleriesPreferences(Profile* profile); 90 explicit MediaGalleriesPreferences(Profile* profile);
88 virtual ~MediaGalleriesPreferences(); 91 virtual ~MediaGalleriesPreferences();
89 92
90 void AddGalleryChangeObserver(GalleryChangeObserver* observer); 93 void AddGalleryChangeObserver(GalleryChangeObserver* observer);
91 void RemoveGalleryChangeObserver(GalleryChangeObserver* observer); 94 void RemoveGalleryChangeObserver(GalleryChangeObserver* observer);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DeviceIdPrefIdsMap; 154 DeviceIdPrefIdsMap;
152 155
153 // Populates the default galleries if this is a fresh profile. 156 // Populates the default galleries if this is a fresh profile.
154 void AddDefaultGalleriesIfFreshProfile(); 157 void AddDefaultGalleriesIfFreshProfile();
155 158
156 // Builds |known_galleries_| from the persistent store. 159 // Builds |known_galleries_| from the persistent store.
157 // Notifies GalleryChangeObservers if |notify_observers| is true. 160 // Notifies GalleryChangeObservers if |notify_observers| is true.
158 void InitFromPrefs(bool notify_observers); 161 void InitFromPrefs(bool notify_observers);
159 162
160 // Notifies |gallery_change_observers_| about changes in |known_galleries_|. 163 // Notifies |gallery_change_observers_| about changes in |known_galleries_|.
161 void NotifyChangeObservers(); 164 void NotifyChangeObservers(const std::string& extension_id);
162 165
163 extensions::ExtensionPrefs* GetExtensionPrefs() const; 166 extensions::ExtensionPrefs* GetExtensionPrefs() const;
164 167
165 // The profile that owns |this|. 168 // The profile that owns |this|.
166 Profile* profile_; 169 Profile* profile_;
167 170
168 // An in-memory cache of known galleries. 171 // An in-memory cache of known galleries.
169 MediaGalleriesPrefInfoMap known_galleries_; 172 MediaGalleriesPrefInfoMap known_galleries_;
170 173
171 // A mapping from device id to the set of gallery pref ids on that device. 174 // A mapping from device id to the set of gallery pref ids on that device.
172 // All pref ids in |device_map_| are also in |known_galleries_|. 175 // All pref ids in |device_map_| are also in |known_galleries_|.
173 DeviceIdPrefIdsMap device_map_; 176 DeviceIdPrefIdsMap device_map_;
174 177
175 ObserverList<GalleryChangeObserver> gallery_change_observers_; 178 ObserverList<GalleryChangeObserver> gallery_change_observers_;
176 179
177 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); 180 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences);
178 }; 181 };
179 182
180 } // namespace chrome 183 } // namespace chrome
181 184
182 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ 185 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698