| OLD | NEW |
| 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 Loading... |
| 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 virtual base::string16 GetHeader() const override; |
| 59 virtual base::string16 GetSubtext() const OVERRIDE; | 59 virtual base::string16 GetSubtext() const override; |
| 60 virtual bool IsAcceptAllowed() const OVERRIDE; | 60 virtual bool IsAcceptAllowed() const override; |
| 61 virtual bool ShouldShowFolderViewer(const Entry& entry) const OVERRIDE; | 61 virtual bool ShouldShowFolderViewer(const Entry& entry) const override; |
| 62 virtual std::vector<base::string16> GetSectionHeaders() const OVERRIDE; | 62 virtual std::vector<base::string16> GetSectionHeaders() const override; |
| 63 virtual Entries GetSectionEntries(size_t index) const OVERRIDE; | 63 virtual 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 virtual base::string16 GetAuxiliaryButtonText() const override; |
| 66 virtual void DidClickAuxiliaryButton() OVERRIDE; | 66 virtual void DidClickAuxiliaryButton() override; |
| 67 virtual void DidToggleEntry(GalleryDialogId gallery_id, | 67 virtual void DidToggleEntry(GalleryDialogId gallery_id, |
| 68 bool selected) OVERRIDE; | 68 bool selected) override; |
| 69 virtual void DidClickOpenFolderViewer(GalleryDialogId gallery_id) OVERRIDE; | 69 virtual void DidClickOpenFolderViewer(GalleryDialogId gallery_id) override; |
| 70 virtual void DidForgetEntry(GalleryDialogId gallery_id) OVERRIDE; | 70 virtual void DidForgetEntry(GalleryDialogId gallery_id) override; |
| 71 virtual base::string16 GetAcceptButtonText() const OVERRIDE; | 71 virtual base::string16 GetAcceptButtonText() const override; |
| 72 virtual void DialogFinished(bool accepted) OVERRIDE; | 72 virtual void DialogFinished(bool accepted) override; |
| 73 virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) OVERRIDE; | 73 virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) override; |
| 74 virtual content::WebContents* WebContents() OVERRIDE; | 74 virtual content::WebContents* WebContents() override; |
| 75 | 75 |
| 76 protected: | 76 protected: |
| 77 friend class MediaGalleriesPermissionControllerTest; | 77 friend class MediaGalleriesPermissionControllerTest; |
| 78 | 78 |
| 79 typedef base::Callback<MediaGalleriesDialog* ( | 79 typedef base::Callback<MediaGalleriesDialog* ( |
| 80 MediaGalleriesDialogController*)> CreateDialogCallback; | 80 MediaGalleriesDialogController*)> CreateDialogCallback; |
| 81 | 81 |
| 82 // For use with tests. | 82 // For use with tests. |
| 83 MediaGalleriesPermissionController( | 83 MediaGalleriesPermissionController( |
| 84 const extensions::Extension& extension, | 84 const extensions::Extension& extension, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 107 DISALLOW_COPY_AND_ASSIGN(DialogIdMap); | 107 DISALLOW_COPY_AND_ASSIGN(DialogIdMap); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 | 110 |
| 111 // Bottom half of constructor -- called when |preferences_| is initialized. | 111 // Bottom half of constructor -- called when |preferences_| is initialized. |
| 112 void OnPreferencesInitialized(); | 112 void OnPreferencesInitialized(); |
| 113 | 113 |
| 114 // SelectFileDialog::Listener implementation: | 114 // SelectFileDialog::Listener implementation: |
| 115 virtual void FileSelected(const base::FilePath& path, | 115 virtual void FileSelected(const base::FilePath& path, |
| 116 int index, | 116 int index, |
| 117 void* params) OVERRIDE; | 117 void* params) override; |
| 118 | 118 |
| 119 // RemovableStorageObserver implementation. | 119 // RemovableStorageObserver implementation. |
| 120 // Used to keep dialog in sync with removable device status. | 120 // Used to keep dialog in sync with removable device status. |
| 121 virtual void OnRemovableStorageAttached( | 121 virtual void OnRemovableStorageAttached( |
| 122 const storage_monitor::StorageInfo& info) OVERRIDE; | 122 const storage_monitor::StorageInfo& info) override; |
| 123 virtual void OnRemovableStorageDetached( | 123 virtual void OnRemovableStorageDetached( |
| 124 const storage_monitor::StorageInfo& info) OVERRIDE; | 124 const storage_monitor::StorageInfo& info) override; |
| 125 | 125 |
| 126 // MediaGalleriesPreferences::GalleryChangeObserver implementations. | 126 // MediaGalleriesPreferences::GalleryChangeObserver implementations. |
| 127 // Used to keep the dialog in sync when the preferences change. | 127 // Used to keep the dialog in sync when the preferences change. |
| 128 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, | 128 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, |
| 129 const std::string& extension_id, | 129 const std::string& extension_id, |
| 130 MediaGalleryPrefId pref_id) OVERRIDE; | 130 MediaGalleryPrefId pref_id) override; |
| 131 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 131 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
| 132 const std::string& extension_id, | 132 const std::string& extension_id, |
| 133 MediaGalleryPrefId pref_id) OVERRIDE; | 133 MediaGalleryPrefId pref_id) override; |
| 134 virtual void OnGalleryAdded(MediaGalleriesPreferences* pref, | 134 virtual void OnGalleryAdded(MediaGalleriesPreferences* pref, |
| 135 MediaGalleryPrefId pref_id) OVERRIDE; | 135 MediaGalleryPrefId pref_id) override; |
| 136 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 136 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
| 137 MediaGalleryPrefId pref_id) OVERRIDE; | 137 MediaGalleryPrefId pref_id) override; |
| 138 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, | 138 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, |
| 139 MediaGalleryPrefId pref_id) OVERRIDE; | 139 MediaGalleryPrefId pref_id) override; |
| 140 | 140 |
| 141 // Populates |known_galleries_| from |preferences_|. Subsequent calls merge | 141 // Populates |known_galleries_| from |preferences_|. Subsequent calls merge |
| 142 // into |known_galleries_| and do not change permissions for user toggled | 142 // into |known_galleries_| and do not change permissions for user toggled |
| 143 // galleries. | 143 // galleries. |
| 144 void InitializePermissions(); | 144 void InitializePermissions(); |
| 145 | 145 |
| 146 // Saves state of |known_galleries_|, |new_galleries_| and | 146 // Saves state of |known_galleries_|, |new_galleries_| and |
| 147 // |forgotten_galleries_| to model. | 147 // |forgotten_galleries_| to model. |
| 148 // | 148 // |
| 149 // NOTE: possible states for a gallery: | 149 // NOTE: possible states for a gallery: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 scoped_ptr<MediaGalleryContextMenu> context_menu_; | 212 scoped_ptr<MediaGalleryContextMenu> context_menu_; |
| 213 | 213 |
| 214 // Creates the dialog. Only changed for unit tests. | 214 // Creates the dialog. Only changed for unit tests. |
| 215 CreateDialogCallback create_dialog_callback_; | 215 CreateDialogCallback create_dialog_callback_; |
| 216 | 216 |
| 217 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController); | 217 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController); |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_
H_ | 220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_
H_ |
| OLD | NEW |