| 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 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/system_monitor/system_monitor.h" | |
| 15 #include "chrome/browser/media_gallery/media_galleries_preferences.h" | 14 #include "chrome/browser/media_gallery/media_galleries_preferences.h" |
| 15 #include "chrome/browser/system_monitor/removable_storage_observer.h" |
| 16 #include "ui/base/dialogs/select_file_dialog.h" | 16 #include "ui/base/dialogs/select_file_dialog.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class WebContents; | 20 class WebContents; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 class Extension; | 24 class Extension; |
| 25 } | 25 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 // Constructs a platform-specific dialog owned and controlled by |controller|. | 42 // Constructs a platform-specific dialog owned and controlled by |controller|. |
| 43 static MediaGalleriesDialog* Create( | 43 static MediaGalleriesDialog* Create( |
| 44 MediaGalleriesDialogController* controller); | 44 MediaGalleriesDialogController* controller); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // The controller is responsible for handling the logic of the dialog and | 47 // The controller is responsible for handling the logic of the dialog and |
| 48 // interfacing with the model (i.e., MediaGalleriesPreferences). It shows | 48 // interfacing with the model (i.e., MediaGalleriesPreferences). It shows |
| 49 // the dialog and owns itself. | 49 // the dialog and owns itself. |
| 50 class MediaGalleriesDialogController | 50 class MediaGalleriesDialogController |
| 51 : public ui::SelectFileDialog::Listener, | 51 : public ui::SelectFileDialog::Listener, |
| 52 public base::SystemMonitor::DevicesChangedObserver { | 52 public RemovableStorageObserver { |
| 53 public: | 53 public: |
| 54 // A fancy pair. | 54 // A fancy pair. |
| 55 struct GalleryPermission { | 55 struct GalleryPermission { |
| 56 GalleryPermission(const MediaGalleryPrefInfo& pref_info, bool allowed) | 56 GalleryPermission(const MediaGalleryPrefInfo& pref_info, bool allowed) |
| 57 : pref_info(pref_info), allowed(allowed) {} | 57 : pref_info(pref_info), allowed(allowed) {} |
| 58 GalleryPermission() {} | 58 GalleryPermission() {} |
| 59 | 59 |
| 60 MediaGalleryPrefInfo pref_info; | 60 MediaGalleryPrefInfo pref_info; |
| 61 bool allowed; | 61 bool allowed; |
| 62 }; | 62 }; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // button, but have not yet been committed to the prefs system and will be | 94 // button, but have not yet been committed to the prefs system and will be |
| 95 // forgotten if the user Cancels. Since they don't have IDs assigned yet, it's | 95 // forgotten if the user Cancels. Since they don't have IDs assigned yet, it's |
| 96 // just a list and not a map. | 96 // just a list and not a map. |
| 97 typedef std::list<GalleryPermission> NewGalleryPermissions; | 97 typedef std::list<GalleryPermission> NewGalleryPermissions; |
| 98 | 98 |
| 99 // SelectFileDialog::Listener implementation: | 99 // SelectFileDialog::Listener implementation: |
| 100 virtual void FileSelected(const FilePath& path, | 100 virtual void FileSelected(const FilePath& path, |
| 101 int index, | 101 int index, |
| 102 void* params) OVERRIDE; | 102 void* params) OVERRIDE; |
| 103 | 103 |
| 104 // base::SystemMonitor::DevicesChangedObserver implementation: | 104 // RemovableStorageObserver implementation: |
| 105 virtual void OnRemovableStorageAttached( | 105 virtual void OnRemovableStorageAttached( |
| 106 const std::string& id, | 106 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 107 const string16& name, | 107 virtual void OnRemovableStorageDetached( |
| 108 const FilePath::StringType& location) OVERRIDE; | 108 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 109 virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE; | |
| 110 | 109 |
| 111 // Populates |known_galleries_|. | 110 // Populates |known_galleries_|. |
| 112 void InitializePermissions(); | 111 void InitializePermissions(); |
| 113 | 112 |
| 114 // Saves state of |known_galleries_| and |new_galleries_| to model. | 113 // Saves state of |known_galleries_| and |new_galleries_| to model. |
| 115 void SavePermissions(); | 114 void SavePermissions(); |
| 116 | 115 |
| 117 // Update the model and view when a device is attached or detached. | 116 // Update the model and view when a device is attached or detached. |
| 118 void UpdateGalleryOnDeviceEvent(const std::string& device_id, bool attached); | 117 void UpdateGalleryOnDeviceEvent(const std::string& device_id, bool attached); |
| 119 | 118 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 scoped_ptr<MediaGalleriesDialog> dialog_; | 138 scoped_ptr<MediaGalleriesDialog> dialog_; |
| 140 | 139 |
| 141 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; | 140 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; |
| 142 | 141 |
| 143 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); | 142 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController); |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 } // namespace chrome | 145 } // namespace chrome |
| 147 | 146 |
| 148 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ | 147 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_ |
| OLD | NEW |