aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-07-06 21:32:33 +0800
committerChristian Persch <chpe@src.gnome.org>2006-07-06 21:32:33 +0800
commit8b9ed362b0de95933c1e0c02fff22ea4c292dd8a (patch)
tree9752b05f330e3dc5d8c6876ba524091b7f13e1bd /embed
parentee6794be251553d214ccbbfa949de576db85adba (diff)
downloadgsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar.gz
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar.bz2
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar.lz
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar.xz
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.tar.zst
gsoc2013-epiphany-8b9ed362b0de95933c1e0c02fff22ea4c292dd8a.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.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/AutoWindowModalState.cpp45
-rw-r--r--embed/mozilla/AutoWindowModalState.h39
-rw-r--r--embed/mozilla/ContentHandler.cpp5
-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.cpp28
-rw-r--r--embed/mozilla/GtkNSSKeyPairDialogs.cpp3
-rw-r--r--embed/mozilla/GtkNSSSecurityWarningDialogs.cpp18
-rw-r--r--embed/mozilla/Makefile.am2
11 files changed, 143 insertions, 21 deletions
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 6c3acd696..3547e7252 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -27,6 +27,7 @@
#include "ContentHandler.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <gtk/gtkdialog.h>
#include <gtk/gtkmessagedialog.h>
@@ -172,9 +173,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 576fab33f..6aa33e5d9 100644
--- a/embed/mozilla/EphyPromptService.cpp
+++ b/embed/mozilla/EphyPromptService.cpp
@@ -23,6 +23,7 @@
#include "EphyPromptService.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsCOMPtr.h>
#include <nsIDOMWindow.h>
@@ -96,6 +97,7 @@ public:
char* ConvertAndEscapeButtonText (const PRUnichar *, PRInt32 = -1);
private:
+ nsCOMPtr<nsIDOMWindow> mWindow;
GtkDialog *mDialog;
GtkWidget *mVBox;
GtkWidget *mCheck;
@@ -115,7 +117,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)
@@ -488,6 +491,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,
@@ -533,6 +538,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 29f54bbbb..bac8c3fcc 100644
--- a/embed/mozilla/FilePicker.cpp
+++ b/embed/mozilla/FilePicker.cpp
@@ -26,6 +26,7 @@
#include "FilePicker.h"
#include "EphyUtils.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsCOMPtr.h>
#undef MOZILLA_INTERNAL_API
@@ -82,6 +83,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);
@@ -436,6 +439,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 1c2283255..14318b4c5 100644
--- a/embed/mozilla/FilePicker.h
+++ b/embed/mozilla/FilePicker.h
@@ -28,6 +28,8 @@
#include <nsEmbedString.h>
#define MOZILLA_INTERNAL_API 1
+class nsIDOMWindow;
+
#include "ephy-file-chooser.h"
#define G_FILEPICKER_CID \
@@ -58,6 +60,7 @@ private:
EphyFileChooser *mDialog;
PRInt16 mMode;
nsEmbedString mDefaultString;
+ nsCOMPtr<nsIDOMWindow> mParent;
};
#endif
diff --git a/embed/mozilla/GtkNSSClientAuthDialogs.cpp b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
index 6d385b7fb..602a6c61b 100644
--- a/embed/mozilla/GtkNSSClientAuthDialogs.cpp
+++ b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
@@ -26,6 +26,7 @@
#include "EphyUtils.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsIDOMWindow.h>
#include <nsIServiceManager.h>
@@ -151,9 +152,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 a00088eac..3c2a39b8b 100644
--- a/embed/mozilla/GtkNSSDialogs.cpp
+++ b/embed/mozilla/GtkNSSDialogs.cpp
@@ -32,6 +32,7 @@
#include "EphyUtils.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsCOMPtr.h>
#include <nsMemory.h>
@@ -212,6 +213,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 ();
@@ -220,12 +224,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);
@@ -554,9 +557,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"),
@@ -771,9 +776,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));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons ("", gparent,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -894,9 +901,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));
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
+ AutoWindowModalState modalState (parent);
+
dialog = gtk_dialog_new_with_buttons ("", gparent,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -1354,8 +1363,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));
diff --git a/embed/mozilla/GtkNSSKeyPairDialogs.cpp b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
index c25076306..42852f561 100644
--- a/embed/mozilla/GtkNSSKeyPairDialogs.cpp
+++ b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
@@ -41,6 +41,7 @@
#include "EphyUtils.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsIServiceManager.h>
#include <nsIInterfaceRequestor.h>
@@ -206,6 +207,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 19868253a..966384209 100644
--- a/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
+++ b/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
@@ -48,6 +48,7 @@
#include "GtkNSSSecurityWarningDialogs.h"
#include "EphyUtils.h"
#include "AutoJSContextStack.h"
+#include "AutoWindowModalState.h"
#include <nsCOMPtr.h>
#include <nsIPrefBranch.h>
@@ -225,21 +226,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 5658c8571..0a37225df 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 \