Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 class MediaGalleriesDialogController; | 29 class MediaGalleriesDialogController; |
| 30 | 30 |
| 31 // The view. | 31 // The view. |
| 32 class MediaGalleriesDialog { | 32 class MediaGalleriesDialog { |
| 33 public: | 33 public: |
| 34 virtual ~MediaGalleriesDialog(); | 34 virtual ~MediaGalleriesDialog(); |
| 35 | 35 |
| 36 // Updates the checkbox state for |gallery|. |gallery| is owned by the | 36 // Updates the checkbox state for |gallery|. |gallery| is owned by the |
| 37 // controller and is guaranteed to live longer than the dialog. If the | 37 // controller and is guaranteed to live longer than the dialog. If the |
| 38 // checkbox doesn't already exist, it should be created. | 38 // checkbox doesn't already exist, it should be created. |
| 39 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, | 39 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, |
|
vandebo (ex-Chrome)
2013/01/31 01:54:07
It seems to me that there should be three methods,
Lei Zhang
2013/01/31 06:59:21
You should know that Update does more than just up
vandebo (ex-Chrome)
2013/01/31 19:38:50
What about UpdateGallery(PrefInfo, enum {unchecked
Lei Zhang
2013/02/01 22:04:11
I really would like to keep Remove separate from U
| |
| 40 bool permitted) = 0; | 40 bool permitted) = 0; |
| 41 | 41 |
| 42 // If there exists a checkbox for |gallery|, it should be removed. | |
| 43 virtual void ForgetGallery(const MediaGalleryPrefInfo* gallery) = 0; | |
| 44 | |
| 42 // Constructs a platform-specific dialog owned and controlled by |controller|. | 45 // Constructs a platform-specific dialog owned and controlled by |controller|. |
| 43 static MediaGalleriesDialog* Create( | 46 static MediaGalleriesDialog* Create( |
| 44 MediaGalleriesDialogController* controller); | 47 MediaGalleriesDialogController* controller); |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 // The controller is responsible for handling the logic of the dialog and | 50 // The controller is responsible for handling the logic of the dialog and |
| 48 // interfacing with the model (i.e., MediaGalleriesPreferences). It shows | 51 // interfacing with the model (i.e., MediaGalleriesPreferences). It shows |
| 49 // the dialog and owns itself. | 52 // the dialog and owns itself. |
| 50 class MediaGalleriesDialogController | 53 class MediaGalleriesDialogController |
| 51 : public ui::SelectFileDialog::Listener, | 54 : public ui::SelectFileDialog::Listener, |
| 52 public RemovableStorageObserver { | 55 public RemovableStorageObserver, |
| 56 public MediaGalleriesPreferences::GalleryChangeObserver { | |
| 53 public: | 57 public: |
| 54 // A fancy pair. | 58 // A fancy pair. |
| 55 struct GalleryPermission { | 59 struct GalleryPermission { |
| 56 GalleryPermission(const MediaGalleryPrefInfo& pref_info, bool allowed) | 60 GalleryPermission(const MediaGalleryPrefInfo& pref_info, bool allowed) |
| 57 : pref_info(pref_info), allowed(allowed) {} | 61 : pref_info(pref_info), allowed(allowed) {} |
| 58 GalleryPermission() {} | 62 GalleryPermission() {} |
| 59 | 63 |
| 60 MediaGalleryPrefInfo pref_info; | 64 MediaGalleryPrefInfo pref_info; |
| 61 bool allowed; | 65 bool allowed; |
| 62 }; | 66 }; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 virtual void FileSelected(const FilePath& path, | 104 virtual void FileSelected(const FilePath& path, |
| 101 int index, | 105 int index, |
| 102 void* params) OVERRIDE; | 106 void* params) OVERRIDE; |
| 103 | 107 |
| 104 // RemovableStorageObserver implementation: | 108 // RemovableStorageObserver implementation: |
| 105 virtual void OnRemovableStorageAttached( | 109 virtual void OnRemovableStorageAttached( |
| 106 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; | 110 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 107 virtual void OnRemovableStorageDetached( | 111 virtual void OnRemovableStorageDetached( |
| 108 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; | 112 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 109 | 113 |
| 114 // MediaGalleriesPreferences::GalleryChangeObserver implementation: | |
| 115 virtual void OnGalleryChanged(MediaGalleriesPreferences* pref) OVERRIDE; | |
| 116 | |
| 110 // Populates |known_galleries_|. | 117 // Populates |known_galleries_|. |
| 111 void InitializePermissions(); | 118 void InitializePermissions(); |
| 112 | 119 |
| 113 // Saves state of |known_galleries_| and |new_galleries_| to model. | 120 // Saves state of |known_galleries_| and |new_galleries_| to model. |
| 114 void SavePermissions(); | 121 void SavePermissions(); |
| 115 | 122 |
| 116 // Update the model and view when a device is attached or detached. | 123 // Updates the model and view when |preferences_| changes. Some of the |
| 124 // possible changes includes a gallery getting blacklisted, or a new | |
| 125 // auto detected gallery coming available. | |
|
vandebo (ex-Chrome)
2013/01/31 01:54:07
nit: coming->becoming
Lei Zhang
2013/02/01 22:04:11
Done.
| |
| 126 void UpdateGalleriesOnPreferencesEvent(); | |
| 127 | |
| 128 // Updates the model and view when a device is attached or detached. | |
| 117 void UpdateGalleriesOnDeviceEvent(const std::string& device_id); | 129 void UpdateGalleriesOnDeviceEvent(const std::string& device_id); |
|
vandebo (ex-Chrome)
2013/01/31 01:54:07
Do you still need this when you have the OnPrefere
Lei Zhang
2013/01/31 06:59:21
There's no preference event when a device gets det
vandebo (ex-Chrome)
2013/01/31 19:38:50
Oh, you still need these to update the attached/de
| |
| 118 | 130 |
| 119 // The web contents from which the request originated. | 131 // The web contents from which the request originated. |
| 120 content::WebContents* web_contents_; | 132 content::WebContents* web_contents_; |
| 121 | 133 |
| 122 // This is just a reference, but it's assumed that it won't become invalid | 134 // This is just a reference, but it's assumed that it won't become invalid |
| 123 // while the dialog is showing. Will be NULL only during tests. | 135 // while the dialog is showing. Will be NULL only during tests. |
| 124 const extensions::Extension* extension_; | 136 const extensions::Extension* extension_; |
| 125 | 137 |
| 126 // This map excludes those galleries which have been blacklisted; it only | 138 // This map excludes those galleries which have been blacklisted; it only |
| 127 // counts active known galleries. | 139 // counts active known galleries. |
| 128 KnownGalleryPermissions known_galleries_; | 140 KnownGalleryPermissions known_galleries_; |
| 141 | |
| 142 // Map of new galleries the user added, but have not saved. This list should | |
| 143 // never overlap with |known_galleries_|. | |
| 129 NewGalleryPermissions new_galleries_; | 144 NewGalleryPermissions new_galleries_; |
| 130 | 145 |
| 131 // We run this callback when done. | 146 // Callback to run when the dialog closes. |
| 132 base::Closure on_finish_; | 147 base::Closure on_finish_; |
| 133 | 148 |
| 134 // The model that tracks galleries and extensions' permissions. | 149 // The model that tracks galleries and extensions' permissions. |
| 135 MediaGalleriesPreferences* preferences_; | 150 MediaGalleriesPreferences* preferences_; |
| 136 | 151 |
| 137 // The view that's showing. | 152 // The view that's showing. |
| 138 scoped_ptr<MediaGalleriesDialog> dialog_; | 153 scoped_ptr<MediaGalleriesDialog> dialog_; |
| 139 | 154 |
| 140 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; | 155 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; |
| 141 | 156 |
| 142 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); | 157 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); |
| 143 }; | 158 }; |
| 144 | 159 |
| 145 } // namespace chrome | 160 } // namespace chrome |
| 146 | 161 |
| 147 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ | 162 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ |
| OLD | NEW |