| 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 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 // The constructor creates a dialog controller which owns itself. | 63 // The constructor creates a dialog controller which owns itself. |
| 64 MediaGalleriesDialogController(TabContents* tab_contents, | 64 MediaGalleriesDialogController(TabContents* tab_contents, |
| 65 const extensions::Extension& extension, | 65 const extensions::Extension& extension, |
| 66 const base::Callback<void(void)>& on_finish); | 66 const base::Callback<void(void)>& on_finish); |
| 67 | 67 |
| 68 // Called by the view. | 68 // Called by the view. |
| 69 string16 GetHeader(); | 69 string16 GetHeader(); |
| 70 string16 GetSubtext(); | 70 string16 GetSubtext(); |
| 71 void OnAddFolderClicked(); | 71 void OnAddFolderClicked(); |
| 72 void GalleryToggled(const MediaGalleryPrefInfo* pref_info, bool enabled); | 72 virtual void GalleryToggled(const MediaGalleryPrefInfo* pref_info, |
| 73 void DialogFinished(bool accepted); | 73 bool enabled); |
| 74 virtual void DialogFinished(bool accepted); |
| 74 | 75 |
| 75 // SelectFileDialog::Listener implementation: | 76 // SelectFileDialog::Listener implementation: |
| 76 virtual void FileSelected(const FilePath& path, | 77 virtual void FileSelected(const FilePath& path, |
| 77 int index, | 78 int index, |
| 78 void* params) OVERRIDE; | 79 void* params) OVERRIDE; |
| 79 const KnownGalleryPermissions& permissions() const { | 80 const KnownGalleryPermissions& permissions() const { |
| 80 return known_galleries_; | 81 return known_galleries_; |
| 81 } | 82 } |
| 82 | 83 |
| 83 TabContents* tab_contents() const { | 84 TabContents* tab_contents() const { |
| 84 return tab_contents_; | 85 return tab_contents_; |
| 85 } | 86 } |
| 86 | 87 |
| 88 protected: |
| 89 // For use with tests. |
| 90 MediaGalleriesDialogController(); |
| 91 |
| 92 virtual ~MediaGalleriesDialogController(); |
| 93 |
| 94 // This map excludes those galleries which have been blacklisted; it only |
| 95 // counts active known galleries. |
| 96 KnownGalleryPermissions known_galleries_; |
| 97 |
| 87 private: | 98 private: |
| 88 // This type is for media galleries that have been added via "add gallery" | 99 // This type is for media galleries that have been added via "add gallery" |
| 89 // button, but have not yet been committed to the prefs system and will be | 100 // button, but have not yet been committed to the prefs system and will be |
| 90 // forgotten if the user Cancels. Since they don't have IDs assigned yet, it's | 101 // forgotten if the user Cancels. Since they don't have IDs assigned yet, it's |
| 91 // just a list and not a map. | 102 // just a list and not a map. |
| 92 typedef std::list<GalleryPermission> NewGalleryPermissions; | 103 typedef std::list<GalleryPermission> NewGalleryPermissions; |
| 93 | 104 |
| 94 virtual ~MediaGalleriesDialogController(); | |
| 95 | |
| 96 // Populates |known_galleries_|. | 105 // Populates |known_galleries_|. |
| 97 void LookUpPermissions(); | 106 void LookUpPermissions(); |
| 98 | 107 |
| 99 // Saves state of |known_galleries_| and |new_galleries_| to model. | 108 // Saves state of |known_galleries_| and |new_galleries_| to model. |
| 100 void SavePermissions(); | 109 void SavePermissions(); |
| 101 | 110 |
| 102 // The tab contents from which the request originated. | 111 // The tab contents from which the request originated. |
| 103 TabContents* tab_contents_; | 112 TabContents* tab_contents_; |
| 104 | 113 |
| 105 // This is just a reference, but it's assumed that it won't become invalid | 114 // This is just a reference, but it's assumed that it won't become invalid |
| 106 // while the dialog is showing. | 115 // while the dialog is showing. Will be NULL only during tests. |
| 107 const extensions::Extension& extension_; | 116 const extensions::Extension* extension_; |
| 108 | 117 |
| 109 // This map excludes those galleries which have been blacklisted; it only | |
| 110 // counts active known galleries. | |
| 111 KnownGalleryPermissions known_galleries_; | |
| 112 NewGalleryPermissions new_galleries_; | 118 NewGalleryPermissions new_galleries_; |
| 113 | 119 |
| 114 // We run this callback when done. | 120 // We run this callback when done. |
| 115 base::Callback<void(void)> on_finish_; | 121 base::Callback<void(void)> on_finish_; |
| 116 | 122 |
| 117 // The model that tracks galleries and extensions' permissions. | 123 // The model that tracks galleries and extensions' permissions. |
| 118 MediaGalleriesPreferences* preferences_; | 124 MediaGalleriesPreferences* preferences_; |
| 119 | 125 |
| 120 // The view that's showing. | 126 // The view that's showing. |
| 121 scoped_ptr<MediaGalleriesDialog> dialog_; | 127 scoped_ptr<MediaGalleriesDialog> dialog_; |
| 122 | 128 |
| 123 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; | 129 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; |
| 124 | 130 |
| 125 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); | 131 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); |
| 126 }; | 132 }; |
| 127 | 133 |
| 128 } // namespace chrome | 134 } // namespace chrome |
| 129 | 135 |
| 130 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ | 136 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ |
| OLD | NEW |