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 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" | 5 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/certificate_viewer.h" | 16 #include "chrome/browser/certificate_viewer.h" |
17 #include "chrome/browser/ssl/ssl_client_auth_observer.h" | 17 #include "chrome/browser/ssl/ssl_client_auth_observer.h" |
18 #include "chrome/browser/ui/crypto_module_password_dialog.h" | 18 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" |
19 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 19 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
20 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
21 #include "chrome/common/net/x509_certificate_model.h" | 21 #include "chrome/common/net/x509_certificate_model.h" |
22 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 22 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "net/cert/x509_certificate.h" | 25 #include "net/cert/x509_certificate.h" |
26 #include "net/ssl/ssl_cert_request_info.h" | 26 #include "net/ssl/ssl_cert_request_info.h" |
27 #include "ui/base/gtk/gtk_hig_constants.h" | 27 #include "ui/base/gtk/gtk_hig_constants.h" |
28 #include "ui/base/gtk/gtk_signal.h" | 28 #include "ui/base/gtk/gtk_signal.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 void SSLClientCertificateSelector::OnCancelClicked(GtkWidget* button) { | 346 void SSLClientCertificateSelector::OnCancelClicked(GtkWidget* button) { |
347 CertificateSelected(NULL); | 347 CertificateSelected(NULL); |
348 DCHECK(window_); | 348 DCHECK(window_); |
349 gtk_widget_destroy(window_); | 349 gtk_widget_destroy(window_); |
350 } | 350 } |
351 | 351 |
352 void SSLClientCertificateSelector::OnOkClicked(GtkWidget* button) { | 352 void SSLClientCertificateSelector::OnOkClicked(GtkWidget* button) { |
353 net::X509Certificate* cert = GetSelectedCert(); | |
354 | |
355 // Remove the observer before we try unlocking, otherwise we might act on a | 353 // Remove the observer before we try unlocking, otherwise we might act on a |
356 // notification while waiting for the unlock dialog, causing us to delete | 354 // notification while waiting for the unlock dialog, causing us to delete |
357 // ourself before the Unlocked callback gets called. | 355 // ourself before the Unlocked callback gets called. |
358 StopObserving(); | 356 StopObserving(); |
359 | 357 |
358 #if defined(USE_NSS) | |
Ryan Sleevi
2013/12/05 00:23:19
Unnecessary.
There should be no world in which we
mattm
2013/12/05 00:42:44
the linux_redux bot does build UI stuff, so it see
| |
360 GtkWidget* toplevel = gtk_widget_get_toplevel(root_widget_.get()); | 359 GtkWidget* toplevel = gtk_widget_get_toplevel(root_widget_.get()); |
360 net::X509Certificate* cert = GetSelectedCert(); | |
361 | |
361 chrome::UnlockCertSlotIfNecessary( | 362 chrome::UnlockCertSlotIfNecessary( |
362 cert, | 363 cert, |
363 chrome::kCryptoModulePasswordClientAuth, | 364 chrome::kCryptoModulePasswordClientAuth, |
364 cert_request_info()->host_and_port, | 365 cert_request_info()->host_and_port, |
365 GTK_WINDOW(toplevel), | 366 GTK_WINDOW(toplevel), |
366 base::Bind(&SSLClientCertificateSelector::Unlocked, | 367 base::Bind(&SSLClientCertificateSelector::Unlocked, |
367 base::Unretained(this))); | 368 base::Unretained(this))); |
369 #else | |
370 Unlocked(); | |
371 #endif | |
368 } | 372 } |
369 | 373 |
370 void SSLClientCertificateSelector::OnPromptShown(GtkWidget* widget, | 374 void SSLClientCertificateSelector::OnPromptShown(GtkWidget* widget, |
371 GtkWidget* previous_toplevel) { | 375 GtkWidget* previous_toplevel) { |
372 if (!root_widget_.get() || | 376 if (!root_widget_.get() || |
373 !gtk_widget_is_toplevel(gtk_widget_get_toplevel(root_widget_.get()))) | 377 !gtk_widget_is_toplevel(gtk_widget_get_toplevel(root_widget_.get()))) |
374 return; | 378 return; |
375 gtk_widget_set_can_default(select_button_, TRUE); | 379 gtk_widget_set_can_default(select_button_, TRUE); |
376 gtk_widget_grab_default(select_button_); | 380 gtk_widget_grab_default(select_button_); |
377 } | 381 } |
(...skipping 13 matching lines...) Expand all Loading... | |
391 content::WebContents* contents, | 395 content::WebContents* contents, |
392 const net::HttpNetworkSession* network_session, | 396 const net::HttpNetworkSession* network_session, |
393 net::SSLCertRequestInfo* cert_request_info, | 397 net::SSLCertRequestInfo* cert_request_info, |
394 const base::Callback<void(net::X509Certificate*)>& callback) { | 398 const base::Callback<void(net::X509Certificate*)>& callback) { |
395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
396 (new SSLClientCertificateSelector( | 400 (new SSLClientCertificateSelector( |
397 contents, network_session, cert_request_info, callback))->Show(); | 401 contents, network_session, cert_request_info, callback))->Show(); |
398 } | 402 } |
399 | 403 |
400 } // namespace chrome | 404 } // namespace chrome |
OLD | NEW |