| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_SETTINGS_DOWNLOADS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_DOWNLOADS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_DOWNLOADS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_DOWNLOADS_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 13 #include "components/prefs/pref_change_registrar.h" |
| 13 #include "ui/shell_dialogs/select_file_dialog.h" | 14 #include "ui/shell_dialogs/select_file_dialog.h" |
| 14 | 15 |
| 16 class Profile; |
| 17 |
| 15 namespace settings { | 18 namespace settings { |
| 16 | 19 |
| 17 // Chrome "Downloads" settings page UI handler. | 20 // Chrome "Downloads" settings page UI handler. |
| 18 class DownloadsHandler : public SettingsPageUIHandler, | 21 class DownloadsHandler : public SettingsPageUIHandler, |
| 19 public ui::SelectFileDialog::Listener { | 22 public ui::SelectFileDialog::Listener { |
| 20 public: | 23 public: |
| 21 DownloadsHandler(); | 24 explicit DownloadsHandler(Profile* profile); |
| 22 ~DownloadsHandler() override; | 25 ~DownloadsHandler() override; |
| 23 | 26 |
| 24 // SettingsPageUIHandler implementation. | 27 // SettingsPageUIHandler implementation. |
| 25 void RegisterMessages() override; | 28 void RegisterMessages() override; |
| 26 void OnJavascriptAllowed() override {} | 29 void OnJavascriptAllowed() override; |
| 27 void OnJavascriptDisallowed() override {} | 30 void OnJavascriptDisallowed() override; |
| 28 | 31 |
| 29 private: | 32 private: |
| 33 friend class DownloadsHandlerTest; |
| 34 FRIEND_TEST_ALL_PREFIXES(DownloadsHandlerTest, AutoOpenDownloads); |
| 35 |
| 36 // Callback for the "initializeDownloads" message. This starts observers and |
| 37 // retrieves the current browser state. |
| 38 void HandleInitialize(const base::ListValue* args); |
| 39 |
| 40 void SendAutoOpenDownloadsToJavascript(); |
| 41 |
| 42 // Callback for the "selectDownloadLocation" message. This will prompt the |
| 43 // user for a destination folder using platform-specific APIs. |
| 44 void HandleSelectDownloadLocation(const base::ListValue* args); |
| 45 |
| 30 // SelectFileDialog::Listener implementation. | 46 // SelectFileDialog::Listener implementation. |
| 31 void FileSelected(const base::FilePath& path, | 47 void FileSelected(const base::FilePath& path, |
| 32 int index, | 48 int index, |
| 33 void* params) override; | 49 void* params) override; |
| 34 | 50 |
| 35 // Callback for the "selectDownloadLocation" message. This will prompt the | 51 Profile* profile_; |
| 36 // user for a destination folder using platform-specific APIs. | 52 |
| 37 void HandleSelectDownloadLocation(const base::ListValue* args); | 53 PrefChangeRegistrar pref_registrar_; |
| 38 | 54 |
| 39 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; | 55 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; |
| 40 | 56 |
| 41 DISALLOW_COPY_AND_ASSIGN(DownloadsHandler); | 57 DISALLOW_COPY_AND_ASSIGN(DownloadsHandler); |
| 42 }; | 58 }; |
| 43 | 59 |
| 44 } // namespace settings | 60 } // namespace settings |
| 45 | 61 |
| 46 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_DOWNLOADS_HANDLER_H_ | 62 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_DOWNLOADS_HANDLER_H_ |
| OLD | NEW |