Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: chrome/browser/ui/gtk/certificate_viewer.cc

Issue 6793026: Initial support for HSTS certificate locking. This isn't a finished work, but (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/ui/gtk/certificate_viewer.h" 5 #include "chrome/browser/ui/gtk/certificate_viewer.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 26 matching lines...) Expand all
37 row, row + 1); 37 row, row + 1);
38 } 38 }
39 39
40 void AddKeyValue(GtkTable* table, int row, const std::string& text, 40 void AddKeyValue(GtkTable* table, int row, const std::string& text,
41 const std::string& value) { 41 const std::string& value) {
42 gtk_table_attach_defaults( 42 gtk_table_attach_defaults(
43 table, 43 table,
44 gtk_util::IndentWidget( 44 gtk_util::IndentWidget(
45 gtk_util::LeftAlignMisc(gtk_label_new(text.c_str()))), 45 gtk_util::LeftAlignMisc(gtk_label_new(text.c_str()))),
46 0, 1, row, row + 1); 46 0, 1, row, row + 1);
47 GtkWidget* label = gtk_label_new(value.c_str());
48 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
47 gtk_table_attach_defaults( 49 gtk_table_attach_defaults(
48 table, 50 table,
49 gtk_util::LeftAlignMisc(gtk_label_new(value.c_str())), 51 gtk_util::LeftAlignMisc(label),
50 1, 2, row, row + 1); 52 1, 2, row, row + 1);
51 } 53 }
52 54
53 //////////////////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////////////////
54 // CertificateViewer class definition. 56 // CertificateViewer class definition.
55 57
56 class CertificateViewer { 58 class CertificateViewer {
57 public: 59 public:
58 CertificateViewer(gfx::NativeWindow parent, 60 CertificateViewer(gfx::NativeWindow parent,
59 const net::X509Certificate::OSCertHandles& cert_chain_list); 61 const net::X509Certificate::OSCertHandles& cert_chain_list);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 gtk_label_new_with_mnemonic( 172 gtk_label_new_with_mnemonic(
171 gfx::ConvertAcceleratorsFromWindowsStyle( 173 gfx::ConvertAcceleratorsFromWindowsStyle(
172 l10n_util::GetStringUTF8( 174 l10n_util::GetStringUTF8(
173 IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str())); 175 IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str()));
174 176
175 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), NULL); 177 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), NULL);
176 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); 178 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this);
177 } 179 }
178 180
179 CertificateViewer::~CertificateViewer() { 181 CertificateViewer::~CertificateViewer() {
180 x509_certificate_model::DestroyCertChain(&cert_chain_list_); 182 net::X509Certificate::DestroyCertChain(&cert_chain_list_);
181 } 183 }
182 184
183 void CertificateViewer::InitGeneralPage() { 185 void CertificateViewer::InitGeneralPage() {
184 net::X509Certificate::OSCertHandle cert = cert_chain_list_.front(); 186 net::X509Certificate::OSCertHandle cert = cert_chain_list_.front();
185 general_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); 187 general_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing);
186 gtk_container_set_border_width(GTK_CONTAINER(general_page_vbox_), 188 gtk_container_set_border_width(GTK_CONTAINER(general_page_vbox_),
187 gtk_util::kContentAreaBorder); 189 gtk_util::kContentAreaBorder);
188 190
189 GtkWidget* uses_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 191 GtkWidget* uses_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
190 gtk_box_pack_start(GTK_BOX(general_page_vbox_), uses_vbox, FALSE, FALSE, 0); 192 gtk_box_pack_start(GTK_BOX(general_page_vbox_), uses_vbox, FALSE, FALSE, 0);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 -1); 480 -1);
479 481
480 gtk_tree_store_append(store, &iter, &top); 482 gtk_tree_store_append(store, &iter, &top);
481 gtk_tree_store_set( 483 gtk_tree_store_set(
482 store, &iter, 484 store, &iter,
483 FIELDS_NAME, 485 FIELDS_NAME,
484 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE).c_str(), 486 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE).c_str(),
485 FIELDS_VALUE, 487 FIELDS_VALUE,
486 x509_certificate_model::ProcessRawBitsSignatureWrap(cert).c_str(), 488 x509_certificate_model::ProcessRawBitsSignatureWrap(cert).c_str(),
487 -1); 489 -1);
490
491 GtkTreeIter top_fingerprints_iter;
492 gtk_tree_store_append(store, &top_fingerprints_iter, &top);
493 gtk_tree_store_set(
494 store, &top_fingerprints_iter,
495 FIELDS_NAME,
496 l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP).c_str(),
497 FIELDS_VALUE, "",
498 -1);
499
500 GtkTreeIter fingerprints_iter;
501 gtk_tree_store_append(store, &fingerprints_iter, &top_fingerprints_iter);
502 gtk_tree_store_set(
503 store, &fingerprints_iter,
504 FIELDS_NAME,
505 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL).c_str(),
506 FIELDS_VALUE, x509_certificate_model::HashCertSHA256(cert).c_str(),
507 -1);
508
509 gtk_tree_store_append(store, &fingerprints_iter, &top_fingerprints_iter);
510 gtk_tree_store_set(
511 store, &fingerprints_iter,
512 FIELDS_NAME,
513 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL).c_str(),
514 FIELDS_VALUE, x509_certificate_model::HashCertSHA1(cert).c_str(),
515 -1);
488 } 516 }
489 517
490 // static 518 // static
491 GtkTreeStore* CertificateViewer::CreateFieldsTreeStore( 519 GtkTreeStore* CertificateViewer::CreateFieldsTreeStore(
492 net::X509Certificate::OSCertHandle cert) { 520 net::X509Certificate::OSCertHandle cert) {
493 GtkTreeStore* fields_store = gtk_tree_store_new(FIELDS_COLUMNS, G_TYPE_STRING, 521 GtkTreeStore* fields_store = gtk_tree_store_new(FIELDS_COLUMNS, G_TYPE_STRING,
494 G_TYPE_STRING); 522 G_TYPE_STRING);
495 FillTreeStoreWithCertFields(fields_store, cert); 523 FillTreeStoreWithCertFields(fields_store, cert);
496 return fields_store; 524 return fields_store;
497 } 525 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 704
677 void CertificateViewer::Show() { 705 void CertificateViewer::Show() {
678 gtk_util::ShowDialog(dialog_); 706 gtk_util::ShowDialog(dialog_);
679 } 707 }
680 708
681 } // namespace 709 } // namespace
682 710
683 void ShowCertificateViewer(gfx::NativeWindow parent, 711 void ShowCertificateViewer(gfx::NativeWindow parent,
684 net::X509Certificate::OSCertHandle cert) { 712 net::X509Certificate::OSCertHandle cert) {
685 net::X509Certificate::OSCertHandles cert_chain; 713 net::X509Certificate::OSCertHandles cert_chain;
686 x509_certificate_model::GetCertChainFromCert(cert, &cert_chain); 714 net::X509Certificate::GetCertChainFromCert(cert, &cert_chain);
687 (new CertificateViewer(parent, cert_chain))->Show(); 715 (new CertificateViewer(parent, cert_chain))->Show();
688 } 716 }
689 717
690 void ShowCertificateViewer(gfx::NativeWindow parent, 718 void ShowCertificateViewer(gfx::NativeWindow parent,
691 net::X509Certificate* cert) { 719 net::X509Certificate* cert) {
692 ShowCertificateViewer(parent, cert->os_cert_handle()); 720 ShowCertificateViewer(parent, cert->os_cert_handle());
693 } 721 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698