172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/ui/gtk/certificate_viewer.h" 6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <gtk/gtk.h> 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <algorithm> 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <vector> 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/i18n/time_formatting.h" 13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h" 143345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "base/string_number_conversions.h" 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/time.h" 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/utf_string_conversions.h" 1772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/ui/gtk/certificate_dialogs.h" 1872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/ui/gtk/gtk_util.h" 19731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#include "chrome/common/net/x509_certificate_model.h" 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "grit/generated_resources.h" 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "net/base/x509_certificate.h" 2272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "ui/base/l10n/l10n_util.h" 2372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "ui/gfx/gtk_util.h" 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace { 26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochconst char kDetailsFontFamily[] = "monospace"; 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//////////////////////////////////////////////////////////////////////////////// 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gtk utility functions. 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid AddTitle(GtkTable* table, int row, const std::string& text) { 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_table_attach_defaults(table, 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::CreateBoldLabel(text), 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 0, 2, 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch row, row + 1); 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid AddKeyValue(GtkTable* table, int row, const std::string& text, 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const std::string& value) { 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_table_attach_defaults( 42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch table, 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::IndentWidget( 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::LeftAlignMisc(gtk_label_new(text.c_str()))), 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 0, 1, row, row + 1); 46ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen GtkWidget* label = gtk_label_new(value.c_str()); 47ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_label_set_selectable(GTK_LABEL(label), TRUE); 48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_table_attach_defaults( 49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch table, 50ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_util::LeftAlignMisc(label), 51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 1, 2, row, row + 1); 52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//////////////////////////////////////////////////////////////////////////////// 55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// CertificateViewer class definition. 56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass CertificateViewer { 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public: 59731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick CertificateViewer(gfx::NativeWindow parent, 60731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick const net::X509Certificate::OSCertHandles& cert_chain_list); 61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ~CertificateViewer(); 62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void InitGeneralPage(); 64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void InitDetailsPage(); 65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void Show(); 67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private: 69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Indices and column count for the certificate chain hierarchy tree store. 70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch enum { 71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_NAME, 72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_OBJECT, 73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_INDEX, 74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_COLUMNS 75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch }; 76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Indices and column count for the certificate fields tree store. 78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch enum { 79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, 81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_COLUMNS 82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch }; 83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Fill the tree store with the certificate hierarchy, and set |leaf| to the 85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // iter of the leaf node. 86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void FillHierarchyStore(GtkTreeStore* hierarchy_store, 87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter* leaf) const; 88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Fill the tree store with the details of the given certificate. 90731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick static void FillTreeStoreWithCertFields( 91731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick GtkTreeStore* store, net::X509Certificate::OSCertHandle cert); 92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Create a tree store filled with the details of the given certificate. 94731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick static GtkTreeStore* CreateFieldsTreeStore( 95731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandle cert); 96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Callbacks for user selecting elements in the trees. 98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static void OnHierarchySelectionChanged(GtkTreeSelection* selection, 99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CertificateViewer* viewer); 100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static void OnFieldsSelectionChanged(GtkTreeSelection* selection, 101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CertificateViewer* viewer); 102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Callback for export button. 104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static void OnExportClicked(GtkButton *button, CertificateViewer* viewer); 105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The certificate hierarchy (leaf cert first). 107731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandles cert_chain_list_; 108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* dialog_; 110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* notebook_; 111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* general_page_vbox_; 112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* details_page_vbox_; 113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeSelection* hierarchy_selection_; 114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* fields_tree_; 115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTextBuffer* field_value_buffer_; 116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* export_button_; 117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch DISALLOW_COPY_AND_ASSIGN(CertificateViewer); 119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//////////////////////////////////////////////////////////////////////////////// 122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// CertificateViewer implementation. 123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Close button callback. 125dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenvoid OnResponse(GtkWidget* dialog, int response_id) { 126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // "Close" was clicked. 127dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen gtk_widget_destroy(dialog); 128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid OnDestroy(GtkDialog* dialog, CertificateViewer* cert_viewer) { 131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch delete cert_viewer; 132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 134731df977c0511bca2206b5f333555b1205ff1f43Iain MerrickCertificateViewer::CertificateViewer( 135731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick gfx::NativeWindow parent, 136731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick const net::X509Certificate::OSCertHandles& cert_chain_list) 137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch : cert_chain_list_(cert_chain_list) { 138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch dialog_ = gtk_dialog_new_with_buttons( 139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringFUTF8( 140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_INFO_DIALOG_TITLE, 141731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick UTF8ToUTF16( 142731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetTitle( 143731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert_chain_list_.front()))).c_str(), 144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch parent, 145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Non-modal. 146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_DIALOG_NO_SEPARATOR, 147c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_STOCK_CLOSE, 148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_RESPONSE_CLOSE, 149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NULL); 150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), 151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::kContentAreaSpacing); 152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 153731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::RegisterDynamicOids(); 154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch InitGeneralPage(); 155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch InitDetailsPage(); 156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch notebook_ = gtk_notebook_new(); 158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); 159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_notebook_append_page( 161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_NOTEBOOK(notebook_), 162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch general_page_vbox_, 163c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_label_new_with_mnemonic( 164513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch gfx::ConvertAcceleratorsFromWindowsStyle( 165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8( 166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_INFO_GENERAL_TAB_LABEL)).c_str())); 167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_notebook_append_page( 169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_NOTEBOOK(notebook_), 170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch details_page_vbox_, 171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_label_new_with_mnemonic( 172513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch gfx::ConvertAcceleratorsFromWindowsStyle( 173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8( 174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str())); 175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 176dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), NULL); 177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); 178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 180c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochCertificateViewer::~CertificateViewer() { 181731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::DestroyCertChain(&cert_chain_list_); 182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::InitGeneralPage() { 185731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandle cert = cert_chain_list_.front(); 186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch general_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); 187c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_set_border_width(GTK_CONTAINER(general_page_vbox_), 188c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::kContentAreaBorder); 189c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 190c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* uses_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(general_page_vbox_), uses_vbox, FALSE, FALSE, 0); 192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start( 193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_BOX(uses_vbox), 194c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::CreateBoldLabel( 195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_VERIFIED_USAGES_GROUP)), 196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 198c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch std::vector<std::string> usages; 199731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetUsageStrings(cert, &usages); 200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch for (size_t i = 0; i < usages.size(); ++i) 201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start( 202c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_BOX(uses_vbox), 203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::IndentWidget(gtk_util::LeftAlignMisc(gtk_label_new( 204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch usages[i].c_str()))), 205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(general_page_vbox_), gtk_hseparator_new(), 208c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const int num_rows = 21; 211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTable* table = GTK_TABLE(gtk_table_new(num_rows, 2, FALSE)); 212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_table_set_col_spacing(table, 0, gtk_util::kLabelSpacing); 213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_table_set_row_spacings(table, gtk_util::kControlSpacing); 214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(general_page_vbox_), GTK_WIDGET(table), 216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch int row = 0; 218731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick const std::string alternative_text = 219731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); 220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddTitle(table, row++, 221c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)); 222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), 224731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessIDN( 225731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetSubjectCommonName( 226731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text))); 227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), 229731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetSubjectOrgName( 230731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text)); 231c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 232c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), 233731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetSubjectOrgUnitName( 234731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text)); 235c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 236c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL), 237731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetSerialNumberHexified( 238731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text)); 239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). 241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddTitle(table, row++, 243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)); 244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), 246731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessIDN( 247731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetIssuerCommonName( 248731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text))); 249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), 251731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetIssuerOrgName( 252731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text)); 253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), 255731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetIssuerOrgUnitName( 256731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, alternative_text)); 257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). 259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 260731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick base::Time issued, expires; 261c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch std::string issued_str, expires_str; 262731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { 26321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen issued_str = UTF16ToUTF8( 264731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick base::TimeFormatShortDateNumeric(issued)); 26521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen expires_str = UTF16ToUTF8( 266731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick base::TimeFormatShortDateNumeric(expires)); 267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 268731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick issued_str = alternative_text; 269731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick expires_str = alternative_text; 270c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 271c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddTitle(table, row++, 272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)); 273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL), 275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch issued_str); 276c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL), 278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch expires_str); 279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). 281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddTitle(table, row++, 283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); 284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 285c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL), 286731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::HashCertSHA256(cert)); 287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch AddKeyValue(table, row++, 288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL), 289731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::HashCertSHA1(cert)); 290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch DCHECK_EQ(row, num_rows); 292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::FillHierarchyStore(GtkTreeStore* hierarchy_store, 295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter* leaf) const { 296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter parent; 297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter* parent_ptr = NULL; 298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter iter; 299731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick gint index = cert_chain_list_.size() - 1; 300731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick for (net::X509Certificate::OSCertHandles::const_reverse_iterator i = 301731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert_chain_list_.rbegin(); 302731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick i != cert_chain_list_.rend(); ++i, --index) { 303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(hierarchy_store, &iter, parent_ptr); 304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeStore* fields_store = CreateFieldsTreeStore(*i); 305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch hierarchy_store, &iter, 307731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick HIERARCHY_NAME, x509_certificate_model::GetTitle(*i).c_str(), 308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_OBJECT, fields_store, 309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HIERARCHY_INDEX, index, 310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_object_unref(fields_store); 312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch parent = iter; 313c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch parent_ptr = &parent; 314c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *leaf = iter; 316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 317c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 318c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// static 319731df977c0511bca2206b5f333555b1205ff1f43Iain Merrickvoid CertificateViewer::FillTreeStoreWithCertFields( 320731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick GtkTreeStore* store, net::X509Certificate::OSCertHandle cert) { 321c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter top; 322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &top, NULL); 323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 324c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &top, 325731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_NAME, x509_certificate_model::GetTitle(cert).c_str(), 326c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, "", 327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 328c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 329c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter cert_iter; 330c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &cert_iter, &top); 331c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 332c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &cert_iter, 333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE).c_str(), 335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, "", 336c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 337c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 338c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch std::string version_str; 339731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick std::string version = x509_certificate_model::GetVersion(cert); 340731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick if (!version.empty()) 341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch version_str = l10n_util::GetStringFUTF8(IDS_CERT_DETAILS_VERSION_FORMAT, 342731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick UTF8ToUTF16(version)); 343c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter iter; 344c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &cert_iter); 345c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 346c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VERSION).c_str(), 349c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, version_str.c_str(), 350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 351c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 352c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &cert_iter); 353c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 354c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 355c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 356c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SERIAL_NUMBER).c_str(), 357731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, 358731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetSerialNumberHexified( 359731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, 360731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT)).c_str(), 361c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 362c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 363c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &cert_iter); 364c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 365c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 366c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 367c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), 368731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, 369731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessSecAlgorithmSignature(cert).c_str(), 370c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 371c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 372c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &cert_iter); 373c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 374c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 375c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 376c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_ISSUER).c_str(), 377731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, x509_certificate_model::GetIssuerName(cert).c_str(), 378c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 379c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 380c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter validity_iter; 381c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &validity_iter, &cert_iter); 382c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 383c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &validity_iter, 384c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 385c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VALIDITY).c_str(), 386c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, "", 387c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 388c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 389731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick base::Time issued, expires; 390c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch std::string issued_str, expires_str; 391731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { 39221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen issued_str = UTF16ToUTF8(base::TimeFormatShortDateAndTime(issued)); 39321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen expires_str = UTF16ToUTF8(base::TimeFormatShortDateAndTime(expires)); 394c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 395c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &validity_iter); 396c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 397c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 398c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 399c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_BEFORE).c_str(), 400c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, issued_str.c_str(), 401c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 402c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &validity_iter); 403c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 404c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 405c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 406c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_AFTER).c_str(), 407c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, expires_str.c_str(), 408c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 409c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 410c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &cert_iter); 411c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 412c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 413c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 414c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT).c_str(), 415731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, x509_certificate_model::GetSubjectName(cert).c_str(), 416c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 417c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 418c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter subject_public_key_iter; 419c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &subject_public_key_iter, &cert_iter); 420c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 421c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &subject_public_key_iter, 422c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 423c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_INFO).c_str(), 424c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, "", 425c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 426c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 427c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &subject_public_key_iter); 428c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 429c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 430c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 431c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_ALG).c_str(), 432c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, 433731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessSecAlgorithmSubjectPublicKey(cert).c_str(), 434c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 435c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 436c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &subject_public_key_iter); 437c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 438c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 439c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 440c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY).c_str(), 441c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, 442731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessSubjectPublicKeyInfo(cert).c_str(), 443c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 444c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 445731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::Extensions extensions; 446731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetExtensions( 447731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), 448731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), 449731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick cert, &extensions); 450731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick 451731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick if (!extensions.empty()) { 452c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter extensions_iter; 453c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &extensions_iter, &cert_iter); 454c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 455c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &extensions_iter, 456c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 457c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_EXTENSIONS).c_str(), 458c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, "", 459c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 460c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 461731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick for (x509_certificate_model::Extensions::const_iterator i = 462731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick extensions.begin(); i != extensions.end(); ++i) { 463c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &extensions_iter); 464c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 465c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 466731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_NAME, i->name.c_str(), 467731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, i->value.c_str(), 468c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 469c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 470c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 471c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 472c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &top); 473c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 474c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 475c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 476c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), 477c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_VALUE, 478731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessSecAlgorithmSignatureWrap(cert).c_str(), 479c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 480c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 481c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_append(store, &iter, &top); 482c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_store_set( 483c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch store, &iter, 484c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FIELDS_NAME, 485c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE).c_str(), 486731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick FIELDS_VALUE, 487731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::ProcessRawBitsSignatureWrap(cert).c_str(), 488c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch -1); 489ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 490ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen GtkTreeIter top_fingerprints_iter; 491ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_append(store, &top_fingerprints_iter, &top); 492ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_set( 493ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen store, &top_fingerprints_iter, 494ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_NAME, 495ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP).c_str(), 496ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_VALUE, "", 497ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen -1); 498ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 499ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen GtkTreeIter fingerprints_iter; 500ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_append(store, &fingerprints_iter, &top_fingerprints_iter); 501ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_set( 502ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen store, &fingerprints_iter, 503ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_NAME, 504ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL).c_str(), 505ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_VALUE, x509_certificate_model::HashCertSHA256(cert).c_str(), 506ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen -1); 507ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 508ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_append(store, &fingerprints_iter, &top_fingerprints_iter); 509ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen gtk_tree_store_set( 510ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen store, &fingerprints_iter, 511ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_NAME, 512ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL).c_str(), 513ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen FIELDS_VALUE, x509_certificate_model::HashCertSHA1(cert).c_str(), 514ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen -1); 515c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 516c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 517c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// static 518731df977c0511bca2206b5f333555b1205ff1f43Iain MerrickGtkTreeStore* CertificateViewer::CreateFieldsTreeStore( 519731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandle cert) { 520c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeStore* fields_store = gtk_tree_store_new(FIELDS_COLUMNS, G_TYPE_STRING, 521c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_TYPE_STRING); 522c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FillTreeStoreWithCertFields(fields_store, cert); 523c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return fields_store; 524c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 525c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 526c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::InitDetailsPage() { 527c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch details_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); 528c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_set_border_width(GTK_CONTAINER(details_page_vbox_), 529c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::kContentAreaBorder); 530c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 531c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* hierarchy_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 532c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(details_page_vbox_), hierarchy_vbox, 533c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 534c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 535c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(hierarchy_vbox), 536c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::CreateBoldLabel(l10n_util::GetStringUTF8( 537c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_DETAILS_CERTIFICATE_HIERARCHY_LABEL)), 538c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 539c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 540c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeStore* hierarchy_store = gtk_tree_store_new(HIERARCHY_COLUMNS, 541c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_TYPE_STRING, 542c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_TYPE_OBJECT, 543c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_TYPE_INT); 544c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter hierarchy_leaf_iter; 545c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FillHierarchyStore(hierarchy_store, &hierarchy_leaf_iter); 546c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* hierarchy_tree = gtk_tree_view_new_with_model( 547c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_MODEL(hierarchy_store)); 548c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(hierarchy_tree), FALSE); 549c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_append_column( 550c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_VIEW(hierarchy_tree), 551c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_column_new_with_attributes("", gtk_cell_renderer_text_new(), 552c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch "text", HIERARCHY_NAME, 553c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NULL)); 554c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_expand_all(GTK_TREE_VIEW(hierarchy_tree)); 555c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch hierarchy_selection_ = gtk_tree_view_get_selection( 556c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_VIEW(hierarchy_tree)); 557c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_selection_set_mode(hierarchy_selection_, GTK_SELECTION_SINGLE); 558c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_signal_connect(hierarchy_selection_, "changed", 559c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_CALLBACK(OnHierarchySelectionChanged), this); 560c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* hierarchy_scroll_window = gtk_scrolled_window_new(NULL, NULL); 561c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(hierarchy_scroll_window), 562c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_AUTOMATIC, 563c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_NEVER); 564c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_shadow_type( 565c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_SCROLLED_WINDOW(hierarchy_scroll_window), GTK_SHADOW_ETCHED_IN); 566c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_add(GTK_CONTAINER(hierarchy_scroll_window), hierarchy_tree); 567c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(hierarchy_vbox), 568c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch hierarchy_scroll_window, FALSE, FALSE, 0); 569c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 570c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* fields_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 571c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(details_page_vbox_), fields_vbox, 572c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch TRUE, TRUE, 0); 573c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(fields_vbox), 574c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::CreateBoldLabel(l10n_util::GetStringUTF8( 575c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_DETAILS_CERTIFICATE_FIELDS_LABEL)), 576c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 577c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 578c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch fields_tree_ = gtk_tree_view_new(); 579c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(fields_tree_), FALSE); 580c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_append_column( 581c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_VIEW(fields_tree_), 582c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_column_new_with_attributes("", gtk_cell_renderer_text_new(), 583c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch "text", FIELDS_NAME, 584c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NULL)); 585c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeSelection* fields_selection = gtk_tree_view_get_selection( 586c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_VIEW(fields_tree_)); 587c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_selection_set_mode(fields_selection, GTK_SELECTION_SINGLE); 588c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_signal_connect(fields_selection, "changed", 589c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_CALLBACK(OnFieldsSelectionChanged), this); 590c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* fields_scroll_window = gtk_scrolled_window_new(NULL, NULL); 591c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(fields_scroll_window), 592c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_AUTOMATIC, 593c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_AUTOMATIC); 594c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_shadow_type( 595c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_SCROLLED_WINDOW(fields_scroll_window), GTK_SHADOW_ETCHED_IN); 596c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_add(GTK_CONTAINER(fields_scroll_window), fields_tree_); 597c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(fields_vbox), 598c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch fields_scroll_window, TRUE, TRUE, 0); 599c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 600c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* value_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 601c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(details_page_vbox_), value_vbox, 602c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch TRUE, TRUE, 0); 603c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(value_vbox), 604c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::CreateBoldLabel(l10n_util::GetStringUTF8( 605c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_DETAILS_CERTIFICATE_FIELD_VALUE_LABEL)), 606c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 607c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 608c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // TODO(mattm): fix text view coloring (should have grey background). 609c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* field_value_view = gtk_text_view_new(); 610c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_text_view_set_editable(GTK_TEXT_VIEW(field_value_view), FALSE); 611c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(field_value_view), GTK_WRAP_NONE); 612c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch field_value_buffer_ = gtk_text_view_get_buffer( 613c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TEXT_VIEW(field_value_view)); 614c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* value_scroll_window = gtk_scrolled_window_new(NULL, NULL); 615c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(value_scroll_window), 616c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_AUTOMATIC, 617c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_POLICY_AUTOMATIC); 618c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_scrolled_window_set_shadow_type( 619c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_SCROLLED_WINDOW(value_scroll_window), GTK_SHADOW_ETCHED_IN); 620c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_container_add(GTK_CONTAINER(value_scroll_window), field_value_view); 621c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(value_vbox), 622c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch value_scroll_window, TRUE, TRUE, 0); 623c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 624c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_widget_ensure_style(field_value_view); 625c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch PangoFontDescription* font_desc = pango_font_description_copy( 626c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_widget_get_style(field_value_view)->font_desc); 627c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch pango_font_description_set_family(font_desc, kDetailsFontFamily); 628c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_widget_modify_font(field_value_view, font_desc); 629c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch pango_font_description_free(font_desc); 630c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 631c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkWidget* export_hbox = gtk_hbox_new(FALSE, 0); 632c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(details_page_vbox_), export_hbox, 633c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 634c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch export_button_ = gtk_button_new_with_mnemonic( 635513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch gfx::ConvertAcceleratorsFromWindowsStyle( 636c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch l10n_util::GetStringUTF8( 637c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch IDS_CERT_DETAILS_EXPORT_CERTIFICATE)).c_str()); 638c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_signal_connect(export_button_, "clicked", 639c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch G_CALLBACK(OnExportClicked), this); 640c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_box_pack_start(GTK_BOX(export_hbox), export_button_, 641c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FALSE, FALSE, 0); 642c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 643c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Select the initial certificate in the hierarchy. 644c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_selection_select_iter(hierarchy_selection_, &hierarchy_leaf_iter); 645c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 646c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 647c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// static 648c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::OnHierarchySelectionChanged( 649c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeSelection* selection, CertificateViewer* viewer) { 650c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter iter; 651c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeModel* model; 652c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (gtk_tree_selection_get_selected(selection, &model, &iter)) { 653c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeStore* fields_store = NULL; 654c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_model_get(model, &iter, HIERARCHY_OBJECT, &fields_store, -1); 655c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_set_model(GTK_TREE_VIEW(viewer->fields_tree_), 656c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GTK_TREE_MODEL(fields_store)); 657c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_expand_all(GTK_TREE_VIEW(viewer->fields_tree_)); 658c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_widget_set_sensitive(viewer->export_button_, TRUE); 659c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 660c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_view_set_model(GTK_TREE_VIEW(viewer->fields_tree_), NULL); 661c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_widget_set_sensitive(viewer->export_button_, FALSE); 662c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 663c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 664c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 665c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// static 666c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::OnFieldsSelectionChanged(GtkTreeSelection* selection, 667c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CertificateViewer* viewer) { 668c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter iter; 669c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeModel* model; 670c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (gtk_tree_selection_get_selected(selection, &model, &iter)) { 671c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gchar* value_string = NULL; 672c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_model_get(model, &iter, FIELDS_VALUE, &value_string, -1); 673c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (value_string) { 674c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_text_buffer_set_text(viewer->field_value_buffer_, value_string, -1); 675c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch g_free(value_string); 676c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 677c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_text_buffer_set_text(viewer->field_value_buffer_, "", 0); 678c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 679c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 680c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_text_buffer_set_text(viewer->field_value_buffer_, "", 0); 681c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 682c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 683c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 684c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// static 685c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::OnExportClicked(GtkButton *button, 686c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CertificateViewer* viewer) { 687c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeIter iter; 688c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch GtkTreeModel* model; 689c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (!gtk_tree_selection_get_selected(viewer->hierarchy_selection_, &model, 690c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch &iter)) 691c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return; 692c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gint cert_index = -1; 693c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_tree_model_get(model, &iter, HIERARCHY_INDEX, &cert_index, -1); 694c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 695c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (cert_index < 0) { 696c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NOTREACHED(); 697c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return; 698c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 699c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 700ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ShowCertExportDialog(NULL, GTK_WINDOW(viewer->dialog_), 701731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick viewer->cert_chain_list_[cert_index]); 702c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 703c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 704c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CertificateViewer::Show() { 705c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch gtk_util::ShowDialog(dialog_); 706c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 707c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 708c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} // namespace 709c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 710731df977c0511bca2206b5f333555b1205ff1f43Iain Merrickvoid ShowCertificateViewer(gfx::NativeWindow parent, 711731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandle cert) { 712731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick net::X509Certificate::OSCertHandles cert_chain; 713731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick x509_certificate_model::GetCertChainFromCert(cert, &cert_chain); 714c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch (new CertificateViewer(parent, cert_chain))->Show(); 715c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 716c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 717c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid ShowCertificateViewer(gfx::NativeWindow parent, 718c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch net::X509Certificate* cert) { 719c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ShowCertificateViewer(parent, cert->os_cert_handle()); 720c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 721