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

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

Issue 10826129: Media galleries: configuration dialog controller and GTK impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const Extension* -> const Extension& Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
7
8 #include <list>
9 #include <map>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h"
13 #include "chrome/browser/media_gallery/media_galleries_preferences.h"
14 #include "ui/base/dialogs/select_file_dialog.h"
15 #include "ui/gfx/native_widget_types.h"
16
17 namespace extensions {
18 struct Extension;
19 }
20
21 class TabContents;
22
23 namespace chrome {
24
25 class MediaGalleriesDialogController;
26
27 // The view.
28 class MediaGalleriesDialog {
29 public:
30 // Updates the checkbox state for |gallery|. |gallery| is owned by the
31 // controller and is guaranteed to live longer than the dialog. If the
32 // checkbox doesn't already exist, it should be created.
33 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery,
34 bool permitted) = 0;
35
36 // Constructs a platform-specific dialog owned and controlled by |controller|.
37 static MediaGalleriesDialog* Create(
38 MediaGalleriesDialogController* controller);
39 };
40
41 // An interface that notifies the caller when the user has finished interacting
42 // with the dialog.
43 class MediaGalleriesDialogDelegate {
vandebo (ex-Chrome) 2012/08/08 19:24:21 Is there a reason to use a delegate instead of a c
Evan Stade 2012/08/08 21:48:57 Done.
44 public:
45 // Called when the dialog has been dismissed.
46 virtual void MediaGalleriesDialogFinished() = 0;
47 };
48
49 // The controller is responsible for handling the logic of the dialog and
50 // interfacing with the model (i.e., MediaGalleriesPreferences). It shows
51 // the dialog and owns itself.
52 class MediaGalleriesDialogController : public ui::SelectFileDialog::Listener {
53 public:
54 // The constructor creates a dialog controller which owns itself.
55 MediaGalleriesDialogController(TabContents* tab_contents,
56 const extensions::Extension& extension,
57 MediaGalleriesDialogDelegate* delegate);
58
59 // Called by the view.
60 string16 GetHeader();
61 string16 GetSubtext();
62 void OnAddFolderClicked();
63 void GalleryToggled(const MediaGalleryPrefInfo*, bool enabled);
vandebo (ex-Chrome) 2012/08/08 19:24:21 This can be const ref
Evan Stade 2012/08/08 21:48:57 same case as UpdateGallery
64 void DialogFinished(bool accepted);
65
66 // SelectFileDialog::Listener implementation:
67 virtual void FileSelected(const FilePath& path,
68 int index,
69 void* params) OVERRIDE;
70
71 struct GalleryPermission {
vandebo (ex-Chrome) 2012/08/08 19:24:21 Should go above the constructor (implied by style
Evan Stade 2012/08/08 21:48:57 Done.
72 GalleryPermission(const MediaGalleryPrefInfo& pref_info, bool allowed)
73 : pref_info(pref_info), allowed(allowed) {}
74 GalleryPermission() {}
75
76 MediaGalleryPrefInfo pref_info;
77 bool allowed;
78 };
79
80 // This type keeps track of media galleries already known to the prefs system.
81 typedef std::map<MediaGalleryPrefId, GalleryPermission>
vandebo (ex-Chrome) 2012/08/08 19:24:21 typedefs should be above constructors
Evan Stade 2012/08/08 21:48:57 Done.
82 KnownGalleryPermissions;
83 const KnownGalleryPermissions& permissions() const {
84 return known_galleries_;
85 }
86
87 TabContents* tab_contents() const {
88 return tab_contents_;
89 }
90
91 private:
92 virtual ~MediaGalleriesDialogController();
93
94 // Populates |known_galleries_|.
95 void LookUpPermissions();
96
97 // Saves state of |known_galleries_| and |new_galleries_| to model.
98 void SavePermissions();
99
100 // This type is for media galleries that have been added via "add gallery"
101 // button, but have not yet been committed to the prefs system and will be
102 // forgotten if the user Cancels. Since they don't have IDs assigned yet, it's
103 // just a list and not a map.
104 typedef std::list<GalleryPermission> NewGalleryPermissions;
vandebo (ex-Chrome) 2012/08/08 19:24:21 above destructor
Evan Stade 2012/08/08 21:48:57 Done.
105
106 // The tab contents from which the request originated.
107 TabContents* tab_contents_;
108
109 // This is just a reference, but it's assumed that it won't become invalid
110 // while the dialog is showing.
111 const extensions::Extension& extension_;
112
113 // This map excludes those galleries which have been blacklisted; it only
114 // counts active known galleries.
115 KnownGalleryPermissions known_galleries_;
116 NewGalleryPermissions new_galleries_;
117
118 // We notify this delegate when done.
119 MediaGalleriesDialogDelegate* delegate_;
120
121 // The model that tracks galleries and extensions' permissions.
122 MediaGalleriesPreferences* preferences_;
123
124 // The view that's showing.
125 scoped_ptr<MediaGalleriesDialog> dialog_;
126
127 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_;
128
129 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController);
130 };
131
132 } // namespace chrome
133
134 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698