OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "chrome/browser/prefs/pref_member.h" | |
12 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" | |
13 #include "chrome/browser/search_engines/template_url_service_observer.h" | |
14 #include "chrome/browser/shell_integration.h" | |
15 #include "chrome/browser/sync/profile_sync_service_observer.h" | |
16 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
17 #include "ui/base/dialogs/select_file_dialog.h" | |
18 #include "ui/base/models/table_model_observer.h" | |
19 | |
20 #if defined(OS_CHROMEOS) | |
21 #include "chrome/browser/chromeos/system/pointer_device_observer.h" | |
22 #else | |
23 #include "chrome/browser/prefs/pref_set_observer.h" | |
24 #endif // defined(OS_CHROMEOS) | |
25 | |
26 class AutocompleteController; | |
27 class CloudPrintSetupHandler; | |
28 class CustomHomePagesTableModel; | |
29 class TemplateURLService; | |
30 | |
31 namespace options { | |
32 | |
33 // Chrome browser options page UI handler. | |
34 class BrowserOptionsHandler | |
35 : public OptionsPageUIHandler, | |
36 public CloudPrintSetupHandlerDelegate, | |
37 public ProfileSyncServiceObserver, | |
38 public ui::SelectFileDialog::Listener, | |
39 public ShellIntegration::DefaultWebClientObserver, | |
40 #if defined(OS_CHROMEOS) | |
41 public chromeos::system::PointerDeviceObserver::Observer, | |
42 #endif | |
43 public TemplateURLServiceObserver { | |
44 public: | |
45 BrowserOptionsHandler(); | |
46 virtual ~BrowserOptionsHandler(); | |
47 | |
48 // OptionsPageUIHandler implementation. | |
49 virtual void GetLocalizedValues(DictionaryValue* values) OVERRIDE; | |
50 virtual void InitializeHandler() OVERRIDE; | |
51 virtual void InitializePage() OVERRIDE; | |
52 virtual void RegisterMessages() OVERRIDE; | |
53 | |
54 // ProfileSyncServiceObserver implementation. | |
55 virtual void OnStateChanged() OVERRIDE; | |
56 | |
57 // ShellIntegration::DefaultWebClientObserver implementation. | |
58 virtual void SetDefaultWebClientUIState( | |
59 ShellIntegration::DefaultWebClientUIState state) OVERRIDE; | |
60 virtual bool IsInteractiveSetDefaultPermitted() OVERRIDE; | |
61 | |
62 // TemplateURLServiceObserver implementation. | |
63 virtual void OnTemplateURLServiceChanged() OVERRIDE; | |
64 | |
65 private: | |
66 // content::NotificationObserver implementation. | |
67 virtual void Observe(int type, | |
68 const content::NotificationSource& source, | |
69 const content::NotificationDetails& details) OVERRIDE; | |
70 | |
71 // SelectFileDialog::Listener implementation | |
72 virtual void FileSelected(const FilePath& path, | |
73 int index, | |
74 void* params) OVERRIDE; | |
75 | |
76 // CloudPrintSetupHandler::Delegate implementation. | |
77 virtual void OnCloudPrintSetupClosed() OVERRIDE; | |
78 | |
79 #if defined(OS_CHROMEOS) | |
80 // PointerDeviceObserver::Observer implementation. | |
81 virtual void TouchpadExists(bool exists) OVERRIDE; | |
82 virtual void MouseExists(bool exists) OVERRIDE; | |
83 #endif | |
84 | |
85 // Makes this the default browser. Called from WebUI. | |
86 void BecomeDefaultBrowser(const base::ListValue* args); | |
87 | |
88 // Sets the search engine at the given index to be default. Called from WebUI. | |
89 void SetDefaultSearchEngine(const base::ListValue* args); | |
90 | |
91 // Enables/disables auto-launching of Chrome on computer startup. | |
92 void ToggleAutoLaunch(const base::ListValue* args); | |
93 | |
94 // Checks (on the file thread) whether the user is in the auto-launch trial | |
95 // and whether Chrome is set to auto-launch at login. Gets a reply on the UI | |
96 // thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in | |
97 // as a parameter to avoid the need to lock between this function and the | |
98 // destructor. |profile_path| is the full path to the current profile. | |
99 void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this, | |
100 const FilePath& profile_path); | |
101 | |
102 // Sets up (on the UI thread) the necessary bindings for toggling auto-launch | |
103 // (if the user is part of the auto-launch and makes sure the HTML UI knows | |
104 // whether Chrome will auto-launch at login. | |
105 void CheckAutoLaunchCallback(bool is_in_auto_launch_group, | |
106 bool will_launch_at_login); | |
107 | |
108 // Returns the string ID for the given default browser state. | |
109 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state); | |
110 | |
111 // Gets the current default browser state, and asynchronously reports it to | |
112 // the WebUI page. | |
113 void UpdateDefaultBrowserState(); | |
114 | |
115 // Updates the UI with the given state for the default browser. | |
116 void SetDefaultBrowserUIString(int status_string_id); | |
117 | |
118 // Loads the possible default search engine list and reports it to the WebUI. | |
119 void AddTemplateUrlServiceObserver(); | |
120 | |
121 // Creates a list of dictionaries where each dictionary is of the form: | |
122 // profileInfo = { | |
123 // name: "Profile Name", | |
124 // iconURL: "chrome://path/to/icon/image", | |
125 // filePath: "/path/to/profile/data/on/disk", | |
126 // isCurrentProfile: false | |
127 // }; | |
128 scoped_ptr<ListValue> GetProfilesInfoList(); | |
129 | |
130 // Sends an array of Profile objects to javascript. | |
131 void SendProfilesInfo(); | |
132 | |
133 // Asynchronously opens a new browser window to create a new profile. | |
134 void CreateProfile(const base::ListValue* args); | |
135 | |
136 // Generates a DictionaryValue object that represents a new profile's | |
137 // name and icon. | |
138 // |args| is not used. | |
139 void CreateProfileInfo(const base::ListValue* args); | |
140 | |
141 void ObserveThemeChanged(); | |
142 void ThemesReset(const base::ListValue* args); | |
143 #if defined(TOOLKIT_GTK) | |
144 void ThemesSetGTK(const base::ListValue* args); | |
145 #endif | |
146 | |
147 #if defined(OS_CHROMEOS) | |
148 void UpdateAccountPicture(); | |
149 #endif | |
150 | |
151 // Callback for the "selectDownloadLocation" message. This will prompt the | |
152 // user for a destination folder using platform-specific APIs. | |
153 void HandleSelectDownloadLocation(const ListValue* args); | |
154 | |
155 // Callback for the "autoOpenFileTypesResetToDefault" message. This will | |
156 // remove all auto-open file-type settings. | |
157 void HandleAutoOpenButton(const ListValue* args); | |
158 | |
159 // Callback for the "metricsReportingCheckboxAction" message. This is called | |
160 // if the user toggles the metrics reporting checkbox. | |
161 void HandleMetricsReportingCheckbox(const ListValue* args); | |
162 | |
163 // Callback for the "defaultFontSizeAction" message. This is called if the | |
164 // user changes the default font size. |args| is an array that contains | |
165 // one item, the font size as a numeric value. | |
166 void HandleDefaultFontSize(const ListValue* args); | |
167 | |
168 // Callback for the "defaultZoomFactorAction" message. This is called if the | |
169 // user changes the default zoom factor. |args| is an array that contains | |
170 // one item, the zoom factor as a numeric value. | |
171 void HandleDefaultZoomFactor(const ListValue* args); | |
172 | |
173 // Callback for the "Check for server certificate revocation" checkbox. This | |
174 // is called if the user toggles the "Check for server certificate revocation" | |
175 // checkbox. | |
176 void HandleCheckRevocationCheckbox(const ListValue* args); | |
177 | |
178 // Callback for the "Use SSL 3.0" checkbox. This is called if the user toggles | |
179 // the "Use SSL 3.0" checkbox. | |
180 void HandleUseSSL3Checkbox(const ListValue* args); | |
181 | |
182 // Callback for the "Use TLS 1.0" checkbox. This is called if the user toggles | |
183 // the "Use TLS 1.0" checkbox. | |
184 void HandleUseTLS1Checkbox(const ListValue* args); | |
185 | |
186 #if !defined(OS_CHROMEOS) | |
187 // Callback for the "showNetworkProxySettings" message. This will invoke | |
188 // an appropriate dialog for configuring proxy settings. | |
189 void ShowNetworkProxySettings(const ListValue* args); | |
190 #endif | |
191 | |
192 #if !defined(USE_NSS) | |
193 // Callback for the "showManageSSLCertificates" message. This will invoke | |
194 // an appropriate certificate management action based on the platform. | |
195 void ShowManageSSLCertificates(const ListValue* args); | |
196 #endif | |
197 | |
198 // Callback for the Cloud Print manage button. This will open a new | |
199 // tab pointed at the management URL. | |
200 void ShowCloudPrintManagePage(const ListValue* args); | |
201 | |
202 // Register localized values used by Cloud Print | |
203 void RegisterCloudPrintValues(DictionaryValue* values); | |
204 | |
205 #if !defined(OS_CHROMEOS) | |
206 // Callback for the Sign in to Cloud Print button. This will start | |
207 // the authentication process. | |
208 void ShowCloudPrintSetupDialog(const ListValue* args); | |
209 | |
210 // Callback for the Disable Cloud Print button. This will sign out | |
211 // of cloud print. | |
212 void HandleDisableCloudPrintConnector(const ListValue* args); | |
213 | |
214 // Pings the service to send us it's current notion of the enabled state. | |
215 void RefreshCloudPrintStatusFromService(); | |
216 | |
217 // Setup the enabled or disabled state of the cloud print connector | |
218 // management UI. | |
219 void SetupCloudPrintConnectorSection(); | |
220 | |
221 // Remove cloud print connector section if cloud print connector management | |
222 // UI is disabled. | |
223 void RemoveCloudPrintConnectorSection(); | |
224 #endif | |
225 | |
226 #if defined(OS_CHROMEOS) | |
227 // Opens the wallpaper manager component extension. | |
228 void HandleOpenWallpaperManager(const base::ListValue* args); | |
229 | |
230 // Called when the accessibility checkbox values are changed. | |
231 // |args| will contain the checkbox checked state as a string | |
232 // ("true" or "false"). | |
233 void SpokenFeedbackChangeCallback(const base::ListValue* args); | |
234 void HighContrastChangeCallback(const base::ListValue* args); | |
235 void ScreenMagnifierChangeCallback(const base::ListValue* args); | |
236 void VirtualKeyboardChangeCallback(const base::ListValue* args); | |
237 #endif | |
238 | |
239 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
240 // Sets up the checked state for the "Continue running background apps..." | |
241 // checkbox. | |
242 void SetupBackgroundModeSettings(); | |
243 | |
244 // Callback for the "Continue running background apps..." checkbox. | |
245 void HandleBackgroundModeCheckbox(const ListValue* args); | |
246 #endif | |
247 | |
248 // Setup the checked state for the metrics reporting checkbox. | |
249 void SetupMetricsReportingCheckbox(); | |
250 | |
251 // Setup the visibility for the metrics reporting setting. | |
252 void SetupMetricsReportingSettingVisibility(); | |
253 | |
254 // Setup the visibility for the password generation setting. | |
255 void SetupPasswordGenerationSettingVisibility(); | |
256 | |
257 // Setup the font size selector control. | |
258 void SetupFontSizeSelector(); | |
259 | |
260 // Setup the page zoom selector control. | |
261 void SetupPageZoomSelector(); | |
262 | |
263 // Setup the visibility of the reset button. | |
264 void SetupAutoOpenFileTypes(); | |
265 | |
266 // Setup the proxy settings section UI. | |
267 void SetupProxySettingsSection(); | |
268 | |
269 // Setup the checked state for SSL related checkboxes. | |
270 void SetupSSLConfigSettings(); | |
271 | |
272 #if defined(OS_CHROMEOS) | |
273 // Setup the accessibility features for ChromeOS. | |
274 void SetupAccessibilityFeatures(); | |
275 #endif | |
276 | |
277 // Returns a newly created dictionary with a number of properties that | |
278 // correspond to the status of sync. | |
279 scoped_ptr<DictionaryValue> GetSyncStateDictionary(); | |
280 | |
281 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | |
282 | |
283 StringPrefMember homepage_; | |
284 BooleanPrefMember default_browser_policy_; | |
285 | |
286 TemplateURLService* template_url_service_; // Weak. | |
287 | |
288 // Used to get |weak_ptr_| to self for use on the File thread. | |
289 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_file_; | |
290 // Used to post update tasks to the UI thread. | |
291 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_ui_; | |
292 | |
293 // True if the multiprofiles switch is enabled. | |
294 bool multiprofile_; | |
295 | |
296 scoped_refptr<ui::SelectFileDialog> select_folder_dialog_; | |
297 | |
298 #if !defined(OS_CHROMEOS) | |
299 BooleanPrefMember enable_metrics_recording_; | |
300 StringPrefMember cloud_print_connector_email_; | |
301 BooleanPrefMember cloud_print_connector_enabled_; | |
302 bool cloud_print_connector_ui_enabled_; | |
303 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; | |
304 #endif | |
305 | |
306 // SSLConfigService prefs. | |
307 BooleanPrefMember rev_checking_enabled_; | |
308 | |
309 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
310 BooleanPrefMember background_mode_enabled_; | |
311 #endif | |
312 | |
313 StringPrefMember auto_open_files_; | |
314 IntegerPrefMember default_font_size_; | |
315 DoublePrefMember default_zoom_level_; | |
316 | |
317 #if !defined(OS_CHROMEOS) | |
318 scoped_ptr<PrefSetObserver> proxy_prefs_; | |
319 #endif // !defined(OS_CHROMEOS) | |
320 | |
321 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | |
322 }; | |
323 | |
324 } // namespace options | |
325 | |
326 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
OLD | NEW |