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

Side by Side Diff: chrome/browser/media_galleries/media_galleries_permission_controller.h

Issue 321443003: Change the media galleries permission dialog to have a suggestions section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update test Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const extensions::Extension& extension, 84 const extensions::Extension& extension,
85 MediaGalleriesPreferences* preferences, 85 MediaGalleriesPreferences* preferences,
86 const CreateDialogCallback& create_dialog_callback, 86 const CreateDialogCallback& create_dialog_callback,
87 const base::Closure& on_finish); 87 const base::Closure& on_finish);
88 88
89 virtual ~MediaGalleriesPermissionController(); 89 virtual ~MediaGalleriesPermissionController();
90 90
91 private: 91 private:
92 // This type keeps track of media galleries already known to the prefs system. 92 // This type keeps track of media galleries already known to the prefs system.
93 typedef std::map<GalleryDialogId, Entry> GalleryPermissionsMap; 93 typedef std::map<GalleryDialogId, Entry> GalleryPermissionsMap;
94 typedef std::map<GalleryDialogId, bool /*permitted*/> ToggledGalleryMap;
94 95
95 class DialogIdMap { 96 class DialogIdMap {
96 public: 97 public:
97 DialogIdMap(); 98 DialogIdMap();
98 ~DialogIdMap(); 99 ~DialogIdMap();
99 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id); 100 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id);
100 MediaGalleryPrefId GetPrefId(GalleryDialogId id); 101 MediaGalleryPrefId GetPrefId(GalleryDialogId id) const;
101 102
102 private: 103 private:
103 GalleryDialogId next_dialog_id_; 104 GalleryDialogId next_dialog_id_;
104 std::map<MediaGalleryPrefId, GalleryDialogId> back_map_; 105 std::map<MediaGalleryPrefId, GalleryDialogId> back_map_;
105 std::vector<MediaGalleryPrefId> forward_mapping_; 106 std::vector<MediaGalleryPrefId> forward_mapping_;
106 DISALLOW_COPY_AND_ASSIGN(DialogIdMap); 107 DISALLOW_COPY_AND_ASSIGN(DialogIdMap);
107 }; 108 };
108 109
109 110
110 // Bottom half of constructor -- called when |preferences_| is initialized. 111 // Bottom half of constructor -- called when |preferences_| is initialized.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 // Updates the model and view when |preferences_| changes. Some of the 160 // Updates the model and view when |preferences_| changes. Some of the
160 // possible changes includes a gallery getting blacklisted, or a new 161 // possible changes includes a gallery getting blacklisted, or a new
161 // auto detected gallery becoming available. 162 // auto detected gallery becoming available.
162 void UpdateGalleriesOnPreferencesEvent(); 163 void UpdateGalleriesOnPreferencesEvent();
163 164
164 // Updates the model and view when a device is attached or detached. 165 // Updates the model and view when a device is attached or detached.
165 void UpdateGalleriesOnDeviceEvent(const std::string& device_id); 166 void UpdateGalleriesOnDeviceEvent(const std::string& device_id);
166 167
167 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id); 168 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id);
168 MediaGalleryPrefId GetPrefId(GalleryDialogId id); 169 MediaGalleryPrefId GetPrefId(GalleryDialogId id) const;
169 170
170 Profile* GetProfile(); 171 Profile* GetProfile();
171 172
172 // The web contents from which the request originated. 173 // The web contents from which the request originated.
173 content::WebContents* web_contents_; 174 content::WebContents* web_contents_;
174 175
175 // This is just a reference, but it's assumed that it won't become invalid 176 // This is just a reference, but it's assumed that it won't become invalid
176 // while the dialog is showing. 177 // while the dialog is showing.
177 const extensions::Extension* extension_; 178 const extensions::Extension* extension_;
178 179
179 // Mapping between pref ids and dialog ids. 180 // Mapping between pref ids and dialog ids.
180 DialogIdMap id_map_; 181 DialogIdMap id_map_;
181 182
182 // This map excludes those galleries which have been blacklisted; it only 183 // This map excludes those galleries which have been blacklisted; it only
183 // counts active known galleries. 184 // counts active known galleries.
184 GalleryPermissionsMap known_galleries_; 185 GalleryPermissionsMap known_galleries_;
185 186
186 // Galleries in |known_galleries_| that the user have toggled. 187 // Galleries in |known_galleries_| that the user have toggled.
187 std::set<GalleryDialogId> toggled_galleries_; 188 ToggledGalleryMap toggled_galleries_;
189
190 // The current set of permitted galleries (according to prefs).
191 MediaGalleryPrefIdSet pref_permitted_galleries_;
188 192
189 // Map of new galleries the user added, but have not saved. This list should 193 // Map of new galleries the user added, but have not saved. This list should
190 // never overlap with |known_galleries_|. 194 // never overlap with |known_galleries_|.
191 GalleryPermissionsMap new_galleries_; 195 GalleryPermissionsMap new_galleries_;
192 196
193 // Galleries in |known_galleries_| that the user has forgotten. 197 // Galleries in |known_galleries_| that the user has forgotten.
194 std::set<GalleryDialogId> forgotten_galleries_; 198 std::set<GalleryDialogId> forgotten_galleries_;
195 199
196 // Callback to run when the dialog closes. 200 // Callback to run when the dialog closes.
197 base::Closure on_finish_; 201 base::Closure on_finish_;
198 202
199 // The model that tracks galleries and extensions' permissions. 203 // The model that tracks galleries and extensions' permissions.
200 // This is the authoritative source for gallery information. 204 // This is the authoritative source for gallery information.
201 MediaGalleriesPreferences* preferences_; 205 MediaGalleriesPreferences* preferences_;
202 206
203 // The view that's showing. 207 // The view that's showing.
204 scoped_ptr<MediaGalleriesDialog> dialog_; 208 scoped_ptr<MediaGalleriesDialog> dialog_;
205 209
206 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; 210 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_;
207 211
208 scoped_ptr<MediaGalleryContextMenu> context_menu_; 212 scoped_ptr<MediaGalleryContextMenu> context_menu_;
209 213
210 // Creates the dialog. Only changed for unit tests. 214 // Creates the dialog. Only changed for unit tests.
211 CreateDialogCallback create_dialog_callback_; 215 CreateDialogCallback create_dialog_callback_;
212 216
213 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController); 217 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController);
214 }; 218 };
215 219
216 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_ H_ 220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_ H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/media_galleries/media_galleries_permission_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698