aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-07-06 21:22:35 +0800
committerChristian Persch <chpe@src.gnome.org>2006-07-06 21:22:35 +0800
commitd86cac67a766a04b93c94365ff162f64a1954644 (patch)
treef37e82765868a2343b94dd4574c826ad05780e9f
parent942d6ff58714449de8ad005313811db0b3177a4d (diff)
downloadgsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar.gz
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar.bz2
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar.lz
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar.xz
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.tar.zst
gsoc2013-epiphany-d86cac67a766a04b93c94365ff162f64a1954644.zip
A embed/mozilla/AutoWindowModalState.cpp: A
2006-07-06 Christian Persch <chpe@cvs.gnome.org> A embed/mozilla/AutoWindowModalState.cpp: A embed/mozilla/AutoWindowModalState.h: * embed/mozilla/ContentHandler.cpp: * embed/mozilla/EphyPromptService.cpp: * embed/mozilla/FilePicker.cpp: * embed/mozilla/FilePicker.h: * embed/mozilla/GtkNSSClientAuthDialogs.cpp: * embed/mozilla/GtkNSSDialogs.cpp: * embed/mozilla/GtkNSSKeyPairDialogs.cpp: * embed/mozilla/GtkNSSSecurityWarningDialogs.cpp: * embed/mozilla/Makefile.am: Prevent DOM window closure while we display a modal dialogue on it.
-rw-r--r--ChangeLog16
-rw-r--r--embed/mozilla/AutoWindowModalState.cpp45
-rw-r--r--embed/mozilla/AutoWindowModalState.h39
-rw-r--r--embed/mozilla/ContentHandler.cpp8
-rw-r--r--embed/mozilla/EphyPromptService.cpp10
-rw-r--r--embed/mozilla/FilePicker.cpp6
-rw-r--r--embed/mozilla/FilePicker.h3
-rw-r--r--embed/mozilla/GtkNSSClientAuthDialogs.cpp5
-rw-r--r--embed/mozilla/GtkNSSDialogs.cpp36
-rw-r--r--embed/mozilla/GtkNSSKeyPairDialogs.cpp3
-rw-r--r--embed/mozilla/GtkNSSSecurityWarningDialogs.cpp18
-rw-r--r--embed/mozilla/Makefile.am2
12 files changed, 166 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dc07edf4..31b6e4ed6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-07-06 Christian Persch <chpe@cvs.gnome.org>
+
+ A embed/mozilla/AutoWindowModalState.cpp:
+ A embed/mozilla/AutoWindowModalState.h:
+ * embed/mozilla/ContentHandler.cpp:
+ * embed/mozilla/EphyPromptService.cpp:
+ * embed/mozilla/FilePicker.cpp:
+ * embed/mozilla/FilePicker.h:
+ * embed/mozilla/GtkNSSClientAuthDialogs.cpp:
+ * embed/mozilla/GtkNSSDialogs.cpp:
+ * embed/mozilla/GtkNSSKeyPairDialogs.cpp:
+ * embed/mozilla/GtkNSSSecurityWarningDialogs.cpp:
+ * embed/mozilla/Makefile.am:
+
+ Prevent DOM window closure while we display a modal dialogue on it.
+
2006-07-01 Christian Persch <chpe@cvs.gnome.org>
* src/bookmarks/ephy-bookmark-action.c
diff --git a/embed/mozilla/AutoWindowModalState.cpp b/embed/mozilla/AutoWindowModalState.cpp
new file mode 100644
index 000000000..e9930d809
--- /dev/null
+++ b/embed/mozilla/AutoWindowModalState.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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$
+ */
+
+#include <mozilla-config.h>
+#include "config.h"
+
+#include <nsPIDOMWindow.h>
+
+#include "AutoWindowModalState.h"
+
+AutoWindowModalState::AutoWindowModalState (nsIDOMWindow *aWindow)
+{
+#ifdef HAVE_GECKO_1_9
+ mWindow = do_QueryInterface (aWindow);
+ if (mWindow) {
+ mWindow->EnterModalState ();
+ }
+#endif
+}
+
+AutoWindowModalState::~AutoWindowModalState()
+{
+#ifdef HAVE_GECKO_1_9
+ if (mWindow) {
+ mWindow->LeaveModalState ();
+ }
+#endif
+}
diff --git a/embed/mozilla/AutoWindowModalState.h b/embed/mozilla/AutoWindowModalState.h
new file mode 100644
index 000000000..6e7ab9ac9
--- /dev/null
+++ b/embed/mozilla/AutoWindowModalState.h
@@ -0,0 +1,39 @@
+/*
+ * 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 AUTO_WINDOWMODALSTATE_H
+#define AUTO_WINDOWMODALSTATE_H
+
+#include <nsCOMPtr.h>
+
+class nsPIDomWindow;
+
+class AutoWindowModalState
+{
+ public:
+ AutoWindowModalState (nsIDOMWindow *);
+ ~AutoWindowModalState ();
+
+ private:
+
+ nsCOMPtr<nsPIDomWindow> mWindow;
+};
+
+#endif
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index 5d28268d6..5fbc91090 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -57,11 +57,11 @@
#include "ephy-prefs.h"
#include "ephy-stock-icons.h"
+#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "MozDownload.h"
-#include "AutoJSContextStack.h"
-
#include "ContentHandler.h"
/* FIXME: we don't generally have a timestamp for the user action which initiated this
@@ -139,9 +139,11 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parentDOMWindow = do_GetInterface (aWindowContext);
+ nsCOMPtr<nsIDOMWindow> parentDOMWindow (do_GetInterface (aWindowContext));
GtkWidget *parentWindow = GTK_WIDGET (EphyUtils::FindGtkParent (parentDOMWindow));
+ AutoWindowModalState modalState (parentDOMWindow);
+
dialog = ephy_file_chooser_new (_("Save"), parentWindow,
GTK_FILE_CHOOSER_ACTION_SAVE,
CONF_STATE_SAVE_DIR,
diff --git a/embed/mozilla/EphyPromptService.cpp b/embed/mozilla/EphyPromptService.cpp
index ceed6e0ab..4d934f23a 100644
--- a/embed/mozilla/EphyPromptService.cpp
+++ b/embed/mozilla/EphyPromptService.cpp
@@ -37,6 +37,7 @@
#include "ephy-debug.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "EphyPromptService.h"
@@ -79,6 +80,7 @@ public:
char* ConvertAndEscapeButtonText (const PRUnichar *, PRInt32 = -1);
private:
+ nsCOMPtr<nsIDOMWindow> mWindow;
GtkDialog *mDialog;
GtkWidget *mVBox;
GtkWidget *mCheck;
@@ -98,7 +100,8 @@ Prompter::Prompter (const char *aStock,
nsIDOMWindow *aParent,
const PRUnichar *aTitle,
const PRUnichar *aText)
- : mDialog(nsnull)
+ : mWindow (aParent)
+ , mDialog(nsnull)
, mVBox(nsnull)
, mCheck(nsnull)
, mSizeGroup(nsnull)
@@ -470,6 +473,8 @@ Prompter::Run (PRBool *aSuccess)
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
+ AutoWindowModalState modalState (mWindow);
+
if (mDelay)
{
guint timeout = g_timeout_add (TIMEOUT,
@@ -515,6 +520,9 @@ DeletePrompter (gpointer aPromptPtr,
void
Prompter::Show ()
{
+ /* We don't need it anymore */
+ mWindow = nsnull;
+
gtk_window_set_modal (GTK_WINDOW (mDialog), FALSE);
g_signal_connect (mDialog, "response",
diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp
index aff2249ce..a8f478ef8 100644
--- a/embed/mozilla/FilePicker.cpp
+++ b/embed/mozilla/FilePicker.cpp
@@ -44,6 +44,7 @@
#include "ephy-prefs.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "FilePicker.h"
@@ -77,6 +78,8 @@ NS_IMETHODIMP GFilePicker::Init(nsIDOMWindowInternal *parent, const PRUnichar *t
{
LOG ("GFilePicker::Init");
+ mParent = do_QueryInterface (parent);
+
GtkWidget *gtkparent = EphyUtils::FindGtkParent (parent);
#if defined(MOZ_NSIFILEPICKER_NSASTRING_)
NS_ENSURE_TRUE (gtkparent, NS_ERROR_FAILURE);
@@ -431,6 +434,9 @@ NS_IMETHODIMP GFilePicker::Show(PRInt16 *_retval)
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
+ AutoWindowModalState (mParent);
+ mParent = nsnull;
+
LOG ("GFilePicker::Show");
gtk_window_set_modal (GTK_WINDOW (mDialog), TRUE);
diff --git a/embed/mozilla/FilePicker.h b/embed/mozilla/FilePicker.h
index cdbfd243f..dd43d0a5e 100644
--- a/embed/mozilla/FilePicker.h
+++ b/embed/mozilla/FilePicker.h
@@ -24,6 +24,8 @@
#include <nsIFilePicker.h>
+class nsIDOMWindow;
+
#include "ephy-file-chooser.h"
#define G_FILEPICKER_CID \
@@ -54,6 +56,7 @@ private:
EphyFileChooser *mDialog;
PRInt16 mMode;
nsString mDefaultString;
+ nsCOMPtr<nsIDOMWindow> mParent;
};
#endif
diff --git a/embed/mozilla/GtkNSSClientAuthDialogs.cpp b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
index d6765c15e..f4f043176 100644
--- a/embed/mozilla/GtkNSSClientAuthDialogs.cpp
+++ b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
@@ -57,6 +57,7 @@
#include "ephy-state.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "GtkNSSClientAuthDialogs.h"
@@ -149,9 +150,11 @@ GtkNSSClientAuthDialogs::ChooseCertificate (nsIInterfaceRequestor *ctx,
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons ("",
GTK_WINDOW (gparent),
GTK_DIALOG_DESTROY_WITH_PARENT,
diff --git a/embed/mozilla/GtkNSSDialogs.cpp b/embed/mozilla/GtkNSSDialogs.cpp
index e3c9b5bcc..9c7f4cd12 100644
--- a/embed/mozilla/GtkNSSDialogs.cpp
+++ b/embed/mozilla/GtkNSSDialogs.cpp
@@ -87,6 +87,7 @@
#include "ephy-password-dialog.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "GtkNSSDialogs.h"
@@ -227,6 +228,9 @@ display_cert_warning_box (nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *label, *checkbox, *vbox, *button;
int res;
+ g_return_val_if_fail (markup_text, GTK_RESPONSE_CANCEL);
+ g_return_val_if_fail (!checkbox_text || checkbox_value, GTK_RESPONSE_CANCEL);
+
nsresult rv;
AutoJSContextStack stack;
rv = stack.Init ();
@@ -235,12 +239,11 @@ display_cert_warning_box (nsIInterfaceRequestor *ctx,
/* NOTE: Due to a mozilla bug [https://bugzilla.mozilla.org/show_bug.cgi?id=306288],
* we will always end up without a parent!
*/
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
- g_return_val_if_fail (markup_text, GTK_RESPONSE_CANCEL);
- g_return_val_if_fail (!checkbox_text || checkbox_value, GTK_RESPONSE_CANCEL);
-
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons ("", gparent,
GTK_DIALOG_DESTROY_WITH_PARENT,
(char *) NULL);
@@ -612,9 +615,11 @@ GtkNSSDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons (_("Trust new Certificate Authority?"), gparent,
GTK_DIALOG_DESTROY_WITH_PARENT,
_("_View Certificate"),
@@ -743,9 +748,11 @@ GtkNSSDialogs::SetPKCS12FilePassword(nsIInterfaceRequestor *ctx,
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWidget *gparent = EphyUtils::FindGtkParent (parent);
+ AutoWindowModalState modalState (parent);
+
dialog = ephy_password_dialog_new (gparent,
_("Select Password"),
EphyPasswordDialogFlags(EPHY_PASSWORD_DIALOG_FLAGS_SHOW_NEW_PASSWORD |
@@ -791,9 +798,11 @@ GtkNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor *ctx,
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWidget *gparent = EphyUtils::FindGtkParent (parent);
+ AutoWindowModalState modalState (parent);
+
GtkWidget *dialog = ephy_password_dialog_new
(gparent,
"",
@@ -1208,8 +1217,11 @@ GtkNSSDialogs::ViewCert(nsIInterfaceRequestor *ctx,
dialog = glade_xml_get_widget (gxml, "viewcert_dialog");
g_return_val_if_fail (dialog != NULL, NS_ERROR_FAILURE);
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+
+ AutoWindowModalState modalState (parent);
+
if (gparent)
{
gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(gparent));
@@ -1391,9 +1403,11 @@ GtkNSSDialogs::SetPassword(nsIInterfaceRequestor *aCtx,
PRUint32 status = nsIPKCS11Slot::SLOT_UNINITIALIZED;
slot->GetStatus (&status);
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (aCtx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (aCtx));
GtkWidget *gparent = EphyUtils::FindGtkParent (parent);
+ AutoWindowModalState modalState (parent);
+
EphyPasswordDialogFlags flags =
EphyPasswordDialogFlags (EPHY_PASSWORD_DIALOG_FLAGS_SHOW_NEW_PASSWORD |
EPHY_PASSWORD_DIALOG_FLAGS_SHOW_QUALITY_METER);
@@ -1478,9 +1492,11 @@ GtkNSSDialogs::GetPassword(nsIInterfaceRequestor *aCtx,
rv = stack.Init ();
if (NS_FAILED (rv)) return rv;
- nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (aCtx);
+ nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (aCtx));
GtkWidget *gparent = EphyUtils::FindGtkParent (parent);
+ AutoWindowModalState modalState (parent);
+
EphyPasswordDialogFlags flags =
EphyPasswordDialogFlags (EPHY_PASSWORD_DIALOG_FLAGS_SHOW_PASSWORD);
diff --git a/embed/mozilla/GtkNSSKeyPairDialogs.cpp b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
index 238e183c7..be0a68e6c 100644
--- a/embed/mozilla/GtkNSSKeyPairDialogs.cpp
+++ b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
@@ -49,6 +49,7 @@
#include "ephy-gui.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "GtkNSSKeyPairDialogs.h"
@@ -148,6 +149,8 @@ GtkNSSKeyPairDialogs::DisplayGeneratingKeypairInfo (nsIInterfaceRequestor *ctx,
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons ("", gparent,
GTK_DIALOG_DESTROY_WITH_PARENT, (char *) NULL);
diff --git a/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp b/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
index fca676a52..125b2e611 100644
--- a/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
+++ b/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
@@ -61,6 +61,7 @@
#include <nsServiceManagerUtils.h>
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include "EphyUtils.h"
#include "GtkNSSSecurityWarningDialogs.h"
@@ -226,21 +227,18 @@ GtkNSSSecurityWarningDialogs::DoDialog (nsIInterfaceRequestor *aContext,
return;
}
- AutoJSContextStack stack;
- rv = stack.Init ();
- if (NS_FAILED (rv)) return;
-
- /* Didn't you know it, mozilla SUCKS!
- * the "aContext" interface requestor is made from a nsIDOMWindow,
- * but can only give out a nsIPrompt, from where there's no way to get
- * the nsIDOMWindow back! Therefore we cannot display this dialogue with
- * a parent, and HAVE TO make it modal.
+ /* On 1.8.0, domWin will be always nsnull, because of
* https://bugzilla.mozilla.org/show_bug.cgi?id=277587
*/
- /* domWin will be always nsnull, until the mozilla bug is fixed */
nsCOMPtr<nsIDOMWindow> domWin (do_GetInterface (aContext));
GtkWidget *parent = EphyUtils::FindGtkParent (domWin);
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return;
+
+ AutoWindowModalState modalState (domWin);
+
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_MODAL, aType,
aButtons, aPrimary);
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index a117955ff..38b58fd0d 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -3,6 +3,8 @@ noinst_LTLIBRARIES = libephymozillaembed.la
libephymozillaembed_la_SOURCES = \
AutoJSContextStack.cpp \
AutoJSContextStack.h \
+ AutoWindowModalState.cpp \
+ AutoWindowModalState.h \
ContentHandler.cpp \
ContentHandler.h \
EphyAboutModule.cpp \