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 | |
12 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
13 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
14 #include "base/callback.h" | 9 #include "base/callback.h" |
15 #include "base/values.h" | 10 #include "base/values.h" |
16 #include "chrome/browser/download/download_manager.h" | 11 #include "chrome/browser/download/download_manager.h" |
| 12 #include "chrome/browser/metrics/user_metrics.h" |
17 #include "chrome/browser/pref_service.h" | 13 #include "chrome/browser/pref_service.h" |
18 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
19 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
20 #include "chrome/browser/tab_contents/tab_contents_view.h" | 16 #include "chrome/browser/tab_contents/tab_contents_view.h" |
21 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
22 #include "chrome/common/notification_type.h" | 18 #include "chrome/common/notification_type.h" |
23 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
24 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
25 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
26 #include "grit/locale_settings.h" | 22 #include "grit/locale_settings.h" |
27 | 23 |
| 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 | |
38 AdvancedOptionsHandler::AdvancedOptionsHandler() { | 32 AdvancedOptionsHandler::AdvancedOptionsHandler() { |
39 } | 33 } |
40 | 34 |
41 AdvancedOptionsHandler::~AdvancedOptionsHandler() { | 35 AdvancedOptionsHandler::~AdvancedOptionsHandler() { |
42 } | 36 } |
43 | 37 |
44 void AdvancedOptionsHandler::GetLocalizedValues( | 38 void AdvancedOptionsHandler::GetLocalizedValues( |
45 DictionaryValue* localized_strings) { | 39 DictionaryValue* localized_strings) { |
46 DCHECK(localized_strings); | 40 DCHECK(localized_strings); |
47 | 41 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 144 |
151 void AdvancedOptionsHandler::RegisterMessages() { | 145 void AdvancedOptionsHandler::RegisterMessages() { |
152 // Setup handlers specific to this panel. | 146 // Setup handlers specific to this panel. |
153 DCHECK(dom_ui_); | 147 DCHECK(dom_ui_); |
154 dom_ui_->RegisterMessageCallback("selectDownloadLocation", | 148 dom_ui_->RegisterMessageCallback("selectDownloadLocation", |
155 NewCallback(this, | 149 NewCallback(this, |
156 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); | 150 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); |
157 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", | 151 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", |
158 NewCallback(this, | 152 NewCallback(this, |
159 &AdvancedOptionsHandler::HandleAutoOpenButton)); | 153 &AdvancedOptionsHandler::HandleAutoOpenButton)); |
| 154 #if !defined(OS_CHROMEOS) |
160 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", | 155 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", |
161 NewCallback(this, | 156 NewCallback(this, |
162 &AdvancedOptionsHandler::ShowManageSSLCertificates)); | 157 &AdvancedOptionsHandler::ShowManageSSLCertificates)); |
163 dom_ui_->RegisterMessageCallback("showNetworkProxySettings", | 158 dom_ui_->RegisterMessageCallback("showNetworkProxySettings", |
164 NewCallback(this, | 159 NewCallback(this, |
165 &AdvancedOptionsHandler::ShowNetworkProxySettings)); | 160 &AdvancedOptionsHandler::ShowNetworkProxySettings)); |
| 161 #endif |
166 | 162 |
167 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
168 // Setup Windows specific callbacks. | 164 // Setup Windows specific callbacks. |
169 dom_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", | 165 dom_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", |
170 NewCallback(this, | 166 NewCallback(this, |
171 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); | 167 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); |
172 dom_ui_->RegisterMessageCallback("useSSL2CheckboxAction", | 168 dom_ui_->RegisterMessageCallback("useSSL2CheckboxAction", |
173 NewCallback(this, | 169 NewCallback(this, |
174 &AdvancedOptionsHandler::HandleUseSSL2Checkbox)); | 170 &AdvancedOptionsHandler::HandleUseSSL2Checkbox)); |
175 #endif | 171 #endif |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 "arguments"; | 238 "arguments"; |
243 return; | 239 return; |
244 } | 240 } |
245 std::string checked_str; | 241 std::string checked_str; |
246 if (list->GetString(0, &checked_str)) { | 242 if (list->GetString(0, &checked_str)) { |
247 net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); | 243 net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); |
248 } | 244 } |
249 } | 245 } |
250 #endif | 246 #endif |
251 | 247 |
| 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 |
252 void AdvancedOptionsHandler::SetupDownloadLocationPath() { | 263 void AdvancedOptionsHandler::SetupDownloadLocationPath() { |
253 DCHECK(dom_ui_); | 264 DCHECK(dom_ui_); |
254 StringValue value(default_download_location_.GetValue().value()); | 265 StringValue value(default_download_location_.GetValue().value()); |
255 dom_ui_->CallJavascriptFunction( | 266 dom_ui_->CallJavascriptFunction( |
256 L"advancedOptionsSetDownloadLocationPath", value); | 267 L"advancedOptionsSetDownloadLocationPath", value); |
257 } | 268 } |
258 | 269 |
259 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 270 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
260 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 271 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
261 // We enable the button if the user has any auto-open file types registered. | 272 // We enable the button if the user has any auto-open file types registered. |
(...skipping 17 matching lines...) Expand all Loading... |
279 useSSLSetting = config.ssl2_enabled; | 290 useSSLSetting = config.ssl2_enabled; |
280 } | 291 } |
281 FundamentalValue checkRevocationValue(checkRevocationSetting); | 292 FundamentalValue checkRevocationValue(checkRevocationSetting); |
282 dom_ui_->CallJavascriptFunction( | 293 dom_ui_->CallJavascriptFunction( |
283 L"advancedOptionsSetCheckRevocationCheckboxState", checkRevocationValue); | 294 L"advancedOptionsSetCheckRevocationCheckboxState", checkRevocationValue); |
284 FundamentalValue useSSLValue(useSSLSetting); | 295 FundamentalValue useSSLValue(useSSLSetting); |
285 dom_ui_->CallJavascriptFunction( | 296 dom_ui_->CallJavascriptFunction( |
286 L"advancedOptionsSetUseSSL2CheckboxStatechecked", useSSLValue); | 297 L"advancedOptionsSetUseSSL2CheckboxStatechecked", useSSLValue); |
287 } | 298 } |
288 #endif | 299 #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 |