• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_
7 #pragma once
8 
9 #include "chrome/browser/prefs/pref_member.h"
10 #include "chrome/browser/prefs/pref_set_observer.h"
11 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h"
12 #include "chrome/browser/remoting/remoting_options_handler.h"
13 #include "chrome/browser/ui/shell_dialogs.h"
14 #include "chrome/browser/ui/webui/options/options_ui.h"
15 
16 class OptionsManagedBannerHandler;
17 class CloudPrintSetupHandler;
18 
19 // Chrome advanced options page UI handler.
20 class AdvancedOptionsHandler
21     : public OptionsPageUIHandler,
22       public SelectFileDialog::Listener,
23       public CloudPrintSetupHandlerDelegate {
24  public:
25   AdvancedOptionsHandler();
26   virtual ~AdvancedOptionsHandler();
27 
28   // OptionsPageUIHandler implementation.
29   virtual void GetLocalizedValues(DictionaryValue* localized_strings);
30   virtual void Initialize();
31 
32   // WebUIMessageHandler implementation.
33   virtual WebUIMessageHandler* Attach(WebUI* web_ui);
34   virtual void RegisterMessages();
35 
36   // NotificationObserver implementation.
37   virtual void Observe(NotificationType type,
38                        const NotificationSource& source,
39                        const NotificationDetails& details);
40 
41   // SelectFileDialog::Listener implementation
42   virtual void FileSelected(const FilePath& path, int index, void* params);
43 
44   // CloudPrintSetupHandler::Delegate implementation.
45   virtual void OnCloudPrintSetupClosed();
46 
47  private:
48   // Callback for the "selectDownloadLocation" message.  This will prompt
49   // the user for a destination folder using platform-specific APIs.
50   void HandleSelectDownloadLocation(const ListValue* args);
51 
52   // Callback for the "promptForDownloadAction" message.  This will set
53   // the ask for save location pref accordingly.
54   void HandlePromptForDownload(const ListValue* args);
55 
56   // Callback for the "autoOpenFileTypesResetToDefault" message.  This will
57   // remove all auto-open file-type settings.
58   void HandleAutoOpenButton(const ListValue* args);
59 
60   // Callback for the "metricsReportingCheckboxAction" message.  This is called
61   // if the user toggles the metrics reporting checkbox.
62   void HandleMetricsReportingCheckbox(const ListValue* args);
63 
64   // Callback for the "defaultFontSizeAction" message.  This is called if the
65   // user changes the default font size.  |args| is an array that contains
66   // one item, the font size as a numeric value.
67   void HandleDefaultFontSize(const ListValue* args);
68 
69   // Callback for the "Check for server certificate revocation" checkbox. This
70   // is called if the user toggles the "Check for server certificate revocation"
71   // checkbox.
72   void HandleCheckRevocationCheckbox(const ListValue* args);
73 
74   // Callback for the "Use SSL 3.0" checkbox. This is called if the user toggles
75   // the "Use SSL 3.0" checkbox.
76   void HandleUseSSL3Checkbox(const ListValue* args);
77 
78   // Callback for the "Use TLS 1.0" checkbox. This is called if the user toggles
79   // the "Use TLS 1.0" checkbox.
80   void HandleUseTLS1Checkbox(const ListValue* args);
81 
82 #if !defined(OS_CHROMEOS)
83   // Callback for the "showNetworkProxySettings" message. This will invoke
84   // an appropriate dialog for configuring proxy settings.
85   void ShowNetworkProxySettings(const ListValue* args);
86 #endif
87 
88 #if !defined(USE_NSS)
89   // Callback for the "showManageSSLCertificates" message. This will invoke
90   // an appropriate certificate management action based on the platform.
91   void ShowManageSSLCertificates(const ListValue* args);
92 #endif
93 
94 #if !defined(OS_CHROMEOS)
95   // Callback for the Sign in to Cloud Print button.  This will start
96   // the authentication process.
97   void ShowCloudPrintSetupDialog(const ListValue* args);
98 
99   // Callback for the Disable Cloud Print button.  This will sign out
100   // of cloud print.
101   void HandleDisableCloudPrintProxy(const ListValue* args);
102 
103   // Callback for the Cloud Print manage button.  This will open a new
104   // tab pointed at the management URL.
105   void ShowCloudPrintManagePage(const ListValue* args);
106 
107   // Pings the service to send us it's current notion of the enabled state.
108   void RefreshCloudPrintStatusFromService();
109 
110   // Setup the enabled or disabled state of the cloud print proxy
111   // management UI.
112   void SetupCloudPrintProxySection();
113 
114   // Remove cloud print proxy section if cloud print proxy management UI is
115   // disabled.
116   void RemoveCloudPrintProxySection();
117 
118 #endif
119 
120 #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
121   // Removes remoting section. Called if remoting is not enabled.
122   void RemoveRemotingSection();
123 
124   // Callback for Setup Remoting button.
125   void ShowRemotingSetupDialog(const ListValue* args);
126 
127   // Disable Remoting.
128   void DisableRemoting(const ListValue* args);
129 #endif
130 
131   // Setup the checked state for the metrics reporting checkbox.
132   void SetupMetricsReportingCheckbox();
133 
134   // Setup the visibility for the metrics reporting setting.
135   void SetupMetricsReportingSettingVisibility();
136 
137   void SetupFontSizeLabel();
138 
139   // Setup the download path based on user preferences.
140   void SetupDownloadLocationPath();
141 
142   // Setup the pref whether to prompt for download location every time.
143   void SetupPromptForDownload();
144 
145   // Setup the enabled state of the reset button.
146   void SetupAutoOpenFileTypesDisabledAttribute();
147 
148   // Setup the proxy settings section UI.
149   void SetupProxySettingsSection();
150 
151   // Setup the checked state for SSL related checkboxes.
152   void SetupSSLConfigSettings();
153 
154   scoped_refptr<SelectFileDialog> select_folder_dialog_;
155 
156 #if !defined(OS_CHROMEOS)
157   BooleanPrefMember enable_metrics_recording_;
158   StringPrefMember cloud_print_proxy_email_;
159   BooleanPrefMember cloud_print_proxy_enabled_;
160   bool cloud_print_proxy_ui_enabled_;
161   scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_;
162 #endif
163 
164   // SSLConfigService prefs.
165   BooleanPrefMember rev_checking_enabled_;
166   BooleanPrefMember ssl3_enabled_;
167   BooleanPrefMember tls1_enabled_;
168 
169 #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
170   remoting::RemotingOptionsHandler remoting_options_handler_;
171 #endif
172 
173   FilePathPrefMember default_download_location_;
174   BooleanPrefMember ask_for_save_location_;
175   StringPrefMember auto_open_files_;
176   IntegerPrefMember default_font_size_;
177   scoped_ptr<PrefSetObserver> proxy_prefs_;
178   scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
179 
180   DISALLOW_COPY_AND_ASSIGN(AdvancedOptionsHandler);
181 };
182 
183 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_
184