OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ADVANCED_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/prefs/pref_member.h" | 9 #include "chrome/browser/prefs/pref_member.h" |
10 #include "chrome/browser/prefs/pref_set_observer.h" | 10 #include "chrome/browser/prefs/pref_set_observer.h" |
11 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" | 11 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
12 #include "chrome/browser/ui/shell_dialogs.h" | 12 #include "chrome/browser/ui/shell_dialogs.h" |
13 #include "chrome/browser/ui/webui/options/options_ui.h" | 13 #include "chrome/browser/ui/webui/options/options_ui.h" |
14 | 14 |
15 class CloudPrintSetupHandler; | 15 class CloudPrintSetupHandler; |
16 | 16 |
17 // Chrome advanced options page UI handler. | 17 // Chrome advanced options page UI handler. |
18 class AdvancedOptionsHandler | 18 class AdvancedOptionsHandler |
19 : public OptionsPageUIHandler, | 19 : public OptionsPageUIHandler, |
20 public SelectFileDialog::Listener, | 20 public SelectFileDialog::Listener, |
21 public CloudPrintSetupHandlerDelegate { | 21 public CloudPrintSetupHandlerDelegate { |
22 public: | 22 public: |
| 23 |
| 24 class DownloadPathChecker |
| 25 : public base::RefCountedThreadSafe<DownloadPathChecker> { |
| 26 public: |
| 27 explicit DownloadPathChecker(AdvancedOptionsHandler* handler); |
| 28 |
| 29 // Check if the download folder still exists. If the download folder |
| 30 // does not exist, the download folder is changed to the user's |
| 31 // "Downloads" folder. This check runs in the background and may finish |
| 32 // asynchronously after this method returns. |
| 33 void CheckIfDownloadPathExists(const FilePath& path); |
| 34 |
| 35 private: |
| 36 friend class base::RefCountedThreadSafe<DownloadPathChecker>; |
| 37 ~DownloadPathChecker(); |
| 38 |
| 39 // Called on the FILE thread to check the existence of the download folder. |
| 40 // If it does not exist, this method tells the user's "Downloads" |
| 41 // to OnDownloadPathChanged(). |
| 42 void CheckIfDownloadPathExistsOnFileThread(const FilePath& path); |
| 43 |
| 44 // Called on the UI thread when the FILE thread finds that the download |
| 45 // folder does not exist. This method changes the download folder to |
| 46 // the user's "Downloads" folder and notifies this preference change |
| 47 // to observers. |
| 48 void OnDownloadPathChanged(const FilePath path); |
| 49 |
| 50 // The handler we will report back to. |
| 51 AdvancedOptionsHandler* handler_; |
| 52 }; |
| 53 |
23 AdvancedOptionsHandler(); | 54 AdvancedOptionsHandler(); |
24 virtual ~AdvancedOptionsHandler(); | 55 virtual ~AdvancedOptionsHandler(); |
25 | 56 |
26 // OptionsPageUIHandler implementation. | 57 // OptionsPageUIHandler implementation. |
27 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 58 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
28 virtual void Initialize(); | 59 virtual void Initialize(); |
29 | 60 |
30 // WebUIMessageHandler implementation. | 61 // WebUIMessageHandler implementation. |
31 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 62 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
32 virtual void RegisterMessages(); | 63 virtual void RegisterMessages(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 #endif | 156 #endif |
126 | 157 |
127 // Setup the checked state for the metrics reporting checkbox. | 158 // Setup the checked state for the metrics reporting checkbox. |
128 void SetupMetricsReportingCheckbox(); | 159 void SetupMetricsReportingCheckbox(); |
129 | 160 |
130 // Setup the visibility for the metrics reporting setting. | 161 // Setup the visibility for the metrics reporting setting. |
131 void SetupMetricsReportingSettingVisibility(); | 162 void SetupMetricsReportingSettingVisibility(); |
132 | 163 |
133 void SetupFontSizeLabel(); | 164 void SetupFontSizeLabel(); |
134 | 165 |
135 // Setup the download path based on user preferences. | 166 // Setup the download folder based on user preferences. |
136 void SetupDownloadLocationPath(); | 167 void SetupDownloadLocationPath(); |
137 | 168 |
138 // Setup the pref whether to prompt for download location every time. | 169 // Setup the pref whether to prompt for download location every time. |
139 void SetupPromptForDownload(); | 170 void SetupPromptForDownload(); |
140 | 171 |
141 // Setup the enabled state of the reset button. | 172 // Setup the enabled state of the reset button. |
142 void SetupAutoOpenFileTypesDisabledAttribute(); | 173 void SetupAutoOpenFileTypesDisabledAttribute(); |
143 | 174 |
144 // Setup the proxy settings section UI. | 175 // Setup the proxy settings section UI. |
145 void SetupProxySettingsSection(); | 176 void SetupProxySettingsSection(); |
146 | 177 |
147 // Setup the checked state for SSL related checkboxes. | 178 // Setup the checked state for SSL related checkboxes. |
148 void SetupSSLConfigSettings(); | 179 void SetupSSLConfigSettings(); |
149 | 180 |
| 181 scoped_refptr<DownloadPathChecker> download_path_checker_; |
| 182 |
150 scoped_refptr<SelectFileDialog> select_folder_dialog_; | 183 scoped_refptr<SelectFileDialog> select_folder_dialog_; |
151 | 184 |
152 #if !defined(OS_CHROMEOS) | 185 #if !defined(OS_CHROMEOS) |
153 BooleanPrefMember enable_metrics_recording_; | 186 BooleanPrefMember enable_metrics_recording_; |
154 StringPrefMember cloud_print_proxy_email_; | 187 StringPrefMember cloud_print_proxy_email_; |
155 BooleanPrefMember cloud_print_proxy_enabled_; | 188 BooleanPrefMember cloud_print_proxy_enabled_; |
156 bool cloud_print_proxy_ui_enabled_; | 189 bool cloud_print_proxy_ui_enabled_; |
157 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; | 190 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; |
158 #endif | 191 #endif |
159 | 192 |
160 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 193 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
161 BooleanPrefMember background_mode_enabled_; | 194 BooleanPrefMember background_mode_enabled_; |
162 #endif | 195 #endif |
163 | 196 |
164 FilePathPrefMember default_download_location_; | 197 FilePathPrefMember default_download_location_; |
165 BooleanPrefMember ask_for_save_location_; | 198 BooleanPrefMember ask_for_save_location_; |
166 BooleanPrefMember allow_file_selection_dialogs_; | 199 BooleanPrefMember allow_file_selection_dialogs_; |
167 StringPrefMember auto_open_files_; | 200 StringPrefMember auto_open_files_; |
168 IntegerPrefMember default_font_size_; | 201 IntegerPrefMember default_font_size_; |
169 scoped_ptr<PrefSetObserver> proxy_prefs_; | 202 scoped_ptr<PrefSetObserver> proxy_prefs_; |
170 | 203 |
171 DISALLOW_COPY_AND_ASSIGN(AdvancedOptionsHandler); | 204 DISALLOW_COPY_AND_ASSIGN(AdvancedOptionsHandler); |
172 }; | 205 }; |
173 | 206 |
174 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_ | 207 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_ |
OLD | NEW |