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 // GalleryWatchStateTracker tracks the gallery watchers, updates the | 5 // GalleryWatchStateTracker tracks the gallery watchers, updates the |
6 // extension state storage and observes the extension registry events. | 6 // extension state storage and observes the extension registry events. |
7 // GalleryWatchStateTracker lives on the UI thread. | 7 // GalleryWatchStateTracker lives on the UI thread. |
8 | 8 |
9 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_STAT
E_TRACKER_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_STAT
E_TRACKER_H_ |
10 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_STAT
E_TRACKER_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_STAT
E_TRACKER_H_ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // Updates the storage for the given extension on the receipt of gallery | 51 // Updates the storage for the given extension on the receipt of gallery |
52 // watch removed event. | 52 // watch removed event. |
53 void OnGalleryWatchRemoved(const std::string& extension_id, | 53 void OnGalleryWatchRemoved(const std::string& extension_id, |
54 MediaGalleryPrefId gallery_id); | 54 MediaGalleryPrefId gallery_id); |
55 | 55 |
56 // Updates the state of the gallery watchers on the receipt of access | 56 // Updates the state of the gallery watchers on the receipt of access |
57 // permission changed event for the extension specified by the | 57 // permission changed event for the extension specified by the |
58 // |extension_id|. | 58 // |extension_id|. |
59 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, | 59 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, |
60 const std::string& extension_id, | 60 const std::string& extension_id, |
61 MediaGalleryPrefId gallery_id) OVERRIDE; | 61 MediaGalleryPrefId gallery_id) override; |
62 | 62 |
63 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 63 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
64 const std::string& extension_id, | 64 const std::string& extension_id, |
65 MediaGalleryPrefId gallery_id) OVERRIDE; | 65 MediaGalleryPrefId gallery_id) override; |
66 | 66 |
67 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 67 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
68 MediaGalleryPrefId gallery_id) OVERRIDE; | 68 MediaGalleryPrefId gallery_id) override; |
69 | 69 |
70 // Returns a set of watched gallery identifiers for the extension specified | 70 // Returns a set of watched gallery identifiers for the extension specified |
71 // by the |extension_id|. | 71 // by the |extension_id|. |
72 MediaGalleryPrefIdSet GetAllWatchedGalleryIDsForExtension( | 72 MediaGalleryPrefIdSet GetAllWatchedGalleryIDsForExtension( |
73 const std::string& extension_id) const; | 73 const std::string& extension_id) const; |
74 | 74 |
75 // Removes all the gallery watchers associated with the extension specified | 75 // Removes all the gallery watchers associated with the extension specified |
76 // by the |extension_id|. | 76 // by the |extension_id|. |
77 void RemoveAllGalleryWatchersForExtension( | 77 void RemoveAllGalleryWatchersForExtension( |
78 const std::string& extension_id, | 78 const std::string& extension_id, |
79 MediaGalleriesPreferences* preferences); | 79 MediaGalleriesPreferences* preferences); |
80 | 80 |
81 private: | 81 private: |
82 // Key: Gallery identifier. | 82 // Key: Gallery identifier. |
83 // Value: True if the watcher is active. Watcher will be active only if | 83 // Value: True if the watcher is active. Watcher will be active only if |
84 // the extension has access permission to the watched gallery and a watcher | 84 // the extension has access permission to the watched gallery and a watcher |
85 // has been successfully setup. | 85 // has been successfully setup. |
86 typedef std::map<MediaGalleryPrefId, bool> WatchedGalleriesMap; | 86 typedef std::map<MediaGalleryPrefId, bool> WatchedGalleriesMap; |
87 | 87 |
88 // Key: Extension identifier. | 88 // Key: Extension identifier. |
89 // Value: Map of watched gallery information. | 89 // Value: Map of watched gallery information. |
90 typedef std::map<std::string, WatchedGalleriesMap> WatchedExtensionsMap; | 90 typedef std::map<std::string, WatchedGalleriesMap> WatchedExtensionsMap; |
91 | 91 |
92 // extensions::ExtensionRegistryObserver implementation. | 92 // extensions::ExtensionRegistryObserver implementation. |
93 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 93 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
94 const Extension* extension) OVERRIDE; | 94 const Extension* extension) override; |
95 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, | 95 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, |
96 const Extension* extension, | 96 const Extension* extension, |
97 UnloadedExtensionInfo::Reason reason) | 97 UnloadedExtensionInfo::Reason reason) |
98 OVERRIDE; | 98 override; |
99 | 99 |
100 // Syncs media gallery watch data for the given extension to/from the state | 100 // Syncs media gallery watch data for the given extension to/from the state |
101 // storage. | 101 // storage. |
102 void WriteToStorage(const std::string& extension_id); | 102 void WriteToStorage(const std::string& extension_id); |
103 void ReadFromStorage(const std::string& extension_id, | 103 void ReadFromStorage(const std::string& extension_id, |
104 scoped_ptr<base::Value> value); | 104 scoped_ptr<base::Value> value); |
105 | 105 |
106 // Sets up the gallery watcher on the receipt of granted gallery permission | 106 // Sets up the gallery watcher on the receipt of granted gallery permission |
107 // event. | 107 // event. |
108 void SetupGalleryWatch(const std::string& extension_id, | 108 void SetupGalleryWatch(const std::string& extension_id, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // A map of watched gallery details, per extension. | 144 // A map of watched gallery details, per extension. |
145 WatchedExtensionsMap watched_extensions_map_; | 145 WatchedExtensionsMap watched_extensions_map_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(GalleryWatchStateTracker); | 147 DISALLOW_COPY_AND_ASSIGN(GalleryWatchStateTracker); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace extensions | 150 } // namespace extensions |
151 | 151 |
152 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_S
TATE_TRACKER_H_ | 152 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_S
TATE_TRACKER_H_ |
OLD | NEW |