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 notification events. | 6 // extension state storage and observes the notification 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // Updates the storage for the given extension on the receipt of gallery | 46 // Updates the storage for the given extension on the receipt of gallery |
47 // watch removed event. | 47 // watch removed event. |
48 void OnGalleryWatchRemoved(const std::string& extension_id, | 48 void OnGalleryWatchRemoved(const std::string& extension_id, |
49 chrome::MediaGalleryPrefId gallery_id); | 49 chrome::MediaGalleryPrefId gallery_id); |
50 | 50 |
51 // Updates the state of the gallery watchers on the receipt of access | 51 // Updates the state of the gallery watchers on the receipt of access |
52 // permission changed event for the extension specified by the |extension_id|. | 52 // permission changed event for the extension specified by the |extension_id|. |
53 // |has_permission| is set to true if the user granted permission to | 53 // |has_permission| is set to true if the user granted permission to |
54 // access the gallery associated with the |gallery_id| and is set to false | 54 // access the gallery associated with the |gallery_id| and is set to false |
55 // if the user revoked the gallery permission. | 55 // if the user revoked the gallery permission. |
56 void OnGalleryPermissionChanged(const std::string& extension_id, | 56 void OnGalleryPermissionChanged( |
vandebo (ex-Chrome)
2013/05/22 21:40:34
Can you base this change on the other, so we don't
Greg Billock
2013/05/23 00:55:59
Yeah, I'll do that.
| |
57 chrome::MediaGalleryPrefId gallery_id, | 57 const std::string& extension_id, |
58 bool has_permission); | 58 chrome::MediaGalleryPrefId gallery_id, |
59 bool has_permission, | |
60 chrome::MediaGalleriesPreferences* preferences); | |
59 | 61 |
60 // Returns a set of watched gallery identifiers for the extension specified | 62 // Returns a set of watched gallery identifiers for the extension specified |
61 // by the |extension_id|. | 63 // by the |extension_id|. |
62 chrome::MediaGalleryPrefIdSet GetAllWatchedGalleryIDsForExtension( | 64 chrome::MediaGalleryPrefIdSet GetAllWatchedGalleryIDsForExtension( |
63 const std::string& extension_id) const; | 65 const std::string& extension_id) const; |
64 | 66 |
65 // Removes all the gallery watchers associated with the extension specified | 67 // Removes all the gallery watchers associated with the extension specified |
66 // by the |extension_id|. | 68 // by the |extension_id|. |
67 void RemoveAllGalleryWatchersForExtension(const std::string& extension_id); | 69 void RemoveAllGalleryWatchersForExtension( |
70 const std::string& extension_id, | |
71 chrome::MediaGalleriesPreferences* preferences); | |
68 | 72 |
69 private: | 73 private: |
70 // Key: Gallery identifier. | 74 // Key: Gallery identifier. |
71 // Value: True if the watcher is active. Watcher will be active only if | 75 // Value: True if the watcher is active. Watcher will be active only if |
72 // the extension has access permission to the watched gallery and a watcher | 76 // the extension has access permission to the watched gallery and a watcher |
73 // has been successfully setup. | 77 // has been successfully setup. |
74 typedef std::map<chrome::MediaGalleryPrefId, bool> WatchedGalleriesMap; | 78 typedef std::map<chrome::MediaGalleryPrefId, bool> WatchedGalleriesMap; |
75 | 79 |
76 // Key: Extension identifier. | 80 // Key: Extension identifier. |
77 // Value: Map of watched gallery information. | 81 // Value: Map of watched gallery information. |
78 typedef std::map<std::string, WatchedGalleriesMap> WatchedExtensionsMap; | 82 typedef std::map<std::string, WatchedGalleriesMap> WatchedExtensionsMap; |
79 | 83 |
84 // Bottom half of constructor. Called once the storage monitor is initialized, | |
85 // and sets up notification observer. | |
86 void OnStorageMonitorInitialized(); | |
87 | |
80 // content::NotificationObserver implementation. | 88 // content::NotificationObserver implementation. |
81 virtual void Observe(int type, | 89 virtual void Observe(int type, |
82 const content::NotificationSource& source, | 90 const content::NotificationSource& source, |
83 const content::NotificationDetails& details) OVERRIDE; | 91 const content::NotificationDetails& details) OVERRIDE; |
84 | 92 |
85 // Syncs media gallery watch data for the given extension to/from the state | 93 // Syncs media gallery watch data for the given extension to/from the state |
86 // storage. | 94 // storage. |
87 void WriteToStorage(const std::string& extension_id); | 95 void WriteToStorage(const std::string& extension_id); |
88 void ReadFromStorage(const std::string& extension_id, | 96 void ReadFromStorage(const std::string& extension_id, |
89 scoped_ptr<base::Value> value); | 97 scoped_ptr<base::Value> value); |
90 | 98 |
91 // Sets up the gallery watcher on the receipt of granted gallery permission | 99 // Sets up the gallery watcher on the receipt of granted gallery permission |
92 // event. | 100 // event. |
93 void SetupGalleryWatch(const std::string& extension_id, | 101 void SetupGalleryWatch(const std::string& extension_id, |
94 chrome::MediaGalleryPrefId gallery_id); | 102 chrome::MediaGalleryPrefId gallery_id, |
103 chrome::MediaGalleriesPreferences* preferences); | |
95 | 104 |
96 // Removes the gallery watcher on the receipt of revoked gallery permission | 105 // Removes the gallery watcher on the receipt of revoked gallery permission |
97 // event. | 106 // event. |
98 void RemoveGalleryWatch(const std::string& extension_id, | 107 void RemoveGalleryWatch(const std::string& extension_id, |
99 chrome::MediaGalleryPrefId gallery_id); | 108 chrome::MediaGalleryPrefId gallery_id, |
109 chrome::MediaGalleriesPreferences* preferences); | |
100 | 110 |
101 // Returns true if a gallery watcher exists for the extension. | 111 // Returns true if a gallery watcher exists for the extension. |
102 // Set |has_active_watcher| to true to find if the gallery watcher is active. | 112 // Set |has_active_watcher| to true to find if the gallery watcher is active. |
103 bool HasGalleryWatchInfo(const std::string& extension_id, | 113 bool HasGalleryWatchInfo(const std::string& extension_id, |
104 chrome::MediaGalleryPrefId gallery_id, | 114 chrome::MediaGalleryPrefId gallery_id, |
105 bool has_active_watcher); | 115 bool has_active_watcher); |
106 | 116 |
107 // Handles the setup gallery watch request response. When an extension is | 117 // Handles the setup gallery watch request response. When an extension is |
108 // loaded, GalleryWatchStateTracker reads the storage and sends request to | 118 // loaded, GalleryWatchStateTracker reads the storage and sends request to |
109 // setup gallery watchers for the known watch paths. | 119 // setup gallery watchers for the known watch paths. |
(...skipping 18 matching lines...) Expand all Loading... | |
128 | 138 |
129 // A map of watched gallery details, per extension. | 139 // A map of watched gallery details, per extension. |
130 WatchedExtensionsMap watched_extensions_map_; | 140 WatchedExtensionsMap watched_extensions_map_; |
131 | 141 |
132 DISALLOW_COPY_AND_ASSIGN(GalleryWatchStateTracker); | 142 DISALLOW_COPY_AND_ASSIGN(GalleryWatchStateTracker); |
133 }; | 143 }; |
134 | 144 |
135 } // namespace extensions | 145 } // namespace extensions |
136 | 146 |
137 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_S TATE_TRACKER_H_ | 147 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_S TATE_TRACKER_H_ |
OLD | NEW |