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_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
13 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
14 #include "chrome/browser/prefs/pref_member.h" | 14 #include "chrome/browser/prefs/pref_member.h" |
| 15 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
15 #include "chrome/browser/search_engines/template_url_service_observer.h" | 16 #include "chrome/browser/search_engines/template_url_service_observer.h" |
16 #include "chrome/browser/shell_integration.h" | 17 #include "chrome/browser/shell_integration.h" |
17 #include "chrome/browser/sync/profile_sync_service_observer.h" | 18 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 19 #include "chrome/browser/ui/select_file_dialog.h" |
18 #include "chrome/browser/ui/webui/options2/options_ui2.h" | 20 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
19 #include "ui/base/models/table_model_observer.h" | 21 #include "ui/base/models/table_model_observer.h" |
20 | 22 |
| 23 #if !defined(OS_CHROMEOS) |
| 24 #include "chrome/browser/prefs/pref_set_observer.h" |
| 25 #endif // !defined(OS_CHROMEOS) |
| 26 |
21 class AutocompleteController; | 27 class AutocompleteController; |
| 28 class CloudPrintSetupHandler; |
22 class CustomHomePagesTableModel; | 29 class CustomHomePagesTableModel; |
23 class TemplateURLService; | 30 class TemplateURLService; |
24 | 31 |
25 namespace options2 { | 32 namespace options2 { |
26 | 33 |
27 // Chrome browser options page UI handler. | 34 // Chrome browser options page UI handler. |
28 class BrowserOptionsHandler | 35 class BrowserOptionsHandler |
29 : public OptionsPageUIHandler, | 36 : public OptionsPageUIHandler, |
| 37 public AutocompleteControllerDelegate, |
| 38 public CloudPrintSetupHandlerDelegate, |
30 public ProfileSyncServiceObserver, | 39 public ProfileSyncServiceObserver, |
31 public AutocompleteControllerDelegate, | 40 public SelectFileDialog::Listener, |
32 public ShellIntegration::DefaultWebClientObserver, | 41 public ShellIntegration::DefaultWebClientObserver, |
33 public TemplateURLServiceObserver { | 42 public TemplateURLServiceObserver { |
34 public: | 43 public: |
35 BrowserOptionsHandler(); | 44 BrowserOptionsHandler(); |
36 virtual ~BrowserOptionsHandler(); | 45 virtual ~BrowserOptionsHandler(); |
37 | 46 |
38 virtual void Initialize() OVERRIDE; | 47 virtual void Initialize() OVERRIDE; |
39 | 48 |
40 // OptionsPageUIHandler implementation. | 49 // OptionsPageUIHandler implementation. |
41 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | 50 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
53 | 62 |
54 // TemplateURLServiceObserver implementation. | 63 // TemplateURLServiceObserver implementation. |
55 virtual void OnTemplateURLServiceChanged() OVERRIDE; | 64 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
56 | 65 |
57 private: | 66 private: |
58 // content::NotificationObserver implementation. | 67 // content::NotificationObserver implementation. |
59 virtual void Observe(int type, | 68 virtual void Observe(int type, |
60 const content::NotificationSource& source, | 69 const content::NotificationSource& source, |
61 const content::NotificationDetails& details) OVERRIDE; | 70 const content::NotificationDetails& details) OVERRIDE; |
62 | 71 |
| 72 // SelectFileDialog::Listener implementation |
| 73 virtual void FileSelected(const FilePath& path, |
| 74 int index, |
| 75 void* params) OVERRIDE; |
| 76 |
| 77 // CloudPrintSetupHandler::Delegate implementation. |
| 78 virtual void OnCloudPrintSetupClosed() OVERRIDE; |
| 79 |
63 // Makes this the default browser. Called from WebUI. | 80 // Makes this the default browser. Called from WebUI. |
64 void BecomeDefaultBrowser(const base::ListValue* args); | 81 void BecomeDefaultBrowser(const base::ListValue* args); |
65 | 82 |
66 // Sets the search engine at the given index to be default. Called from WebUI. | 83 // Sets the search engine at the given index to be default. Called from WebUI. |
67 void SetDefaultSearchEngine(const base::ListValue* args); | 84 void SetDefaultSearchEngine(const base::ListValue* args); |
68 | 85 |
69 // Gets autocomplete suggestions asynchronously for the given string. | 86 // Gets autocomplete suggestions asynchronously for the given string. |
70 // Called from WebUI. | 87 // Called from WebUI. |
71 void RequestAutocompleteSuggestions(const base::ListValue* args); | 88 void RequestAutocompleteSuggestions(const base::ListValue* args); |
72 | 89 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 #if defined(OS_CHROMEOS) | 150 #if defined(OS_CHROMEOS) |
134 // Called when the System configuration screen is used to adjust | 151 // Called when the System configuration screen is used to adjust |
135 // the screen brightness. | 152 // the screen brightness. |
136 // |args| will be an empty list. | 153 // |args| will be an empty list. |
137 void DecreaseScreenBrightnessCallback(const base::ListValue* args); | 154 void DecreaseScreenBrightnessCallback(const base::ListValue* args); |
138 void IncreaseScreenBrightnessCallback(const base::ListValue* args); | 155 void IncreaseScreenBrightnessCallback(const base::ListValue* args); |
139 | 156 |
140 void UpdateAccountPicture(); | 157 void UpdateAccountPicture(); |
141 #endif | 158 #endif |
142 | 159 |
| 160 // Callback for the "selectDownloadLocation" message. This will prompt the |
| 161 // user for a destination folder using platform-specific APIs. |
| 162 void HandleSelectDownloadLocation(const ListValue* args); |
| 163 |
| 164 // Callback for the "autoOpenFileTypesResetToDefault" message. This will |
| 165 // remove all auto-open file-type settings. |
| 166 void HandleAutoOpenButton(const ListValue* args); |
| 167 |
| 168 // Callback for the "metricsReportingCheckboxAction" message. This is called |
| 169 // if the user toggles the metrics reporting checkbox. |
| 170 void HandleMetricsReportingCheckbox(const ListValue* args); |
| 171 |
| 172 // Callback for the "defaultFontSizeAction" message. This is called if the |
| 173 // user changes the default font size. |args| is an array that contains |
| 174 // one item, the font size as a numeric value. |
| 175 void HandleDefaultFontSize(const ListValue* args); |
| 176 |
| 177 // Callback for the "defaultZoomFactorAction" message. This is called if the |
| 178 // user changes the default zoom factor. |args| is an array that contains |
| 179 // one item, the zoom factor as a numeric value. |
| 180 void HandleDefaultZoomFactor(const ListValue* args); |
| 181 |
| 182 // Callback for the "Check for server certificate revocation" checkbox. This |
| 183 // is called if the user toggles the "Check for server certificate revocation" |
| 184 // checkbox. |
| 185 void HandleCheckRevocationCheckbox(const ListValue* args); |
| 186 |
| 187 // Callback for the "Use SSL 3.0" checkbox. This is called if the user toggles |
| 188 // the "Use SSL 3.0" checkbox. |
| 189 void HandleUseSSL3Checkbox(const ListValue* args); |
| 190 |
| 191 // Callback for the "Use TLS 1.0" checkbox. This is called if the user toggles |
| 192 // the "Use TLS 1.0" checkbox. |
| 193 void HandleUseTLS1Checkbox(const ListValue* args); |
| 194 |
| 195 #if !defined(OS_CHROMEOS) |
| 196 // Callback for the "showNetworkProxySettings" message. This will invoke |
| 197 // an appropriate dialog for configuring proxy settings. |
| 198 void ShowNetworkProxySettings(const ListValue* args); |
| 199 #endif |
| 200 |
| 201 #if !defined(USE_NSS) |
| 202 // Callback for the "showManageSSLCertificates" message. This will invoke |
| 203 // an appropriate certificate management action based on the platform. |
| 204 void ShowManageSSLCertificates(const ListValue* args); |
| 205 #endif |
| 206 |
| 207 // Callback for the Cloud Print manage button. This will open a new |
| 208 // tab pointed at the management URL. |
| 209 void ShowCloudPrintManagePage(const ListValue* args); |
| 210 |
| 211 // Register localized strings used by Cloud Print |
| 212 void RegisterCloudPrintStrings(DictionaryValue* localized_strings); |
| 213 |
| 214 #if !defined(OS_CHROMEOS) |
| 215 // Callback for the Sign in to Cloud Print button. This will start |
| 216 // the authentication process. |
| 217 void ShowCloudPrintSetupDialog(const ListValue* args); |
| 218 |
| 219 // Callback for the Disable Cloud Print button. This will sign out |
| 220 // of cloud print. |
| 221 void HandleDisableCloudPrintConnector(const ListValue* args); |
| 222 |
| 223 // Pings the service to send us it's current notion of the enabled state. |
| 224 void RefreshCloudPrintStatusFromService(); |
| 225 |
| 226 // Setup the enabled or disabled state of the cloud print connector |
| 227 // management UI. |
| 228 void SetupCloudPrintConnectorSection(); |
| 229 |
| 230 // Remove cloud print connector section if cloud print connector management |
| 231 // UI is disabled. |
| 232 void RemoveCloudPrintConnectorSection(); |
| 233 #endif |
| 234 |
| 235 #if defined(OS_CHROMEOS) |
| 236 // Called when the accessibility checkbox values are changed. |
| 237 // |args| will contain the checkbox checked state as a string |
| 238 // ("true" or "false"). |
| 239 void SpokenFeedbackChangeCallback(const base::ListValue* args); |
| 240 void HighContrastChangeCallback(const base::ListValue* args); |
| 241 void ScreenMagnifierChangeCallback(const base::ListValue* args); |
| 242 void VirtualKeyboardChangeCallback(const base::ListValue* args); |
| 243 #endif |
| 244 |
| 245 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 246 // Sets up the checked state for the "Continue running background apps..." |
| 247 // checkbox. |
| 248 void SetupBackgroundModeSettings(); |
| 249 |
| 250 // Callback for the "Continue running background apps..." checkbox. |
| 251 void HandleBackgroundModeCheckbox(const ListValue* args); |
| 252 #endif |
| 253 |
| 254 // Setup the checked state for the metrics reporting checkbox. |
| 255 void SetupMetricsReportingCheckbox(); |
| 256 |
| 257 // Setup the visibility for the metrics reporting setting. |
| 258 void SetupMetricsReportingSettingVisibility(); |
| 259 |
| 260 // Setup the font size selector control. |
| 261 void SetupFontSizeSelector(); |
| 262 |
| 263 // Setup the page zoom selector control. |
| 264 void SetupPageZoomSelector(); |
| 265 |
| 266 // Setup the enabled state of the reset button. |
| 267 void SetupAutoOpenFileTypesDisabledAttribute(); |
| 268 |
| 269 // Setup the proxy settings section UI. |
| 270 void SetupProxySettingsSection(); |
| 271 |
| 272 // Setup the checked state for SSL related checkboxes. |
| 273 void SetupSSLConfigSettings(); |
| 274 |
| 275 #if defined(OS_CHROMEOS) |
| 276 // Setup the accessibility features for ChromeOS. |
| 277 void SetupAccessibilityFeatures(); |
| 278 #endif |
| 279 |
143 // Returns a newly created dictionary with a number of properties that | 280 // Returns a newly created dictionary with a number of properties that |
144 // correspond to the status of sync. | 281 // correspond to the status of sync. |
145 DictionaryValue* GetSyncStateDictionary(); | 282 DictionaryValue* GetSyncStateDictionary(); |
146 | 283 |
147 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | 284 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; |
148 | 285 |
149 StringPrefMember homepage_; | 286 StringPrefMember homepage_; |
150 BooleanPrefMember default_browser_policy_; | 287 BooleanPrefMember default_browser_policy_; |
151 | 288 |
152 // Used to observe updates to the preference of the list of URLs to load | 289 // Used to observe updates to the preference of the list of URLs to load |
153 // on startup, which can be updated via sync. | 290 // on startup, which can be updated via sync. |
154 PrefChangeRegistrar pref_change_registrar_; | 291 PrefChangeRegistrar pref_change_registrar_; |
155 | 292 |
156 TemplateURLService* template_url_service_; // Weak. | 293 TemplateURLService* template_url_service_; // Weak. |
157 | 294 |
158 scoped_ptr<AutocompleteController> autocomplete_controller_; | 295 scoped_ptr<AutocompleteController> autocomplete_controller_; |
159 | 296 |
160 // Used to get |weak_ptr_| to self for use on the File thread. | 297 // Used to get |weak_ptr_| to self for use on the File thread. |
161 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_file_; | 298 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_file_; |
162 // Used to post update tasks to the UI thread. | 299 // Used to post update tasks to the UI thread. |
163 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_ui_; | 300 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_ui_; |
164 | 301 |
165 // True if the multiprofiles switch is enabled. | 302 // True if the multiprofiles switch is enabled. |
166 bool multiprofile_; | 303 bool multiprofile_; |
167 | 304 |
| 305 scoped_refptr<SelectFileDialog> select_folder_dialog_; |
| 306 |
| 307 #if !defined(OS_CHROMEOS) |
| 308 BooleanPrefMember enable_metrics_recording_; |
| 309 StringPrefMember cloud_print_connector_email_; |
| 310 BooleanPrefMember cloud_print_connector_enabled_; |
| 311 bool cloud_print_connector_ui_enabled_; |
| 312 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; |
| 313 #endif |
| 314 |
| 315 // SSLConfigService prefs. |
| 316 BooleanPrefMember rev_checking_enabled_; |
| 317 |
| 318 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 319 BooleanPrefMember background_mode_enabled_; |
| 320 #endif |
| 321 |
| 322 StringPrefMember auto_open_files_; |
| 323 IntegerPrefMember default_font_size_; |
| 324 DoublePrefMember default_zoom_level_; |
| 325 |
| 326 #if !defined(OS_CHROMEOS) |
| 327 scoped_ptr<PrefSetObserver> proxy_prefs_; |
| 328 #endif // !defined(OS_CHROMEOS) |
| 329 |
168 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | 330 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); |
169 }; | 331 }; |
170 | 332 |
171 } // namespace options2 | 333 } // namespace options2 |
172 | 334 |
173 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 335 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
OLD | NEW |