OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/dom_ui/advanced_options_handler.h" | 5 #include "chrome/browser/dom_ui/advanced_options_handler.h" |
6 | 6 |
| 7 #if defined(OS_WIN) |
| 8 #include <cryptuiapi.h> |
| 9 #pragma comment(lib, "cryptui.lib") |
| 10 #endif |
| 11 |
7 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
9 #include "base/callback.h" | 14 #include "base/callback.h" |
10 #include "base/values.h" | 15 #include "base/values.h" |
11 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
12 #include "chrome/browser/metrics/user_metrics.h" | |
13 #include "chrome/browser/pref_service.h" | 17 #include "chrome/browser/pref_service.h" |
14 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
16 #include "chrome/browser/tab_contents/tab_contents_view.h" | 20 #include "chrome/browser/tab_contents/tab_contents_view.h" |
17 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
18 #include "chrome/common/notification_type.h" | 22 #include "chrome/common/notification_type.h" |
19 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
20 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
21 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
22 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
23 | 27 |
24 #if !defined(OS_CHROMEOS) | |
25 #include "chrome/browser/dom_ui/advanced_options_utils.h" | |
26 #endif | |
27 | |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 #include "net/base/ssl_config_service_win.h" | 29 #include "net/base/ssl_config_service_win.h" |
30 #endif | 30 #endif |
31 | 31 |
| 32 #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) |
| 33 // The URL for Linux ssl certificate configuration help. |
| 34 const char* const kLinuxCertificatesConfigUrl = |
| 35 "http://code.google.com/p/chromium/wiki/LinuxCertManagement"; |
| 36 #endif |
| 37 |
32 AdvancedOptionsHandler::AdvancedOptionsHandler() { | 38 AdvancedOptionsHandler::AdvancedOptionsHandler() { |
33 } | 39 } |
34 | 40 |
35 AdvancedOptionsHandler::~AdvancedOptionsHandler() { | 41 AdvancedOptionsHandler::~AdvancedOptionsHandler() { |
36 } | 42 } |
37 | 43 |
38 void AdvancedOptionsHandler::GetLocalizedValues( | 44 void AdvancedOptionsHandler::GetLocalizedValues( |
39 DictionaryValue* localized_strings) { | 45 DictionaryValue* localized_strings) { |
40 DCHECK(localized_strings); | 46 DCHECK(localized_strings); |
41 | 47 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 150 |
145 void AdvancedOptionsHandler::RegisterMessages() { | 151 void AdvancedOptionsHandler::RegisterMessages() { |
146 // Setup handlers specific to this panel. | 152 // Setup handlers specific to this panel. |
147 DCHECK(dom_ui_); | 153 DCHECK(dom_ui_); |
148 dom_ui_->RegisterMessageCallback("selectDownloadLocation", | 154 dom_ui_->RegisterMessageCallback("selectDownloadLocation", |
149 NewCallback(this, | 155 NewCallback(this, |
150 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); | 156 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); |
151 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", | 157 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", |
152 NewCallback(this, | 158 NewCallback(this, |
153 &AdvancedOptionsHandler::HandleAutoOpenButton)); | 159 &AdvancedOptionsHandler::HandleAutoOpenButton)); |
154 #if !defined(OS_CHROMEOS) | |
155 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", | 160 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", |
156 NewCallback(this, | 161 NewCallback(this, |
157 &AdvancedOptionsHandler::ShowManageSSLCertificates)); | 162 &AdvancedOptionsHandler::ShowManageSSLCertificates)); |
158 dom_ui_->RegisterMessageCallback("showNetworkProxySettings", | 163 dom_ui_->RegisterMessageCallback("showNetworkProxySettings", |
159 NewCallback(this, | 164 NewCallback(this, |
160 &AdvancedOptionsHandler::ShowNetworkProxySettings)); | 165 &AdvancedOptionsHandler::ShowNetworkProxySettings)); |
161 #endif | |
162 | 166 |
163 #if defined(OS_WIN) | 167 #if defined(OS_WIN) |
164 // Setup Windows specific callbacks. | 168 // Setup Windows specific callbacks. |
165 dom_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", | 169 dom_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", |
166 NewCallback(this, | 170 NewCallback(this, |
167 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); | 171 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); |
168 dom_ui_->RegisterMessageCallback("useSSL2CheckboxAction", | 172 dom_ui_->RegisterMessageCallback("useSSL2CheckboxAction", |
169 NewCallback(this, | 173 NewCallback(this, |
170 &AdvancedOptionsHandler::HandleUseSSL2Checkbox)); | 174 &AdvancedOptionsHandler::HandleUseSSL2Checkbox)); |
171 #endif | 175 #endif |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 "arguments"; | 242 "arguments"; |
239 return; | 243 return; |
240 } | 244 } |
241 std::string checked_str; | 245 std::string checked_str; |
242 if (list->GetString(0, &checked_str)) { | 246 if (list->GetString(0, &checked_str)) { |
243 net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); | 247 net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); |
244 } | 248 } |
245 } | 249 } |
246 #endif | 250 #endif |
247 | 251 |
248 #if !defined(OS_CHROMEOS) | |
249 void AdvancedOptionsHandler::ShowNetworkProxySettings(const Value* value) { | |
250 UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings"), NULL); | |
251 DCHECK(dom_ui_); | |
252 AdvancedOptionsUtilities::ShowNetworkProxySettings(dom_ui_->tab_contents()); | |
253 } | |
254 | |
255 void AdvancedOptionsHandler::ShowManageSSLCertificates(const Value* value) { | |
256 UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates"), | |
257 NULL); | |
258 DCHECK(dom_ui_); | |
259 AdvancedOptionsUtilities::ShowManageSSLCertificates(dom_ui_->tab_contents()); | |
260 } | |
261 #endif | |
262 | |
263 void AdvancedOptionsHandler::SetupDownloadLocationPath() { | 252 void AdvancedOptionsHandler::SetupDownloadLocationPath() { |
264 DCHECK(dom_ui_); | 253 DCHECK(dom_ui_); |
265 StringValue value(default_download_location_.GetValue().value()); | 254 StringValue value(default_download_location_.GetValue().value()); |
266 dom_ui_->CallJavascriptFunction( | 255 dom_ui_->CallJavascriptFunction( |
267 L"advancedOptionsSetDownloadLocationPath", value); | 256 L"advancedOptionsSetDownloadLocationPath", value); |
268 } | 257 } |
269 | 258 |
270 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 259 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
271 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 260 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
272 // We enable the button if the user has any auto-open file types registered. | 261 // We enable the button if the user has any auto-open file types registered. |
(...skipping 17 matching lines...) Expand all Loading... |
290 useSSLSetting = config.ssl2_enabled; | 279 useSSLSetting = config.ssl2_enabled; |
291 } | 280 } |
292 FundamentalValue checkRevocationValue(checkRevocationSetting); | 281 FundamentalValue checkRevocationValue(checkRevocationSetting); |
293 dom_ui_->CallJavascriptFunction( | 282 dom_ui_->CallJavascriptFunction( |
294 L"advancedOptionsSetCheckRevocationCheckboxState", checkRevocationValue); | 283 L"advancedOptionsSetCheckRevocationCheckboxState", checkRevocationValue); |
295 FundamentalValue useSSLValue(useSSLSetting); | 284 FundamentalValue useSSLValue(useSSLSetting); |
296 dom_ui_->CallJavascriptFunction( | 285 dom_ui_->CallJavascriptFunction( |
297 L"advancedOptionsSetUseSSL2CheckboxStatechecked", useSSLValue); | 286 L"advancedOptionsSetUseSSL2CheckboxStatechecked", useSSLValue); |
298 } | 287 } |
299 #endif | 288 #endif |
| 289 |
| 290 void AdvancedOptionsHandler::ShowNetworkProxySettings(const Value* value) { |
| 291 #if defined(OS_MACOSX) |
| 292 AdvancedOptionsUtilities::ShowNetworkProxySettings(); |
| 293 #endif |
| 294 } |
| 295 |
| 296 void AdvancedOptionsHandler::ShowManageSSLCertificates(const Value* value) { |
| 297 #if defined(OS_MACOSX) |
| 298 AdvancedOptionsUtilities::ShowManageSSLCertificates(); |
| 299 #elif defined(OS_WIN) |
| 300 DCHECK(dom_ui_); |
| 301 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; |
| 302 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); |
| 303 cert_mgr.hwndParent = |
| 304 dom_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); |
| 305 ::CryptUIDlgCertMgr(&cert_mgr); |
| 306 #elif defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) |
| 307 DCHECK(dom_ui_); |
| 308 dom_ui_->tab_contents()->OpenURL(GURL(kLinuxCertificatesConfigUrl), GURL(), |
| 309 NEW_WINDOW, PageTransition::LINK); |
| 310 #endif |
| 311 } |
OLD | NEW |