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

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

Issue 660343006: Standardize usage of virtual/override/final in chrome/browser/media_galleries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 public ui::SelectFileDialog::Listener, 48 public ui::SelectFileDialog::Listener,
49 public storage_monitor::RemovableStorageObserver, 49 public storage_monitor::RemovableStorageObserver,
50 public MediaGalleriesPreferences::GalleryChangeObserver { 50 public MediaGalleriesPreferences::GalleryChangeObserver {
51 public: 51 public:
52 // The constructor creates a dialog controller which owns itself. 52 // The constructor creates a dialog controller which owns itself.
53 MediaGalleriesPermissionController(content::WebContents* web_contents, 53 MediaGalleriesPermissionController(content::WebContents* web_contents,
54 const extensions::Extension& extension, 54 const extensions::Extension& extension,
55 const base::Closure& on_finish); 55 const base::Closure& on_finish);
56 56
57 // MediaGalleriesDialogController implementation. 57 // MediaGalleriesDialogController implementation.
58 virtual base::string16 GetHeader() const override; 58 base::string16 GetHeader() const override;
59 virtual base::string16 GetSubtext() const override; 59 base::string16 GetSubtext() const override;
60 virtual bool IsAcceptAllowed() const override; 60 bool IsAcceptAllowed() const override;
61 virtual bool ShouldShowFolderViewer(const Entry& entry) const override; 61 bool ShouldShowFolderViewer(const Entry& entry) const override;
62 virtual std::vector<base::string16> GetSectionHeaders() const override; 62 std::vector<base::string16> GetSectionHeaders() const override;
63 virtual Entries GetSectionEntries(size_t index) const override; 63 Entries GetSectionEntries(size_t index) const override;
64 // Auxiliary button for this dialog is the 'Add Folder' button. 64 // Auxiliary button for this dialog is the 'Add Folder' button.
65 virtual base::string16 GetAuxiliaryButtonText() const override; 65 base::string16 GetAuxiliaryButtonText() const override;
66 virtual void DidClickAuxiliaryButton() override; 66 void DidClickAuxiliaryButton() override;
67 virtual void DidToggleEntry(GalleryDialogId gallery_id, 67 void DidToggleEntry(GalleryDialogId gallery_id, bool selected) override;
68 bool selected) override; 68 void DidClickOpenFolderViewer(GalleryDialogId gallery_id) override;
69 virtual void DidClickOpenFolderViewer(GalleryDialogId gallery_id) override; 69 void DidForgetEntry(GalleryDialogId gallery_id) override;
70 virtual void DidForgetEntry(GalleryDialogId gallery_id) override; 70 base::string16 GetAcceptButtonText() const override;
71 virtual base::string16 GetAcceptButtonText() const override; 71 void DialogFinished(bool accepted) override;
72 virtual void DialogFinished(bool accepted) override; 72 ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) override;
73 virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) override; 73 content::WebContents* WebContents() override;
74 virtual content::WebContents* WebContents() override;
75 74
76 protected: 75 protected:
77 friend class MediaGalleriesPermissionControllerTest; 76 friend class MediaGalleriesPermissionControllerTest;
78 77
79 typedef base::Callback<MediaGalleriesDialog* ( 78 typedef base::Callback<MediaGalleriesDialog* (
80 MediaGalleriesDialogController*)> CreateDialogCallback; 79 MediaGalleriesDialogController*)> CreateDialogCallback;
81 80
82 // For use with tests. 81 // For use with tests.
83 MediaGalleriesPermissionController( 82 MediaGalleriesPermissionController(
84 const extensions::Extension& extension, 83 const extensions::Extension& extension,
85 MediaGalleriesPreferences* preferences, 84 MediaGalleriesPreferences* preferences,
86 const CreateDialogCallback& create_dialog_callback, 85 const CreateDialogCallback& create_dialog_callback,
87 const base::Closure& on_finish); 86 const base::Closure& on_finish);
88 87
89 virtual ~MediaGalleriesPermissionController(); 88 ~MediaGalleriesPermissionController() override;
90 89
91 private: 90 private:
92 // This type keeps track of media galleries already known to the prefs system. 91 // This type keeps track of media galleries already known to the prefs system.
93 typedef std::map<GalleryDialogId, Entry> GalleryPermissionsMap; 92 typedef std::map<GalleryDialogId, Entry> GalleryPermissionsMap;
94 typedef std::map<GalleryDialogId, bool /*permitted*/> ToggledGalleryMap; 93 typedef std::map<GalleryDialogId, bool /*permitted*/> ToggledGalleryMap;
95 94
96 class DialogIdMap { 95 class DialogIdMap {
97 public: 96 public:
98 DialogIdMap(); 97 DialogIdMap();
99 ~DialogIdMap(); 98 ~DialogIdMap();
100 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id); 99 GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id);
101 MediaGalleryPrefId GetPrefId(GalleryDialogId id) const; 100 MediaGalleryPrefId GetPrefId(GalleryDialogId id) const;
102 101
103 private: 102 private:
104 GalleryDialogId next_dialog_id_; 103 GalleryDialogId next_dialog_id_;
105 std::map<MediaGalleryPrefId, GalleryDialogId> back_map_; 104 std::map<MediaGalleryPrefId, GalleryDialogId> back_map_;
106 std::vector<MediaGalleryPrefId> forward_mapping_; 105 std::vector<MediaGalleryPrefId> forward_mapping_;
107 DISALLOW_COPY_AND_ASSIGN(DialogIdMap); 106 DISALLOW_COPY_AND_ASSIGN(DialogIdMap);
108 }; 107 };
109 108
110 109
111 // Bottom half of constructor -- called when |preferences_| is initialized. 110 // Bottom half of constructor -- called when |preferences_| is initialized.
112 void OnPreferencesInitialized(); 111 void OnPreferencesInitialized();
113 112
114 // SelectFileDialog::Listener implementation: 113 // SelectFileDialog::Listener implementation:
115 virtual void FileSelected(const base::FilePath& path, 114 void FileSelected(const base::FilePath& path,
116 int index, 115 int index,
117 void* params) override; 116 void* params) override;
118 117
119 // RemovableStorageObserver implementation. 118 // RemovableStorageObserver implementation.
120 // Used to keep dialog in sync with removable device status. 119 // Used to keep dialog in sync with removable device status.
121 virtual void OnRemovableStorageAttached( 120 void OnRemovableStorageAttached(
122 const storage_monitor::StorageInfo& info) override; 121 const storage_monitor::StorageInfo& info) override;
123 virtual void OnRemovableStorageDetached( 122 void OnRemovableStorageDetached(
124 const storage_monitor::StorageInfo& info) override; 123 const storage_monitor::StorageInfo& info) override;
125 124
126 // MediaGalleriesPreferences::GalleryChangeObserver implementations. 125 // MediaGalleriesPreferences::GalleryChangeObserver implementations.
127 // Used to keep the dialog in sync when the preferences change. 126 // Used to keep the dialog in sync when the preferences change.
128 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, 127 void OnPermissionAdded(MediaGalleriesPreferences* pref,
129 const std::string& extension_id, 128 const std::string& extension_id,
130 MediaGalleryPrefId pref_id) override; 129 MediaGalleryPrefId pref_id) override;
131 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, 130 void OnPermissionRemoved(MediaGalleriesPreferences* pref,
132 const std::string& extension_id, 131 const std::string& extension_id,
133 MediaGalleryPrefId pref_id) override; 132 MediaGalleryPrefId pref_id) override;
134 virtual void OnGalleryAdded(MediaGalleriesPreferences* pref, 133 void OnGalleryAdded(MediaGalleriesPreferences* pref,
135 MediaGalleryPrefId pref_id) override; 134 MediaGalleryPrefId pref_id) override;
136 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, 135 void OnGalleryRemoved(MediaGalleriesPreferences* pref,
137 MediaGalleryPrefId pref_id) override; 136 MediaGalleryPrefId pref_id) override;
138 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, 137 void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref,
139 MediaGalleryPrefId pref_id) override; 138 MediaGalleryPrefId pref_id) override;
140 139
141 // Populates |known_galleries_| from |preferences_|. Subsequent calls merge 140 // Populates |known_galleries_| from |preferences_|. Subsequent calls merge
142 // into |known_galleries_| and do not change permissions for user toggled 141 // into |known_galleries_| and do not change permissions for user toggled
143 // galleries. 142 // galleries.
144 void InitializePermissions(); 143 void InitializePermissions();
145 144
146 // Saves state of |known_galleries_|, |new_galleries_| and 145 // Saves state of |known_galleries_|, |new_galleries_| and
147 // |forgotten_galleries_| to model. 146 // |forgotten_galleries_| to model.
148 // 147 //
149 // NOTE: possible states for a gallery: 148 // NOTE: possible states for a gallery:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 210
212 scoped_ptr<MediaGalleryContextMenu> context_menu_; 211 scoped_ptr<MediaGalleryContextMenu> context_menu_;
213 212
214 // Creates the dialog. Only changed for unit tests. 213 // Creates the dialog. Only changed for unit tests.
215 CreateDialogCallback create_dialog_callback_; 214 CreateDialogCallback create_dialog_callback_;
216 215
217 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController); 216 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController);
218 }; 217 };
219 218
220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_ H_ 219 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698