| 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_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| 10 #include "chrome/browser/ui/webui/options/options_ui.h" | 11 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 11 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 12 #include "ui/shell_dialogs/select_file_dialog.h" | 13 #include "ui/shell_dialogs/select_file_dialog.h" |
| 13 | 14 |
| 15 namespace chrome { |
| 16 class MediaGalleriesPreferences; |
| 17 } |
| 18 |
| 14 namespace options { | 19 namespace options { |
| 15 | 20 |
| 16 // Handles messages related to adding or removing media galleries. | 21 // Handles messages related to adding or removing media galleries. |
| 17 class MediaGalleriesHandler : public OptionsPageUIHandler, | 22 class MediaGalleriesHandler : public OptionsPageUIHandler, |
| 18 public ui::SelectFileDialog::Listener { | 23 public ui::SelectFileDialog::Listener { |
| 19 public: | 24 public: |
| 20 MediaGalleriesHandler(); | 25 MediaGalleriesHandler(); |
| 21 virtual ~MediaGalleriesHandler(); | 26 virtual ~MediaGalleriesHandler(); |
| 22 | 27 |
| 23 // OptionsPageUIHandler implementation. | 28 // OptionsPageUIHandler implementation. |
| 24 virtual void GetLocalizedValues(base::DictionaryValue* values) OVERRIDE; | 29 virtual void GetLocalizedValues(base::DictionaryValue* values) OVERRIDE; |
| 25 virtual void InitializePage() OVERRIDE; | 30 virtual void InitializePage() OVERRIDE; |
| 26 virtual void RegisterMessages() OVERRIDE; | 31 virtual void RegisterMessages() OVERRIDE; |
| 27 | 32 |
| 28 // SelectFileDialog::Listener implementation. | 33 // SelectFileDialog::Listener implementation. |
| 29 virtual void FileSelected(const base::FilePath& path, | 34 virtual void FileSelected(const base::FilePath& path, |
| 30 int index, | 35 int index, |
| 31 void* params) OVERRIDE; | 36 void* params) OVERRIDE; |
| 32 | 37 |
| 33 private: | 38 private: |
| 34 // Handles the "addNewGallery" message (no arguments). | 39 // Handles the "addNewGallery" message (no arguments). |
| 35 void HandleAddNewGallery(const base::ListValue* args); | 40 void HandleAddNewGallery(const base::ListValue* args); |
| 36 // Handles "forgetGallery" message. The first and only argument is the id of | 41 // Handles "forgetGallery" message. The first and only argument is the id of |
| 37 // the gallery. | 42 // the gallery. |
| 38 void HandleForgetGallery(const base::ListValue* args); | 43 void HandleForgetGallery(const base::ListValue* args); |
| 44 // Bottom half of |HandleForgetGallery| after async call to get the |
| 45 // |preferences|. |
| 46 void HandleForgetGalleryWithPreferences( |
| 47 uint64 id, |
| 48 chrome::MediaGalleriesPreferences* preferences); |
| 39 | 49 |
| 40 // Called when the list of known galleries has changed; updates the page. | 50 // Called when the list of known galleries has changed; updates the page. |
| 41 void OnGalleriesChanged(); | 51 void OnGalleriesChanged(); |
| 42 | 52 |
| 53 // Bottom half of |OnGalleriesChanged| after async call to get the |
| 54 // |preferences|. |
| 55 void OnGalleriesChangedWithPreferences( |
| 56 chrome::MediaGalleriesPreferences* preferences); |
| 57 |
| 58 // Bottom half of |FileSelected| after async call to get the |
| 59 // |preferences|. |
| 60 void FileSelectedWithPreferences( |
| 61 base::FilePath path, |
| 62 chrome::MediaGalleriesPreferences* preferences); |
| 63 |
| 43 PrefChangeRegistrar pref_change_registrar_; | 64 PrefChangeRegistrar pref_change_registrar_; |
| 44 | 65 |
| 45 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 66 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 46 | 67 |
| 68 base::WeakPtrFactory<MediaGalleriesHandler> weak_ptr_factory_; |
| 69 |
| 47 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesHandler); | 70 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesHandler); |
| 48 }; | 71 }; |
| 49 | 72 |
| 50 } // namespace options | 73 } // namespace options |
| 51 | 74 |
| 52 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ | 75 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_ |
| OLD | NEW |