aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-07-23 03:05:20 +0800
committerChristian Persch <chpe@src.gnome.org>2006-07-23 03:05:20 +0800
commitcc4f8cb9866d2d1df8ded5e48491d4a5154f031b (patch)
tree3750f7fcb0637291ddd8beffec41c8d28e6eb53d
parent2bbc8ce5db41c0e1f956af24ede67f7946fc844d (diff)
downloadgsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar.gz
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar.bz2
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar.lz
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar.xz
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.tar.zst
gsoc2013-epiphany-cc4f8cb9866d2d1df8ded5e48491d4a5154f031b.zip
Implement nsIFormSigningDialog. Bug #312869.
2006-07-22 Christian Persch <chpe@cvs.gnome.org> * data/glade/Makefile.am: * data/glade/form-signing-dialog.glade: * embed/mozilla/GeckoFormSigningDialog.cpp: * embed/mozilla/GeckoFormSigningDialog.h: * embed/mozilla/MozRegisterComponents.cpp: Implement nsIFormSigningDialog. Bug #312869.
-rw-r--r--ChangeLog10
-rw-r--r--data/glade/Makefile.am7
-rw-r--r--data/glade/form-signing-dialog.glade280
-rw-r--r--embed/mozilla/GeckoFormSigningDialog.cpp157
-rw-r--r--embed/mozilla/GeckoFormSigningDialog.h42
-rw-r--r--embed/mozilla/MozRegisterComponents.cpp10
6 files changed, 502 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d70fb7d26..4d495df4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-07-22 Christian Persch <chpe@cvs.gnome.org>
+
+ * data/glade/Makefile.am:
+ * data/glade/form-signing-dialog.glade:
+ * embed/mozilla/GeckoFormSigningDialog.cpp:
+ * embed/mozilla/GeckoFormSigningDialog.h:
+ * embed/mozilla/MozRegisterComponents.cpp:
+
+ Implement nsIFormSigningDialog. Bug #312869.
+
2006-07-21 Christian Persch <chpe@cvs.gnome.org>
* data/epiphany.schemas.in:
diff --git a/data/glade/Makefile.am b/data/glade/Makefile.am
index a557e2a77..0ef74593f 100644
--- a/data/glade/Makefile.am
+++ b/data/glade/Makefile.am
@@ -1,8 +1,9 @@
gladedir = $(pkgdatadir)/glade
glade_DATA = \
- certificate-dialogs.glade \
- epiphany.glade \
- prefs-dialog.glade \
+ certificate-dialogs.glade \
+ epiphany.glade \
+ form-signing-dialog.glade \
+ prefs-dialog.glade \
print.glade
if ENABLE_CERTIFICATE_MANAGER
diff --git a/data/glade/form-signing-dialog.glade b/data/glade/form-signing-dialog.glade
new file mode 100644
index 000000000..54238cdcf
--- /dev/null
+++ b/data/glade/form-signing-dialog.glade
@@ -0,0 +1,280 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkDialog" id="form_signing_dialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Sign Text</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">True</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="icon_name">stock_signature</property>
+ <property name="role">epiphany-form-signing-dialog</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="help_button">
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-11</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox0">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">18</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="primary_label">
+ <property name="visible">True</property>
+ <property name="label"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTextView" id="textview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="overwrite">False</property>
+ <property name="accepts_tab">False</property>
+ <property name="justification">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap_mode">GTK_WRAP_NONE</property>
+ <property name="cursor_visible">True</property>
+ <property name="pixels_above_lines">0</property>
+ <property name="pixels_below_lines">0</property>
+ <property name="pixels_inside_wrap">0</property>
+ <property name="left_margin">0</property>
+ <property name="right_margin">0</property>
+ <property name="indent">0</property>
+ <property name="text" translatable="yes"></property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label86">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">To confirm that you want to sign the above text, choose a certificate to sign the text with and enter its password below.</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="label87">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Certificate:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label88">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Password:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">password_entry</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="password_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">ā—</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
diff --git a/embed/mozilla/GeckoFormSigningDialog.cpp b/embed/mozilla/GeckoFormSigningDialog.cpp
new file mode 100644
index 000000000..4c22ab1e2
--- /dev/null
+++ b/embed/mozilla/GeckoFormSigningDialog.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "mozilla-config.h"
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glade/glade-xml.h>
+
+#include <nsStringAPI.h>
+
+#include <nsCOMPtr.h>
+#include <nsIDOMWindow.h>
+#include <nsIInterfaceRequestor.h>
+#include <nsIInterfaceRequestorUtils.h>
+
+#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
+#include "ephy-embed-shell.h"
+#include "ephy-file-helpers.h"
+#include "ephy-prefs.h"
+
+#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
+#include "EphyUtils.h"
+
+#include "GeckoFormSigningDialog.h"
+
+#define LITERAL(s) NS_REINTERPRET_CAST(const nsAString::char_type*, NS_L(s))
+
+NS_IMPL_ISUPPORTS1 (GeckoFormSigningDialog,
+ nsIFormSigningDialog)
+
+GeckoFormSigningDialog::GeckoFormSigningDialog()
+{
+ LOG ("GeckoFormSigningDialog ctor [%p]", this);
+}
+
+GeckoFormSigningDialog::~GeckoFormSigningDialog()
+{
+ LOG ("GeckoFormSigningDialog dtor [%p]", this);
+}
+
+/* nsIFormSigningDialog implementation */
+
+/* boolean confirmSignText (in nsIInterfaceRequestor ctxt,
+ in AString host,
+ in AString signText,
+ [array, size_is (count)] in wstring certNickList,
+ [array, size_is (count)] in wstring certDetailsList,
+ in PRUint32 count,
+ out PRInt32 selectedIndex,
+ out AString password); */
+NS_IMETHODIMP
+GeckoFormSigningDialog::ConfirmSignText (nsIInterfaceRequestor *ctx,
+ const nsAString & host,
+ const nsAString & signText,
+ const PRUnichar **certNickList,
+ const PRUnichar **certDetailsList,
+ PRUint32 count,
+ PRInt32 *selectedIndex,
+ nsAString &_password,
+ PRBool *_cancelled)
+{
+ /* FIXME: limit |signText| to a sensitlbe length (maybe 100k)? */
+
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
+ if (!parent) {
+ parent = EphyJSUtils::GetDOMWindowFromCallContext ();
+ g_print ("Fallback window %p\n", (void*)parent.get());
+ }
+ GtkWidget *gparent = EphyUtils::FindGtkParent (parent);
+
+ AutoWindowModalState modalState (parent);
+
+ GladeXML *gxml = glade_xml_new (ephy_file ("form-signing-dialog.glade"),
+ "form_signing_dialog", NULL);
+ g_return_val_if_fail (gxml, NS_ERROR_FAILURE);
+
+ GtkWidget *dialog = glade_xml_get_widget (gxml, "form_signing_dialog");
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gparent));
+
+ GtkLabel *primary_label = GTK_LABEL (glade_xml_get_widget (gxml, "primary_label"));
+ char *primary = g_strdup_printf (_("The web site ā€œ%sā€ requests that you sign the following text:"),
+ NS_ConvertUTF16toUTF8 (host).get ());
+ gtk_label_set_text (primary_label, primary);
+ g_free (primary);
+
+ GtkTextView *textview = GTK_TEXT_VIEW (glade_xml_get_widget (gxml, "textview"));
+ NS_ConvertUTF16toUTF8 text (signText);
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (textview),
+ text.get (), text.Length ());
+
+ GtkTable *table = GTK_TABLE (glade_xml_get_widget (gxml, "table"));
+ GtkComboBox *combo = GTK_COMBO_BOX (gtk_combo_box_new_text ());
+ for (PRUint32 i = 0; i < count; ++i) {
+ gtk_combo_box_append_text (combo, NS_ConvertUTF16toUTF8 (certNickList[i]).get ());
+ }
+
+ gtk_combo_box_set_active (combo, 0);
+ gtk_table_attach_defaults (table, GTK_WIDGET (combo), 1, 2, 0, 1);
+ gtk_widget_show (GTK_WIDGET (combo));
+
+ /* FIXME: Add "View Certificate" button */
+
+ GtkEntry *password_entry = GTK_ENTRY (glade_xml_get_widget (gxml, "password_entry"));
+
+ GtkWidget *button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Sign text"),
+ GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
+ gtk_widget_grab_focus (button);
+
+ /* FIXME: make Sign insensitive for some time (proportional to text length, with maximum?) */
+
+ g_object_unref (gxml);
+
+ int response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ *_cancelled = response != GTK_RESPONSE_ACCEPT;
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ _password = NS_ConvertUTF8toUTF16 (gtk_entry_get_text (password_entry));
+ *selectedIndex = gtk_combo_box_get_active (combo);
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return NS_OK;
+}
diff --git a/embed/mozilla/GeckoFormSigningDialog.h b/embed/mozilla/GeckoFormSigningDialog.h
new file mode 100644
index 000000000..8fe261827
--- /dev/null
+++ b/embed/mozilla/GeckoFormSigningDialog.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef GECKO_FORMSIGNINGDIALOGS_H
+#define GECKO_FORMSIGNINGDIALOGS_H
+
+#include <nsIFormSigningDialog.h>
+
+/* 4e42a43e-fbc5-40cc-bcbb-8cbc4e2101eb */
+#define GECKO_FORMSIGNINGDIALOGS_CID \
+{ 0x4e42a43e, 0xfbc5, 0x40cc, { 0xbc, 0xbb, 0x8c, 0xbc, 0x4e, 0x21, 0x01, 0xeb } }
+
+#define GECKO_FORMSIGNINGDIALOGS_CLASSNAME "Gecko Form Signing Dialogs"
+
+class GeckoFormSigningDialog : public nsIFormSigningDialog
+{
+ public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIFORMSIGNINGDIALOG
+
+ GeckoFormSigningDialog();
+ ~GeckoFormSigningDialog();
+};
+
+#endif /* GECKO_FORMSIGNINGDIALOGS_H */
diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp
index 1c93ebeed..86ce9fc21 100644
--- a/embed/mozilla/MozRegisterComponents.cpp
+++ b/embed/mozilla/MozRegisterComponents.cpp
@@ -73,6 +73,7 @@
#include "GtkNSSDialogs.h"
#include "GtkNSSKeyPairDialogs.h"
#include "GtkNSSSecurityWarningDialogs.h"
+#include "GeckoFormSigningDialog.h"
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(EphyAboutModule)
@@ -98,6 +99,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSClientAuthDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSKeyPairDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSSecurityWarningDialogs)
+NS_GENERIC_FACTORY_CONSTRUCTOR(GeckoFormSigningDialog)
#endif
#define XPINSTALL_CONTRACTID NS_CONTENT_HANDLER_CONTRACTID_PREFIX "application/x-xpinstall"
@@ -194,7 +196,13 @@ static const nsModuleComponentInfo sAppComps[] = {
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
GtkNSSSecurityWarningDialogsConstructor
},
-#endif
+ {
+ GECKO_FORMSIGNINGDIALOGS_CLASSNAME,
+ GECKO_FORMSIGNINGDIALOGS_CID,
+ NS_FORMSIGNINGDIALOG_CONTRACTID,
+ GeckoFormSigningDialogConstructor
+ },
+#endif /* HAVE_MOZILLA_PSM */
{
NS_IHELPERAPPLAUNCHERDLG_CLASSNAME,
G_CONTENTHANDLER_CID,