summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-13 02:39:48 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-13 02:39:48 +0000
commit2f1d657749a93faca39baf53d3eaee520e32dd55 (patch)
treec930750ef1c58b269463cb7de9cdfe5421fc2300 /chrome
parentf0740ed6f2a7bdefff6137be215a8d1401465d79 (diff)
downloadchromium_src-2f1d657749a93faca39baf53d3eaee520e32dd55.zip
chromium_src-2f1d657749a93faca39baf53d3eaee520e32dd55.tar.gz
chromium_src-2f1d657749a93faca39baf53d3eaee520e32dd55.tar.bz2
Linux: Certificate Manager skeleton.
Not actually hooked up to the options dialog since it doesn't do anything useful yet. BUG=19991 TEST=none Review URL: http://codereview.chromium.org/593076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd54
-rw-r--r--chrome/browser/gtk/certificate_manager.cc296
-rw-r--r--chrome/browser/gtk/certificate_manager.h12
-rw-r--r--chrome/browser/gtk/certificate_viewer.cc13
-rw-r--r--chrome/browser/gtk/certificate_viewer.h3
-rwxr-xr-xchrome/chrome_browser.gypi2
6 files changed, 375 insertions, 5 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 7f28c30..535dde8 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -2709,6 +2709,60 @@ each locale. -->
</message>
+ <!-- Certificate manager dialog strings. These are only used on platforms that don't have a native certificate manager dialog, such as Linux. -->
+ <message name="IDS_CERTIFICATE_MANAGER_TITLE" desc="String to be displayed in the title bar of the certificate manager dialog">
+ Certificate Manager
+ </message>
+ <message name="IDS_CERT_MANAGER_PERSONAL_CERTS_TAB_LABEL" desc="Title of the notebook page displaying the user's own certificates">
+ Your Certificates
+ </message>
+ <message name="IDS_CERT_MANAGER_OTHER_PEOPLES_CERTS_TAB_LABEL" desc="Title of the notebook page displaying other individual's certificates">
+ People
+ </message>
+ <message name="IDS_CERT_MANAGER_SERVER_CERTS_TAB_LABEL" desc="Title of the notebook page displaying server certificates">
+ Servers
+ </message>
+ <message name="IDS_CERT_MANAGER_CERT_AUTHORITIES_TAB_LABEL" desc="Title of the notebook page displaying certificate authorities">
+ Authorities
+ </message>
+ <message name="IDS_CERT_MANAGER_UNKNOWN_TAB_LABEL" desc="Title of the notebook page displaying certificates that don't fall under any of the other categories">
+ Others
+ </message>
+ <message name="IDS_CERT_MANAGER_USER_TREE_DESCRIPTION" desc="Description label above the tree showing the user's own certificates">
+ You have certificates from these organizations that identify you:
+ </message>
+ <message name="IDS_CERT_MANAGER_OTHER_PEOPLE_TREE_DESCRIPTION" desc="Description label above the tree showing other individual's certificates">
+ You have certificates on file that identify these people:
+ </message>
+ <message name="IDS_CERT_MANAGER_SERVER_TREE_DESCRIPTION" desc="Description label above the tree showing server certificates">
+ You have certificates on file that identify these servers:
+ </message>
+ <message name="IDS_CERT_MANAGER_AUTHORITIES_TREE_DESCRIPTION" desc="Description label above the Certificate Authorities tree">
+ You have certificates on file that identify these certificate authorities:
+ </message>
+ <message name="IDS_CERT_MANAGER_UNKNOWN_TREE_DESCRIPTION" desc="Description label above the tree showing certificates that don't fall under any of the other categories">
+ You have certificates on file that do not fit in any of the other categories:
+ </message>
+ <message name="IDS_CERT_MANAGER_NAME_COLUMN_LABEL" desc="Label for the certificate name column of the certificate tree in the certificate manager">
+ Certificate Name
+ </message>
+ <message name="IDS_CERT_MANAGER_DEVICE_COLUMN_LABEL" desc="Label for the security device column of the certificate tree in the certificate manager">
+ Security Device
+ </message>
+ <message name="IDS_CERT_MANAGER_SERIAL_NUMBER_COLUMN_LABEL" desc="Label for the serial number column of the certificate tree in the certificate manager">
+ Serial Number
+ </message>
+ <message name="IDS_CERT_MANAGER_EXPIRES_COLUMN_LABEL" desc="Label for the expires on column of the certificate tree in the certificate manager">
+ Expires On
+ </message>
+ <message name="IDS_CERT_MANAGER_EMAIL_ADDRESS_COLUMN_LABEL" desc="Label for the email address column of the certificate tree in the certificate manager">
+ Email Address
+ </message>
+ <message name="IDS_CERT_MANAGER_VIEW_CERT_BUTTON" desc="Label for the button in the certificate manager which launches the certificate viewer for the selected certificate">
+ &amp;View
+ </message>
+
+
<!-- General wizard strings -->
<message name="IDS_WIZARD_NEXT" desc="The wizard next button label">
Next
diff --git a/chrome/browser/gtk/certificate_manager.cc b/chrome/browser/gtk/certificate_manager.cc
new file mode 100644
index 0000000..c842c1c
--- /dev/null
+++ b/chrome/browser/gtk/certificate_manager.cc
@@ -0,0 +1,296 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/certificate_manager.h"
+
+#include <cert.h>
+
+#include <gtk/gtk.h>
+
+#include "app/l10n_util.h"
+#include "chrome/browser/gtk/certificate_viewer.h"
+#include "chrome/common/gtk_util.h"
+#include "grit/generated_resources.h"
+
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+// CertificatePage class definition.
+
+class CertificatePage {
+ public:
+ // The categories of certificates that can be displayed.
+ enum CertType {
+ USER_CERTS = 0,
+ EMAIL_CERTS,
+ SERVER_CERTS,
+ CA_CERTS,
+ UNKNOWN_CERTS,
+ NUM_CERT_TYPES
+ };
+
+ explicit CertificatePage(CertType type);
+
+ // Get the top-level widget of this page.
+ GtkWidget* widget() {
+ return vbox_;
+ }
+
+ private:
+ // Columns of the tree store.
+ enum {
+ CERT_NAME,
+ CERT_SECURITY_DEVICE,
+ CERT_SERIAL_NUMBER,
+ CERT_EXPIRES_ON,
+ CERT_ADDRESS,
+ CERT_POINTER,
+ CERT_STORE_NUM_COLUMNS
+ };
+
+ // Gtk event callbacks.
+ static void OnSelectionChanged(GtkTreeSelection* selection,
+ CertificatePage* page);
+ static void OnViewClicked(GtkButton *button, CertificatePage* page);
+
+ // The top-level widget of this page.
+ GtkWidget* vbox_;
+
+ GtkTreeStore* store_;
+ GtkTreeSelection* selection_;
+
+ GtkWidget* view_button_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// CertificatePage implementation.
+
+CertificatePage::CertificatePage(CertType type) {
+ vbox_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox_),
+ gtk_util::kContentAreaBorder);
+
+ static const int kDescriptionIds[] = {
+ IDS_CERT_MANAGER_USER_TREE_DESCRIPTION,
+ IDS_CERT_MANAGER_OTHER_PEOPLE_TREE_DESCRIPTION,
+ IDS_CERT_MANAGER_SERVER_TREE_DESCRIPTION,
+ IDS_CERT_MANAGER_AUTHORITIES_TREE_DESCRIPTION,
+ IDS_CERT_MANAGER_UNKNOWN_TREE_DESCRIPTION,
+ };
+ DCHECK_EQ(arraysize(kDescriptionIds),
+ static_cast<size_t>(NUM_CERT_TYPES));
+ GtkWidget* description_label = gtk_label_new(l10n_util::GetStringUTF8(
+ kDescriptionIds[type]).c_str());
+ gtk_misc_set_alignment(GTK_MISC(description_label), 0, 0.5);
+ gtk_box_pack_start(GTK_BOX(vbox_), description_label, FALSE, FALSE, 0);
+
+ store_ = gtk_tree_store_new(CERT_STORE_NUM_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+ GtkWidget* tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store_));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
+ selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+ gtk_tree_selection_set_mode(selection_, GTK_SELECTION_SINGLE);
+ g_signal_connect(selection_, "changed", G_CALLBACK(OnSelectionChanged), this);
+
+ gtk_tree_view_append_column(
+ GTK_TREE_VIEW(tree),
+ gtk_tree_view_column_new_with_attributes(
+ l10n_util::GetStringUTF8(IDS_CERT_MANAGER_NAME_COLUMN_LABEL).c_str(),
+ gtk_cell_renderer_text_new(),
+ "text", CERT_NAME,
+ NULL));
+
+ if (type == USER_CERTS || type == CA_CERTS || type == UNKNOWN_CERTS)
+ gtk_tree_view_append_column(
+ GTK_TREE_VIEW(tree),
+ gtk_tree_view_column_new_with_attributes(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_DEVICE_COLUMN_LABEL).c_str(),
+ gtk_cell_renderer_text_new(),
+ "text", CERT_SECURITY_DEVICE,
+ NULL));
+
+ if (type == USER_CERTS)
+ gtk_tree_view_append_column(
+ GTK_TREE_VIEW(tree),
+ gtk_tree_view_column_new_with_attributes(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_SERIAL_NUMBER_COLUMN_LABEL).c_str(),
+ gtk_cell_renderer_text_new(),
+ "text", CERT_SERIAL_NUMBER,
+ NULL));
+
+ if (type == USER_CERTS || type == EMAIL_CERTS || type == SERVER_CERTS)
+ gtk_tree_view_append_column(
+ GTK_TREE_VIEW(tree),
+ gtk_tree_view_column_new_with_attributes(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_EXPIRES_COLUMN_LABEL).c_str(),
+ gtk_cell_renderer_text_new(),
+ "text", CERT_EXPIRES_ON,
+ NULL));
+
+ if (type == EMAIL_CERTS)
+ gtk_tree_view_append_column(
+ GTK_TREE_VIEW(tree),
+ gtk_tree_view_column_new_with_attributes(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_EMAIL_ADDRESS_COLUMN_LABEL).c_str(),
+ gtk_cell_renderer_text_new(),
+ "text", CERT_ADDRESS,
+ NULL));
+
+ GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(
+ GTK_SCROLLED_WINDOW(scroll_window), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(scroll_window), tree);
+ gtk_box_pack_start(GTK_BOX(vbox_), scroll_window, TRUE, TRUE, 0);
+
+ GtkWidget* button_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_box_pack_start(GTK_BOX(vbox_), button_box, FALSE, FALSE, 0);
+
+ view_button_ = gtk_button_new_with_mnemonic(
+ gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_VIEW_CERT_BUTTON)).c_str());
+ gtk_widget_set_sensitive(view_button_, FALSE);
+ g_signal_connect(view_button_, "clicked",
+ G_CALLBACK(OnViewClicked), this);
+ gtk_box_pack_start(GTK_BOX(button_box), view_button_, FALSE, FALSE, 0);
+
+ // TODO(mattm): Add buttons for import, export, delete, etc
+
+ // TODO(mattm): Populate the tree.
+}
+
+// static
+void CertificatePage::OnSelectionChanged(GtkTreeSelection* selection,
+ CertificatePage* page) {
+ CERTCertificate* cert = NULL;
+ GtkTreeIter iter;
+ GtkTreeModel* model;
+ if (gtk_tree_selection_get_selected(page->selection_, &model, &iter))
+ gtk_tree_model_get(model, &iter, CERT_POINTER, &cert, -1);
+
+ gtk_widget_set_sensitive(page->view_button_, cert ? TRUE : FALSE);
+}
+
+// static
+void CertificatePage::OnViewClicked(GtkButton *button, CertificatePage* page) {
+ GtkTreeIter iter;
+ GtkTreeModel* model;
+ if (!gtk_tree_selection_get_selected(page->selection_, &model, &iter))
+ return;
+
+ CERTCertificate* cert = NULL;
+ gtk_tree_model_get(model, &iter, CERT_POINTER, &cert, -1);
+ if (cert)
+ ShowCertificateViewer(GTK_WINDOW(gtk_widget_get_toplevel(page->widget())),
+ cert);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// CertificateManager class definition.
+
+class CertificateManager {
+ public:
+ explicit CertificateManager(gfx::NativeWindow parent);
+
+ void Show();
+
+ private:
+ CertificatePage user_page_;
+ CertificatePage email_page_;
+ CertificatePage server_page_;
+ CertificatePage ca_page_;
+ CertificatePage unknown_page_;
+
+ GtkWidget* dialog_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// CertificateManager implementation.
+
+void OnDestroy(GtkDialog* dialog, CertificateManager* cert_manager) {
+ delete cert_manager;
+}
+
+CertificateManager::CertificateManager(gfx::NativeWindow parent)
+ : user_page_(CertificatePage::USER_CERTS),
+ email_page_(CertificatePage::EMAIL_CERTS),
+ server_page_(CertificatePage::SERVER_CERTS),
+ ca_page_(CertificatePage::CA_CERTS),
+ unknown_page_(CertificatePage::UNKNOWN_CERTS) {
+ dialog_ = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_CERTIFICATE_MANAGER_TITLE).c_str(),
+ parent,
+ // Non-modal.
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL);
+ gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox),
+ gtk_util::kContentAreaSpacing);
+ gtk_window_set_default_size(GTK_WINDOW(dialog_), 600, 440);
+
+ GtkWidget* notebook = gtk_notebook_new();
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook);
+
+ // TODO(mattm): Remember which page user viewed last.
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook),
+ user_page_.widget(),
+ gtk_label_new_with_mnemonic(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_PERSONAL_CERTS_TAB_LABEL).c_str()));
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook),
+ email_page_.widget(),
+ gtk_label_new_with_mnemonic(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_OTHER_PEOPLES_CERTS_TAB_LABEL).c_str()));
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook),
+ server_page_.widget(),
+ gtk_label_new_with_mnemonic(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_SERVER_CERTS_TAB_LABEL).c_str()));
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook),
+ ca_page_.widget(),
+ gtk_label_new_with_mnemonic(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_CERT_AUTHORITIES_TAB_LABEL).c_str()));
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook),
+ unknown_page_.widget(),
+ gtk_label_new_with_mnemonic(
+ l10n_util::GetStringUTF8(
+ IDS_CERT_MANAGER_UNKNOWN_TAB_LABEL).c_str()));
+
+ g_signal_connect(dialog_, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+ g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this);
+}
+
+void CertificateManager::Show() {
+ gtk_widget_show_all(dialog_);
+}
+
+} // namespace
+
+void ShowCertificateManager(gfx::NativeWindow parent) {
+ (new CertificateManager(parent))->Show();
+}
diff --git a/chrome/browser/gtk/certificate_manager.h b/chrome/browser/gtk/certificate_manager.h
new file mode 100644
index 0000000..8dabbc2
--- /dev/null
+++ b/chrome/browser/gtk/certificate_manager.h
@@ -0,0 +1,12 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GTK_CERTIFICATE_MANAGER_H_
+#define CHROME_BROWSER_GTK_CERTIFICATE_MANAGER_H_
+
+#include "app/gfx/native_widget_types.h"
+
+void ShowCertificateManager(gfx::NativeWindow parent);
+
+#endif // CHROME_BROWSER_GTK_CERTIFICATE_MANAGER_H_
diff --git a/chrome/browser/gtk/certificate_viewer.cc b/chrome/browser/gtk/certificate_viewer.cc
index 9be1f65..6c14cab 100644
--- a/chrome/browser/gtk/certificate_viewer.cc
+++ b/chrome/browser/gtk/certificate_viewer.cc
@@ -890,6 +890,13 @@ void CertificateViewer::Show() {
} // namespace
+void ShowCertificateViewer(gfx::NativeWindow parent, CERTCertificate* cert) {
+ CERTCertList* cert_chain = CERT_GetCertChainFromCert(
+ cert, PR_Now(), certUsageSSLServer);
+ DCHECK(cert_chain);
+ (new CertificateViewer(parent, cert_chain))->Show();
+}
+
void ShowCertificateViewer(gfx::NativeWindow parent, int cert_id) {
scoped_refptr<net::X509Certificate> cert;
CertStore::GetSharedInstance()->RetrieveCert(cert_id, &cert);
@@ -898,9 +905,5 @@ void ShowCertificateViewer(gfx::NativeWindow parent, int cert_id) {
// we displayed the page info.
return;
}
-
- CERTCertList* cert_chain = CERT_GetCertChainFromCert(
- cert->os_cert_handle(), PR_Now(), certUsageSSLServer);
- DCHECK(cert_chain);
- (new CertificateViewer(parent, cert_chain))->Show();
+ ShowCertificateViewer(parent, cert->os_cert_handle());
}
diff --git a/chrome/browser/gtk/certificate_viewer.h b/chrome/browser/gtk/certificate_viewer.h
index f5ebf44..d4b412e 100644
--- a/chrome/browser/gtk/certificate_viewer.h
+++ b/chrome/browser/gtk/certificate_viewer.h
@@ -7,6 +7,9 @@
#include "app/gfx/native_widget_types.h"
+typedef struct CERTCertificateStr CERTCertificate;
+
+void ShowCertificateViewer(gfx::NativeWindow parent, CERTCertificate* cert);
void ShowCertificateViewer(gfx::NativeWindow parent, int cert_id);
#endif // CHROME_BROWSER_GTK_CERTIFICATE_VIEWER_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 5422542..a0ac454 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -990,6 +990,8 @@
'browser/gtk/browser_window_gtk.h',
'browser/gtk/cairo_cached_surface.cc',
'browser/gtk/cairo_cached_surface.h',
+ 'browser/gtk/certificate_manager.cc',
+ 'browser/gtk/certificate_manager.h',
'browser/gtk/certificate_viewer.cc',
'browser/gtk/certificate_viewer.h',
'browser/gtk/clear_browsing_data_dialog_gtk.cc',