diff options
Diffstat (limited to 'embed/xulrunner/utils')
-rw-r--r-- | embed/xulrunner/utils/AutoJSContextStack.cpp | 48 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoJSContextStack.h | 41 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoWindowModalState.cpp | 43 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoWindowModalState.h | 38 | ||||
-rw-r--r-- | embed/xulrunner/utils/EphyBadCertRejector.cpp | 68 | ||||
-rw-r--r-- | embed/xulrunner/utils/EphyBadCertRejector.h | 36 | ||||
-rw-r--r-- | embed/xulrunner/utils/EphyUtils.cpp | 203 | ||||
-rw-r--r-- | embed/xulrunner/utils/EphyUtils.h | 66 | ||||
-rw-r--r-- | embed/xulrunner/utils/GeckoUtils.cpp | 87 | ||||
-rw-r--r-- | embed/xulrunner/utils/GeckoUtils.h | 34 | ||||
-rw-r--r-- | embed/xulrunner/utils/Makefile.am | 43 | ||||
-rw-r--r-- | embed/xulrunner/utils/ggeAutoModalDialog.cpp | 189 | ||||
-rw-r--r-- | embed/xulrunner/utils/ggeAutoModalDialog.h | 70 | ||||
-rw-r--r-- | embed/xulrunner/utils/ggeAutoSurvivalArea.cpp | 42 | ||||
-rw-r--r-- | embed/xulrunner/utils/ggeAutoSurvivalArea.h | 44 |
15 files changed, 0 insertions, 1052 deletions
diff --git a/embed/xulrunner/utils/AutoJSContextStack.cpp b/embed/xulrunner/utils/AutoJSContextStack.cpp deleted file mode 100644 index 9c918fc3b..000000000 --- a/embed/xulrunner/utils/AutoJSContextStack.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 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 <xpcom-config.h> -#include "config.h" - -#include "AutoJSContextStack.h" - -#include <nsIServiceManager.h> -#include <nsServiceManagerUtils.h> - -AutoJSContextStack::~AutoJSContextStack() -{ - if (mStack) { - JSContext* cx; - mStack->Pop (&cx); - - NS_ASSERTION(cx == nsnull, "We pushed a null context but popped a non-null context!?"); - } -} - -nsresult -AutoJSContextStack::Init() -{ - nsresult rv; - mStack = do_GetService ("@mozilla.org/js/xpc/ContextStack;1", &rv); - if (NS_FAILED (rv)) - return rv; - - return mStack->Push (nsnull); -} diff --git a/embed/xulrunner/utils/AutoJSContextStack.h b/embed/xulrunner/utils/AutoJSContextStack.h deleted file mode 100644 index 5294e7d4e..000000000 --- a/embed/xulrunner/utils/AutoJSContextStack.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 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_JSCONTEXTSTACK_H -#define AUTO_JSCONTEXTSTACK_H - -struct JSContext; - -#include <nsCOMPtr.h> -#include <nsIJSContextStack.h> - -class AutoJSContextStack -{ - public: - AutoJSContextStack () { } - ~AutoJSContextStack (); - - nsresult Init (); - - private: - nsCOMPtr<nsIJSContextStack> mStack; -}; - -#endif diff --git a/embed/xulrunner/utils/AutoWindowModalState.cpp b/embed/xulrunner/utils/AutoWindowModalState.cpp deleted file mode 100644 index 79fb2c15a..000000000 --- a/embed/xulrunner/utils/AutoWindowModalState.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#include <xpcom-config.h> -#include "config.h" - -#include "AutoWindowModalState.h" - -AutoWindowModalState::AutoWindowModalState (nsIDOMWindow *aWindow) -{ - if (aWindow) { - mWindow = do_QueryInterface (aWindow); - NS_ASSERTION (mWindow, "Should have a window here!"); - } - - if (mWindow) { - mWindow->EnterModalState (); - } -} - -AutoWindowModalState::~AutoWindowModalState() -{ - if (mWindow) { - mWindow->LeaveModalState (); - } -} diff --git a/embed/xulrunner/utils/AutoWindowModalState.h b/embed/xulrunner/utils/AutoWindowModalState.h deleted file mode 100644 index 557865799..000000000 --- a/embed/xulrunner/utils/AutoWindowModalState.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef AUTO_WINDOWMODALSTATE_H -#define AUTO_WINDOWMODALSTATE_H - -#include <nsCOMPtr.h> -#include <nsPIDOMWindow.h> - -class AutoWindowModalState -{ - public: - AutoWindowModalState (nsIDOMWindow *); - ~AutoWindowModalState (); - - private: - - nsCOMPtr<nsPIDOMWindow> mWindow; -}; - -#endif diff --git a/embed/xulrunner/utils/EphyBadCertRejector.cpp b/embed/xulrunner/utils/EphyBadCertRejector.cpp deleted file mode 100644 index 5aad7d92f..000000000 --- a/embed/xulrunner/utils/EphyBadCertRejector.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright © 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#include <xpcom-config.h> -#include "config.h" - -#include "EphyBadCertRejector.h" - -NS_IMPL_THREADSAFE_ISUPPORTS1 (EphyBadCertRejector, nsIBadCertListener) - -/* boolean confirmUnknownIssuer (in nsIInterfaceRequestor socketInfo, in nsIX509Cert cert, out short certAddType); */ -NS_IMETHODIMP -EphyBadCertRejector::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo, - nsIX509Cert *cert, - PRInt16 *certAddType, - PRBool *_retval) -{ - *certAddType = nsIBadCertListener::UNINIT_ADD_FLAG; - *_retval = PR_FALSE; - return NS_OK; -} - -/* boolean confirmMismatchDomain (in nsIInterfaceRequestor socketInfo, in AUTF8String targetURL, in nsIX509Cert cert); */ -NS_IMETHODIMP -EphyBadCertRejector::ConfirmMismatchDomain(nsIInterfaceRequestor *socketInfo, - const nsACString & targetURL, - nsIX509Cert *cert, - PRBool *_retval) -{ - *_retval = PR_FALSE; - return NS_OK; -} - -/* boolean confirmCertExpired (in nsIInterfaceRequestor socketInfo, in nsIX509Cert cert); */ -NS_IMETHODIMP -EphyBadCertRejector::ConfirmCertExpired(nsIInterfaceRequestor *socketInfo, - nsIX509Cert *cert, - PRBool *_retval) -{ - *_retval = PR_FALSE; - return NS_OK; -} - -/* void notifyCrlNextupdate (in nsIInterfaceRequestor socketInfo, in AUTF8String targetURL, in nsIX509Cert cert); */ -NS_IMETHODIMP -EphyBadCertRejector::NotifyCrlNextupdate(nsIInterfaceRequestor *socketInfo, - const nsACString & targetURL, - nsIX509Cert *cert) -{ - return NS_OK; -} diff --git a/embed/xulrunner/utils/EphyBadCertRejector.h b/embed/xulrunner/utils/EphyBadCertRejector.h deleted file mode 100644 index dcab75c6c..000000000 --- a/embed/xulrunner/utils/EphyBadCertRejector.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef EPHY_BAD_CERT_REJECTOR_H -#define EPHY_BAD_CERT_REJECTOR_H - -#include <nsIBadCertListener.h> - -class EphyBadCertRejector : public nsIBadCertListener -{ - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIBADCERTLISTENER - - EphyBadCertRejector () { } - ~EphyBadCertRejector () { } -}; - -#endif diff --git a/embed/xulrunner/utils/EphyUtils.cpp b/embed/xulrunner/utils/EphyUtils.cpp deleted file mode 100644 index a433294c8..000000000 --- a/embed/xulrunner/utils/EphyUtils.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright © 2004 Marco Pesenti Gritti - * - * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#include <xpcom-config.h> -#include "config.h" - -#include <nsStringGlue.h> - -#include <nsCOMPtr.h> -#include <nsDOMJSUtils.h> /* for GetScriptContextFromJSContext */ -#include <nsIDOMWindow.h> -#include <nsIEmbeddingSiteWindow.h> -#include <nsIFile.h> -#include <nsIIOService.h> -#include <nsIScriptContext.h> -#include <nsIScriptGlobalObject.h> -#include <nsIServiceManager.h> -#include <nsIURI.h> -#include <nsIWebBrowserChrome.h> -#include <nsIWindowWatcher.h> -#include <nsIXPConnect.h> -#include <nsPIDOMWindow.h> -#include <nsServiceManagerUtils.h> -#include <nsXPCOM.h> - -#include "EphyUtils.h" - -nsresult -EphyUtils::GetIOService (nsIIOService **ioService) -{ - nsresult rv; - - nsCOMPtr<nsIServiceManager> mgr; - NS_GetServiceManager (getter_AddRefs (mgr)); - if (!mgr) return NS_ERROR_FAILURE; - - rv = mgr->GetServiceByContractID ("@mozilla.org/network/io-service;1", - NS_GET_IID (nsIIOService), - (void **)ioService); - return rv; -} - -nsresult -EphyUtils::NewURI (nsIURI **result, - const nsAString &spec, - const char *charset, - nsIURI *baseURI) -{ - nsCString cSpec; - NS_UTF16ToCString (spec, NS_CSTRING_ENCODING_UTF8, cSpec); - - return NewURI (result, cSpec, charset, baseURI); -} - -nsresult -EphyUtils::NewURI (nsIURI **result, - const nsACString &spec, - const char *charset, - nsIURI *baseURI) -{ - nsresult rv; - nsCOMPtr<nsIIOService> ioService; - rv = EphyUtils::GetIOService (getter_AddRefs (ioService)); - NS_ENSURE_SUCCESS (rv, rv); - - return ioService->NewURI (spec, charset, baseURI, result); -} - -nsresult -EphyUtils::NewFileURI (nsIURI **result, - nsIFile *spec) -{ - nsresult rv; - nsCOMPtr<nsIIOService> ioService; - rv = EphyUtils::GetIOService (getter_AddRefs (ioService)); - NS_ENSURE_SUCCESS (rv, rv); - - return ioService->NewFileURI (spec, result); -} - -GtkWidget * -EphyUtils::FindEmbed (nsIDOMWindow *aDOMWindow) -{ - if (!aDOMWindow) return nsnull; - - nsCOMPtr<nsIWindowWatcher> wwatch - (do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - NS_ENSURE_TRUE (wwatch, nsnull); - - /* this DOM window may belong to some inner frame, we need - * to get the topmost DOM window to get the embed - */ - nsCOMPtr<nsIDOMWindow> topWindow; - aDOMWindow->GetTop (getter_AddRefs (topWindow)); - if (!topWindow) return nsnull; - - nsCOMPtr<nsIWebBrowserChrome> windowChrome; - wwatch->GetChromeForWindow (topWindow, getter_AddRefs(windowChrome)); - NS_ENSURE_TRUE (windowChrome, nsnull); - - nsCOMPtr<nsIEmbeddingSiteWindow> window (do_QueryInterface(windowChrome)); - NS_ENSURE_TRUE (window, nsnull); - - nsresult rv; - GtkWidget *mozembed; - rv = window->GetSiteWindow ((void **)&mozembed); - NS_ENSURE_SUCCESS (rv, nsnull); - - return mozembed; -} - -GtkWidget * -EphyUtils::FindGtkParent (nsIDOMWindow *aDOMWindow) -{ - GtkWidget *embed = FindEmbed (aDOMWindow); - if (!embed) return nsnull; - - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (embed)); - if (!GTK_WIDGET_TOPLEVEL (toplevel)) return nsnull; - - return toplevel; -} - -char * -EphyUtils::ConvertUTF16toUTF8 (const PRUnichar *aText, - PRInt32 aMaxLength) -{ - if (aText == nsnull) return NULL; - - /* This depends on the assumption that - * typeof(PRUnichar) == typeof (gunichar2) == uint16, - * which should be pretty safe. - */ - glong n_read = 0, n_written = 0; - char *converted = g_utf16_to_utf8 ((gunichar2*) aText, aMaxLength, - &n_read, &n_written, NULL); - /* FIXME loop from the end while !g_unichar_isspace (char)? */ - - return converted; -} - -/* This isn't completely accurate: if you do window.prompt in one window, then - * call this in another window, it still returns TRUE ! Those are the wonders - * of recursive mainloops :-( - */ -PRBool -EphyJSUtils::IsCalledFromScript () -{ - nsresult rv; - nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv)); - NS_ENSURE_SUCCESS (rv, PR_FALSE); - - nsCOMPtr<nsIXPCNativeCallContext> ncc; - rv = xpc->GetCurrentNativeCallContext (getter_AddRefs (ncc)); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - - return nsnull != ncc; -} - -/* NOTE: Only call this when we're SURE that we're called directly from JS! */ -nsIDOMWindow * -EphyJSUtils::GetDOMWindowFromCallContext () -{ - nsresult rv; - nsCOMPtr<nsIXPConnect> xpc (do_GetService(nsIXPConnect::GetCID(), &rv)); - NS_ENSURE_SUCCESS (rv, nsnull); - - nsCOMPtr<nsIXPCNativeCallContext> ncc; - rv = xpc->GetCurrentNativeCallContext (getter_AddRefs (ncc)); - NS_ENSURE_SUCCESS (rv, nsnull); - - JSContext *cx = nsnull; - rv = ncc->GetJSContext(&cx); - NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && cx, nsnull); - - nsIScriptContext* scriptContext = GetScriptContextFromJSContext (cx); - if (!scriptContext) return nsnull; - - nsIScriptGlobalObject *globalObject = scriptContext->GetGlobalObject(); - if (!globalObject) return nsnull; - - nsCOMPtr<nsPIDOMWindow> piWindow (do_QueryInterface (globalObject)); - if (!piWindow) return nsnull; - - return piWindow->GetOuterWindow (); -} diff --git a/embed/xulrunner/utils/EphyUtils.h b/embed/xulrunner/utils/EphyUtils.h deleted file mode 100644 index 65b1edb04..000000000 --- a/embed/xulrunner/utils/EphyUtils.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2004 Marco Pesenti Gritti - * - * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef EPHY_UTILS_H -#define EPHY_UTILS_H - -#include <nscore.h> - -#include <gtk/gtkwidget.h> - -class nsACString; -class nsAString; -class nsIDOMWindow; -class nsIFile; -class nsIIOService; -class nsIURI; - -namespace EphyUtils -{ - nsresult GetIOService (nsIIOService **ioService); - - nsresult NewURI (nsIURI **result, - const nsAString &spec, - const char *charset = nsnull, - nsIURI *baseURI = nsnull); - - nsresult NewURI (nsIURI **result, - const nsACString &spec, - const char *charset = nsnull, - nsIURI *baseURI = nsnull); - - nsresult NewFileURI (nsIURI **result, - nsIFile *spec); - - GtkWidget *FindEmbed (nsIDOMWindow *aDOMWindow); - - GtkWidget *FindGtkParent (nsIDOMWindow *aDOMWindow); - - char * ConvertUTF16toUTF8 (const PRUnichar*, PRInt32); -} - -namespace EphyJSUtils -{ - PRBool IsCalledFromScript (); - - /* not addref'd! */ nsIDOMWindow* GetDOMWindowFromCallContext (); -} - -#endif diff --git a/embed/xulrunner/utils/GeckoUtils.cpp b/embed/xulrunner/utils/GeckoUtils.cpp deleted file mode 100644 index c71fce4ba..000000000 --- a/embed/xulrunner/utils/GeckoUtils.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright © 2003 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Brian Ryner <bryner@brianryner.com> - * - * $Id$ - */ - -#include <xpcom-config.h> -#include "config.h" - -#include "GeckoUtils.h" - -#include "gecko-embed.h" - -#include <nsCOMPtr.h> -#include <nsIDOMWindow.h> -#include <nsIWindowWatcher.h> -#include <nsIWebBrowserChrome.h> -#include <nsIEmbeddingSiteWindow.h> -#include <nsIServiceManager.h> -#include <nsServiceManagerUtils.h> - -GtkWidget * -GeckoUtils::GetGeckoEmbedForDOMWindow (nsIDOMWindow * aDOMWindow) -{ - if (!aDOMWindow) - return NULL; - - /* Get the toplevel DOM window, in case this window is a frame */ - nsCOMPtr<nsIDOMWindow> domWin; - aDOMWindow->GetTop (getter_AddRefs (domWin)); - if (!domWin) - return NULL; - - nsCOMPtr< nsIWindowWatcher> wwatch - (do_GetService ("@mozilla.org/embedcomp/window-watcher;1")); - NS_ENSURE_TRUE (wwatch, NULL); - - nsCOMPtr<nsIWebBrowserChrome> chrome; - wwatch->GetChromeForWindow (domWin, getter_AddRefs (chrome)); - - nsCOMPtr <nsIEmbeddingSiteWindow> siteWindow (do_QueryInterface (chrome)); - if (!siteWindow) - return NULL; - - GtkWidget *widget; - siteWindow->GetSiteWindow ((void **) &widget); - if (!widget || !GECKO_IS_EMBED (widget)) - return NULL; - - return widget; -} - -GtkWidget * -GeckoUtils::GetGtkWindowForDOMWindow (nsIDOMWindow * aDOMWindow) -{ - GtkWidget *embed = GeckoUtils::GetGeckoEmbedForDOMWindow (aDOMWindow); - if (!embed) - return NULL; - - GtkWidget *gtkWin = gtk_widget_get_toplevel (embed); - if (!GTK_WIDGET_TOPLEVEL (gtkWin)) - return NULL; - - return gtkWin; -} diff --git a/embed/xulrunner/utils/GeckoUtils.h b/embed/xulrunner/utils/GeckoUtils.h deleted file mode 100644 index 05012e6b2..000000000 --- a/embed/xulrunner/utils/GeckoUtils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 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_UTILS_H -#define GECKO_UTILS_H - -#include <gtk/gtkwidget.h> - -class nsIDOMWindow; - -namespace GeckoUtils -{ - GtkWidget* GetGeckoEmbedForDOMWindow (nsIDOMWindow*); - GtkWidget* GetGtkWindowForDOMWindow (nsIDOMWindow*); -} - -#endif diff --git a/embed/xulrunner/utils/Makefile.am b/embed/xulrunner/utils/Makefile.am deleted file mode 100644 index a66ecf054..000000000 --- a/embed/xulrunner/utils/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -NULL = - -noinst_LTLIBRARIES = libephyxulrunnerutils.la - -libephyxulrunnerutils_la_SOURCES = \ - AutoJSContextStack.cpp \ - AutoJSContextStack.h \ - AutoWindowModalState.cpp \ - AutoWindowModalState.h \ - EphyBadCertRejector.cpp \ - EphyBadCertRejector.h \ - EphyUtils.cpp \ - EphyUtils.h \ - GeckoUtils.cpp \ - GeckoUtils.h \ - ggeAutoModalDialog.cpp \ - ggeAutoModalDialog.h \ - ggeAutoSurvivalArea.cpp \ - ggeAutoSurvivalArea.h \ - $(NULL) - -libephyxulrunnerutils_la_CPPFLAGS = \ - -I$(top_srcdir)/embed/xulrunner/src \ - $(LIBXUL_CXXCPPFLAGS) \ - $(LIBXUL_INCLUDES) \ - $(AM_CPPFLAGS) - -libephyxulrunnerutils_la_CXXFLAGS = \ - $(LIBXUL_CXXFLAGS) \ - $(GTK_CFLAGS) \ - $(AM_CXXFLAGS) - -libephyxulrunnerutils_la_LDFLAGS = \ - $(AM_LDFLAGS) - -libephyxulrunnerutils_la_LIBADD = \ - $(LIBXUL_LIBS) - -CLEANFILES = - $(NULL) - -EXTRA_DIST = \ - $(NULL) diff --git a/embed/xulrunner/utils/ggeAutoModalDialog.cpp b/embed/xulrunner/utils/ggeAutoModalDialog.cpp deleted file mode 100644 index 761e871d9..000000000 --- a/embed/xulrunner/utils/ggeAutoModalDialog.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Some code taken from mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp - * which was under MPL/LGPL/GPL tri-licence and is here being used under the licence above. - * Original notice: - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - */ - -#include <xpcom-config.h> -#include <config.h> - -struct JSContext; /* Just so we don't need to include a bunch of JS headers */ - -#include <nsIDOMDocumentEvent.h> -#include <nsIDOMDocument.h> -#include <nsIDOMEvent.h> -#include <nsIDOMEventTarget.h> -#include <nsIJSContextStack.h> -#include <nsIPrivateDOMEvent.h> -#include <nsPIDOMWindow.h> -#include <nsServiceManagerUtils.h> -#include <nsThreadUtils.h> - -#include <gtk/gtkdialog.h> - -#include "ggeAutoModalDialog.h" - -ggeAutoModalDialog::ggeAutoModalDialog (nsIDOMWindow *aWindow, - PRBool aNotifyDOM) - : mWindow (aWindow), - mPWindow (do_QueryInterface (aWindow)), - mStack (do_GetService ("@mozilla.org/js/xpc/ContextStack;1")), - mDefaultEnabled (DispatchEvent ("DOMWillOpenModalDialog", aNotifyDOM)), - mContextPushed (PR_FALSE), - mModalStateSet (PR_FALSE) -{ - /* First we check whether we should show the dialogue at all */ - if (aNotifyDOM) { - if (!mDefaultEnabled) { - return; - } - } - - if (mStack) { - mContextPushed = NS_SUCCEEDED (mStack->Push (nsnull)); - } - - if (mWindow) { - NS_ASSERTION (mPWindow, "Should have a window here!"); - - mPWindow->EnterModalState (); - mModalStateSet = PR_TRUE; - } -} - -ggeAutoModalDialog::~ggeAutoModalDialog () -{ - if (mModalStateSet) { - NS_ASSERTION (mPWindow, "Should have a window here!"); - mPWindow->LeaveModalState (); - } - - if (mContextPushed) { - NS_ASSERTION (mStack, "Should have a stack!"); - - JSContext* cx; - mStack->Pop (&cx); - - NS_ASSERTION(cx == nsnull, "We pushed a null context but popped a non-null context!?"); - } - -} - -/* static */ void PR_CALLBACK -ggeAutoModalDialog::ResponseCallback (GtkWidget *aDialog, - int aResponse, - void *aData) -{ - ggeAutoModalDialog *obj = reinterpret_cast<ggeAutoModalDialog*>(aData); - - gtk_widget_hide (aDialog); - obj->mResponse = aResponse; - obj->mContinueModalLoop = PR_FALSE; -} - -/* static */ gboolean PR_CALLBACK -ggeAutoModalDialog::DeleteCallback (GtkWidget *aDialog, - void *aEvent, - void *aData) -{ - gtk_dialog_response (GTK_DIALOG (aDialog), GTK_RESPONSE_DELETE_EVENT); - return TRUE; -} - -void -ggeAutoModalDialog::Run (GtkWidget *aDialog) -{ - NS_ASSERTION (ShouldShow(), "Calling ::Run on a prevented dialogue!"); - - /* Do NOT use gtk_dialog_run here, since it blocks the network thread! - * See https://bugzilla.mozilla.org/show_bug.cgi?id=338225 - */ - - // Reset popup state while opening a modal dialog, and firing - // events about the dialog, to prevent the current state from - // being active the whole time a modal dialog is open. - nsAutoPopupStatePusher popupStatePusher (mPWindow, openAbused); - - mDialog = aDialog; - g_object_ref_sink (mDialog); - mResponse = GTK_RESPONSE_DELETE_EVENT; - - gulong responseHandler = g_signal_connect (mDialog, "response", - G_CALLBACK (ResponseCallback), - reinterpret_cast<void*>(this)); - gulong deleteHandler = g_signal_connect (mDialog, "delete-event", - G_CALLBACK (DeleteCallback), - reinterpret_cast<void*>(this)); - - nsCOMPtr<nsIThread> thread (do_GetCurrentThread ()); - NS_ASSERTION (thread, "No UI thread?"); - - mContinueModalLoop = PR_TRUE; - while (mContinueModalLoop) { - if (!NS_ProcessNextEvent (thread)) - break; - } - - g_signal_handler_disconnect (mDialog, responseHandler); - g_signal_handler_disconnect (mDialog, deleteHandler); - /* FIXME */ - g_object_unref (mDialog); - mDialog = NULL; -} - -PRBool -ggeAutoModalDialog::DispatchEvent (const char *aEventName, - PRBool aDoNotify) -{ - if (!mWindow || !aDoNotify) { - return PR_TRUE; - } - - nsCOMPtr<nsIDOMDocument> domdoc; - mWindow->GetDocument (getter_AddRefs (domdoc)); - - nsCOMPtr<nsIDOMDocumentEvent> docevent (do_QueryInterface (domdoc)); - nsCOMPtr<nsIDOMEvent> event; - - PRBool defaultActionEnabled = PR_TRUE; - - if (docevent) { - docevent->CreateEvent (NS_LITERAL_STRING ("Events"), getter_AddRefs (event)); - - nsCOMPtr<nsIPrivateDOMEvent> privateEvent (do_QueryInterface (event)); - if (privateEvent) { - event->InitEvent (NS_ConvertASCIItoUTF16 (aEventName), PR_TRUE, PR_TRUE); - - privateEvent->SetTrusted(PR_TRUE); - - nsCOMPtr<nsIDOMEventTarget> target (do_QueryInterface (mWindow)); - - target->DispatchEvent (event, &defaultActionEnabled); - } - } - - return defaultActionEnabled; -} diff --git a/embed/xulrunner/utils/ggeAutoModalDialog.h b/embed/xulrunner/utils/ggeAutoModalDialog.h deleted file mode 100644 index 07299b609..000000000 --- a/embed/xulrunner/utils/ggeAutoModalDialog.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef GGE_AUTOMODALDIALOG_H -#define GGE_AUTOMODALDIALOG_H - -#include <nsCOMPtr.h> - -#include <gtk/gtkwidget.h> - -class nsPIDOMWindow; -class nsIJSContextStack; - -/** - * ggeAutoModalDialog: - * A stack-based helper class for modal GTK+ dialogues. - * - * You MUST check ::ShouldShow() before showing the dialogue! - */ -class ggeAutoModalDialog -{ - public: - ggeAutoModalDialog (nsIDOMWindow *, - PRBool aNotifyDOM = PR_TRUE); - ~ggeAutoModalDialog (); - - PRBool ShouldShow () { return mDefaultEnabled && mContextPushed; } - - void Run (GtkWidget *aDialog); - int Response () { return mResponse; } - - private: - // stack only please - void *operator new (size_t) CPP_THROW_NEW; - - PRBool DispatchEvent (const char*, PRBool); - - static void PR_CALLBACK ResponseCallback (GtkWidget*, int, void*); - static gboolean PR_CALLBACK DeleteCallback (GtkWidget*, void*, void*); - - nsCOMPtr<nsIDOMWindow> mWindow; - nsCOMPtr<nsPIDOMWindow> mPWindow; - nsCOMPtr<nsIJSContextStack> mStack; - - GtkWidget *mDialog; - int mResponse; - PRPackedBool mDefaultEnabled; - PRPackedBool mContextPushed; - PRPackedBool mModalStateSet; - PRPackedBool mContinueModalLoop; -}; - -#endif diff --git a/embed/xulrunner/utils/ggeAutoSurvivalArea.cpp b/embed/xulrunner/utils/ggeAutoSurvivalArea.cpp deleted file mode 100644 index 0344edabe..000000000 --- a/embed/xulrunner/utils/ggeAutoSurvivalArea.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2007 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. - */ - -#include <xpcom-config.h> -#include <config.h> - -#include <nsIAppStartup.h> -#include <nsIServiceManager.h> -#include <nsServiceManagerUtils.h> -#include <nsXPFEComponentsCID.h> - -#include "ggeAutoSurvivalArea.h" - -ggeAutoSurvivalArea::ggeAutoSurvivalArea() - : mAppStartup (do_GetService (NS_APPSTARTUP_CONTRACTID)) -{ - if (mAppStartup) { - mAppStartup->EnterLastWindowClosingSurvivalArea (); - } -} - -ggeAutoSurvivalArea::~ggeAutoSurvivalArea() -{ - if (mAppStartup) { - mAppStartup->ExitLastWindowClosingSurvivalArea (); - } -} diff --git a/embed/xulrunner/utils/ggeAutoSurvivalArea.h b/embed/xulrunner/utils/ggeAutoSurvivalArea.h deleted file mode 100644 index 10b9a07e5..000000000 --- a/embed/xulrunner/utils/ggeAutoSurvivalArea.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2007 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. - */ - -#ifndef GGE_AUTOSURVIVALAREA_H -#define GGE_AUTOSURVIVALAREA_H - -#include <nsCOMPtr.h> - -class nsIAppStartup; - -/** - * ggeAutoSurvivalArea: - * - * A helper class that has to be used whenever a window being open - * should prevent the application from shutting down. (Only needed for - * non-DOM windows.) - * Use on the stack or on the heap. - */ - -class ggeAutoSurvivalArea { - public: - ggeAutoSurvivalArea (); - ~ggeAutoSurvivalArea (); - - private: - nsCOMPtr<nsIAppStartup> mAppStartup; -}; - -#endif /* !GGE_AUTOSURVIVALAREA_H */ |