| 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> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 std::vector<std::string> details_strings_; | 86 std::vector<std::string> details_strings_; |
| 87 | 87 |
| 88 GtkWidget* cert_combo_box_; | 88 GtkWidget* cert_combo_box_; |
| 89 GtkTextBuffer* cert_details_buffer_; | 89 GtkTextBuffer* cert_details_buffer_; |
| 90 | 90 |
| 91 ui::OwnedWidgetGtk root_widget_; | 91 ui::OwnedWidgetGtk root_widget_; |
| 92 // Hold on to the select button to focus it. | 92 // Hold on to the select button to focus it. |
| 93 GtkWidget* select_button_; | 93 GtkWidget* select_button_; |
| 94 | 94 |
| 95 WebContents* web_contents_; | 95 WebContents* web_contents_; |
| 96 ConstrainedWindow* window_; | 96 WebContentsModalDialog* window_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector); | 98 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 SSLClientCertificateSelector::SSLClientCertificateSelector( | 101 SSLClientCertificateSelector::SSLClientCertificateSelector( |
| 102 WebContents* web_contents, | 102 WebContents* web_contents, |
| 103 const net::HttpNetworkSession* network_session, | 103 const net::HttpNetworkSession* network_session, |
| 104 net::SSLCertRequestInfo* cert_request_info, | 104 net::SSLCertRequestInfo* cert_request_info, |
| 105 const base::Callback<void(net::X509Certificate*)>& callback) | 105 const base::Callback<void(net::X509Certificate*)>& callback) |
| 106 : SSLClientAuthObserver(network_session, cert_request_info, callback), | 106 : SSLClientAuthObserver(network_session, cert_request_info, callback), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 root_widget_.Destroy(); | 195 root_widget_.Destroy(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void SSLClientCertificateSelector::Show() { | 198 void SSLClientCertificateSelector::Show() { |
| 199 DCHECK(!window_); | 199 DCHECK(!window_); |
| 200 window_ = new ConstrainedWindowGtk(web_contents_, this); | 200 window_ = new ConstrainedWindowGtk(web_contents_, this); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void SSLClientCertificateSelector::OnCertSelectedByNotification() { | 203 void SSLClientCertificateSelector::OnCertSelectedByNotification() { |
| 204 DCHECK(window_); | 204 DCHECK(window_); |
| 205 window_->CloseConstrainedWindow(); | 205 window_->CloseWebContentsModalDialog(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 GtkWidget* SSLClientCertificateSelector::GetFocusWidget() { | 208 GtkWidget* SSLClientCertificateSelector::GetFocusWidget() { |
| 209 return select_button_; | 209 return select_button_; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void SSLClientCertificateSelector::DeleteDelegate() { | 212 void SSLClientCertificateSelector::DeleteDelegate() { |
| 213 // The dialog was closed by escape key. | 213 // The dialog was closed by escape key. |
| 214 StopObserving(); | 214 StopObserving(); |
| 215 CertificateSelected(NULL); | 215 CertificateSelected(NULL); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 321 } |
| 322 | 322 |
| 323 return rv; | 323 return rv; |
| 324 } | 324 } |
| 325 | 325 |
| 326 void SSLClientCertificateSelector::Unlocked() { | 326 void SSLClientCertificateSelector::Unlocked() { |
| 327 // TODO(mattm): refactor so we don't need to call GetSelectedCert again. | 327 // TODO(mattm): refactor so we don't need to call GetSelectedCert again. |
| 328 net::X509Certificate* cert = GetSelectedCert(); | 328 net::X509Certificate* cert = GetSelectedCert(); |
| 329 CertificateSelected(cert); | 329 CertificateSelected(cert); |
| 330 DCHECK(window_); | 330 DCHECK(window_); |
| 331 window_->CloseConstrainedWindow(); | 331 window_->CloseWebContentsModalDialog(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void SSLClientCertificateSelector::OnComboBoxChanged(GtkWidget* combo_box) { | 334 void SSLClientCertificateSelector::OnComboBoxChanged(GtkWidget* combo_box) { |
| 335 int selected = gtk_combo_box_get_active( | 335 int selected = gtk_combo_box_get_active( |
| 336 GTK_COMBO_BOX(cert_combo_box_)); | 336 GTK_COMBO_BOX(cert_combo_box_)); |
| 337 if (selected < 0) | 337 if (selected < 0) |
| 338 return; | 338 return; |
| 339 gtk_text_buffer_set_text(cert_details_buffer_, | 339 gtk_text_buffer_set_text(cert_details_buffer_, |
| 340 details_strings_[selected].c_str(), | 340 details_strings_[selected].c_str(), |
| 341 details_strings_[selected].size()); | 341 details_strings_[selected].size()); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void SSLClientCertificateSelector::OnViewClicked(GtkWidget* button) { | 344 void SSLClientCertificateSelector::OnViewClicked(GtkWidget* button) { |
| 345 net::X509Certificate* cert = GetSelectedCert(); | 345 net::X509Certificate* cert = GetSelectedCert(); |
| 346 if (cert) { | 346 if (cert) { |
| 347 GtkWidget* toplevel = gtk_widget_get_toplevel(root_widget_.get()); | 347 GtkWidget* toplevel = gtk_widget_get_toplevel(root_widget_.get()); |
| 348 ShowCertificateViewer(web_contents_, GTK_WINDOW(toplevel), cert); | 348 ShowCertificateViewer(web_contents_, GTK_WINDOW(toplevel), cert); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 void SSLClientCertificateSelector::OnCancelClicked(GtkWidget* button) { | 352 void SSLClientCertificateSelector::OnCancelClicked(GtkWidget* button) { |
| 353 CertificateSelected(NULL); | 353 CertificateSelected(NULL); |
| 354 DCHECK(window_); | 354 DCHECK(window_); |
| 355 window_->CloseConstrainedWindow(); | 355 window_->CloseWebContentsModalDialog(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void SSLClientCertificateSelector::OnOkClicked(GtkWidget* button) { | 358 void SSLClientCertificateSelector::OnOkClicked(GtkWidget* button) { |
| 359 net::X509Certificate* cert = GetSelectedCert(); | 359 net::X509Certificate* cert = GetSelectedCert(); |
| 360 | 360 |
| 361 // Remove the observer before we try unlocking, otherwise we might act on a | 361 // Remove the observer before we try unlocking, otherwise we might act on a |
| 362 // notification while waiting for the unlock dialog, causing us to delete | 362 // notification while waiting for the unlock dialog, causing us to delete |
| 363 // ourself before the Unlocked callback gets called. | 363 // ourself before the Unlocked callback gets called. |
| 364 StopObserving(); | 364 StopObserving(); |
| 365 | 365 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 388 content::WebContents* contents, | 388 content::WebContents* contents, |
| 389 const net::HttpNetworkSession* network_session, | 389 const net::HttpNetworkSession* network_session, |
| 390 net::SSLCertRequestInfo* cert_request_info, | 390 net::SSLCertRequestInfo* cert_request_info, |
| 391 const base::Callback<void(net::X509Certificate*)>& callback) { | 391 const base::Callback<void(net::X509Certificate*)>& callback) { |
| 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 393 (new SSLClientCertificateSelector( | 393 (new SSLClientCertificateSelector( |
| 394 contents, network_session, cert_request_info, callback))->Show(); | 394 contents, network_session, cert_request_info, callback))->Show(); |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace chrome | 397 } // namespace chrome |
| OLD | NEW |