firefox6-36-gtkembed.diff revision 20829
20829N/Adiff --git a/embedding/browser/gtk/Makefile.in b/embedding/browser/gtk/Makefile.in
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/Makefile.in
20829N/A@@ -0,0 +1,54 @@
20829N/A+#
20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+#
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# http://www.mozilla.org/MPL/
20829N/A+#
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# License.
20829N/A+#
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+#
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Christopher Blizzard.
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+#
20829N/A+# Contributor(s):
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+#
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+#
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+
20829N/A+DEPTH = ../../..
20829N/A+topsrcdir = @top_srcdir@
20829N/A+srcdir = @srcdir@
20829N/A+VPATH = @srcdir@
20829N/A+
20829N/A+include $(DEPTH)/config/autoconf.mk
20829N/A+
20829N/A+MODULE = gtkembedmoz
20829N/A+
20829N/A+DIRS=src
20829N/A+
20829N/A+ifdef ENABLE_TESTS
20829N/A+TOOL_DIRS += tests
20829N/A+endif
20829N/A+
20829N/A+include $(topsrcdir)/config/rules.mk
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedCertificates.cpp b/embedding/browser/gtk/src/EmbedCertificates.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedCertificates.cpp
20829N/A@@ -0,0 +1,253 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Terry Hayes <thayes@netscape.com>
20829N/A+ * Javier Delgadillo <javi@netscape.com>
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+/**
20829N/A+ * Derived from nsNSSDialogs http://landfill.mozilla.org/mxr-test/seamonkey/source/security/manager/pki/src/nsNSSDialogs.cpp
20829N/A+ */
20829N/A+#include <strings.h>
20829N/A+#include "nsIURI.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include "nsServiceManagerUtils.h"
20829N/A+#include "nsIWebNavigationInfo.h"
20829N/A+#include "nsDocShellCID.h"
20829N/A+#include "nsCOMPtr.h"
20829N/A+#ifdef MOZILLA_INTERNAL_API
20829N/A+#include "nsString.h"
20829N/A+#include "nsXPIDLString.h"
20829N/A+#include "nsReadableUtils.h"
20829N/A+#else
20829N/A+#include "nsStringAPI.h"
20829N/A+#endif
20829N/A+#include "nsIPrompt.h"
20829N/A+#include "nsIDOMWindowInternal.h"
20829N/A+#include "nsIComponentManager.h"
20829N/A+#include "nsIServiceManager.h"
20829N/A+#include "nsIStringBundle.h"
20829N/A+#include "nsIInterfaceRequestor.h"
20829N/A+#include "nsIInterfaceRequestorUtils.h"
20829N/A+#include "nsIX509Cert.h"
20829N/A+#include "nsIX509CertDB.h"
20829N/A+#include "nsIDateTimeFormat.h"
20829N/A+#include "nsDateTimeFormatCID.h"
20829N/A+#include "EmbedCertificates.h"
20829N/A+#include "nsIKeygenThread.h"
20829N/A+#include "nsIX509CertValidity.h"
20829N/A+#include "nsICRLInfo.h"
20829N/A+#include "gtkmozembed.h"
20829N/A+
20829N/A+#define PIPSTRING_BUNDLE_URL "chrome://pippki/locale/pippki.properties"
20829N/A+
20829N/A+EmbedCertificates::EmbedCertificates(void)
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+EmbedCertificates::~EmbedCertificates()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_THREADSAFE_ADDREF(EmbedCertificates)
20829N/A+NS_IMPL_THREADSAFE_RELEASE(EmbedCertificates)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedCertificates)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsITokenPasswordDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsICertificateDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsIClientAuthDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsICertPickDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsITokenDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsIGeneratingKeypairInfoDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCryptoDialogs)
20829N/A+NS_INTERFACE_MAP_END
20829N/A+
20829N/A+nsresult
20829N/A+EmbedCertificates::Init(void)
20829N/A+{
20829N/A+ nsresult rv;
20829N/A+ nsCOMPtr<nsIStringBundleService> service =
20829N/A+ do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
20829N/A+ if (NS_FAILED(rv)) return NS_OK;
20829N/A+ rv = service->CreateBundle(PIPSTRING_BUNDLE_URL,
20829N/A+ getter_AddRefs(mPIPStringBundle));
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedCertificates::SetPassword(nsIInterfaceRequestor *ctx,
20829N/A+ const PRUnichar *tokenName, PRBool* _canceled)
20829N/A+{
20829N/A+ *_canceled = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedCertificates::GetPassword(nsIInterfaceRequestor *ctx,
20829N/A+ const PRUnichar *tokenName,
20829N/A+ PRUnichar **_password,
20829N/A+ PRBool* _canceled)
20829N/A+{
20829N/A+ *_canceled = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::CrlImportStatusDialog(nsIInterfaceRequestor *ctx, nsICRLInfo *crl)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
20829N/A+ nsIX509Cert *cert,
20829N/A+ PRUint32 *_trust,
20829N/A+ PRBool *_retval)
20829N/A+{
20829N/A+ // If an implementation chooses not to implement UI for displaying
20829N/A+ // the cert and asking the user for confirmation,
20829N/A+ // then this function must return PR_FALSE.
20829N/A+ *_retval = PR_FALSE;
20829N/A+ *_trust = nsIX509CertDB::UNTRUSTED;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::NotifyCACertExists(nsIInterfaceRequestor *ctx)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::ChooseCertificate(
20829N/A+ nsIInterfaceRequestor *ctx,
20829N/A+ const PRUnichar *cn,
20829N/A+ const PRUnichar *organization,
20829N/A+ const PRUnichar *issuer,
20829N/A+ const PRUnichar **certNickList,
20829N/A+ const PRUnichar **certDetailsList,
20829N/A+ PRUint32 count,
20829N/A+ PRInt32 *selectedIndex,
20829N/A+ PRBool *canceled)
20829N/A+{
20829N/A+ *canceled = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::PickCertificate(
20829N/A+ nsIInterfaceRequestor *ctx,
20829N/A+ const PRUnichar **certNickList,
20829N/A+ const PRUnichar **certDetailsList,
20829N/A+ PRUint32 count,
20829N/A+ PRInt32 *selectedIndex,
20829N/A+ PRBool *canceled)
20829N/A+{
20829N/A+ *canceled = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::SetPKCS12FilePassword(
20829N/A+ nsIInterfaceRequestor *ctx,
20829N/A+ nsAString &_password,
20829N/A+ PRBool *_retval)
20829N/A+{
20829N/A+ /* The person who wrote this method implementation did
20829N/A+ * not read the contract.
20829N/A+ */
20829N/A+ *_retval = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::GetPKCS12FilePassword(
20829N/A+ nsIInterfaceRequestor *ctx,
20829N/A+ nsAString &_password,
20829N/A+ PRBool *_retval)
20829N/A+{
20829N/A+ /* The person who wrote this method implementation did
20829N/A+ * not read the contract.
20829N/A+ */
20829N/A+ *_retval = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+/* void viewCert (in nsIX509Cert cert); */
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::ViewCert(
20829N/A+ nsIInterfaceRequestor *ctx,
20829N/A+ nsIX509Cert *cert)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *aCtx, nsIKeygenThread *runnable)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::ChooseToken(
20829N/A+ nsIInterfaceRequestor *aCtx,
20829N/A+ const PRUnichar **aTokenList,
20829N/A+ PRUint32 aCount,
20829N/A+ PRUnichar **aTokenChosen,
20829N/A+ PRBool *aCanceled)
20829N/A+{
20829N/A+ *aCanceled = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::DisplayProtectedAuth(
20829N/A+ nsIInterfaceRequestor *aCtx,
20829N/A+ nsIProtectedAuthThread *runnable)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+/* boolean ConfirmKeyEscrow (in nsIX509Cert escrowAuthority); */
20829N/A+NS_IMETHODIMP
20829N/A+EmbedCertificates::ConfirmKeyEscrow(nsIX509Cert *escrowAuthority, PRBool *_retval)
20829N/A+{
20829N/A+ // If an implementation chooses not to implement UI that asks the user for
20829N/A+ // confirmation to hand out the private key,
20829N/A+ // then this function must return PR_FALSE.
20829N/A+ *_retval = PR_FALSE;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedCertificates.h b/embedding/browser/gtk/src/EmbedCertificates.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedCertificates.h
20829N/A@@ -0,0 +1,84 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Terry Hayes <thayes@netscape.com>
20829N/A+ * Javier Delgadillo <javi@netscape.com>
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+/**
20829N/A+ * Derived from nsNSSDialogs http://landfill.mozilla.org/mxr-test/seamonkey/source/security/manager/pki/src/nsNSSDialogs.h
20829N/A+ */
20829N/A+#ifndef __EmbedCertificates_h
20829N/A+#define __EmbedCertificates_h
20829N/A+#include "nsITokenPasswordDialogs.h"
20829N/A+#include "nsICertificateDialogs.h"
20829N/A+#include "nsIClientAuthDialogs.h"
20829N/A+#include "nsICertPickDialogs.h"
20829N/A+#include "nsITokenDialogs.h"
20829N/A+#include "nsIDOMCryptoDialogs.h"
20829N/A+#include "nsIGenKeypairInfoDlg.h"
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsIStringBundle.h"
20829N/A+#define EMBED_CERTIFICATES_CID \
20829N/A+ { 0x518e071f, 0x1dd2, 0x11b2, \
20829N/A+ { 0x93, 0x7e, 0xc4, 0x5f, 0x14, 0xde, 0xf7, 0x78 }}
20829N/A+#define EMBED_CERTIFICATES_DESCRIPTION "Certificates Listener Impl"
20829N/A+class EmbedPrivate;
20829N/A+class EmbedCertificates
20829N/A+: public nsITokenPasswordDialogs,
20829N/A+ public nsICertificateDialogs,
20829N/A+ public nsIClientAuthDialogs,
20829N/A+ public nsICertPickDialogs,
20829N/A+ public nsITokenDialogs,
20829N/A+ public nsIDOMCryptoDialogs,
20829N/A+ public nsIGeneratingKeypairInfoDialogs
20829N/A+{
20829N/A+ public:
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+ NS_DECL_NSITOKENPASSWORDDIALOGS
20829N/A+ NS_DECL_NSICERTIFICATEDIALOGS
20829N/A+ NS_DECL_NSICLIENTAUTHDIALOGS
20829N/A+ NS_DECL_NSICERTPICKDIALOGS
20829N/A+ NS_DECL_NSITOKENDIALOGS
20829N/A+ NS_DECL_NSIDOMCRYPTODIALOGS
20829N/A+ NS_DECL_NSIGENERATINGKEYPAIRINFODIALOGS
20829N/A+ EmbedCertificates();
20829N/A+ virtual ~EmbedCertificates();
20829N/A+ nsresult Init(void);
20829N/A+ protected:
20829N/A+ nsCOMPtr<nsIStringBundle> mPIPStringBundle;
20829N/A+};
20829N/A+#endif /* __EmbedCertificates_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedContentListener.cpp b/embedding/browser/gtk/src/EmbedContentListener.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedContentListener.cpp
20829N/A@@ -0,0 +1,156 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsIURI.h"
20829N/A+
20829N/A+#include "EmbedContentListener.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+
20829N/A+#include "nsServiceManagerUtils.h"
20829N/A+#include "nsIWebNavigationInfo.h"
20829N/A+#include "nsDocShellCID.h"
20829N/A+
20829N/A+EmbedContentListener::EmbedContentListener(void)
20829N/A+{
20829N/A+ mOwner = nsnull;
20829N/A+}
20829N/A+
20829N/A+EmbedContentListener::~EmbedContentListener()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ISUPPORTS2(EmbedContentListener,
20829N/A+ nsIURIContentListener,
20829N/A+ nsISupportsWeakReference)
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContentListener::Init(EmbedPrivate *aOwner)
20829N/A+{
20829N/A+ mOwner = aOwner;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
20829N/A+ PRBool *aAbortOpen)
20829N/A+{
20829N/A+ nsresult rv;
20829N/A+
20829N/A+ nsCAutoString specString;
20829N/A+ rv = aURI->GetSpec(specString);
20829N/A+
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return rv;
20829N/A+
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[OPEN_URI], 0,
20829N/A+ specString.get(), &return_val);
20829N/A+
20829N/A+ *aAbortOpen = return_val;
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::DoContent(const char *aContentType,
20829N/A+ PRBool aIsContentPreferred,
20829N/A+ nsIRequest *aRequest,
20829N/A+ nsIStreamListener **aContentHandler,
20829N/A+ PRBool *aAbortProcess)
20829N/A+{
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::IsPreferred(const char *aContentType,
20829N/A+ char **aDesiredContentType,
20829N/A+ PRBool *aCanHandleContent)
20829N/A+{
20829N/A+ return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
20829N/A+ aCanHandleContent);
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::CanHandleContent(const char *aContentType,
20829N/A+ PRBool aIsContentPreferred,
20829N/A+ char **aDesiredContentType,
20829N/A+ PRBool *_retval)
20829N/A+{
20829N/A+ *_retval = PR_FALSE;
20829N/A+ *aDesiredContentType = nsnull;
20829N/A+
20829N/A+ if (aContentType) {
20829N/A+ nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
20829N/A+ do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
20829N/A+ if (webNavInfo) {
20829N/A+ PRUint32 canHandle;
20829N/A+ nsresult rv =
20829N/A+ webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
20829N/A+ mOwner ? mOwner->mNavigation.get() : nsnull,
20829N/A+ &canHandle);
20829N/A+ NS_ENSURE_SUCCESS(rv, rv);
20829N/A+ *_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
20829N/A+ }
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::GetLoadCookie(nsISupports **aLoadCookie)
20829N/A+{
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::SetLoadCookie(nsISupports *aLoadCookie)
20829N/A+{
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::GetParentContentListener(nsIURIContentListener **aParent)
20829N/A+{
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedContentListener::SetParentContentListener(nsIURIContentListener *aParent)
20829N/A+{
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+}
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedContentListener.h b/embedding/browser/gtk/src/EmbedContentListener.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedContentListener.h
20829N/A@@ -0,0 +1,66 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedContentListener_h
20829N/A+#define __EmbedContentListener_h
20829N/A+
20829N/A+#include "nsIURIContentListener.h"
20829N/A+#include "nsWeakReference.h"
20829N/A+
20829N/A+class EmbedPrivate;
20829N/A+
20829N/A+class EmbedContentListener : public nsIURIContentListener,
20829N/A+ public nsSupportsWeakReference
20829N/A+{
20829N/A+ public:
20829N/A+
20829N/A+ EmbedContentListener();
20829N/A+ virtual ~EmbedContentListener();
20829N/A+
20829N/A+ nsresult Init (EmbedPrivate *aOwner);
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+
20829N/A+ NS_DECL_NSIURICONTENTLISTENER
20829N/A+
20829N/A+ private:
20829N/A+
20829N/A+ EmbedPrivate *mOwner;
20829N/A+
20829N/A+};
20829N/A+
20829N/A+#endif /* __EmbedContentListener_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
20829N/A@@ -0,0 +1,618 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Oleg Romashin.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#include "EmbedContextMenuInfo.h"
20829N/A+#include "nsIImageLoadingContent.h"
20829N/A+#include "imgILoader.h"
20829N/A+#include "nsIDOMDocument.h"
20829N/A+#include "nsIDOMHTMLDocument.h"
20829N/A+#include "nsIDOMHTMLElement.h"
20829N/A+#include "nsIDOMHTMLHtmlElement.h"
20829N/A+#include "nsIDOMHTMLAnchorElement.h"
20829N/A+#include "nsIDOMHTMLImageElement.h"
20829N/A+#include "nsIDOMHTMLAreaElement.h"
20829N/A+#include "nsIDOMHTMLLinkElement.h"
20829N/A+#include "nsIDOMDocumentView.h"
20829N/A+#include "nsIDOMAbstractView.h"
20829N/A+#include "nsIDOMViewCSS.h"
20829N/A+#include "nsIDOMCSSStyleDeclaration.h"
20829N/A+#include "nsIDOMCSSValue.h"
20829N/A+#include "nsIDOMCSSPrimitiveValue.h"
20829N/A+#include "nsNetUtil.h"
20829N/A+#include "nsUnicharUtils.h"
20829N/A+#include "nsIDOMMouseEvent.h"
20829N/A+#include "nsIDOMNSEvent.h"
20829N/A+#include "nsIDOMWindow.h"
20829N/A+#include "nsIDOMWindowCollection.h"
20829N/A+#include "nsIWebBrowser.h"
20829N/A+#include "nsIContent.h"
20829N/A+#include "nsIPresShell.h"
20829N/A+#include "nsIFormControl.h"
20829N/A+#include "nsIDOMNSHTMLTextAreaElement.h"
20829N/A+#include "nsIDOMHTMLInputElement.h"
20829N/A+#include "nsIDOMHTMLTextAreaElement.h"
20829N/A+#include "nsIDOMNSHTMLDocument.h"
20829N/A+#include "nsIDOMNodeList.h"
20829N/A+#include "nsISelection.h"
20829N/A+#include "nsIDocument.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include <stdio.h>
20829N/A+#include <stdarg.h>
20829N/A+#include <stdlib.h>
20829N/A+#include <glib.h>
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+#include "nsIFrame.h"
20829N/A+#endif
20829N/A+
20829N/A+//*****************************************************************************
20829N/A+// class EmbedContextMenuInfo
20829N/A+//*****************************************************************************
20829N/A+EmbedContextMenuInfo::EmbedContextMenuInfo(EmbedPrivate *aOwner) : mCtxFrameNum(-1), mEmbedCtxType(0)
20829N/A+{
20829N/A+ mOwner = aOwner;
20829N/A+ mEventNode = nsnull;
20829N/A+ mCtxDocument = nsnull;
20829N/A+ mNSHHTMLElement = nsnull;
20829N/A+ mNSHHTMLElementSc = nsnull;
20829N/A+ mCtxEvent = nsnull;
20829N/A+ mEventNode = nsnull;
20829N/A+ mFormRect = nsIntRect(0,0,0,0);
20829N/A+}
20829N/A+
20829N/A+EmbedContextMenuInfo::~EmbedContextMenuInfo(void)
20829N/A+{
20829N/A+ mEventNode = nsnull;
20829N/A+ mCtxDocument = nsnull;
20829N/A+ mNSHHTMLElement = nsnull;
20829N/A+ mNSHHTMLElementSc = nsnull;
20829N/A+ mCtxEvent = nsnull;
20829N/A+ mEventNode = nsnull;
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ADDREF(EmbedContextMenuInfo)
20829N/A+NS_IMPL_RELEASE(EmbedContextMenuInfo)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedContextMenuInfo)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsISupports)
20829N/A+NS_INTERFACE_MAP_END
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::SetFrameIndex()
20829N/A+{
20829N/A+ nsCOMPtr<nsIDOMWindowCollection> frames;
20829N/A+ mCtxDomWindow->GetFrames(getter_AddRefs(frames));
20829N/A+ nsCOMPtr<nsIDOMWindow> currentWindow;
20829N/A+ PRUint32 frameCount = 0;
20829N/A+ frames->GetLength(&frameCount);
20829N/A+ for (unsigned int i= 0; i < frameCount; i++) {
20829N/A+ frames->Item(i, getter_AddRefs(currentWindow));
20829N/A+ nsCOMPtr<nsIDOMDocument> currentDoc;
20829N/A+ currentWindow->GetDocument(getter_AddRefs(currentDoc));
20829N/A+ if (currentDoc == mCtxDocument) {
20829N/A+ mCtxFrameNum = i;
20829N/A+ mCtxDomWindow = currentWindow;
20829N/A+ nsCOMPtr<nsIDOMNSDocument> doc = do_QueryInterface(currentDoc);
20829N/A+ if (doc)
20829N/A+ doc->GetTitle(mCtxDocTitle);
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ }
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::GetFormControlType(nsIDOMEvent* aEvent)
20829N/A+{
20829N/A+ if (!aEvent)
20829N/A+ return NS_OK;
20829N/A+ nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
20829N/A+ nsCOMPtr<nsIDOMEventTarget> target;
20829N/A+ nsevent->GetOriginalTarget(getter_AddRefs(target));
20829N/A+ // mOrigTarget = target;
20829N/A+ if (SetFormControlType(target)) {
20829N/A+ nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(target);
20829N/A+ if (!eventNode)
20829N/A+ return NS_OK;
20829N/A+ //Frame Stuff
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ nsresult rv = eventNode->GetOwnerDocument(getter_AddRefs(domDoc));
20829N/A+ if (!NS_SUCCEEDED(rv) || !domDoc) {
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ mEventNode = eventNode;
20829N/A+ mCtxDocument = domDoc;
20829N/A+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
20829N/A+ if (!doc)
20829N/A+ return NS_OK;
20829N/A+ nsIPresShell *presShell = doc->GetShell();
20829N/A+ if (!presShell)
20829N/A+ return NS_OK;
20829N/A+ nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
20829N/A+ nsIFrame* frame = nsnull;
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+ frame = tgContent->GetDocument() == presShell->GetDocument() ?
20829N/A+ tgContent->GetPrimaryFrame() : nsnull;
20829N/A+ if (frame)
20829N/A+ mFormRect = frame->GetScreenRectExternal();
20829N/A+#endif
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::SetFormControlType(nsIDOMEventTarget *originalTarget)
20829N/A+{
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsCOMPtr<nsIContent> targetContent = do_QueryInterface(originalTarget);
20829N/A+ mCtxFormType = 0;
20829N/A+ if (targetContent && targetContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL)) {
20829N/A+ nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(targetContent));
20829N/A+ if (formControl) {
20829N/A+ mCtxFormType = formControl->GetType();
20829N/A+ rv = NS_OK;
20829N/A+ //#ifdef MOZ_LOGGING
20829N/A+ switch (mCtxFormType) {
20829N/A+ case NS_FORM_BUTTON_BUTTON:
20829N/A+ break;
20829N/A+ case NS_FORM_BUTTON_RESET:
20829N/A+ break;
20829N/A+ case NS_FORM_BUTTON_SUBMIT:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_BUTTON:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_CHECKBOX:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_FILE:
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_HIDDEN:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_RESET:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_IMAGE:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_PASSWORD:
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IPASSWORD;
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_RADIO:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_SUBMIT:
20829N/A+ break;
20829N/A+ case NS_FORM_INPUT_EMAIL:
20829N/A+ case NS_FORM_INPUT_SEARCH:
20829N/A+ case NS_FORM_INPUT_TEXT:
20829N/A+ case NS_FORM_INPUT_TEL:
20829N/A+ case NS_FORM_INPUT_URL:
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ break;
20829N/A+ case NS_FORM_LABEL:
20829N/A+ break;
20829N/A+ case NS_FORM_SELECT:
20829N/A+ break;
20829N/A+ case NS_FORM_TEXTAREA:
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ break;
20829N/A+ case NS_FORM_OBJECT:
20829N/A+ break;
20829N/A+ case NS_FORM_OUTPUT:
20829N/A+ break;
20829N/A+ default:
20829N/A+ break;
20829N/A+ }
20829N/A+ if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
20829N/A+ PRBool rdonly = PR_FALSE;
20829N/A+ if (mCtxFormType == NS_FORM_TEXTAREA) {
20829N/A+ nsCOMPtr<nsIDOMHTMLTextAreaElement> input;
20829N/A+ input = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (!NS_FAILED(rv) && input)
20829N/A+ rv = input->GetReadOnly(&rdonly);
20829N/A+ if (!NS_FAILED(rv) && rdonly) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
20829N/A+ }
20829N/A+ } else {
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> input;
20829N/A+ input = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (!NS_FAILED(rv) && input)
20829N/A+ rv = input->GetReadOnly(&rdonly);
20829N/A+ if (!NS_FAILED(rv) && rdonly) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
20829N/A+ }
20829N/A+ }
20829N/A+ }
20829N/A+ //#endif
20829N/A+ }
20829N/A+ }
20829N/A+ return rv;
20829N/A+}
20829N/A+
20829N/A+const char*
20829N/A+EmbedContextMenuInfo::GetSelectedText()
20829N/A+{
20829N/A+ nsString cString;
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ if (mCtxFormType != 0 && mEventNode) {
20829N/A+ PRInt32 TextLength = 0, selStart = 0, selEnd = 0;
20829N/A+ if (mCtxFormType == NS_FORM_INPUT_TEXT || mCtxFormType == NS_FORM_INPUT_FILE) {
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> nsinput = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nsinput)
20829N/A+ nsinput->GetTextLength(&TextLength);
20829N/A+ if (TextLength > 0) {
20829N/A+ nsinput->GetSelectionEnd(&selEnd);
20829N/A+ nsinput->GetSelectionStart(&selStart);
20829N/A+ if (selStart < selEnd || mCtxFormType == NS_FORM_INPUT_FILE) {
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetValue(cString);
20829N/A+ }
20829N/A+ }
20829N/A+ } else if (mCtxFormType == NS_FORM_TEXTAREA) {
20829N/A+ nsCOMPtr<nsIDOMNSHTMLTextAreaElement> nsinput = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nsinput)
20829N/A+ nsinput->GetTextLength(&TextLength);
20829N/A+ if (TextLength > 0) {
20829N/A+ nsinput->GetSelectionStart(&selStart);
20829N/A+ nsinput->GetSelectionEnd(&selEnd);
20829N/A+ if (selStart < selEnd) {
20829N/A+ nsCOMPtr<nsIDOMHTMLTextAreaElement> input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetValue(cString);
20829N/A+ }
20829N/A+ }
20829N/A+ }
20829N/A+ if (NS_SUCCEEDED(rv) && !cString.IsEmpty()) {
20829N/A+ if (selStart < selEnd) {
20829N/A+ cString.Cut(0, selStart);
20829N/A+ cString.Cut(selEnd-selStart, TextLength);
20829N/A+ }
20829N/A+ rv = NS_OK;
20829N/A+ }
20829N/A+ } else if (mCtxDocument) {
20829N/A+ nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument, &rv);
20829N/A+ if (NS_FAILED(rv) || !htmlDoc)
20829N/A+ return nsnull;
20829N/A+ rv = htmlDoc->GetSelection(cString);
20829N/A+ if (NS_FAILED(rv) || cString.IsEmpty())
20829N/A+ return nsnull;
20829N/A+ rv = NS_OK;
20829N/A+ }
20829N/A+ if (rv == NS_OK) {
20829N/A+ return NS_ConvertUTF16toUTF8(cString).get();
20829N/A+ }
20829N/A+ return nsnull;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
20829N/A+ PRInt32 *aWidth, PRInt32 *aHeight)
20829N/A+{
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsCOMPtr<nsIDOMHTMLImageElement> image =
20829N/A+ do_QueryInterface(node, &rv);
20829N/A+ if (image) {
20829N/A+ rv = image->GetSrc(aHref);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ return rv;
20829N/A+ }
20829N/A+ rv = image->GetWidth(aWidth);
20829N/A+ rv = image->GetHeight(aHeight);
20829N/A+ rv = NS_OK;
20829N/A+ }
20829N/A+ return rv;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::GetImageRequest(imgIRequest **aRequest, nsIDOMNode *aDOMNode)
20829N/A+{
20829N/A+ NS_ENSURE_ARG(aDOMNode);
20829N/A+ NS_ENSURE_ARG_POINTER(aRequest);
20829N/A+
20829N/A+ // Get content
20829N/A+ nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(aDOMNode));
20829N/A+ NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
20829N/A+
20829N/A+ return content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
20829N/A+ aRequest);
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::CheckDomHtmlNode(nsIDOMNode *aNode)
20829N/A+{
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsString uTag;
20829N/A+ PRUint16 dnode_type;
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMNode> node;
20829N/A+ if (!aNode && mEventNode)
20829N/A+ node = mEventNode;
20829N/A+ nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(node, &rv);
20829N/A+ if (!element) {
20829N/A+ element = do_QueryInterface(mOrigNode, &rv);
20829N/A+ if (element) {
20829N/A+ node = mOrigNode;
20829N/A+ element = do_QueryInterface(node, &rv);
20829N/A+ }
20829N/A+ }
20829N/A+
20829N/A+ rv = node->GetNodeType(&dnode_type);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ return rv;
20829N/A+ }
20829N/A+
20829N/A+ if (!((nsIDOMNode::ELEMENT_NODE == dnode_type) && element)) {
20829N/A+ return rv;
20829N/A+ }
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> nodeElement = do_QueryInterface(node, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nodeElement) {
20829N/A+ mNSHHTMLElement = nodeElement;
20829N/A+ } else {
20829N/A+ mNSHHTMLElement = nsnull;
20829N/A+ }
20829N/A+ rv = element->GetLocalName(uTag);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ return rv;
20829N/A+ }
20829N/A+ if (uTag.LowerCaseEqualsLiteral("object")) {
20829N/A+ }
20829N/A+ else if (uTag.LowerCaseEqualsLiteral("html")) {
20829N/A+ }
20829N/A+ else if (uTag.LowerCaseEqualsLiteral("a")) {
20829N/A+ nsCOMPtr<nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(node);
20829N/A+ anchor->GetHref(mCtxHref);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
20829N/A+ if (anchor && !mCtxHref.IsEmpty()) {
20829N/A+ if (mCtxHref.LowerCaseEqualsLiteral("text/smartbookmark")) {
20829N/A+ nsCOMPtr<nsIDOMNode> childNode;
20829N/A+ node->GetFirstChild(getter_AddRefs(childNode));
20829N/A+ if (childNode) {
20829N/A+ PRInt32 width, height;
20829N/A+ rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
20829N/A+ if (NS_SUCCEEDED(rv))
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
20829N/A+ }
20829N/A+ } else if (StringBeginsWith(mCtxHref, NS_LITERAL_STRING("mailto:"))) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_EMAIL;
20829N/A+ }
20829N/A+ }
20829N/A+ }
20829N/A+ else if (uTag.LowerCaseEqualsLiteral("area")) {
20829N/A+ nsCOMPtr<nsIDOMHTMLAreaElement> area = do_QueryInterface(node, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && area) {
20829N/A+ PRBool aNoHref = PR_FALSE;
20829N/A+ rv = area->GetNoHref(&aNoHref);
20829N/A+ if (!aNoHref)
20829N/A+ rv = area->GetHref(mCtxHref);
20829N/A+ else
20829N/A+ rv = area->GetTarget(mCtxHref);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
20829N/A+ rv = NS_OK;
20829N/A+ }
20829N/A+ }
20829N/A+ else if (uTag.LowerCaseEqualsLiteral("img")) {
20829N/A+ PRInt32 width, height;
20829N/A+ rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
20829N/A+ if (NS_SUCCEEDED(rv))
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
20829N/A+ } else {
20829N/A+ rv = NS_ERROR_FAILURE;
20829N/A+ }
20829N/A+ return rv;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::UpdateContextData(void *aEvent)
20829N/A+{
20829N/A+ NS_ENSURE_ARG_POINTER(aEvent);
20829N/A+ nsresult rv;
20829N/A+ nsCOMPtr<nsIDOMEvent> event = do_QueryInterface((nsISupports*)aEvent, &rv);
20829N/A+ if (NS_FAILED(rv) || !event)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+ return UpdateContextData(event);
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::GetElementForScroll(nsIDOMEvent *aEvent)
20829N/A+{
20829N/A+ if (!aEvent) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
20829N/A+ nsCOMPtr<nsIDOMEventTarget> target;
20829N/A+ nsevent->GetOriginalTarget(getter_AddRefs(target));
20829N/A+ if (!target) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNode> targetDOMNode(do_QueryInterface(target));
20829N/A+ if (!targetDOMNode) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMDocument> targetDOMDocument;
20829N/A+ targetDOMNode->GetOwnerDocument(getter_AddRefs(targetDOMDocument));
20829N/A+ if (!targetDOMDocument) return NS_ERROR_UNEXPECTED;
20829N/A+ return GetElementForScroll(targetDOMDocument);
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::GetElementForScroll(nsIDOMDocument *targetDOMDocument)
20829N/A+{
20829N/A+ nsCOMPtr<nsIDOMElement> targetDOMElement;
20829N/A+ targetDOMDocument->GetDocumentElement(getter_AddRefs(targetDOMElement));
20829N/A+ if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
20829N/A+ nsString bodyName(NS_LITERAL_STRING("body"));
20829N/A+ nsCOMPtr<nsIDOMNodeList> bodyList;
20829N/A+ targetDOMElement->GetElementsByTagName(bodyName, getter_AddRefs(bodyList));
20829N/A+ PRUint32 i = 0;
20829N/A+ bodyList->GetLength(&i);
20829N/A+ if (i) {
20829N/A+ nsCOMPtr<nsIDOMNode> domBodyNode;
20829N/A+ bodyList->Item(0, getter_AddRefs(domBodyNode));
20829N/A+ if (!domBodyNode) return NS_ERROR_UNEXPECTED;
20829N/A+ mNSHHTMLElementSc = do_QueryInterface(domBodyNode);
20829N/A+ if (!mNSHHTMLElementSc) return NS_ERROR_UNEXPECTED;
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedContextMenuInfo::UpdateContextData(nsIDOMEvent *aDOMEvent)
20829N/A+{
20829N/A+ if (mCtxEvent == aDOMEvent)
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ nsresult rv = nsnull;
20829N/A+ mCtxEvent = aDOMEvent;
20829N/A+ NS_ENSURE_ARG_POINTER(mCtxEvent);
20829N/A+
20829N/A+ PRUint16 eventphase;
20829N/A+ mCtxEvent->GetEventPhase(&eventphase);
20829N/A+ if (!eventphase) {
20829N/A+ mCtxEvent = nsnull;
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+ }
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMEventTarget> originalTarget = nsnull;
20829N/A+ nsCOMPtr<nsIDOMNode> originalNode = nsnull;
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMNSEvent> aEvent = do_QueryInterface(mCtxEvent, &rv);
20829N/A+ if (NS_FAILED(rv) || !aEvent)
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(mCtxEvent, &rv));
20829N/A+ if (mouseEvent) {
20829N/A+ ((nsIDOMMouseEvent*)mouseEvent)->GetClientX(&mX);
20829N/A+ ((nsIDOMMouseEvent*)mouseEvent)->GetClientY(&mY);
20829N/A+ }
20829N/A+
20829N/A+ if (aEvent)
20829N/A+ rv = aEvent->GetOriginalTarget(getter_AddRefs(originalTarget));
20829N/A+ originalNode = do_QueryInterface(originalTarget);
20829N/A+ if (NS_FAILED(rv) || !originalNode)
20829N/A+ return NS_ERROR_NULL_POINTER;
20829N/A+
20829N/A+ // nsresult SelText = mOwner->ClipBoardAction(GTK_MOZ_EMBED_CAN_COPY);
20829N/A+ if (originalNode == mOrigNode)
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ mEmbedCtxType = GTK_MOZ_EMBED_CTX_NONE;
20829N/A+ mOrigNode = originalNode;
20829N/A+ if (mOrigNode) {
20829N/A+ nsString SOrigNode;
20829N/A+ mOrigNode->GetNodeName(SOrigNode);
20829N/A+ if (SOrigNode.EqualsLiteral("#document"))
20829N/A+ return NS_OK;
20829N/A+ if (SOrigNode.EqualsLiteral("xul:thumb")
20829N/A+ || SOrigNode.EqualsLiteral("xul:slider")
20829N/A+ || SOrigNode.EqualsLiteral("xul:scrollbarbutton")
20829N/A+ || SOrigNode.EqualsLiteral("xul:vbox")
20829N/A+ || SOrigNode.EqualsLiteral("xul:spacer")) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_XUL;
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ }
20829N/A+ if (mCtxEvent)
20829N/A+ rv = mCtxEvent->GetTarget(getter_AddRefs(mEventTarget));
20829N/A+ if (NS_FAILED(rv) || !mEventTarget) {
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(mEventTarget, &rv);
20829N/A+ mEventNode = eventNode;
20829N/A+ //Frame Stuff
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ if (mEventNode)
20829N/A+ rv = mEventNode->GetOwnerDocument(getter_AddRefs(domDoc));
20829N/A+ if (!NS_SUCCEEDED(rv) || !domDoc) {
20829N/A+ // return NS_OK;
20829N/A+ }
20829N/A+ if (NS_SUCCEEDED(rv) && domDoc && mCtxDocument != domDoc) {
20829N/A+ mCtxDocument = domDoc;
20829N/A+ mNSHHTMLElementSc = nsnull;
20829N/A+ mCtxDocument->GetDocumentURI(mCtxURI);
20829N/A+ NS_ENSURE_ARG_POINTER(mOwner);
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mOwner->mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(mCtxDomWindow));
20829N/A+ nsCOMPtr<nsIDOMDocument> mainDocument;
20829N/A+ mCtxDomWindow->GetDocument(getter_AddRefs(mainDocument));
20829N/A+ if (!mainDocument) {
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ mCtxFrameNum = -1;
20829N/A+ if (mainDocument != domDoc) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IFRAME;
20829N/A+ SetFrameIndex();
20829N/A+ }
20829N/A+ }
20829N/A+ nsCOMPtr<nsIDOMElement> targetDOMElement;
20829N/A+ mCtxDocument->GetDocumentElement(getter_AddRefs(targetDOMElement));
20829N/A+ if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument);
20829N/A+ if (htmlDoc) {
20829N/A+ nsString DMode;
20829N/A+ htmlDoc->GetDesignMode(DMode);
20829N/A+ if (DMode.EqualsLiteral("on")) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_RICHEDIT;
20829N/A+ }
20829N/A+ }
20829N/A+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
20829N/A+ if (!doc)
20829N/A+ return NS_OK;
20829N/A+ nsIPresShell *presShell = doc->GetShell();
20829N/A+ if (!presShell)
20829N/A+ return NS_OK;
20829N/A+ nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
20829N/A+ nsIFrame* frame = nsnull;
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+ if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_RICHEDIT)
20829N/A+ frame = presShell->GetRootFrame();
20829N/A+ else if (tgContent->GetDocument() == presShell->GetDocument()) {
20829N/A+ frame = tgContent->GetPrimaryFrame();
20829N/A+ }
20829N/A+ if (frame) {
20829N/A+ mFormRect = frame->GetScreenRectExternal();
20829N/A+ }
20829N/A+#endif
20829N/A+ if (NS_SUCCEEDED(SetFormControlType(mEventTarget))) {
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+ CheckDomHtmlNode();
20829N/A+ nsCOMPtr<nsIDOMNode> node = mEventNode;
20829N/A+ nsCOMPtr<nsIDOMNode> parentNode;
20829N/A+ node->GetParentNode(getter_AddRefs(parentNode));
20829N/A+ node = parentNode;
20829N/A+ while (node) {
20829N/A+ if (NS_FAILED(CheckDomHtmlNode()))
20829N/A+ break;
20829N/A+ node->GetParentNode(getter_AddRefs(parentNode));
20829N/A+ node = parentNode;
20829N/A+ }
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_DOCUMENT;
20829N/A+ return NS_OK;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedContextMenuInfo.h b/embedding/browser/gtk/src/EmbedContextMenuInfo.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.h
20829N/A@@ -0,0 +1,101 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+/*
20829N/A+ * ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is the Mozilla browser.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Oleg Romashin.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#ifndef EmbedContextMenuInfo_h__
20829N/A+#define EmbedContextMenuInfo_h__
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsIDOMNode.h"
20829N/A+#include "nsIDOMEvent.h"
20829N/A+#include "imgIContainer.h"
20829N/A+#include "imgIRequest.h"
20829N/A+#include "nsIDOMEventTarget.h"
20829N/A+#include "nsRect.h"
20829N/A+// for strings
20829N/A+#ifdef MOZILLA_INTERNAL_API
20829N/A+#include "nsXPIDLString.h"
20829N/A+#include "nsReadableUtils.h"
20829N/A+#endif
20829N/A+#include "EmbedWindow.h"
20829N/A+#include "nsIDOMNSHTMLElement.h"
20829N/A+//*****************************************************************************
20829N/A+// class EmbedContextMenuInfo
20829N/A+//
20829N/A+//*****************************************************************************
20829N/A+class EmbedContextMenuInfo : public nsISupports
20829N/A+{
20829N/A+public:
20829N/A+ EmbedContextMenuInfo(EmbedPrivate *aOwner);
20829N/A+ virtual ~EmbedContextMenuInfo(void);
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+ nsresult GetFormControlType(nsIDOMEvent *aDOMEvent);
20829N/A+ nsresult UpdateContextData(nsIDOMEvent *aDOMEvent);
20829N/A+ nsresult UpdateContextData(void *aEvent);
20829N/A+ const char* GetSelectedText();
20829N/A+ nsresult GetElementForScroll(nsIDOMDocument *targetDOMDocument);
20829N/A+ nsresult GetElementForScroll(nsIDOMEvent *aEvent);
20829N/A+ nsresult CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
20829N/A+ PRInt32 *aWidth, PRInt32 *aHeight);
20829N/A+ nsresult GetImageRequest(imgIRequest **aRequest, nsIDOMNode *aDOMNode);
20829N/A+ nsString GetCtxDocTitle(void) { return mCtxDocTitle; }
20829N/A+
20829N/A+
20829N/A+ PRInt32 mX, mY, mObjWidth, mObjHeight, mCtxFrameNum;
20829N/A+ nsString mCtxURI, mCtxHref, mCtxImgHref;
20829N/A+ PRUint32 mEmbedCtxType;
20829N/A+ PRInt32 mCtxFormType;
20829N/A+ nsCOMPtr<nsIDOMNode> mEventNode;
20829N/A+ nsCOMPtr<nsIDOMEventTarget> mEventTarget;
20829N/A+ nsCOMPtr<nsIDOMDocument>mCtxDocument;
20829N/A+ nsIntRect mFormRect;
20829N/A+ nsCOMPtr<nsIDOMWindow> mCtxDomWindow;
20829N/A+ nsCOMPtr<nsIDOMEvent> mCtxEvent;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElement;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElementSc;
20829N/A+private:
20829N/A+ nsresult SetFrameIndex();
20829N/A+ nsresult SetFormControlType(nsIDOMEventTarget *originalTarget);
20829N/A+ nsresult CheckDomHtmlNode(nsIDOMNode *aNode = nsnull);
20829N/A+
20829N/A+ EmbedPrivate *mOwner;
20829N/A+ nsCOMPtr<nsIDOMNode> mOrigNode;
20829N/A+ nsString mCtxDocTitle;
20829N/A+}; // class EmbedContextMenuInfo
20829N/A+#endif // EmbedContextMenuInfo_h__
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedEventListener.cpp b/embedding/browser/gtk/src/EmbedEventListener.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedEventListener.cpp
20829N/A@@ -0,0 +1,304 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsIDOMMouseEvent.h"
20829N/A+
20829N/A+#include "nsIDOMKeyEvent.h"
20829N/A+#include "nsIDOMUIEvent.h"
20829N/A+
20829N/A+#include "EmbedEventListener.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+
20829N/A+EmbedEventListener::EmbedEventListener(void)
20829N/A+{
20829N/A+ mOwner = nsnull;
20829N/A+}
20829N/A+
20829N/A+EmbedEventListener::~EmbedEventListener()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ADDREF(EmbedEventListener)
20829N/A+NS_IMPL_RELEASE(EmbedEventListener)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedEventListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMUIListener)
20829N/A+NS_INTERFACE_MAP_END
20829N/A+
20829N/A+nsresult
20829N/A+EmbedEventListener::Init(EmbedPrivate *aOwner)
20829N/A+{
20829N/A+ mOwner = aOwner;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!keyEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return FALSE to this function to mark the event as not
20829N/A+ // consumed...
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_DOWN], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!keyEvent)
20829N/A+ return NS_OK;
20829N/A+ // return FALSE to this function to mark this event as not
20829N/A+ // consumed...
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_UP], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!keyEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_PRESS], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseDown(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_DOWN], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseUp(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_UP], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseClick(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_CLICK], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseDblClick(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_DBL_CLICK], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseOver(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_OVER], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::MouseOut(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!mouseEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_OUT], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::Activate(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!uiEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_ACTIVATE], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::FocusIn(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!uiEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_FOCUS_IN], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedEventListener::FocusOut(nsIDOMEvent* aDOMEvent)
20829N/A+{
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ if (!uiEvent)
20829N/A+ return NS_OK;
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ gint return_val = FALSE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_FOCUS_OUT], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+ if (return_val) {
20829N/A+ aDOMEvent->StopPropagation();
20829N/A+ aDOMEvent->PreventDefault();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedEventListener.h b/embedding/browser/gtk/src/EmbedEventListener.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedEventListener.h
20829N/A@@ -0,0 +1,90 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedEventListener_h
20829N/A+#define __EmbedEventListener_h
20829N/A+
20829N/A+#include "nsIDOMKeyListener.h"
20829N/A+#include "nsIDOMMouseListener.h"
20829N/A+#include "nsIDOMUIListener.h"
20829N/A+
20829N/A+class EmbedPrivate;
20829N/A+
20829N/A+class EmbedEventListener : public nsIDOMKeyListener,
20829N/A+ public nsIDOMMouseListener,
20829N/A+ public nsIDOMUIListener
20829N/A+{
20829N/A+ public:
20829N/A+
20829N/A+ EmbedEventListener();
20829N/A+ virtual ~EmbedEventListener();
20829N/A+
20829N/A+ nsresult Init(EmbedPrivate *aOwner);
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+
20829N/A+ // nsIDOMEventListener
20829N/A+
20829N/A+ NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
20829N/A+
20829N/A+ // nsIDOMKeyListener
20829N/A+
20829N/A+ NS_IMETHOD KeyDown(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD KeyUp(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD KeyPress(nsIDOMEvent* aDOMEvent);
20829N/A+
20829N/A+ // nsIDOMMouseListener
20829N/A+
20829N/A+ NS_IMETHOD MouseDown(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseUp(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseClick(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseDblClick(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseOver(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseOut(nsIDOMEvent* aDOMEvent);
20829N/A+
20829N/A+ // nsIDOMUIListener
20829N/A+
20829N/A+ NS_IMETHOD Activate(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD FocusIn(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD FocusOut(nsIDOMEvent* aDOMEvent);
20829N/A+
20829N/A+ private:
20829N/A+
20829N/A+ EmbedPrivate *mOwner;
20829N/A+};
20829N/A+
20829N/A+#endif /* __EmbedEventListener_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedGtkTools.cpp b/embedding/browser/gtk/src/EmbedGtkTools.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedGtkTools.cpp
20829N/A@@ -0,0 +1,88 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=4 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Oleg Romashin.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "EmbedGtkTools.h"
20829N/A+#ifndef MOZILLA_INTERNAL_API
20829N/A+#include "nsServiceManagerUtils.h"
20829N/A+#endif
20829N/A+#include "EmbedPrivate.h"
20829N/A+
20829N/A+GtkWidget * GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+{
20829N/A+ nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
20829N/A+ if (!aDOMWindow)
20829N/A+ return NULL;
20829N/A+ nsCOMPtr<nsIWebBrowserChrome> chrome;
20829N/A+ wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
20829N/A+ if (!chrome) {
20829N/A+ return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
20829N/A+ }
20829N/A+
20829N/A+ nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = nsnull;
20829N/A+ siteWindow = do_QueryInterface(chrome);
20829N/A+
20829N/A+ if (!siteWindow) {
20829N/A+ return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
20829N/A+ }
20829N/A+
20829N/A+ GtkWidget* parentWidget;
20829N/A+ siteWindow->GetSiteWindow((void**)&parentWidget);
20829N/A+ if (GTK_IS_WIDGET(parentWidget))
20829N/A+ return parentWidget;
20829N/A+ return NULL;
20829N/A+}
20829N/A+
20829N/A+GtkWindow * GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+{
20829N/A+ GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aDOMWindow);
20829N/A+ if (!parentWidget)
20829N/A+ return NULL;
20829N/A+ GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
20829N/A+ if (GTK_WIDGET_TOPLEVEL(gtkWin))
20829N/A+ return GTK_WINDOW(gtkWin);
20829N/A+ return NULL;
20829N/A+}
20829N/A+
20829N/A+nsresult GetContentViewer(nsIWebBrowser *webBrowser, nsIContentViewer **aViewer)
20829N/A+{
20829N/A+ g_return_val_if_fail(webBrowser, NS_ERROR_FAILURE);
20829N/A+ nsCOMPtr<nsIDocShell> docShell(do_GetInterface((nsISupports*)webBrowser));
20829N/A+ NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
20829N/A+ return docShell->GetContentViewer(aViewer);
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedGtkTools.h b/embedding/browser/gtk/src/EmbedGtkTools.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedGtkTools.h
20829N/A@@ -0,0 +1,67 @@
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Oleg Romashin.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#ifndef __EmbedTools_h
20829N/A+#define __EmbedTools_h
20829N/A+
20829N/A+#include "nsCOMPtr.h"
20829N/A+#ifdef MOZILLA_INTERNAL_API
20829N/A+#include "nsString.h"
20829N/A+#else
20829N/A+#include "nsStringAPI.h"
20829N/A+#endif
20829N/A+#include "nsIDOMWindow.h"
20829N/A+#include "nsIWindowWatcher.h"
20829N/A+#include "nsIWebBrowserChrome.h"
20829N/A+#include "nsIEmbeddingSiteWindow.h"
20829N/A+#include "nsIServiceManager.h"
20829N/A+#include "nsIContentViewer.h"
20829N/A+#include "nsIDocShell.h"
20829N/A+#include "nsIInterfaceRequestorUtils.h"
20829N/A+#include <gtk/gtk.h>
20829N/A+
20829N/A+GtkWidget*
20829N/A+GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+
20829N/A+GtkWindow*
20829N/A+GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+
20829N/A+nsresult
20829N/A+GetContentViewer(nsIWebBrowser *webBrowser, nsIContentViewer **aViewer);
20829N/A+
20829N/A+#endif /* __EmbedTools_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedPrivate.cpp b/embedding/browser/gtk/src/EmbedPrivate.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedPrivate.cpp
20829N/A@@ -0,0 +1,983 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsIDocShell.h"
20829N/A+#include "nsIWebProgress.h"
20829N/A+#include "nsIWidget.h"
20829N/A+#include "nsCRT.h"
20829N/A+#include "nsNetUtil.h"
20829N/A+#include "nsIWebBrowserStream.h"
20829N/A+#include "nsIWebBrowserFocus.h"
20829N/A+#include "nsIDirectoryService.h"
20829N/A+#include "nsAppDirectoryServiceDefs.h"
20829N/A+
20829N/A+// for do_GetInterface
20829N/A+#include "nsIInterfaceRequestor.h"
20829N/A+// for do_CreateInstance
20829N/A+#include "nsIComponentManager.h"
20829N/A+#include "nsComponentManagerUtils.h"
20829N/A+
20829N/A+// for initializing our window watcher service
20829N/A+#include "nsIWindowWatcher.h"
20829N/A+
20829N/A+#include "nsILocalFile.h"
20829N/A+
20829N/A+#include "nsXULAppAPI.h"
20829N/A+
20829N/A+// all of the crap that we need for event listeners
20829N/A+// and when chrome windows finish loading
20829N/A+#include "nsIDOMWindow.h"
20829N/A+#include "nsPIDOMWindow.h"
20829N/A+#include "nsIDOMWindowInternal.h"
20829N/A+
20829N/A+// For seting scrollbar visibilty
20829N/A+#include "nsIDOMBarProp.h"
20829N/A+
20829N/A+// all of our local includes
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include "EmbedWindow.h"
20829N/A+#include "EmbedProgress.h"
20829N/A+#include "EmbedContentListener.h"
20829N/A+#include "EmbedEventListener.h"
20829N/A+#include "EmbedWindowCreator.h"
20829N/A+#include "GtkPromptService.h"
20829N/A+
20829N/A+#include "mozilla/ModuleUtils.h"
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+#include "nsIAccessibilityService.h"
20829N/A+#include "nsIAccessible.h"
20829N/A+#include "nsIDOMDocument.h"
20829N/A+#endif
20829N/A+
20829N/A+PRUint32 EmbedPrivate::sWidgetCount = 0;
20829N/A+
20829N/A+char *EmbedPrivate::sPath = nsnull;
20829N/A+char *EmbedPrivate::sCompPath = nsnull;
20829N/A+nsTArray<EmbedPrivate*> *EmbedPrivate::sWindowList = nsnull;
20829N/A+nsILocalFile *EmbedPrivate::sProfileDir = nsnull;
20829N/A+nsISupports *EmbedPrivate::sProfileLock = nsnull;
20829N/A+GtkWidget *EmbedPrivate::sOffscreenWindow = 0;
20829N/A+GtkWidget *EmbedPrivate::sOffscreenFixed = 0;
20829N/A+
20829N/A+nsIDirectoryServiceProvider *EmbedPrivate::sAppFileLocProvider = nsnull;
20829N/A+
20829N/A+class GTKEmbedDirectoryProvider : public nsIDirectoryServiceProvider2
20829N/A+{
20829N/A+public:
20829N/A+ NS_DECL_ISUPPORTS_INHERITED
20829N/A+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
20829N/A+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
20829N/A+};
20829N/A+
20829N/A+static const GTKEmbedDirectoryProvider kDirectoryProvider;
20829N/A+
20829N/A+NS_IMPL_QUERY_INTERFACE2(GTKEmbedDirectoryProvider,
20829N/A+ nsIDirectoryServiceProvider,
20829N/A+ nsIDirectoryServiceProvider2)
20829N/A+
20829N/A+NS_IMETHODIMP_(nsrefcnt)
20829N/A+GTKEmbedDirectoryProvider::AddRef()
20829N/A+{
20829N/A+ return 1;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP_(nsrefcnt)
20829N/A+GTKEmbedDirectoryProvider::Release()
20829N/A+{
20829N/A+ return 1;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GTKEmbedDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
20829N/A+ nsIFile* *aResult)
20829N/A+{
20829N/A+ if (EmbedPrivate::sAppFileLocProvider) {
20829N/A+ nsresult rv = EmbedPrivate::sAppFileLocProvider->GetFile(aKey, aPersist,
20829N/A+ aResult);
20829N/A+ if (NS_SUCCEEDED(rv))
20829N/A+ return rv;
20829N/A+ }
20829N/A+
20829N/A+ if (EmbedPrivate::sProfileDir && (!strcmp(aKey, NS_APP_USER_PROFILE_50_DIR)
20829N/A+ || !strcmp(aKey, NS_APP_PROFILE_DIR_STARTUP))) {
20829N/A+ *aPersist = PR_TRUE;
20829N/A+ return EmbedPrivate::sProfileDir->Clone(aResult);
20829N/A+ }
20829N/A+
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GTKEmbedDirectoryProvider::GetFiles(const char *aKey,
20829N/A+ nsISimpleEnumerator* *aResult)
20829N/A+{
20829N/A+ nsCOMPtr<nsIDirectoryServiceProvider2>
20829N/A+ dp2(do_QueryInterface(EmbedPrivate::sAppFileLocProvider));
20829N/A+
20829N/A+ if (!dp2)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ return dp2->GetFiles(aKey, aResult);
20829N/A+}
20829N/A+
20829N/A+#define NS_PROMPTSERVICE_CID \
20829N/A+ {0x95611356, 0xf583, 0x46f5, {0x81, 0xff, 0x4b, 0x3e, 0x01, 0x62, 0xc6, 0x19}}
20829N/A+
20829N/A+NS_GENERIC_FACTORY_CONSTRUCTOR(GtkPromptService)
20829N/A+NS_DEFINE_NAMED_CID(NS_PROMPTSERVICE_CID);
20829N/A+
20829N/A+static const mozilla::Module::CIDEntry kDefaultPromptCIDs[] = {
20829N/A+ { &kNS_PROMPTSERVICE_CID, false, NULL, GtkPromptServiceConstructor },
20829N/A+ { NULL }
20829N/A+};
20829N/A+
20829N/A+static const mozilla::Module::ContractIDEntry kDefaultPromptContracts[] = {
20829N/A+ { "@mozilla.org/embedcomp/prompt-service;1", &kNS_PROMPTSERVICE_CID },
20829N/A+ { NULL }
20829N/A+};
20829N/A+
20829N/A+static const mozilla::Module kDefaultPromptModule = {
20829N/A+ mozilla::Module::kVersion,
20829N/A+ kDefaultPromptCIDs,
20829N/A+ kDefaultPromptContracts
20829N/A+};
20829N/A+
20829N/A+EmbedPrivate::EmbedPrivate(void)
20829N/A+{
20829N/A+ mOwningWidget = nsnull;
20829N/A+ mWindow = nsnull;
20829N/A+ mProgress = nsnull;
20829N/A+ mContentListener = nsnull;
20829N/A+ mEventListener = nsnull;
20829N/A+ mChromeMask = nsIWebBrowserChrome::CHROME_ALL;
20829N/A+ mIsChrome = PR_FALSE;
20829N/A+ mChromeLoaded = PR_FALSE;
20829N/A+ mListenersAttached = PR_FALSE;
20829N/A+ mMozWindowWidget = 0;
20829N/A+ mIsDestroyed = PR_FALSE;
20829N/A+
20829N/A+ PushStartup();
20829N/A+ if (!sWindowList) {
20829N/A+ sWindowList = new nsTArray<EmbedPrivate*>();
20829N/A+ }
20829N/A+ sWindowList->AppendElement(this);
20829N/A+}
20829N/A+
20829N/A+EmbedPrivate::~EmbedPrivate()
20829N/A+{
20829N/A+ sWindowList->RemoveElement(this);
20829N/A+ PopStartup();
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::Init(GtkMozEmbed *aOwningWidget)
20829N/A+{
20829N/A+ // are we being re-initialized?
20829N/A+ if (mOwningWidget)
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ // hang on with a reference to the owning widget
20829N/A+ mOwningWidget = aOwningWidget;
20829N/A+
20829N/A+ // Create our embed window, and create an owning reference to it and
20829N/A+ // initialize it. It is assumed that this window will be destroyed
20829N/A+ // when we go out of scope.
20829N/A+ mWindow = new EmbedWindow();
20829N/A+ mWindowGuard = static_cast<nsIWebBrowserChrome *>(mWindow);
20829N/A+ mWindow->Init(this);
20829N/A+
20829N/A+ // Create our progress listener object, make an owning reference,
20829N/A+ // and initialize it. It is assumed that this progress listener
20829N/A+ // will be destroyed when we go out of scope.
20829N/A+ mProgress = new EmbedProgress();
20829N/A+ mProgressGuard = static_cast<nsIWebProgressListener *>
20829N/A+ (mProgress);
20829N/A+ mProgress->Init(this);
20829N/A+
20829N/A+ // Create our content listener object, initialize it and attach it.
20829N/A+ // It is assumed that this will be destroyed when we go out of
20829N/A+ // scope.
20829N/A+ mContentListener = new EmbedContentListener();
20829N/A+ mContentListenerGuard = static_cast<nsISupports*>(static_cast<nsIURIContentListener*>(mContentListener));
20829N/A+ mContentListener->Init(this);
20829N/A+
20829N/A+ // Create our key listener object and initialize it. It is assumed
20829N/A+ // that this will be destroyed before we go out of scope.
20829N/A+ mEventListener = new EmbedEventListener();
20829N/A+ mEventListenerGuard =
20829N/A+ static_cast<nsISupports *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+ mEventListener->Init(this);
20829N/A+
20829N/A+ // has the window creator service been set up?
20829N/A+ static int initialized = PR_FALSE;
20829N/A+ // Set up our window creator ( only once )
20829N/A+ if (!initialized) {
20829N/A+ // We set this flag here instead of on success. If it failed we
20829N/A+ // don't want to keep trying and leaking window creator objects.
20829N/A+ initialized = PR_TRUE;
20829N/A+
20829N/A+ // create our local object
20829N/A+ EmbedWindowCreator *creator = new EmbedWindowCreator();
20829N/A+ nsCOMPtr<nsIWindowCreator> windowCreator;
20829N/A+ windowCreator = static_cast<nsIWindowCreator *>(creator);
20829N/A+
20829N/A+ // Attach it via the watcher service
20829N/A+ nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
20829N/A+ if (watcher)
20829N/A+ watcher->SetWindowCreator(windowCreator);
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::Realize(PRBool *aAlreadyRealized)
20829N/A+{
20829N/A+
20829N/A+ *aAlreadyRealized = PR_FALSE;
20829N/A+
20829N/A+ // create the offscreen window if we have to
20829N/A+ EnsureOffscreenWindow();
20829N/A+
20829N/A+ // Have we ever been initialized before? If so then just reparent
20829N/A+ // from the offscreen window.
20829N/A+ if (mMozWindowWidget) {
20829N/A+ gtk_widget_reparent(mMozWindowWidget, GTK_WIDGET(mOwningWidget));
20829N/A+ *aAlreadyRealized = PR_TRUE;
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // get a handle on the navigation object
20829N/A+ mNavigation = do_QueryInterface(webBrowser);
20829N/A+
20829N/A+ // Create our session history object and tell the navigation object
20829N/A+ // to use it. We need to do this before we create the web browser
20829N/A+ // window.
20829N/A+ mSessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
20829N/A+ mNavigation->SetSessionHistory(mSessionHistory);
20829N/A+
20829N/A+ // create the window
20829N/A+ mWindow->CreateWindow();
20829N/A+
20829N/A+ // bind the progress listener to the browser object
20829N/A+ nsCOMPtr<nsISupportsWeakReference> supportsWeak;
20829N/A+ supportsWeak = do_QueryInterface(mProgressGuard);
20829N/A+ nsCOMPtr<nsIWeakReference> weakRef;
20829N/A+ supportsWeak->GetWeakReference(getter_AddRefs(weakRef));
20829N/A+ webBrowser->AddWebBrowserListener(weakRef,
20829N/A+ NS_GET_IID(nsIWebProgressListener));
20829N/A+
20829N/A+ // set ourselves as the parent uri content listener
20829N/A+ nsCOMPtr<nsIURIContentListener> uriListener;
20829N/A+ uriListener = do_QueryInterface(mContentListenerGuard);
20829N/A+ webBrowser->SetParentURIContentListener(uriListener);
20829N/A+
20829N/A+ // save the window id of the newly created window
20829N/A+ nsCOMPtr<nsIWidget> mozWidget;
20829N/A+ mWindow->mBaseWindow->GetMainWidget(getter_AddRefs(mozWidget));
20829N/A+ // get the native drawing area
20829N/A+ GdkWindow *tmp_window =
20829N/A+ static_cast<GdkWindow *>(
20829N/A+ mozWidget->GetNativeData(NS_NATIVE_WINDOW));
20829N/A+ // and, thanks to superwin we actually need the parent of that.
20829N/A+ tmp_window = gdk_window_get_parent(tmp_window);
20829N/A+ // save the widget ID - it should be the mozarea of the window.
20829N/A+ gpointer data = nsnull;
20829N/A+ gdk_window_get_user_data(tmp_window, &data);
20829N/A+ mMozWindowWidget = static_cast<GtkWidget *>(data);
20829N/A+
20829N/A+ // Apply the current chrome mask
20829N/A+ ApplyChromeMask();
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Unrealize(void)
20829N/A+{
20829N/A+ // reparent to our offscreen window
20829N/A+ gtk_widget_reparent(mMozWindowWidget, sOffscreenFixed);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Show(void)
20829N/A+{
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // and set the visibility on the thing
20829N/A+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webBrowser);
20829N/A+ baseWindow->SetVisibility(PR_TRUE);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Hide(void)
20829N/A+{
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // and set the visibility on the thing
20829N/A+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webBrowser);
20829N/A+ baseWindow->SetVisibility(PR_FALSE);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Resize(PRUint32 aWidth, PRUint32 aHeight)
20829N/A+{
20829N/A+ mWindow->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER,
20829N/A+ 0, 0, aWidth, aHeight);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Destroy(void)
20829N/A+{
20829N/A+ // This flag might have been set from
20829N/A+ // EmbedWindow::DestroyBrowserWindow() as well if someone used a
20829N/A+ // window.close() or something or some other script action to close
20829N/A+ // the window. No harm setting it again.
20829N/A+ mIsDestroyed = PR_TRUE;
20829N/A+
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // Release our progress listener
20829N/A+ nsCOMPtr<nsISupportsWeakReference> supportsWeak;
20829N/A+ supportsWeak = do_QueryInterface(mProgressGuard);
20829N/A+ nsCOMPtr<nsIWeakReference> weakRef;
20829N/A+ supportsWeak->GetWeakReference(getter_AddRefs(weakRef));
20829N/A+ webBrowser->RemoveWebBrowserListener(weakRef,
20829N/A+ NS_GET_IID(nsIWebProgressListener));
20829N/A+ weakRef = nsnull;
20829N/A+ supportsWeak = nsnull;
20829N/A+
20829N/A+ // Release our content listener
20829N/A+ webBrowser->SetParentURIContentListener(nsnull);
20829N/A+ mContentListenerGuard = nsnull;
20829N/A+ mContentListener = nsnull;
20829N/A+
20829N/A+ // Now that we have removed the listener, release our progress
20829N/A+ // object
20829N/A+ mProgressGuard = nsnull;
20829N/A+ mProgress = nsnull;
20829N/A+
20829N/A+ // detach our event listeners and release the event receiver
20829N/A+ DetachListeners();
20829N/A+ if (mEventTarget)
20829N/A+ mEventTarget = nsnull;
20829N/A+
20829N/A+ // destroy our child window
20829N/A+ mWindow->ReleaseChildren();
20829N/A+
20829N/A+ // release navigation
20829N/A+ mNavigation = nsnull;
20829N/A+
20829N/A+ // release session history
20829N/A+ mSessionHistory = nsnull;
20829N/A+
20829N/A+ mOwningWidget = nsnull;
20829N/A+
20829N/A+ mMozWindowWidget = 0;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::SetURI(const char *aURI)
20829N/A+{
20829N/A+ mURI.Assign(aURI);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::LoadCurrentURI(void)
20829N/A+{
20829N/A+ if (mURI.Length()) {
20829N/A+ nsCOMPtr<nsPIDOMWindow> piWin;
20829N/A+ GetPIDOMWindow(getter_AddRefs(piWin));
20829N/A+
20829N/A+ nsAutoPopupStatePusher popupStatePusher(piWin, openAllowed);
20829N/A+
20829N/A+ mNavigation->LoadURI(NS_ConvertUTF8toUTF16(mURI).get(), // URI string
20829N/A+ nsIWebNavigation::LOAD_FLAGS_NONE | // Load flags
20829N/A+ nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP, // Allow keyword.URL.. functionality
20829N/A+ nsnull, // Referring URI
20829N/A+ nsnull, // Post data
20829N/A+ nsnull); // extra headers
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::Reload(PRUint32 reloadFlags)
20829N/A+{
20829N/A+ /* Use the session history if it is available, this
20829N/A+ * allows framesets to reload correctly */
20829N/A+ nsCOMPtr<nsIWebNavigation> wn;
20829N/A+
20829N/A+ if (mSessionHistory) {
20829N/A+ wn = do_QueryInterface(mSessionHistory);
20829N/A+ }
20829N/A+ if (!wn)
20829N/A+ wn = mNavigation;
20829N/A+
20829N/A+ if (wn)
20829N/A+ wn->Reload(reloadFlags);
20829N/A+}
20829N/A+
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::ApplyChromeMask()
20829N/A+{
20829N/A+ if (mWindow) {
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ if (domWindow) {
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMBarProp> scrollbars;
20829N/A+ domWindow->GetScrollbars(getter_AddRefs(scrollbars));
20829N/A+ if (scrollbars) {
20829N/A+
20829N/A+ scrollbars->SetVisible
20829N/A+ (mChromeMask & nsIWebBrowserChrome::CHROME_SCROLLBARS ?
20829N/A+ PR_TRUE : PR_FALSE);
20829N/A+ }
20829N/A+ }
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::SetChromeMask(PRUint32 aChromeMask)
20829N/A+{
20829N/A+ mChromeMask = aChromeMask;
20829N/A+
20829N/A+ ApplyChromeMask();
20829N/A+}
20829N/A+
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::PushStartup(void)
20829N/A+{
20829N/A+ // increment the number of widgets
20829N/A+ sWidgetCount++;
20829N/A+
20829N/A+ // if this is the first widget, fire up xpcom
20829N/A+ if (sWidgetCount == 1) {
20829N/A+ nsresult rv;
20829N/A+
20829N/A+ nsCOMPtr<nsILocalFile> binDir;
20829N/A+ if (sCompPath) {
20829N/A+ rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ const char *grePath = sPath;
20829N/A+
20829N/A+ if (!grePath)
20829N/A+ grePath = getenv("MOZILLA_FIVE_HOME");
20829N/A+
20829N/A+ if (!grePath)
20829N/A+ return;
20829N/A+
20829N/A+ nsCOMPtr<nsILocalFile> greDir;
20829N/A+ rv = NS_NewNativeLocalFile(nsDependentCString(grePath), PR_TRUE,
20829N/A+ getter_AddRefs(greDir));
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return;
20829N/A+
20829N/A+ if (sProfileDir && !sProfileLock) {
20829N/A+ rv = XRE_LockProfileDirectory(sProfileDir,
20829N/A+ &sProfileLock);
20829N/A+ if (NS_FAILED(rv)) return;
20829N/A+ }
20829N/A+
20829N/A+ rv = XRE_InitEmbedding2(greDir, binDir,
20829N/A+ const_cast<GTKEmbedDirectoryProvider*>(&kDirectoryProvider));
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return;
20829N/A+
20829N/A+ if (sProfileDir)
20829N/A+ XRE_NotifyProfile();
20829N/A+
20829N/A+ RegisterAppComponents();
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::PopStartup(void)
20829N/A+{
20829N/A+ sWidgetCount--;
20829N/A+ if (sWidgetCount == 0) {
20829N/A+
20829N/A+ // destroy the offscreen window
20829N/A+ DestroyOffscreenWindow();
20829N/A+
20829N/A+ // we no longer need a reference to the DirectoryServiceProvider
20829N/A+ if (sAppFileLocProvider) {
20829N/A+ NS_RELEASE(sAppFileLocProvider);
20829N/A+ sAppFileLocProvider = nsnull;
20829N/A+ }
20829N/A+
20829N/A+ // shut down XPCOM/Embedding
20829N/A+ XRE_TermEmbedding();
20829N/A+
20829N/A+ NS_IF_RELEASE(sProfileLock);
20829N/A+ NS_IF_RELEASE(sProfileDir);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void EmbedPrivate::SetPath(const char *aPath)
20829N/A+{
20829N/A+ if (sPath)
20829N/A+ free(sPath);
20829N/A+ if (aPath)
20829N/A+ sPath = strdup(aPath);
20829N/A+ else
20829N/A+ sPath = nsnull;
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::SetCompPath(const char *aPath)
20829N/A+{
20829N/A+ if (sCompPath)
20829N/A+ free(sCompPath);
20829N/A+ if (aPath)
20829N/A+ sCompPath = strdup(aPath);
20829N/A+ else
20829N/A+ sCompPath = nsnull;
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::SetProfilePath(const char *aDir, const char *aName)
20829N/A+{
20829N/A+ if (sProfileDir) {
20829N/A+ if (sWidgetCount) {
20829N/A+ NS_ERROR("Cannot change profile directory during run.");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ NS_RELEASE(sProfileDir);
20829N/A+ NS_RELEASE(sProfileLock);
20829N/A+ }
20829N/A+
20829N/A+ nsresult rv =
20829N/A+ NS_NewNativeLocalFile(nsDependentCString(aDir), PR_TRUE, &sProfileDir);
20829N/A+
20829N/A+ if (NS_SUCCEEDED(rv) && aName)
20829N/A+ rv = sProfileDir->AppendNative(nsDependentCString(aName));
20829N/A+
20829N/A+ if (NS_SUCCEEDED(rv)) {
20829N/A+ PRBool exists = PR_FALSE;
20829N/A+ rv = sProfileDir->Exists(&exists);
20829N/A+ if (!exists)
20829N/A+ rv = sProfileDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
20829N/A+ rv = XRE_LockProfileDirectory(sProfileDir, &sProfileLock);
20829N/A+ }
20829N/A+
20829N/A+ if (NS_SUCCEEDED(rv)) {
20829N/A+ if (sWidgetCount)
20829N/A+ XRE_NotifyProfile();
20829N/A+
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ NS_WARNING("Failed to lock profile.");
20829N/A+
20829N/A+ // Failed
20829N/A+ NS_IF_RELEASE(sProfileDir);
20829N/A+ NS_IF_RELEASE(sProfileLock);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::SetDirectoryServiceProvider(nsIDirectoryServiceProvider * appFileLocProvider)
20829N/A+{
20829N/A+ if (sAppFileLocProvider)
20829N/A+ NS_RELEASE(sAppFileLocProvider);
20829N/A+
20829N/A+ if (appFileLocProvider) {
20829N/A+ sAppFileLocProvider = appFileLocProvider;
20829N/A+ NS_ADDREF(sAppFileLocProvider);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::OpenStream(const char *aBaseURI, const char *aContentType)
20829N/A+{
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ nsCOMPtr<nsIURI> uri;
20829N/A+ nsresult rv = NS_NewURI(getter_AddRefs(uri), aBaseURI);
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return rv;
20829N/A+
20829N/A+ rv = wbStream->OpenStream(uri, nsDependentCString(aContentType));
20829N/A+ return rv;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::AppendToStream(const PRUint8 *aData, PRUint32 aLen)
20829N/A+{
20829N/A+ // Attach listeners to this document since in some cases we don't
20829N/A+ // get updates for content added this way.
20829N/A+ ContentStateChange();
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ return wbStream->AppendToStream(aData, aLen);
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::CloseStream(void)
20829N/A+{
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ return wbStream->CloseStream();
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+EmbedPrivate *
20829N/A+EmbedPrivate::FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
20829N/A+{
20829N/A+ if (!sWindowList)
20829N/A+ return nsnull;
20829N/A+
20829N/A+ // Get the number of browser windows.
20829N/A+ PRInt32 count = sWindowList->Length();
20829N/A+ // This function doesn't get called very often at all ( only when
20829N/A+ // creating a new window ) so it's OK to walk the list of open
20829N/A+ // windows.
20829N/A+ for (int i = 0; i < count; i++) {
20829N/A+ EmbedPrivate *tmpPrivate = sWindowList->ElementAt(i);
20829N/A+ // get the browser object for that window
20829N/A+ nsIWebBrowserChrome *chrome = static_cast<nsIWebBrowserChrome *>(
20829N/A+ tmpPrivate->mWindow);
20829N/A+ if (chrome == aBrowser)
20829N/A+ return tmpPrivate;
20829N/A+ }
20829N/A+
20829N/A+ return nsnull;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::ContentStateChange(void)
20829N/A+{
20829N/A+
20829N/A+ // we don't attach listeners to chrome
20829N/A+ if (mListenersAttached && !mIsChrome)
20829N/A+ return;
20829N/A+
20829N/A+ GetListener();
20829N/A+
20829N/A+ if (!mEventTarget)
20829N/A+ return;
20829N/A+
20829N/A+ AttachListeners();
20829N/A+
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::ContentFinishedLoading(void)
20829N/A+{
20829N/A+ if (mIsChrome) {
20829N/A+ // We're done loading.
20829N/A+ mChromeLoaded = PR_TRUE;
20829N/A+
20829N/A+ // get the web browser
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // get the content DOM window for that web browser
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ if (!domWindow) {
20829N/A+ NS_WARNING("no dom window in content finished loading\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ // resize the content
20829N/A+ domWindow->SizeToContent();
20829N/A+
20829N/A+ // and since we're done loading show the window, assuming that the
20829N/A+ // visibility flag has been set.
20829N/A+ PRBool visibility;
20829N/A+ mWindow->GetVisibility(&visibility);
20829N/A+ if (visibility)
20829N/A+ mWindow->SetVisibility(PR_TRUE);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::ChildFocusIn(void)
20829N/A+{
20829N/A+ if (mIsDestroyed)
20829N/A+ return;
20829N/A+
20829N/A+ nsresult rv;
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return;
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
20829N/A+ if (!webBrowserFocus)
20829N/A+ return;
20829N/A+
20829N/A+ webBrowserFocus->Activate();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::ChildFocusOut(void)
20829N/A+{
20829N/A+ if (mIsDestroyed)
20829N/A+ return;
20829N/A+
20829N/A+ nsresult rv;
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return;
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
20829N/A+ if (!webBrowserFocus)
20829N/A+ return;
20829N/A+
20829N/A+ webBrowserFocus->Deactivate();
20829N/A+}
20829N/A+
20829N/A+// Get the event listener for the chrome event handler.
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::GetListener(void)
20829N/A+{
20829N/A+ if (mEventTarget)
20829N/A+ return;
20829N/A+
20829N/A+ nsCOMPtr<nsPIDOMWindow> piWin;
20829N/A+ GetPIDOMWindow(getter_AddRefs(piWin));
20829N/A+
20829N/A+ if (!piWin)
20829N/A+ return;
20829N/A+
20829N/A+ mEventTarget = do_QueryInterface(piWin->GetChromeEventHandler());
20829N/A+}
20829N/A+
20829N/A+// attach key and mouse event listeners
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::AttachListeners(void)
20829N/A+{
20829N/A+ if (!mEventTarget || mListenersAttached)
20829N/A+ return;
20829N/A+
20829N/A+ nsIDOMEventListener *eventListener =
20829N/A+ static_cast<nsIDOMEventListener *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+
20829N/A+ // add the key listener
20829N/A+ nsresult rv;
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMKeyListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to add key listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMMouseListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to add mouse listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMUIListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to add UI listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ // ok, all set.
20829N/A+ mListenersAttached = PR_TRUE;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrivate::DetachListeners(void)
20829N/A+{
20829N/A+ if (!mListenersAttached || !mEventTarget)
20829N/A+ return;
20829N/A+
20829N/A+ nsIDOMEventListener *eventListener =
20829N/A+ static_cast<nsIDOMEventListener *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+
20829N/A+ nsresult rv;
20829N/A+ rv = mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMKeyListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to remove key listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ rv =
20829N/A+ mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMMouseListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to remove mouse listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ rv = mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMUIListener));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ NS_WARNING("Failed to remove UI listener\n");
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ mListenersAttached = PR_FALSE;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrivate::GetPIDOMWindow(nsPIDOMWindow **aPIWin)
20829N/A+{
20829N/A+ *aPIWin = nsnull;
20829N/A+
20829N/A+ // get the web browser
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+
20829N/A+ // get the content DOM window for that web browser
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ if (!domWindow)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ // get the private DOM window
20829N/A+ nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
20829N/A+ // and the root window for that DOM window
20829N/A+ *aPIWin = domWindowPrivate->GetPrivateRoot();
20829N/A+
20829N/A+ if (*aPIWin) {
20829N/A+ NS_ADDREF(*aPIWin);
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+}
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+void *
20829N/A+EmbedPrivate::GetAtkObjectForCurrentDocument()
20829N/A+{
20829N/A+ if (!mNavigation)
20829N/A+ return nsnull;
20829N/A+
20829N/A+ nsCOMPtr<nsIAccessibilityService> accService =
20829N/A+ do_GetService("@mozilla.org/accessibilityService;1");
20829N/A+ if (accService) {
20829N/A+ //get current document
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ mNavigation->GetDocument(getter_AddRefs(domDoc));
20829N/A+ NS_ENSURE_TRUE(domDoc, nsnull);
20829N/A+
20829N/A+ nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(domDoc));
20829N/A+ NS_ENSURE_TRUE(domNode, nsnull);
20829N/A+
20829N/A+ nsCOMPtr<nsIAccessible> acc;
20829N/A+ accService->GetAccessibleFor(domNode, getter_AddRefs(acc));
20829N/A+ NS_ENSURE_TRUE(acc, nsnull);
20829N/A+
20829N/A+ void *atkObj = nsnull;
20829N/A+ if (NS_SUCCEEDED(acc->GetNativeInterface(&atkObj)))
20829N/A+ return atkObj;
20829N/A+ }
20829N/A+ return nsnull;
20829N/A+}
20829N/A+#endif /* MOZ_ACCESSIBILITY_ATK */
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::RegisterAppComponents(void)
20829N/A+{
20829N/A+ XRE_AddStaticComponent(&kDefaultPromptModule);
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::EnsureOffscreenWindow(void)
20829N/A+{
20829N/A+ if (sOffscreenWindow)
20829N/A+ return;
20829N/A+ sOffscreenWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ gtk_widget_realize(sOffscreenWindow);
20829N/A+ sOffscreenFixed = gtk_fixed_new();
20829N/A+ gtk_container_add(GTK_CONTAINER(sOffscreenWindow), sOffscreenFixed);
20829N/A+ gtk_widget_realize(sOffscreenFixed);
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedPrivate::DestroyOffscreenWindow(void)
20829N/A+{
20829N/A+ if (!sOffscreenWindow)
20829N/A+ return;
20829N/A+ gtk_widget_destroy(sOffscreenWindow);
20829N/A+ sOffscreenWindow = 0;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedPrivate.h b/embedding/browser/gtk/src/EmbedPrivate.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedPrivate.h
20829N/A@@ -0,0 +1,188 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedPrivate_h
20829N/A+#define __EmbedPrivate_h
20829N/A+
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsStringGlue.h"
20829N/A+#include "nsIWebNavigation.h"
20829N/A+#include "nsISHistory.h"
20829N/A+// for our one function that gets the EmbedPrivate via the chrome
20829N/A+// object.
20829N/A+#include "nsIWebBrowserChrome.h"
20829N/A+#include "nsIAppShell.h"
20829N/A+#include "nsPIDOMEventTarget.h"
20829N/A+#include "nsTArray.h"
20829N/A+
20829N/A+#include "gtkmozembedprivate.h"
20829N/A+
20829N/A+class EmbedProgress;
20829N/A+class EmbedWindow;
20829N/A+class EmbedContentListener;
20829N/A+class EmbedEventListener;
20829N/A+
20829N/A+class nsPIDOMWindow;
20829N/A+class nsIDirectoryServiceProvider;
20829N/A+
20829N/A+class EmbedPrivate {
20829N/A+
20829N/A+ public:
20829N/A+
20829N/A+ EmbedPrivate();
20829N/A+ ~EmbedPrivate();
20829N/A+
20829N/A+ nsresult Init (GtkMozEmbed *aOwningWidget);
20829N/A+ nsresult Realize (PRBool *aAlreadRealized);
20829N/A+ void Unrealize (void);
20829N/A+ void Show (void);
20829N/A+ void Hide (void);
20829N/A+ void Resize (PRUint32 aWidth, PRUint32 aHeight);
20829N/A+ void Destroy (void);
20829N/A+ void SetURI (const char *aURI);
20829N/A+ void LoadCurrentURI (void);
20829N/A+ void Reload (PRUint32 reloadFlags);
20829N/A+
20829N/A+ void SetChromeMask (PRUint32 chromeMask);
20829N/A+ void ApplyChromeMask ();
20829N/A+
20829N/A+ static void PushStartup (void);
20829N/A+ static void PopStartup (void);
20829N/A+ static void SetPath (const char *aPath);
20829N/A+ static void SetCompPath (const char *aPath);
20829N/A+ static void SetProfilePath (const char *aDir, const char *aName);
20829N/A+ static void SetDirectoryServiceProvider (nsIDirectoryServiceProvider * appFileLocProvider);
20829N/A+
20829N/A+ nsresult OpenStream (const char *aBaseURI, const char *aContentType);
20829N/A+ nsresult AppendToStream (const PRUint8 *aData, PRUint32 aLen);
20829N/A+ nsresult CloseStream (void);
20829N/A+
20829N/A+ // This function will find the specific EmbedPrivate object for a
20829N/A+ // given nsIWebBrowserChrome.
20829N/A+ static EmbedPrivate *FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser);
20829N/A+
20829N/A+ // This is an upcall that will come from the progress listener
20829N/A+ // whenever there is a content state change. We need this so we can
20829N/A+ // attach event listeners.
20829N/A+ void ContentStateChange (void);
20829N/A+
20829N/A+ // This is an upcall from the progress listener when content is
20829N/A+ // finished loading. We have this so that if it's chrome content
20829N/A+ // that we can size to content properly and show ourselves if
20829N/A+ // visibility is set.
20829N/A+ void ContentFinishedLoading(void);
20829N/A+
20829N/A+ // these are when the widget itself gets focus in and focus out
20829N/A+ // events
20829N/A+ void ChildFocusIn (void);
20829N/A+ void ChildFocusOut(void);
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+ void *GetAtkObjectForCurrentDocument();
20829N/A+#endif
20829N/A+
20829N/A+ GtkMozEmbed *mOwningWidget;
20829N/A+
20829N/A+ // all of the objects that we own
20829N/A+ EmbedWindow *mWindow;
20829N/A+ nsCOMPtr<nsISupports> mWindowGuard;
20829N/A+ EmbedProgress *mProgress;
20829N/A+ nsCOMPtr<nsISupports> mProgressGuard;
20829N/A+ EmbedContentListener *mContentListener;
20829N/A+ nsCOMPtr<nsISupports> mContentListenerGuard;
20829N/A+ EmbedEventListener *mEventListener;
20829N/A+ nsCOMPtr<nsISupports> mEventListenerGuard;
20829N/A+
20829N/A+ nsCOMPtr<nsIWebNavigation> mNavigation;
20829N/A+ nsCOMPtr<nsISHistory> mSessionHistory;
20829N/A+
20829N/A+ // our event receiver
20829N/A+ nsCOMPtr<nsPIDOMEventTarget> mEventTarget;
20829N/A+
20829N/A+ // the currently loaded uri
20829N/A+ nsCString mURI;
20829N/A+
20829N/A+ // the number of widgets that have been created
20829N/A+ static PRUint32 sWidgetCount;
20829N/A+ // the path to the GRE
20829N/A+ static char *sPath;
20829N/A+ // the path to components
20829N/A+ static char *sCompPath;
20829N/A+ // the appshell we have created
20829N/A+ static nsIAppShell *sAppShell;
20829N/A+ // the list of all open windows
20829N/A+ static nsTArray<EmbedPrivate*> *sWindowList;
20829N/A+ // what is our profile path?
20829N/A+ static nsILocalFile *sProfileDir;
20829N/A+ static nsISupports *sProfileLock;
20829N/A+
20829N/A+ static nsIDirectoryServiceProvider * sAppFileLocProvider;
20829N/A+
20829N/A+ // chrome mask
20829N/A+ PRUint32 mChromeMask;
20829N/A+ // is this a chrome window?
20829N/A+ PRBool mIsChrome;
20829N/A+ // has the chrome finished loading?
20829N/A+ PRBool mChromeLoaded;
20829N/A+ // saved window ID for reparenting later
20829N/A+ GtkWidget *mMozWindowWidget;
20829N/A+ // has someone called Destroy() on us?
20829N/A+ PRBool mIsDestroyed;
20829N/A+
20829N/A+ private:
20829N/A+
20829N/A+ // is the chrome listener attached yet?
20829N/A+ PRBool mListenersAttached;
20829N/A+
20829N/A+ void GetListener (void);
20829N/A+ void AttachListeners(void);
20829N/A+ void DetachListeners(void);
20829N/A+
20829N/A+ // this will get the PIDOMWindow for this widget
20829N/A+ nsresult GetPIDOMWindow (nsPIDOMWindow **aPIWin);
20829N/A+
20829N/A+ static void RegisterAppComponents();
20829N/A+
20829N/A+ // offscreen window methods and the offscreen widget
20829N/A+ static void EnsureOffscreenWindow(void);
20829N/A+ static void DestroyOffscreenWindow(void);
20829N/A+ static GtkWidget *sOffscreenWindow;
20829N/A+ static GtkWidget *sOffscreenFixed;
20829N/A+
20829N/A+};
20829N/A+
20829N/A+#endif /* __EmbedPrivate_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedProgress.cpp b/embedding/browser/gtk/src/EmbedProgress.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedProgress.cpp
20829N/A@@ -0,0 +1,215 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "EmbedProgress.h"
20829N/A+
20829N/A+#include "nsIChannel.h"
20829N/A+#include "nsIWebProgress.h"
20829N/A+#include "nsIDOMWindow.h"
20829N/A+
20829N/A+#include "nsIURI.h"
20829N/A+
20829N/A+EmbedProgress::EmbedProgress(void)
20829N/A+{
20829N/A+ mOwner = nsnull;
20829N/A+}
20829N/A+
20829N/A+EmbedProgress::~EmbedProgress()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ISUPPORTS2(EmbedProgress,
20829N/A+ nsIWebProgressListener,
20829N/A+ nsISupportsWeakReference)
20829N/A+
20829N/A+nsresult
20829N/A+EmbedProgress::Init(EmbedPrivate *aOwner)
20829N/A+{
20829N/A+ mOwner = aOwner;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
20829N/A+ nsIRequest *aRequest,
20829N/A+ PRUint32 aStateFlags,
20829N/A+ nsresult aStatus)
20829N/A+{
20829N/A+ // give the widget a chance to attach any listeners
20829N/A+ mOwner->ContentStateChange();
20829N/A+ // if we've got the start flag, emit the signal
20829N/A+ if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
20829N/A+ (aStateFlags & GTK_MOZ_EMBED_FLAG_START))
20829N/A+ {
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_START], 0);
20829N/A+ }
20829N/A+
20829N/A+ // get the uri for this request
20829N/A+ nsCAutoString uriString;
20829N/A+ RequestToURIString(aRequest, uriString);
20829N/A+
20829N/A+ // is it the same as the current URI?
20829N/A+ if (mOwner->mURI.Equals(uriString))
20829N/A+ {
20829N/A+ // for people who know what they are doing
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STATE], 0,
20829N/A+ aStateFlags, aStatus);
20829N/A+ }
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STATE_ALL], 0,
20829N/A+ uriString.get(),
20829N/A+ (gint)aStateFlags, (gint)aStatus);
20829N/A+ // and for stop, too
20829N/A+ if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
20829N/A+ (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP))
20829N/A+ {
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STOP], 0);
20829N/A+ // let our owner know that the load finished
20829N/A+ mOwner->ContentFinishedLoading();
20829N/A+ }
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedProgress::OnProgressChange(nsIWebProgress *aWebProgress,
20829N/A+ nsIRequest *aRequest,
20829N/A+ PRInt32 aCurSelfProgress,
20829N/A+ PRInt32 aMaxSelfProgress,
20829N/A+ PRInt32 aCurTotalProgress,
20829N/A+ PRInt32 aMaxTotalProgress)
20829N/A+{
20829N/A+
20829N/A+ nsCAutoString uriString;
20829N/A+ RequestToURIString(aRequest, uriString);
20829N/A+
20829N/A+ // is it the same as the current uri?
20829N/A+ if (mOwner->mURI.Equals(uriString)) {
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[PROGRESS], 0,
20829N/A+ aCurTotalProgress, aMaxTotalProgress);
20829N/A+ }
20829N/A+
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[PROGRESS_ALL], 0,
20829N/A+ uriString.get(),
20829N/A+ aCurTotalProgress, aMaxTotalProgress);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
20829N/A+ nsIRequest *aRequest,
20829N/A+ nsIURI *aLocation)
20829N/A+{
20829N/A+ nsCAutoString newURI;
20829N/A+ NS_ENSURE_ARG_POINTER(aLocation);
20829N/A+ aLocation->GetSpec(newURI);
20829N/A+
20829N/A+ // Make sure that this is the primary frame change and not
20829N/A+ // just a subframe.
20829N/A+ PRBool isSubFrameLoad = PR_FALSE;
20829N/A+ if (aWebProgress) {
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ nsCOMPtr<nsIDOMWindow> topDomWindow;
20829N/A+
20829N/A+ aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
20829N/A+
20829N/A+ // get the root dom window
20829N/A+ if (domWindow)
20829N/A+ domWindow->GetTop(getter_AddRefs(topDomWindow));
20829N/A+
20829N/A+ if (domWindow != topDomWindow)
20829N/A+ isSubFrameLoad = PR_TRUE;
20829N/A+ }
20829N/A+
20829N/A+ if (!isSubFrameLoad) {
20829N/A+ mOwner->SetURI(newURI.get());
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[LOCATION], 0);
20829N/A+ }
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedProgress::OnStatusChange(nsIWebProgress *aWebProgress,
20829N/A+ nsIRequest *aRequest,
20829N/A+ nsresult aStatus,
20829N/A+ const PRUnichar *aMessage)
20829N/A+{
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[STATUS_CHANGE], 0,
20829N/A+ static_cast<void *>(aRequest),
20829N/A+ static_cast<int>(aStatus),
20829N/A+ static_cast<const void *>(aMessage));
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress,
20829N/A+ nsIRequest *aRequest,
20829N/A+ PRUint32 aState)
20829N/A+{
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[SECURITY_CHANGE], 0,
20829N/A+ static_cast<void *>(aRequest),
20829N/A+ aState);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+/* static */
20829N/A+void
20829N/A+EmbedProgress::RequestToURIString(nsIRequest *aRequest, nsACString &aString)
20829N/A+{
20829N/A+ // is it a channel
20829N/A+ nsCOMPtr<nsIChannel> channel;
20829N/A+ channel = do_QueryInterface(aRequest);
20829N/A+ if (!channel)
20829N/A+ return;
20829N/A+
20829N/A+ nsCOMPtr<nsIURI> uri;
20829N/A+ channel->GetURI(getter_AddRefs(uri));
20829N/A+ if (!uri)
20829N/A+ return;
20829N/A+
20829N/A+ uri->GetSpec(aString);
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedProgress.h b/embedding/browser/gtk/src/EmbedProgress.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedProgress.h
20829N/A@@ -0,0 +1,66 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedProgress_h
20829N/A+#define __EmbedProgress_h
20829N/A+
20829N/A+#include "nsIWebProgressListener.h"
20829N/A+#include "nsWeakReference.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+
20829N/A+class EmbedProgress : public nsIWebProgressListener,
20829N/A+ public nsSupportsWeakReference
20829N/A+{
20829N/A+ public:
20829N/A+ EmbedProgress();
20829N/A+ virtual ~EmbedProgress();
20829N/A+
20829N/A+ nsresult Init(EmbedPrivate *aOwner);
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+
20829N/A+ NS_DECL_NSIWEBPROGRESSLISTENER
20829N/A+
20829N/A+ private:
20829N/A+
20829N/A+ static void RequestToURIString (nsIRequest *aRequest, nsACString &aString);
20829N/A+
20829N/A+ EmbedPrivate *mOwner;
20829N/A+
20829N/A+};
20829N/A+
20829N/A+#endif /* __EmbedProgress_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedPrompter.cpp b/embedding/browser/gtk/src/EmbedPrompter.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedPrompter.cpp
20829N/A@@ -0,0 +1,411 @@
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "EmbedPrompter.h"
20829N/A+
20829N/A+enum {
20829N/A+ INCLUDE_USERNAME = 1 << 0,
20829N/A+ INCLUDE_PASSWORD = 1 << 1,
20829N/A+ INCLUDE_CHECKBOX = 1 << 2,
20829N/A+ INCLUDE_CANCEL = 1 << 3
20829N/A+};
20829N/A+
20829N/A+struct DialogDescription {
20829N/A+ int flags;
20829N/A+ const gchar* icon;
20829N/A+};
20829N/A+
20829N/A+// This table contains the optional widgets and icons associated with
20829N/A+// each type of dialog.
20829N/A+
20829N/A+static const DialogDescription DialogTable[] = {
20829N/A+ { 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
20829N/A+ { INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
20829N/A+ { INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
20829N/A+ { INCLUDE_CHECKBOX |
20829N/A+ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
20829N/A+ { INCLUDE_CANCEL |
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
20829N/A+ { INCLUDE_CANCEL |
20829N/A+ INCLUDE_USERNAME |
20829N/A+ INCLUDE_PASSWORD |
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
20829N/A+ { INCLUDE_CANCEL |
20829N/A+ INCLUDE_PASSWORD |
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
20829N/A+ { INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
20829N/A+ { INCLUDE_CANCEL |
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
20829N/A+};
20829N/A+
20829N/A+EmbedPrompter::EmbedPrompter(void)
20829N/A+ : mCheckValue(PR_FALSE),
20829N/A+ mItemList(nsnull),
20829N/A+ mItemCount(0),
20829N/A+ mButtonPressed(0),
20829N/A+ mConfirmResult(PR_FALSE),
20829N/A+ mSelectedItem(0),
20829N/A+ mWindow(NULL),
20829N/A+ mUserField(NULL),
20829N/A+ mPassField(NULL),
20829N/A+ mTextField(NULL),
20829N/A+ mComboBox(NULL),
20829N/A+ mCheckBox(NULL)
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+EmbedPrompter::~EmbedPrompter(void)
20829N/A+{
20829N/A+ if (mItemList)
20829N/A+ delete[] mItemList;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedPrompter::Create(PromptType aType, GtkWindow* aParentWindow)
20829N/A+{
20829N/A+ mWindow = gtk_dialog_new_with_buttons(mTitle.get(), aParentWindow,
20829N/A+ (GtkDialogFlags)0,
20829N/A+ NULL);
20829N/A+
20829N/A+ // only add the dialog to the window group if the parent already has a window group,
20829N/A+ // so as not to break app's expectations about modal dialogs.
20829N/A+ if (aParentWindow && aParentWindow->group) {
20829N/A+ gtk_window_group_add_window (aParentWindow->group, GTK_WINDOW (mWindow));
20829N/A+ }
20829N/A+
20829N/A+ // gtk will resize this for us as necessary
20829N/A+ gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
20829N/A+
20829N/A+ // this HBox will contain the icon, and a vbox which contains the
20829N/A+ // dialog text and other widgets.
20829N/A+ GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
20829N/A+
20829N/A+
20829N/A+ // Set up dialog properties according to the GNOME HIG
20829N/A+ // (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows)
20829N/A+
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
20829N/A+ gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
20829N/A+ gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
20829N/A+
20829N/A+
20829N/A+ // This is the VBox which will contain the label and other controls.
20829N/A+ GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
20829N/A+
20829N/A+ // get the stock icon for this dialog and put it in the box
20829N/A+ const gchar* iconDesc = DialogTable[aType].icon;
20829N/A+ GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
20829N/A+ gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
20829N/A+ gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
20829N/A+
20829N/A+ // now pack the label into the vbox
20829N/A+ GtkWidget* label = gtk_label_new(mMessageText.get());
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
20829N/A+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
20829N/A+
20829N/A+ int widgetFlags = DialogTable[aType].flags;
20829N/A+
20829N/A+ if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
20829N/A+
20829N/A+ // If we're creating a username and/or password field, make an hbox
20829N/A+ // which will contain two vboxes, one for the labels and one for the
20829N/A+ // text fields. This will let us line up the textfields.
20829N/A+
20829N/A+ GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
20829N/A+ GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
20829N/A+ GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
20829N/A+
20829N/A+ if (widgetFlags & INCLUDE_USERNAME) {
20829N/A+ GtkWidget* userLabel = gtk_label_new("User Name:");
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
20829N/A+ FALSE, 0);
20829N/A+
20829N/A+ mUserField = gtk_entry_new();
20829N/A+
20829N/A+ if (!mUser.IsEmpty())
20829N/A+ gtk_entry_set_text(GTK_ENTRY(mUserField), mUser.get());
20829N/A+
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassFields), mUserField, FALSE,
20829N/A+ FALSE, 0);
20829N/A+ }
20829N/A+ if (widgetFlags & INCLUDE_PASSWORD) {
20829N/A+ GtkWidget* passLabel = gtk_label_new("Password:");
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassLabels), passLabel, FALSE,
20829N/A+ FALSE, 0);
20829N/A+
20829N/A+ mPassField = gtk_entry_new();
20829N/A+
20829N/A+ if (!mPass.IsEmpty())
20829N/A+ gtk_entry_set_text(GTK_ENTRY(mPassField), mPass.get());
20829N/A+
20829N/A+ gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassFields), mPassField, FALSE,
20829N/A+ FALSE, 0);
20829N/A+ }
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassHBox), userPassLabels, FALSE,
20829N/A+ FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassHBox), userPassFields, FALSE,
20829N/A+ FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), userPassHBox, FALSE, FALSE, 0);
20829N/A+ }
20829N/A+
20829N/A+ if (aType == TYPE_PROMPT) {
20829N/A+ mTextField = gtk_entry_new();
20829N/A+
20829N/A+ if (!mTextValue.IsEmpty())
20829N/A+ gtk_entry_set_text(GTK_ENTRY(mTextField), mTextValue.get());
20829N/A+
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
20829N/A+ }
20829N/A+
20829N/A+ // Add a checkbox
20829N/A+ if ((widgetFlags & INCLUDE_CHECKBOX) && !mCheckMessage.IsEmpty()) {
20829N/A+ mCheckBox = gtk_check_button_new_with_label(mCheckMessage.get());
20829N/A+
20829N/A+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
20829N/A+ mCheckValue);
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
20829N/A+ TRUE);
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
20829N/A+ }
20829N/A+
20829N/A+ // Add a dropdown menu
20829N/A+ if (aType == TYPE_SELECT) {
20829N/A+ // Build up a GtkComboBox containing the items
20829N/A+ GtkWidget* mComboBox = gtk_combo_box_new_text();
20829N/A+ for (PRUint32 i = 0; i < mItemCount; ++i) {
20829N/A+ gtk_combo_box_append_text(GTK_COMBO_BOX(mComboBox), mItemList[i].get());
20829N/A+ }
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mComboBox, FALSE, FALSE, 0);
20829N/A+ }
20829N/A+
20829N/A+ if (aType == TYPE_UNIVERSAL) {
20829N/A+ // Create buttons based on the flags passed in.
20829N/A+ for (PRUint32 i = EMBED_MAX_BUTTONS; i-- > 0; ) {
20829N/A+ if (!mButtonLabels[i].IsEmpty())
20829N/A+ gtk_dialog_add_button(GTK_DIALOG(mWindow),
20829N/A+ mButtonLabels[i].get(), i);
20829N/A+ }
20829N/A+ gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
20829N/A+ } else {
20829N/A+ // Create standard ok and cancel buttons
20829N/A+ if (widgetFlags & INCLUDE_CANCEL)
20829N/A+ gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
20829N/A+ GTK_RESPONSE_CANCEL);
20829N/A+
20829N/A+ GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
20829N/A+ GTK_STOCK_OK,
20829N/A+ GTK_RESPONSE_ACCEPT);
20829N/A+ gtk_widget_grab_default(okButton);
20829N/A+ }
20829N/A+
20829N/A+ // Pack the contentsVBox into the dialogHBox and the dialog.
20829N/A+ gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mWindow)->vbox), dialogHBox, FALSE,
20829N/A+ FALSE, 0);
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetTitle(const PRUnichar *aTitle)
20829N/A+{
20829N/A+ mTitle.Assign(NS_ConvertUTF16toUTF8(aTitle));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetTextValue(const PRUnichar *aTextValue)
20829N/A+{
20829N/A+ mTextValue.Assign(NS_ConvertUTF16toUTF8(aTextValue));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetCheckMessage(const PRUnichar *aMessage)
20829N/A+{
20829N/A+ mCheckMessage.Assign(NS_ConvertUTF16toUTF8(aMessage));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetMessageText(const PRUnichar *aMessageText)
20829N/A+{
20829N/A+ mMessageText.Assign(NS_ConvertUTF16toUTF8(aMessageText));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetUser(const PRUnichar *aUser)
20829N/A+{
20829N/A+ mUser.Assign(NS_ConvertUTF16toUTF8(aUser));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetPassword(const PRUnichar *aPass)
20829N/A+{
20829N/A+ mPass.Assign(NS_ConvertUTF16toUTF8(aPass));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetCheckValue(const PRBool aValue)
20829N/A+{
20829N/A+ mCheckValue = aValue;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetItems(const PRUnichar** aItemArray, PRUint32 aCount)
20829N/A+{
20829N/A+ if (mItemList)
20829N/A+ delete[] mItemList;
20829N/A+
20829N/A+ mItemCount = aCount;
20829N/A+ mItemList = new nsCString[aCount];
20829N/A+ for (PRUint32 i = 0; i < aCount; ++i)
20829N/A+ mItemList[i].Assign(NS_ConvertUTF16toUTF8(aItemArray[i]));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SetButtons(const PRUnichar* aButton0Label,
20829N/A+ const PRUnichar* aButton1Label,
20829N/A+ const PRUnichar* aButton2Label)
20829N/A+{
20829N/A+ mButtonLabels[0].Assign(NS_ConvertUTF16toUTF8(aButton0Label));
20829N/A+ mButtonLabels[1].Assign(NS_ConvertUTF16toUTF8(aButton1Label));
20829N/A+ mButtonLabels[2].Assign(NS_ConvertUTF16toUTF8(aButton2Label));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetCheckValue(PRBool *aValue)
20829N/A+{
20829N/A+ *aValue = mCheckValue;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue)
20829N/A+{
20829N/A+ *aConfirmValue = mConfirmResult;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetTextValue(PRUnichar **aTextValue)
20829N/A+{
20829N/A+ *aTextValue = ToNewUnicode(NS_ConvertUTF8toUTF16(mTextValue));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetUser(PRUnichar **aUser)
20829N/A+{
20829N/A+ *aUser = ToNewUnicode(NS_ConvertUTF8toUTF16(mUser));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetPassword(PRUnichar **aPass)
20829N/A+{
20829N/A+ *aPass = ToNewUnicode(NS_ConvertUTF8toUTF16(mPass));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetSelectedItem(PRInt32 *aIndex)
20829N/A+{
20829N/A+ *aIndex = mSelectedItem;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::GetButtonPressed(PRInt32 *aButton)
20829N/A+{
20829N/A+ *aButton = mButtonPressed;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::Run(void)
20829N/A+{
20829N/A+ gtk_widget_show_all(mWindow);
20829N/A+ gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
20829N/A+ switch (response) {
20829N/A+ case GTK_RESPONSE_NONE:
20829N/A+ case GTK_RESPONSE_CANCEL:
20829N/A+ case GTK_RESPONSE_DELETE_EVENT:
20829N/A+ mConfirmResult = PR_FALSE;
20829N/A+ break;
20829N/A+ case GTK_RESPONSE_ACCEPT:
20829N/A+ mConfirmResult = PR_TRUE;
20829N/A+ SaveDialogValues();
20829N/A+ break;
20829N/A+ default:
20829N/A+ mButtonPressed = response;
20829N/A+ SaveDialogValues();
20829N/A+ }
20829N/A+
20829N/A+ gtk_widget_destroy(mWindow);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedPrompter::SaveDialogValues()
20829N/A+{
20829N/A+ if (mUserField)
20829N/A+ mUser.Assign(gtk_entry_get_text(GTK_ENTRY(mUserField)));
20829N/A+
20829N/A+ if (mPassField)
20829N/A+ mPass.Assign(gtk_entry_get_text(GTK_ENTRY(mPassField)));
20829N/A+
20829N/A+ if (mCheckBox)
20829N/A+ mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
20829N/A+
20829N/A+ if (mTextField)
20829N/A+ mTextValue.Assign(gtk_entry_get_text(GTK_ENTRY(mTextField)));
20829N/A+
20829N/A+ if (mComboBox)
20829N/A+ {
20829N/A+ gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(mComboBox));
20829N/A+ for (PRUint32 i = 0; i < mItemCount; ++i) {
20829N/A+ if(mItemList[i].Equals(str))
20829N/A+ {
20829N/A+ mSelectedItem = i;
20829N/A+ break;
20829N/A+ }
20829N/A+ }
20829N/A+ }
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedPrompter.h b/embedding/browser/gtk/src/EmbedPrompter.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedPrompter.h
20829N/A@@ -0,0 +1,113 @@
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsStringGlue.h"
20829N/A+#include <gtk/gtk.h>
20829N/A+
20829N/A+#define EMBED_MAX_BUTTONS 3
20829N/A+
20829N/A+class EmbedPrompter {
20829N/A+
20829N/A+public:
20829N/A+
20829N/A+ EmbedPrompter();
20829N/A+ ~EmbedPrompter();
20829N/A+
20829N/A+ enum PromptType {
20829N/A+ TYPE_ALERT,
20829N/A+ TYPE_ALERT_CHECK,
20829N/A+ TYPE_CONFIRM,
20829N/A+ TYPE_CONFIRM_CHECK,
20829N/A+ TYPE_PROMPT,
20829N/A+ TYPE_PROMPT_USER_PASS,
20829N/A+ TYPE_PROMPT_PASS,
20829N/A+ TYPE_SELECT,
20829N/A+ TYPE_UNIVERSAL
20829N/A+ };
20829N/A+
20829N/A+ nsresult Create(PromptType aType, GtkWindow* aParentWindow);
20829N/A+ void SetTitle(const PRUnichar *aTitle);
20829N/A+ void SetTextValue (const PRUnichar *aTextValue);
20829N/A+ void SetCheckMessage(const PRUnichar *aCheckMessage);
20829N/A+ void SetCheckValue(const PRBool aValue);
20829N/A+ void SetMessageText(const PRUnichar *aMessageText);
20829N/A+ void SetUser(const PRUnichar *aUser);
20829N/A+ void SetPassword(const PRUnichar *aPass);
20829N/A+ void SetButtons(const PRUnichar* aButton0Label,
20829N/A+ const PRUnichar* aButton1Label,
20829N/A+ const PRUnichar* aButton2Label);
20829N/A+ void SetItems(const PRUnichar **aItemArray, PRUint32 aCount);
20829N/A+
20829N/A+ void GetCheckValue(PRBool *aValue);
20829N/A+ void GetConfirmValue(PRBool *aConfirmValue);
20829N/A+ void GetTextValue(PRUnichar **aTextValue);
20829N/A+ void GetUser(PRUnichar **aUser);
20829N/A+ void GetPassword(PRUnichar **aPass);
20829N/A+ void GetButtonPressed(PRInt32 *aButton);
20829N/A+ void GetSelectedItem(PRInt32 *aIndex);
20829N/A+
20829N/A+ void Run(void);
20829N/A+
20829N/A+private:
20829N/A+
20829N/A+ void SaveDialogValues();
20829N/A+
20829N/A+ nsCString mTitle;
20829N/A+ nsCString mMessageText;
20829N/A+ nsCString mTextValue;
20829N/A+ nsCString mCheckMessage;
20829N/A+ PRBool mCheckValue;
20829N/A+ nsCString mUser;
20829N/A+ nsCString mPass;
20829N/A+ nsCString mButtonLabels[EMBED_MAX_BUTTONS];
20829N/A+ nsCString *mItemList;
20829N/A+ PRUint32 mItemCount;
20829N/A+
20829N/A+ PRInt32 mButtonPressed;
20829N/A+ PRBool mConfirmResult;
20829N/A+ PRInt32 mSelectedItem;
20829N/A+
20829N/A+ GtkWidget *mWindow;
20829N/A+ GtkWidget *mUserField;
20829N/A+ GtkWidget *mPassField;
20829N/A+ GtkWidget *mTextField;
20829N/A+ GtkWidget *mComboBox;
20829N/A+ GtkWidget *mCheckBox;
20829N/A+};
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedWindow.cpp b/embedding/browser/gtk/src/EmbedWindow.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedWindow.cpp
20829N/A@@ -0,0 +1,474 @@
20829N/A+/*
20829N/A+ * vim:ts=2:et:sw=2
20829N/A+ *
20829N/A+ * ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsCWebBrowser.h"
20829N/A+#include "nsIComponentManager.h"
20829N/A+#include "nsComponentManagerUtils.h"
20829N/A+#include "nsIDocShellTreeItem.h"
20829N/A+#include "nsIWidget.h"
20829N/A+
20829N/A+#include "EmbedWindow.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include "EmbedPrompter.h"
20829N/A+
20829N/A+GtkWidget *EmbedWindow::sTipWindow = nsnull;
20829N/A+
20829N/A+EmbedWindow::EmbedWindow(void)
20829N/A+{
20829N/A+ mOwner = nsnull;
20829N/A+ mVisibility = PR_FALSE;
20829N/A+ mIsModal = PR_FALSE;
20829N/A+}
20829N/A+
20829N/A+EmbedWindow::~EmbedWindow(void)
20829N/A+{
20829N/A+ ExitModalEventLoop(PR_FALSE);
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedWindow::Init(EmbedPrivate *aOwner)
20829N/A+{
20829N/A+ // save our owner for later
20829N/A+ mOwner = aOwner;
20829N/A+
20829N/A+ // create our nsIWebBrowser object and set up some basic defaults.
20829N/A+ mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
20829N/A+ if (!mWebBrowser)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome *>(this));
20829N/A+
20829N/A+ nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(mWebBrowser);
20829N/A+ item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+nsresult
20829N/A+EmbedWindow::CreateWindow(void)
20829N/A+{
20829N/A+ nsresult rv;
20829N/A+ GtkWidget *ownerAsWidget = GTK_WIDGET(mOwner->mOwningWidget);
20829N/A+
20829N/A+ // Get the base window interface for the web browser object and
20829N/A+ // create the window.
20829N/A+ mBaseWindow = do_QueryInterface(mWebBrowser);
20829N/A+ rv = mBaseWindow->InitWindow(GTK_WIDGET(mOwner->mOwningWidget),
20829N/A+ nsnull,
20829N/A+ 0, 0,
20829N/A+ ownerAsWidget->allocation.width,
20829N/A+ ownerAsWidget->allocation.height);
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return rv;
20829N/A+
20829N/A+ rv = mBaseWindow->Create();
20829N/A+ if (NS_FAILED(rv))
20829N/A+ return rv;
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+EmbedWindow::ReleaseChildren(void)
20829N/A+{
20829N/A+ ExitModalEventLoop(PR_FALSE);
20829N/A+
20829N/A+ mBaseWindow->Destroy();
20829N/A+ mBaseWindow = 0;
20829N/A+ mWebBrowser = 0;
20829N/A+}
20829N/A+
20829N/A+// nsISupports
20829N/A+
20829N/A+NS_IMPL_ADDREF(EmbedWindow)
20829N/A+NS_IMPL_RELEASE(EmbedWindow)
20829N/A+
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedWindow)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
20829N/A+NS_INTERFACE_MAP_END
20829N/A+
20829N/A+// nsIWebBrowserChrome
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetStatus(PRUint32 aStatusType, const PRUnichar *aStatus)
20829N/A+{
20829N/A+ switch (aStatusType) {
20829N/A+ case STATUS_SCRIPT:
20829N/A+ {
20829N/A+ mJSStatus = aStatus;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[JS_STATUS], 0);
20829N/A+ }
20829N/A+ break;
20829N/A+ case STATUS_SCRIPT_DEFAULT:
20829N/A+ // Gee, that's nice.
20829N/A+ break;
20829N/A+ case STATUS_LINK:
20829N/A+ {
20829N/A+ mLinkMessage = aStatus;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[LINK_MESSAGE], 0);
20829N/A+ }
20829N/A+ break;
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetWebBrowser(nsIWebBrowser **aWebBrowser)
20829N/A+{
20829N/A+ *aWebBrowser = mWebBrowser;
20829N/A+ NS_IF_ADDREF(*aWebBrowser);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetWebBrowser(nsIWebBrowser *aWebBrowser)
20829N/A+{
20829N/A+ mWebBrowser = aWebBrowser;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetChromeFlags(PRUint32 *aChromeFlags)
20829N/A+{
20829N/A+ *aChromeFlags = mOwner->mChromeMask;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetChromeFlags(PRUint32 aChromeFlags)
20829N/A+{
20829N/A+ mOwner->SetChromeMask(aChromeFlags);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::DestroyBrowserWindow(void)
20829N/A+{
20829N/A+ // mark the owner as destroyed so it won't emit events anymore.
20829N/A+ mOwner->mIsDestroyed = PR_TRUE;
20829N/A+
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DESTROY_BROWSER], 0);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
20829N/A+{
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[SIZE_TO], 0, aCX, aCY);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::ShowAsModal(void)
20829N/A+{
20829N/A+ mIsModal = PR_TRUE;
20829N/A+ GtkWidget *toplevel;
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ gtk_grab_add(toplevel);
20829N/A+ gtk_main();
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::IsWindowModal(PRBool *_retval)
20829N/A+{
20829N/A+ *_retval = mIsModal;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::ExitModalEventLoop(nsresult aStatus)
20829N/A+{
20829N/A+ if (mIsModal) {
20829N/A+ GtkWidget *toplevel;
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ gtk_grab_remove(toplevel);
20829N/A+ mIsModal = PR_FALSE;
20829N/A+ gtk_main_quit();
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+// nsIWebBrowserChromeFocus
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::FocusNextElement()
20829N/A+{
20829N/A+ GtkWidget *toplevel;
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WIDGET_TOPLEVEL(toplevel))
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
20829N/A+ GTK_DIR_TAB_FORWARD);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::FocusPrevElement()
20829N/A+{
20829N/A+ GtkWidget *toplevel;
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WIDGET_TOPLEVEL(toplevel))
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
20829N/A+ GTK_DIR_TAB_BACKWARD);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+// nsIEmbeddingSiteWindow
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
20829N/A+ PRInt32 aCX, PRInt32 aCY)
20829N/A+{
20829N/A+ if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
20829N/A+ (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
20829N/A+ return mBaseWindow->SetPositionAndSize(aX, aY, aCX, aCY, PR_TRUE);
20829N/A+ }
20829N/A+ else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
20829N/A+ return mBaseWindow->SetPosition(aX, aY);
20829N/A+ }
20829N/A+ else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
20829N/A+ return mBaseWindow->SetSize(aCX, aCY, PR_TRUE);
20829N/A+ }
20829N/A+ return NS_ERROR_INVALID_ARG;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetDimensions(PRUint32 aFlags, PRInt32 *aX,
20829N/A+ PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
20829N/A+{
20829N/A+ if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
20829N/A+ (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
20829N/A+ return mBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY);
20829N/A+ }
20829N/A+ else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
20829N/A+ return mBaseWindow->GetPosition(aX, aY);
20829N/A+ }
20829N/A+ else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
20829N/A+ return mBaseWindow->GetSize(aCX, aCY);
20829N/A+ }
20829N/A+ return NS_ERROR_INVALID_ARG;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetFocus(void)
20829N/A+{
20829N/A+ // XXX might have to do more here.
20829N/A+ return mBaseWindow->SetFocus();
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetTitle(PRUnichar **aTitle)
20829N/A+{
20829N/A+ *aTitle = ToNewUnicode(mTitle);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetTitle(const PRUnichar *aTitle)
20829N/A+{
20829N/A+ mTitle = aTitle;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[TITLE], 0);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetSiteWindow(void **aSiteWindow)
20829N/A+{
20829N/A+ GtkWidget *ownerAsWidget (GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ *aSiteWindow = static_cast<void *>(ownerAsWidget);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetVisibility(PRBool *aVisibility)
20829N/A+{
20829N/A+ // XXX See bug 312998
20829N/A+ // Work around the problem that sometimes the window
20829N/A+ // is already visible even though mVisibility isn't true
20829N/A+ // yet.
20829N/A+ *aVisibility = mVisibility ||
20829N/A+ (!mOwner->mIsChrome &&
20829N/A+ mOwner->mOwningWidget &&
20829N/A+ GTK_WIDGET_MAPPED(mOwner->mOwningWidget));
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::SetVisibility(PRBool aVisibility)
20829N/A+{
20829N/A+ // We always set the visibility so that if it's chrome and we finish
20829N/A+ // the load we know that we have to show the window.
20829N/A+ mVisibility = aVisibility;
20829N/A+
20829N/A+ // if this is a chrome window and the chrome hasn't finished loading
20829N/A+ // yet then don't show the window yet.
20829N/A+ if (mOwner->mIsChrome && !mOwner->mChromeLoaded)
20829N/A+ return NS_OK;
20829N/A+
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[VISIBILITY], 0,
20829N/A+ aVisibility);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+// nsITooltipListener
20829N/A+
20829N/A+static gint
20829N/A+tooltips_paint_window(GtkWidget *window)
20829N/A+{
20829N/A+ // draw tooltip style border around the text
20829N/A+ gtk_paint_flat_box(window->style, window->window,
20829N/A+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
20829N/A+ NULL, window, "tooltip",
20829N/A+ 0, 0,
20829N/A+ window->allocation.width, window->allocation.height);
20829N/A+
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
20829N/A+ const PRUnichar *aTipText)
20829N/A+{
20829N/A+ nsAutoString tipText ( aTipText );
20829N/A+
20829N/A+ const char* tipString = ToNewUTF8String(tipText);
20829N/A+
20829N/A+ if (sTipWindow)
20829N/A+ gtk_widget_destroy(sTipWindow);
20829N/A+
20829N/A+ // get the root origin for this content window
20829N/A+ nsCOMPtr<nsIWidget> mainWidget;
20829N/A+ mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
20829N/A+ GdkWindow *window;
20829N/A+ window = static_cast<GdkWindow *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
20829N/A+ gint root_x, root_y;
20829N/A+ gdk_window_get_origin(window, &root_x, &root_y);
20829N/A+
20829N/A+ // XXX work around until I can get pink to figure out why
20829N/A+ // tooltips vanish if they show up right at the origin of the
20829N/A+ // cursor.
20829N/A+ root_y += 10;
20829N/A+
20829N/A+ sTipWindow = gtk_window_new(GTK_WINDOW_POPUP);
20829N/A+ gtk_widget_set_app_paintable(sTipWindow, TRUE);
20829N/A+ gtk_window_set_resizable(GTK_WINDOW(sTipWindow), TRUE);
20829N/A+ // needed to get colors + fonts etc correctly
20829N/A+ gtk_widget_set_name(sTipWindow, "gtk-tooltips");
20829N/A+ gtk_window_set_type_hint(GTK_WINDOW(sTipWindow), GDK_WINDOW_TYPE_HINT_TOOLTIP);
20829N/A+
20829N/A+ // set up the popup window as a transient of the widget.
20829N/A+ GtkWidget *toplevel_window;
20829N/A+ toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WINDOW(toplevel_window)) {
20829N/A+ NS_ERROR("no gtk window in hierarchy!");
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+ }
20829N/A+ gtk_window_set_transient_for(GTK_WINDOW(sTipWindow),
20829N/A+ GTK_WINDOW(toplevel_window));
20829N/A+
20829N/A+ // realize the widget
20829N/A+ gtk_widget_realize(sTipWindow);
20829N/A+
20829N/A+ g_signal_connect(G_OBJECT(sTipWindow), "expose_event",
20829N/A+ G_CALLBACK(tooltips_paint_window), NULL);
20829N/A+
20829N/A+ // set up the label for the tooltip
20829N/A+ GtkWidget *label = gtk_label_new(tipString);
20829N/A+ // wrap automatically
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
20829N/A+ gtk_container_add(GTK_CONTAINER(sTipWindow), label);
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(sTipWindow), 4);
20829N/A+ // set the coords for the widget
20829N/A+ gtk_widget_set_uposition(sTipWindow, aXCoords + root_x,
20829N/A+ aYCoords + root_y);
20829N/A+
20829N/A+ // and show it.
20829N/A+ gtk_widget_show_all(sTipWindow);
20829N/A+
20829N/A+ NS_Free( (void*)tipString );
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::OnHideTooltip(void)
20829N/A+{
20829N/A+ if (sTipWindow)
20829N/A+ gtk_widget_destroy(sTipWindow);
20829N/A+ sTipWindow = NULL;
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+// nsIInterfaceRequestor
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindow::GetInterface(const nsIID &aIID, void** aInstancePtr)
20829N/A+{
20829N/A+ nsresult rv;
20829N/A+
20829N/A+ rv = QueryInterface(aIID, aInstancePtr);
20829N/A+
20829N/A+ // pass it up to the web browser object
20829N/A+ if (NS_FAILED(rv) || !*aInstancePtr) {
20829N/A+ nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(mWebBrowser);
20829N/A+ return ir->GetInterface(aIID, aInstancePtr);
20829N/A+ }
20829N/A+
20829N/A+ return rv;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedWindow.h b/embedding/browser/gtk/src/EmbedWindow.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedWindow.h
20829N/A@@ -0,0 +1,101 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedWindow_h
20829N/A+#define __EmbedWindow_h
20829N/A+
20829N/A+#include "nsIWebBrowserChrome.h"
20829N/A+#include "nsIWebBrowserChromeFocus.h"
20829N/A+#include "nsIEmbeddingSiteWindow.h"
20829N/A+#include "nsITooltipListener.h"
20829N/A+#include "nsISupports.h"
20829N/A+#include "nsIWebBrowser.h"
20829N/A+#include "nsIBaseWindow.h"
20829N/A+#include "nsIInterfaceRequestor.h"
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsStringGlue.h"
20829N/A+
20829N/A+#include <gtk/gtk.h>
20829N/A+
20829N/A+class EmbedPrivate;
20829N/A+
20829N/A+class EmbedWindow : public nsIWebBrowserChrome,
20829N/A+ public nsIWebBrowserChromeFocus,
20829N/A+ public nsIEmbeddingSiteWindow,
20829N/A+ public nsITooltipListener,
20829N/A+ public nsIInterfaceRequestor
20829N/A+{
20829N/A+
20829N/A+ public:
20829N/A+
20829N/A+ EmbedWindow();
20829N/A+ virtual ~EmbedWindow();
20829N/A+
20829N/A+ nsresult Init (EmbedPrivate *aOwner);
20829N/A+ nsresult CreateWindow (void);
20829N/A+ void ReleaseChildren (void);
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+
20829N/A+ NS_DECL_NSIWEBBROWSERCHROME
20829N/A+
20829N/A+ NS_DECL_NSIWEBBROWSERCHROMEFOCUS
20829N/A+
20829N/A+ NS_DECL_NSIEMBEDDINGSITEWINDOW
20829N/A+
20829N/A+ NS_DECL_NSITOOLTIPLISTENER
20829N/A+
20829N/A+ NS_DECL_NSIINTERFACEREQUESTOR
20829N/A+
20829N/A+ nsString mTitle;
20829N/A+ nsString mJSStatus;
20829N/A+ nsString mLinkMessage;
20829N/A+
20829N/A+ nsCOMPtr<nsIBaseWindow> mBaseWindow; // [OWNER]
20829N/A+
20829N/A+private:
20829N/A+
20829N/A+ EmbedPrivate *mOwner;
20829N/A+ nsCOMPtr<nsIWebBrowser> mWebBrowser; // [OWNER]
20829N/A+ static GtkWidget *sTipWindow;
20829N/A+ PRBool mVisibility;
20829N/A+ PRBool mIsModal;
20829N/A+
20829N/A+};
20829N/A+
20829N/A+
20829N/A+#endif /* __EmbedWindow_h */
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedWindowCreator.cpp b/embedding/browser/gtk/src/EmbedWindowCreator.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedWindowCreator.cpp
20829N/A@@ -0,0 +1,106 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "EmbedWindowCreator.h"
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include "EmbedWindow.h"
20829N/A+
20829N/A+// in order to create orphaned windows
20829N/A+#include "gtkmozembedprivate.h"
20829N/A+
20829N/A+EmbedWindowCreator::EmbedWindowCreator(void)
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+EmbedWindowCreator::~EmbedWindowCreator()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ISUPPORTS1(EmbedWindowCreator, nsIWindowCreator)
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
20829N/A+ PRUint32 aChromeFlags,
20829N/A+ nsIWebBrowserChrome **_retval)
20829N/A+{
20829N/A+ NS_ENSURE_ARG_POINTER(_retval);
20829N/A+
20829N/A+ GtkMozEmbed *newEmbed = nsnull;
20829N/A+
20829N/A+ // No parent? Ask via the singleton object instead.
20829N/A+ if (!aParent) {
20829N/A+ gtk_moz_embed_single_create_window(&newEmbed,
20829N/A+ (guint)aChromeFlags);
20829N/A+ }
20829N/A+ else {
20829N/A+ // Find the EmbedPrivate object for this web browser chrome object.
20829N/A+ EmbedPrivate *embedPrivate = EmbedPrivate::FindPrivateForBrowser(aParent);
20829N/A+
20829N/A+ if (!embedPrivate)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ g_signal_emit(G_OBJECT(embedPrivate->mOwningWidget),
20829N/A+ moz_embed_signals[NEW_WINDOW], 0,
20829N/A+ &newEmbed, (guint)aChromeFlags);
20829N/A+
20829N/A+ }
20829N/A+
20829N/A+ // check to make sure that we made a new window
20829N/A+ if (!newEmbed)
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+
20829N/A+ // The window _must_ be realized before we pass it back to the
20829N/A+ // function that created it. Functions that create new windows
20829N/A+ // will do things like GetDocShell() and the widget has to be
20829N/A+ // realized before that can happen.
20829N/A+ gtk_widget_realize(GTK_WIDGET(newEmbed));
20829N/A+
20829N/A+ EmbedPrivate *newEmbedPrivate = static_cast<EmbedPrivate *>(newEmbed->data);
20829N/A+
20829N/A+ // set the chrome flag on the new window if it's a chrome open
20829N/A+ if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
20829N/A+ newEmbedPrivate->mIsChrome = PR_TRUE;
20829N/A+
20829N/A+ *_retval = static_cast<nsIWebBrowserChrome *>(newEmbedPrivate->mWindow);
20829N/A+
20829N/A+ if (*_retval) {
20829N/A+ NS_ADDREF(*_retval);
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+
20829N/A+ return NS_ERROR_FAILURE;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/EmbedWindowCreator.h b/embedding/browser/gtk/src/EmbedWindowCreator.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/EmbedWindowCreator.h
20829N/A@@ -0,0 +1,54 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef __EmbedWindowCreator_h
20829N/A+#define __EmbedWindowCreator_h
20829N/A+
20829N/A+#include <nsIWindowCreator.h>
20829N/A+
20829N/A+class EmbedWindowCreator : public nsIWindowCreator
20829N/A+{
20829N/A+ public:
20829N/A+ EmbedWindowCreator();
20829N/A+ virtual ~EmbedWindowCreator();
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+ NS_DECL_NSIWINDOWCREATOR
20829N/A+
20829N/A+};
20829N/A+
20829N/A+#endif /* __EmbedWindowCreator_h */
20829N/Adiff --git a/embedding/browser/gtk/src/GtkPromptService.cpp b/embedding/browser/gtk/src/GtkPromptService.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/GtkPromptService.cpp
20829N/A@@ -0,0 +1,349 @@
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "GtkPromptService.h"
20829N/A+#include "EmbedPrompter.h"
20829N/A+#include "nsStringGlue.h"
20829N/A+#include "nsIWindowWatcher.h"
20829N/A+#include "nsIWebBrowserChrome.h"
20829N/A+#include "nsIEmbeddingSiteWindow.h"
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsIServiceManager.h"
20829N/A+#include "nsServiceManagerUtils.h"
20829N/A+
20829N/A+GtkPromptService::GtkPromptService()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+GtkPromptService::~GtkPromptService()
20829N/A+{
20829N/A+}
20829N/A+
20829N/A+NS_IMPL_ISUPPORTS1(GtkPromptService, nsIPromptService)
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::Alert(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.Create(EmbedPrompter::TYPE_ALERT,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::AlertCheck(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue)
20829N/A+{
20829N/A+ NS_ENSURE_ARG_POINTER(aCheckValue);
20829N/A+
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+ prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::Confirm(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRBool* aConfirm)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.Create(EmbedPrompter::TYPE_CONFIRM,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::ConfirmCheck(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText,
20829N/A+ const PRUnichar* aCheckMsg,
20829N/A+ PRBool* aCheckValue, PRBool* aConfirm)
20829N/A+{
20829N/A+ NS_ENSURE_ARG_POINTER(aCheckValue);
20829N/A+
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+ prompter.Create(EmbedPrompter::TYPE_CONFIRM_CHECK,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::ConfirmEx(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText,
20829N/A+ PRUint32 aButtonFlags,
20829N/A+ const PRUnichar* aButton0Title,
20829N/A+ const PRUnichar* aButton1Title,
20829N/A+ const PRUnichar* aButton2Title,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue,
20829N/A+ PRInt32* aRetVal)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+
20829N/A+ nsAutoString button0Label, button1Label, button2Label;
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
20829N/A+ prompter.SetButtons(button0Label.get(), button1Label.get(),
20829N/A+ button2Label.get());
20829N/A+
20829N/A+ if (aCheckMsg)
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ if (aCheckValue)
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+
20829N/A+ prompter.Create(EmbedPrompter::TYPE_UNIVERSAL,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+
20829N/A+ if (aCheckValue)
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+
20829N/A+ prompter.GetButtonPressed(aRetVal);
20829N/A+
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::Prompt(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRUnichar** aValue,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue,
20829N/A+ PRBool* aConfirm)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetTextValue(*aValue);
20829N/A+ if (aCheckMsg)
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ if (aCheckValue)
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+
20829N/A+ prompter.Create(EmbedPrompter::TYPE_PROMPT,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ if (aCheckValue)
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ if (*aConfirm) {
20829N/A+ if (*aValue)
20829N/A+ NS_Free(*aValue);
20829N/A+ prompter.GetTextValue(aValue);
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::PromptUsernameAndPassword(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText,
20829N/A+ PRUnichar** aUsername,
20829N/A+ PRUnichar** aPassword,
20829N/A+ const PRUnichar* aCheckMsg,
20829N/A+ PRBool* aCheckValue,
20829N/A+ PRBool* aConfirm)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetUser(*aUsername);
20829N/A+ prompter.SetPassword(*aPassword);
20829N/A+ if (aCheckMsg)
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ if (aCheckValue)
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+
20829N/A+ prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ if (aCheckValue)
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ if (*aConfirm) {
20829N/A+ if (*aUsername)
20829N/A+ NS_Free(*aUsername);
20829N/A+ prompter.GetUser(aUsername);
20829N/A+
20829N/A+ if (*aPassword)
20829N/A+ NS_Free(*aPassword);
20829N/A+ prompter.GetPassword(aPassword);
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::PromptPassword(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText,
20829N/A+ PRUnichar** aPassword,
20829N/A+ const PRUnichar* aCheckMsg,
20829N/A+ PRBool* aCheckValue, PRBool* aConfirm)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetPassword(*aPassword);
20829N/A+ if (aCheckMsg)
20829N/A+ prompter.SetCheckMessage(aCheckMsg);
20829N/A+ if (aCheckValue)
20829N/A+ prompter.SetCheckValue(*aCheckValue);
20829N/A+
20829N/A+ prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ if (aCheckValue)
20829N/A+ prompter.GetCheckValue(aCheckValue);
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ if (*aConfirm) {
20829N/A+ if (*aPassword)
20829N/A+ NS_Free(*aPassword);
20829N/A+ prompter.GetPassword(aPassword);
20829N/A+ }
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+NS_IMETHODIMP
20829N/A+GtkPromptService::Select(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRUint32 aCount,
20829N/A+ const PRUnichar** aSelectList, PRInt32* outSelection,
20829N/A+ PRBool* aConfirm)
20829N/A+{
20829N/A+ EmbedPrompter prompter;
20829N/A+ prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Select").get());
20829N/A+ prompter.SetMessageText(aDialogText);
20829N/A+ prompter.SetItems(aSelectList, aCount);
20829N/A+ prompter.Create(EmbedPrompter::TYPE_SELECT,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+ prompter.Run();
20829N/A+ prompter.GetSelectedItem(outSelection);
20829N/A+ prompter.GetConfirmValue(aConfirm);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+GtkWindow*
20829N/A+GtkPromptService::GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+{
20829N/A+ nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
20829N/A+
20829N/A+ if (!aDOMWindow)
20829N/A+ return NULL;
20829N/A+
20829N/A+ nsCOMPtr<nsIWebBrowserChrome> chrome;
20829N/A+ wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
20829N/A+ nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = do_QueryInterface(chrome);
20829N/A+
20829N/A+ if (!siteWindow)
20829N/A+ return NULL;
20829N/A+
20829N/A+ GtkWidget* parentWidget;
20829N/A+ siteWindow->GetSiteWindow((void**)&parentWidget);
20829N/A+
20829N/A+ if (!parentWidget)
20829N/A+ return NULL;
20829N/A+
20829N/A+ GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
20829N/A+ if (GTK_WIDGET_TOPLEVEL(gtkWin))
20829N/A+ return GTK_WINDOW(gtkWin);
20829N/A+
20829N/A+ return NULL;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+GtkPromptService::GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
20829N/A+ const PRUnichar* aStringValue,
20829N/A+ nsAString& aLabel)
20829N/A+{
20829N/A+ PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
20829N/A+ switch (posFlag) {
20829N/A+ case 0:
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_OK:
20829N/A+ aLabel.AssignLiteral(GTK_STOCK_OK);
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_CANCEL:
20829N/A+ aLabel.AssignLiteral(GTK_STOCK_CANCEL);
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_YES:
20829N/A+ aLabel.AssignLiteral(GTK_STOCK_YES);
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_NO:
20829N/A+ aLabel.AssignLiteral(GTK_STOCK_NO);
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_SAVE:
20829N/A+ aLabel.AssignLiteral(GTK_STOCK_SAVE);
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_DONT_SAVE:
20829N/A+ aLabel.AssignLiteral("Don't Save");
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_REVERT:
20829N/A+ aLabel.AssignLiteral("Revert");
20829N/A+ break;
20829N/A+ case BUTTON_TITLE_IS_STRING:
20829N/A+ aLabel = aStringValue;
20829N/A+ break;
20829N/A+ default:
20829N/A+ NS_WARNING("Unexpected button flags");
20829N/A+ }
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/GtkPromptService.h b/embedding/browser/gtk/src/GtkPromptService.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/GtkPromptService.h
20829N/A@@ -0,0 +1,59 @@
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "nsIPromptService.h"
20829N/A+#include "nsStringGlue.h"
20829N/A+#include <gtk/gtk.h>
20829N/A+
20829N/A+class nsIDOMWindow;
20829N/A+
20829N/A+class GtkPromptService : public nsIPromptService
20829N/A+{
20829N/A+public:
20829N/A+ GtkPromptService();
20829N/A+ virtual ~GtkPromptService();
20829N/A+
20829N/A+ NS_DECL_ISUPPORTS
20829N/A+ NS_DECL_NSIPROMPTSERVICE
20829N/A+
20829N/A+private:
20829N/A+ GtkWindow* GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+ void GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
20829N/A+ const PRUnichar* aStringValue, nsAString &aLabel);
20829N/A+};
20829N/Adiff --git a/embedding/browser/gtk/src/Makefile.in b/embedding/browser/gtk/src/Makefile.in
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/Makefile.in
20829N/A@@ -0,0 +1,112 @@
20829N/A+#
20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+#
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# http://www.mozilla.org/MPL/
20829N/A+#
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# License.
20829N/A+#
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+#
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Christopher Blizzard.
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+#
20829N/A+# Contributor(s):
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+#
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+#
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+
20829N/A+DEPTH = ../../../..
20829N/A+topsrcdir = @top_srcdir@
20829N/A+srcdir = @srcdir@
20829N/A+VPATH = @srcdir@
20829N/A+
20829N/A+include $(DEPTH)/config/autoconf.mk
20829N/A+
20829N/A+MODULE = gtkembedmoz
20829N/A+LIBRARY_NAME = gtkembedmoz
20829N/A+LIBXUL_LIBRARY = 1
20829N/A+FORCE_STATIC_LIB = 1
20829N/A+DEFINES += -DIMPL_XREAPI
20829N/A+
20829N/A+
20829N/A+
20829N/A+CPPSRCS = \
20829N/A+ gtkmozembed2.cpp \
20829N/A+ EmbedPrivate.cpp \
20829N/A+ EmbedWindow.cpp \
20829N/A+ EmbedProgress.cpp \
20829N/A+ EmbedContentListener.cpp \
20829N/A+ EmbedEventListener.cpp \
20829N/A+ EmbedWindowCreator.cpp \
20829N/A+ $(NULL)
20829N/A+
20829N/A+ifdef MOZ_ENABLE_GTK2
20829N/A+CSRCS = \
20829N/A+ gtkmozembedmarshal.c
20829N/A+CPPSRCS += \
20829N/A+ EmbedPrompter.cpp \
20829N/A+ GtkPromptService.cpp
20829N/A+endif
20829N/A+
20829N/A+LOCAL_INCLUDES += \
20829N/A+ -I. \
20829N/A+ $(NULL)
20829N/A+
20829N/A+include $(topsrcdir)/config/config.mk
20829N/A+
20829N/A+EXPORTS = \
20829N/A+ gtkmozembed.h \
20829N/A+ gtkmozembed_glue.cpp \
20829N/A+ gtkmozembed_internal.h
20829N/A+
20829N/A+include $(topsrcdir)/config/rules.mk
20829N/A+
20829N/A+ifeq ($(OS_ARCH), SunOS)
20829N/A+ifndef GNU_CC
20829N/A+# When using Sun's WorkShop compiler, including
20829N/A+# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
20829N/A+# causes most of these compiles to fail with:
20829N/A+# line 29: Error: Multiple declaration for std::tm.
20829N/A+# So, this gets around the problem.
20829N/A+DEFINES += -D_TIME_H=1
20829N/A+endif
20829N/A+endif
20829N/A+
20829N/A+CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
20829N/A+CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
20829N/A+DEFINES += -D_IMPL_GTKMOZEMBED
20829N/A+
20829N/A+MARSHAL_FILE = gtkmozembedmarshal
20829N/A+MARSHAL_PREFIX = gtkmozembed
20829N/A+
20829N/A+$(MARSHAL_FILE).h: $(MARSHAL_FILE).list
20829N/A+ glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --header > $@
20829N/A+
20829N/A+$(MARSHAL_FILE).c: $(MARSHAL_FILE).list $(MARSHAL_FILE).h
20829N/A+ glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --body > $@
20829N/A+
20829N/A+gtkmozembed2.$(OBJ_SUFFIX): $(MARSHAL_FILE).h
20829N/A+
20829N/A+GARBAGE += $(MARSHAL_FILE).h $(MARSHAL_FILE).c
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembed.h b/embedding/browser/gtk/src/gtkmozembed.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembed.h
20829N/A@@ -0,0 +1,287 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Ramiro Estrugo <ramiro@eazel.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef gtkmozembed_h
20829N/A+#define gtkmozembed_h
20829N/A+
20829N/A+#include <stddef.h>
20829N/A+#include <gtk/gtk.h>
20829N/A+
20829N/A+#ifdef MOZILLA_CLIENT
20829N/A+#include "nscore.h"
20829N/A+#else /* MOZILLA_CLIENT */
20829N/A+#ifndef nscore_h__
20829N/A+/* Because this header may be included from files which not part of the mozilla
20829N/A+ build system, define macros from nscore.h */
20829N/A+
20829N/A+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
20829N/A+#define NS_HIDDEN __attribute__((visibility("hidden")))
20829N/A+#else
20829N/A+#define NS_HIDDEN
20829N/A+#endif
20829N/A+
20829N/A+#define NS_FROZENCALL
20829N/A+#define NS_EXPORT_(type) type
20829N/A+#define NS_IMPORT_(type) type
20829N/A+#endif /* nscore_h__ */
20829N/A+#endif /* MOZILLA_CLIENT */
20829N/A+
20829N/A+#ifdef XPCOM_GLUE
20829N/A+
20829N/A+#define GTKMOZEMBED_API(type, name, params) \
20829N/A+ typedef type (NS_FROZENCALL * name##Type) params; \
20829N/A+ extern name##Type name NS_HIDDEN;
20829N/A+
20829N/A+#else /* XPCOM_GLUE */
20829N/A+
20829N/A+#ifdef _IMPL_GTKMOZEMBED
20829N/A+#define GTKMOZEMBED_API(type, name, params) NS_EXPORT_(type) name params;
20829N/A+#else
20829N/A+#define GTKMOZEMBED_API(type,name, params) NS_IMPORT_(type) name params;
20829N/A+#endif
20829N/A+
20829N/A+#endif /* XPCOM_GLUE */
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+extern "C" {
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+#define GTK_TYPE_MOZ_EMBED (gtk_moz_embed_get_type())
20829N/A+#define GTK_MOZ_EMBED(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MOZ_EMBED, GtkMozEmbed)
20829N/A+#define GTK_MOZ_EMBED_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED, GtkMozEmbedClass)
20829N/A+#define GTK_IS_MOZ_EMBED(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_MOZ_EMBED)
20829N/A+#define GTK_IS_MOZ_EMBED_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED)
20829N/A+
20829N/A+typedef struct _GtkMozEmbed GtkMozEmbed;
20829N/A+typedef struct _GtkMozEmbedClass GtkMozEmbedClass;
20829N/A+
20829N/A+struct _GtkMozEmbed
20829N/A+{
20829N/A+ GtkBin bin;
20829N/A+ void *data;
20829N/A+};
20829N/A+
20829N/A+struct _GtkMozEmbedClass
20829N/A+{
20829N/A+ GtkBinClass parent_class;
20829N/A+
20829N/A+ void (* link_message) (GtkMozEmbed *embed);
20829N/A+ void (* js_status) (GtkMozEmbed *embed);
20829N/A+ void (* location) (GtkMozEmbed *embed);
20829N/A+ void (* title) (GtkMozEmbed *embed);
20829N/A+ void (* progress) (GtkMozEmbed *embed, gint curprogress,
20829N/A+ gint maxprogress);
20829N/A+ void (* progress_all) (GtkMozEmbed *embed, const char *aURI,
20829N/A+ gint curprogress, gint maxprogress);
20829N/A+ void (* net_state) (GtkMozEmbed *embed, gint state, guint status);
20829N/A+ void (* net_state_all) (GtkMozEmbed *embed, const char *aURI,
20829N/A+ gint state, guint status);
20829N/A+ void (* net_start) (GtkMozEmbed *embed);
20829N/A+ void (* net_stop) (GtkMozEmbed *embed);
20829N/A+ void (* new_window) (GtkMozEmbed *embed, GtkMozEmbed **newEmbed,
20829N/A+ guint chromemask);
20829N/A+ void (* visibility) (GtkMozEmbed *embed, gboolean visibility);
20829N/A+ void (* destroy_brsr) (GtkMozEmbed *embed);
20829N/A+ gint (* open_uri) (GtkMozEmbed *embed, const char *aURI);
20829N/A+ void (* size_to) (GtkMozEmbed *embed, gint width, gint height);
20829N/A+ gint (* dom_key_down) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_key_press) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_key_up) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_down) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_up) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_click) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_dbl_click) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_over) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_out) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ void (* security_change) (GtkMozEmbed *embed, gpointer request,
20829N/A+ guint state);
20829N/A+ void (* status_change) (GtkMozEmbed *embed, gpointer request,
20829N/A+ gint status, gpointer message);
20829N/A+ gint (* dom_activate) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_focus_in) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_focus_out) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+};
20829N/A+
20829N/A+GTKMOZEMBED_API(GType, gtk_moz_embed_get_type, (void))
20829N/A+GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
20829N/A+
20829N/A+/* Tell gtkmozembed where the gtkmozembed libs live. If this is not specified,
20829N/A+ The MOZILLA_FIVE_HOME environment variable is checked. */
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
20829N/A+
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir,
20829N/A+ const char *aName))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed,
20829N/A+ const char *url))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed,
20829N/A+ const char *data,
20829N/A+ guint32 len,
20829N/A+ const char *base_uri,
20829N/A+ const char *mime_type))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
20829N/A+ const char *base_uri,
20829N/A+ const char *mime_type))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
20829N/A+ const char *data,
20829N/A+ guint32 len))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed,
20829N/A+ gint32 flags))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed,
20829N/A+ guint32 flags))
20829N/A+GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
20829N/A+
20829N/A+/* These are straight out of nsIWebProgressListener.h */
20829N/A+
20829N/A+typedef enum
20829N/A+{
20829N/A+ GTK_MOZ_EMBED_FLAG_START = 1,
20829N/A+ GTK_MOZ_EMBED_FLAG_REDIRECTING = 2,
20829N/A+ GTK_MOZ_EMBED_FLAG_TRANSFERRING = 4,
20829N/A+ GTK_MOZ_EMBED_FLAG_NEGOTIATING = 8,
20829N/A+ GTK_MOZ_EMBED_FLAG_STOP = 16,
20829N/A+
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_REQUEST = 65536,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_DOCUMENT = 131072,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_NETWORK = 262144,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_WINDOW = 524288,
20829N/A+
20829N/A+ GTK_MOZ_EMBED_FLAG_RESTORING = 16777216
20829N/A+} GtkMozEmbedProgressFlags;
20829N/A+
20829N/A+/* These are from various networking headers */
20829N/A+
20829N/A+typedef enum
20829N/A+{
20829N/A+ /* NS_ERROR_UNKNOWN_HOST */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_DNS = 2152398878U,
20829N/A+ /* NS_ERROR_CONNECTION_REFUSED */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_CONNECT = 2152398861U,
20829N/A+ /* NS_ERROR_NET_TIMEOUT */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT = 2152398862U,
20829N/A+ /* NS_BINDING_ABORTED */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U
20829N/A+} GtkMozEmbedStatusFlags;
20829N/A+
20829N/A+/* These used to be straight out of nsIWebNavigation.h until the API
20829N/A+ changed. Now there's a mapping table that maps these values to the
20829N/A+ internal values. */
20829N/A+
20829N/A+typedef enum
20829N/A+{
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADNORMAL = 0,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE = 1,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY = 2,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE = 3,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE = 4
20829N/A+} GtkMozEmbedReloadFlags;
20829N/A+
20829N/A+/* These are straight out of nsIWebBrowserChrome.h */
20829N/A+
20829N/A+typedef enum
20829N/A+{
20829N/A+ GTK_MOZ_EMBED_FLAG_DEFAULTCHROME = 1U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON = 2U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON = 4U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON = 8U,
20829N/A+ GTK_MOZ_EMBED_FLAG_MENUBARON = 16U,
20829N/A+ GTK_MOZ_EMBED_FLAG_TOOLBARON = 32U,
20829N/A+ GTK_MOZ_EMBED_FLAG_LOCATIONBARON = 64U,
20829N/A+ GTK_MOZ_EMBED_FLAG_STATUSBARON = 128U,
20829N/A+ GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON = 256U,
20829N/A+ GTK_MOZ_EMBED_FLAG_SCROLLBARSON = 512U,
20829N/A+ GTK_MOZ_EMBED_FLAG_TITLEBARON = 1024U,
20829N/A+ GTK_MOZ_EMBED_FLAG_EXTRACHROMEON = 2048U,
20829N/A+ GTK_MOZ_EMBED_FLAG_ALLCHROME = 4094U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWRAISED = 33554432U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWLOWERED = 67108864U,
20829N/A+ GTK_MOZ_EMBED_FLAG_CENTERSCREEN = 134217728U,
20829N/A+ GTK_MOZ_EMBED_FLAG_DEPENDENT = 268435456U,
20829N/A+ GTK_MOZ_EMBED_FLAG_MODAL = 536870912U,
20829N/A+ GTK_MOZ_EMBED_FLAG_OPENASDIALOG = 1073741824U,
20829N/A+ GTK_MOZ_EMBED_FLAG_OPENASCHROME = 2147483648U
20829N/A+} GtkMozEmbedChromeFlags;
20829N/A+
20829N/A+/* this is a singleton object that you can hook up to to get signals
20829N/A+ that are not handed out on a per widget basis. */
20829N/A+
20829N/A+#define GTK_TYPE_MOZ_EMBED_SINGLE (gtk_moz_embed_single_get_type())
20829N/A+#define GTK_MOZ_EMBED_SINGLE(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingle)
20829N/A+#define GTK_MOZ_EMBED_SINGLE_CLASS(klass) GTK_CHEK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingleClass)
20829N/A+#define GTK_IS_MOZ_EMBED_SINGLE(obj) GTK_CHECK_TYPE((obj), GTK_TYPE_MOZ_EMBED_SINGLE)
20829N/A+#define GTK_IS_MOZ_EMBED_SINGLE_CLASS(klass) GTK_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED)
20829N/A+#define GTK_MOZ_EMBED_SINGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingleClass))
20829N/A+
20829N/A+typedef struct _GtkMozEmbedSingle GtkMozEmbedSingle;
20829N/A+typedef struct _GtkMozEmbedSingleClass GtkMozEmbedSingleClass;
20829N/A+
20829N/A+struct _GtkMozEmbedSingle
20829N/A+{
20829N/A+ GtkObject object;
20829N/A+ void *data;
20829N/A+};
20829N/A+
20829N/A+struct _GtkMozEmbedSingleClass
20829N/A+{
20829N/A+ GtkObjectClass parent_class;
20829N/A+
20829N/A+ void (* new_window_orphan) (GtkMozEmbedSingle *embed,
20829N/A+ GtkMozEmbed **newEmbed,
20829N/A+ guint chromemask);
20829N/A+};
20829N/A+
20829N/A+GTKMOZEMBED_API(GType, gtk_moz_embed_single_get_type, (void))
20829N/A+GTKMOZEMBED_API(GtkMozEmbedSingle *, gtk_moz_embed_single_get, (void))
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+}
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+#endif /* gtkmozembed_h */
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembed2.cpp b/embedding/browser/gtk/src/gtkmozembed2.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembed2.cpp
20829N/A@@ -0,0 +1,1132 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Ramiro Estrugo <ramiro@eazel.com>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include <stdio.h>
20829N/A+
20829N/A+#include "gtkmozembed.h"
20829N/A+#include "gtkmozembedprivate.h"
20829N/A+#include "gtkmozembed_internal.h"
20829N/A+
20829N/A+#include "EmbedPrivate.h"
20829N/A+#include "EmbedWindow.h"
20829N/A+
20829N/A+// so we can do our get_nsIWebBrowser later...
20829N/A+#include "nsIWebBrowser.h"
20829N/A+
20829N/A+#include "gtkmozembedmarshal.h"
20829N/A+
20829N/A+#define NEW_TOOLKIT_STRING(x) g_strdup(NS_ConvertUTF16toUTF8(x).get())
20829N/A+#define GET_OBJECT_CLASS_TYPE(x) G_OBJECT_CLASS_TYPE(x)
20829N/A+
20829N/A+class nsIDirectoryServiceProvider;
20829N/A+
20829N/A+// class and instance initialization
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_class_init(GtkMozEmbedClass *klass);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_init(GtkMozEmbed *embed);
20829N/A+
20829N/A+// GtkObject methods
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_destroy(GtkObject *object);
20829N/A+
20829N/A+// GtkWidget methods
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_realize(GtkWidget *widget);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_unrealize(GtkWidget *widget);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_map(GtkWidget *widget);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_unmap(GtkWidget *widget);
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+static AtkObject* gtk_moz_embed_get_accessible (GtkWidget *widget);
20829N/A+#endif
20829N/A+
20829N/A+static gint
20829N/A+handle_child_focus_in(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ GtkMozEmbed *aEmbed);
20829N/A+
20829N/A+static gint
20829N/A+handle_child_focus_out(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ GtkMozEmbed *aEmbed);
20829N/A+
20829N/A+// globals for this type of widget
20829N/A+
20829N/A+static GtkBinClass *embed_parent_class;
20829N/A+
20829N/A+guint moz_embed_signals[EMBED_LAST_SIGNAL] = { 0 };
20829N/A+
20829N/A+// GtkObject + class-related functions
20829N/A+
20829N/A+GType
20829N/A+gtk_moz_embed_get_type(void)
20829N/A+{
20829N/A+ static GType moz_embed_type = 0;
20829N/A+ if (moz_embed_type == 0)
20829N/A+ {
20829N/A+ const GTypeInfo our_info =
20829N/A+ {
20829N/A+ sizeof(GtkMozEmbedClass),
20829N/A+ NULL, /* base_init */
20829N/A+ NULL, /* base_finalize */
20829N/A+ (GClassInitFunc)gtk_moz_embed_class_init,
20829N/A+ NULL,
20829N/A+ NULL, /* class_data */
20829N/A+ sizeof(GtkMozEmbed),
20829N/A+ 0, /* n_preallocs */
20829N/A+ (GInstanceInitFunc)gtk_moz_embed_init,
20829N/A+ };
20829N/A+
20829N/A+ moz_embed_type = g_type_register_static(GTK_TYPE_BIN,
20829N/A+ "GtkMozEmbed",
20829N/A+ &our_info,
20829N/A+ (GTypeFlags)0);
20829N/A+ }
20829N/A+
20829N/A+ return moz_embed_type;
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_class_init(GtkMozEmbedClass *klass)
20829N/A+{
20829N/A+ GtkContainerClass *container_class;
20829N/A+ GtkWidgetClass *widget_class;
20829N/A+ GtkObjectClass *object_class;
20829N/A+
20829N/A+ container_class = GTK_CONTAINER_CLASS(klass);
20829N/A+ widget_class = GTK_WIDGET_CLASS(klass);
20829N/A+ object_class = GTK_OBJECT_CLASS(klass);
20829N/A+
20829N/A+ embed_parent_class = (GtkBinClass *)g_type_class_peek(gtk_bin_get_type());
20829N/A+
20829N/A+ widget_class->realize = gtk_moz_embed_realize;
20829N/A+ widget_class->unrealize = gtk_moz_embed_unrealize;
20829N/A+ widget_class->size_allocate = gtk_moz_embed_size_allocate;
20829N/A+ widget_class->map = gtk_moz_embed_map;
20829N/A+ widget_class->unmap = gtk_moz_embed_unmap;
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+ widget_class->get_accessible = gtk_moz_embed_get_accessible;
20829N/A+#endif
20829N/A+
20829N/A+ object_class->destroy = gtk_moz_embed_destroy;
20829N/A+
20829N/A+ // set up our signals
20829N/A+
20829N/A+ moz_embed_signals[LINK_MESSAGE] =
20829N/A+ g_signal_new("link_message",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, link_message),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[JS_STATUS] =
20829N/A+ g_signal_new("js_status",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, js_status),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[LOCATION] =
20829N/A+ g_signal_new("location",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, location),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[TITLE] =
20829N/A+ g_signal_new("title",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, title),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[PROGRESS] =
20829N/A+ g_signal_new("progress",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, progress),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__INT_INT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
20829N/A+ moz_embed_signals[PROGRESS_ALL] =
20829N/A+ g_signal_new("progress_all",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, progress_all),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__STRING_INT_INT,
20829N/A+ G_TYPE_NONE, 3,
20829N/A+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
20829N/A+ G_TYPE_INT, G_TYPE_INT);
20829N/A+ moz_embed_signals[NET_STATE] =
20829N/A+ g_signal_new("net_state",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_state),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__INT_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT);
20829N/A+ moz_embed_signals[NET_STATE_ALL] =
20829N/A+ g_signal_new("net_state_all",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_state_all),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__STRING_INT_UINT,
20829N/A+ G_TYPE_NONE, 3,
20829N/A+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
20829N/A+ G_TYPE_INT, G_TYPE_UINT);
20829N/A+ moz_embed_signals[NET_START] =
20829N/A+ g_signal_new("net_start",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_start),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[NET_STOP] =
20829N/A+ g_signal_new("net_stop",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_stop),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[NEW_WINDOW] =
20829N/A+ g_signal_new("new_window",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, new_window),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+ moz_embed_signals[VISIBILITY] =
20829N/A+ g_signal_new("visibility",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, visibility),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__BOOLEAN,
20829N/A+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
20829N/A+ moz_embed_signals[DESTROY_BROWSER] =
20829N/A+ g_signal_new("destroy_browser",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, destroy_brsr),
20829N/A+ NULL, NULL,
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_TYPE_NONE, 0);
20829N/A+ moz_embed_signals[OPEN_URI] =
20829N/A+ g_signal_new("open_uri",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, open_uri),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__STRING,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_STRING |
20829N/A+ G_SIGNAL_TYPE_STATIC_SCOPE);
20829N/A+ moz_embed_signals[SIZE_TO] =
20829N/A+ g_signal_new("size_to",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, size_to),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__INT_INT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
20829N/A+ moz_embed_signals[DOM_KEY_DOWN] =
20829N/A+ g_signal_new("dom_key_down",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_down),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_KEY_PRESS] =
20829N/A+ g_signal_new("dom_key_press",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_press),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_KEY_UP] =
20829N/A+ g_signal_new("dom_key_up",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_up),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_DOWN] =
20829N/A+ g_signal_new("dom_mouse_down",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_down),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_UP] =
20829N/A+ g_signal_new("dom_mouse_up",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_up),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_CLICK] =
20829N/A+ g_signal_new("dom_mouse_click",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_click),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_DBL_CLICK] =
20829N/A+ g_signal_new("dom_mouse_dbl_click",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_dbl_click),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_OVER] =
20829N/A+ g_signal_new("dom_mouse_over",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_over),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_OUT] =
20829N/A+ g_signal_new("dom_mouse_out",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_out),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[SECURITY_CHANGE] =
20829N/A+ g_signal_new("security_change",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, security_change),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+ moz_embed_signals[STATUS_CHANGE] =
20829N/A+ g_signal_new("status_change",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, status_change),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__POINTER_INT_POINTER,
20829N/A+ G_TYPE_NONE, 3,
20829N/A+ G_TYPE_POINTER, G_TYPE_INT, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_ACTIVATE] =
20829N/A+ g_signal_new("dom_activate",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_activate),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_FOCUS_IN] =
20829N/A+ g_signal_new("dom_focus_in",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_focus_in),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_FOCUS_OUT] =
20829N/A+ g_signal_new("dom_focus_out",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_LAST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_focus_out),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_BOOL__POINTER,
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_init(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *priv = new EmbedPrivate();
20829N/A+ embed->data = priv;
20829N/A+ gtk_widget_set_name(GTK_WIDGET(embed), "gtkmozembed");
20829N/A+
20829N/A+ GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(embed), GTK_NO_WINDOW);
20829N/A+}
20829N/A+
20829N/A+GtkWidget *
20829N/A+gtk_moz_embed_new(void)
20829N/A+{
20829N/A+ return GTK_WIDGET(g_object_new(GTK_TYPE_MOZ_EMBED, NULL));
20829N/A+}
20829N/A+
20829N/A+// GtkObject methods
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_destroy(GtkObject *object)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(object != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(object));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(object);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate) {
20829N/A+
20829N/A+ // Destroy the widget only if it's been Init()ed.
20829N/A+ if(embedPrivate->mMozWindowWidget != 0) {
20829N/A+ embedPrivate->Destroy();
20829N/A+ }
20829N/A+
20829N/A+ delete embedPrivate;
20829N/A+ embed->data = NULL;
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+// GtkWidget methods
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_realize(GtkWidget *widget)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+ GdkWindowAttr attributes;
20829N/A+ gint attributes_mask;
20829N/A+
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
20829N/A+
20829N/A+ attributes.window_type = GDK_WINDOW_CHILD;
20829N/A+ attributes.x = widget->allocation.x;
20829N/A+ attributes.y = widget->allocation.y;
20829N/A+ attributes.width = widget->allocation.width;
20829N/A+ attributes.height = widget->allocation.height;
20829N/A+ attributes.wclass = GDK_INPUT_OUTPUT;
20829N/A+ attributes.visual = gtk_widget_get_visual (widget);
20829N/A+ attributes.colormap = gtk_widget_get_colormap (widget);
20829N/A+ attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
20829N/A+
20829N/A+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
20829N/A+
20829N/A+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
20829N/A+ &attributes, attributes_mask);
20829N/A+ gdk_window_set_user_data (widget->window, embed);
20829N/A+
20829N/A+ widget->style = gtk_style_attach (widget->style, widget->window);
20829N/A+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
20829N/A+
20829N/A+ // initialize the window
20829N/A+ nsresult rv;
20829N/A+ rv = embedPrivate->Init(embed);
20829N/A+ g_return_if_fail(NS_SUCCEEDED(rv));
20829N/A+
20829N/A+ PRBool alreadyRealized = PR_FALSE;
20829N/A+ rv = embedPrivate->Realize(&alreadyRealized);
20829N/A+ g_return_if_fail(NS_SUCCEEDED(rv));
20829N/A+
20829N/A+ // if we're already realized we don't need to hook up to anything below
20829N/A+ if (alreadyRealized)
20829N/A+ return;
20829N/A+
20829N/A+ if (embedPrivate->mURI.Length())
20829N/A+ embedPrivate->LoadCurrentURI();
20829N/A+
20829N/A+ // connect to the focus out event for the child
20829N/A+ GtkWidget *child_widget = GTK_BIN(widget)->child;
20829N/A+ g_signal_connect_object(G_OBJECT(child_widget),
20829N/A+ "focus_out_event",
20829N/A+ G_CALLBACK(handle_child_focus_out),
20829N/A+ embed,
20829N/A+ G_CONNECT_AFTER);
20829N/A+ g_signal_connect_object(G_OBJECT(child_widget),
20829N/A+ "focus_in_event",
20829N/A+ G_CALLBACK(handle_child_focus_in),
20829N/A+ embed,
20829N/A+ G_CONNECT_AFTER);
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_unrealize(GtkWidget *widget)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate) {
20829N/A+ embedPrivate->Unrealize();
20829N/A+ }
20829N/A+
20829N/A+ if (GTK_WIDGET_CLASS(embed_parent_class)->unrealize)
20829N/A+ (* GTK_WIDGET_CLASS(embed_parent_class)->unrealize)(widget);
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ widget->allocation = *allocation;
20829N/A+
20829N/A+ if (GTK_WIDGET_REALIZED(widget))
20829N/A+ {
20829N/A+ gdk_window_move_resize(widget->window,
20829N/A+ allocation->x, allocation->y,
20829N/A+ allocation->width, allocation->height);
20829N/A+ embedPrivate->Resize(allocation->width, allocation->height);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_map(GtkWidget *widget)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
20829N/A+
20829N/A+ embedPrivate->Show();
20829N/A+
20829N/A+ gdk_window_show(widget->window);
20829N/A+
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_unmap(GtkWidget *widget)
20829N/A+{
20829N/A+ GtkMozEmbed *embed;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_MAPPED);
20829N/A+
20829N/A+ gdk_window_hide(widget->window);
20829N/A+
20829N/A+ embedPrivate->Hide();
20829N/A+}
20829N/A+
20829N/A+#ifdef MOZ_ACCESSIBILITY_ATK
20829N/A+static AtkObject*
20829N/A+gtk_moz_embed_get_accessible (GtkWidget *widget)
20829N/A+{
20829N/A+ g_return_val_if_fail(widget != NULL, NULL);
20829N/A+ g_return_val_if_fail(GTK_IS_MOZ_EMBED(widget), NULL);
20829N/A+
20829N/A+ GtkMozEmbed *embed = GTK_MOZ_EMBED(widget);;
20829N/A+ EmbedPrivate *embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ return static_cast<AtkObject *>(
20829N/A+ embedPrivate->GetAtkObjectForCurrentDocument());
20829N/A+}
20829N/A+#endif /* MOZ_ACCESSIBILITY_ATK */
20829N/A+
20829N/A+static gint
20829N/A+handle_child_focus_in(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ GtkMozEmbed *aEmbed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)aEmbed->data;
20829N/A+
20829N/A+ embedPrivate->ChildFocusIn();
20829N/A+
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+static gint
20829N/A+handle_child_focus_out(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ GtkMozEmbed *aEmbed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)aEmbed->data;
20829N/A+
20829N/A+ embedPrivate->ChildFocusOut();
20829N/A+
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+// Widget methods
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_push_startup(void)
20829N/A+{
20829N/A+ EmbedPrivate::PushStartup();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_pop_startup(void)
20829N/A+{
20829N/A+ EmbedPrivate::PopStartup();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_set_path(const char *aPath)
20829N/A+{
20829N/A+ EmbedPrivate::SetPath(aPath);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_set_comp_path(const char *aPath)
20829N/A+{
20829N/A+ EmbedPrivate::SetCompPath(aPath);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_set_profile_path(const char *aDir, const char *aName)
20829N/A+{
20829N/A+ EmbedPrivate::SetProfilePath(aDir, aName);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_set_directory_service_provider(nsIDirectoryServiceProvider *appFileLocProvider) {
20829N/A+ EmbedPrivate::SetDirectoryServiceProvider(appFileLocProvider);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_load_url(GtkMozEmbed *embed, const char *url)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(embed != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ embedPrivate->SetURI(url);
20829N/A+
20829N/A+ // If the widget is realized, load the URI. If it isn't then we
20829N/A+ // will load it later.
20829N/A+ if (GTK_WIDGET_REALIZED(embed))
20829N/A+ embedPrivate->LoadCurrentURI();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_stop_load(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail(embed != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->Stop(nsIWebNavigation::STOP_ALL);
20829N/A+}
20829N/A+
20829N/A+gboolean
20829N/A+gtk_moz_embed_can_go_back(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ PRBool retval = PR_FALSE;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), FALSE);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), FALSE);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GetCanGoBack(&retval);
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+gboolean
20829N/A+gtk_moz_embed_can_go_forward(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ PRBool retval = PR_FALSE;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), FALSE);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), FALSE);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GetCanGoForward(&retval);
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_go_back(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GoBack();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_go_forward(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GoForward();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_render_data(GtkMozEmbed *embed, const char *data,
20829N/A+ guint32 len, const char *base_uri,
20829N/A+ const char *mime_type)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ embedPrivate->OpenStream(base_uri, mime_type);
20829N/A+ embedPrivate->AppendToStream((const PRUint8*)data, len);
20829N/A+ embedPrivate->CloseStream();
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_open_stream(GtkMozEmbed *embed, const char *base_uri,
20829N/A+ const char *mime_type)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ embedPrivate->OpenStream(base_uri, mime_type);
20829N/A+}
20829N/A+
20829N/A+void gtk_moz_embed_append_data(GtkMozEmbed *embed, const char *data,
20829N/A+ guint32 len)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->AppendToStream((const PRUint8*)data, len);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_close_stream(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->CloseStream();
20829N/A+}
20829N/A+
20829N/A+char *
20829N/A+gtk_moz_embed_get_link_message(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ char *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mLinkMessage);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+char *
20829N/A+gtk_moz_embed_get_js_status(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ char *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mJSStatus);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+char *
20829N/A+gtk_moz_embed_get_title(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ char *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mTitle);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+char *
20829N/A+gtk_moz_embed_get_location(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ char *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (!embedPrivate->mURI.IsEmpty())
20829N/A+ retval = g_strdup(embedPrivate->mURI.get());
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_reload(GtkMozEmbed *embed, gint32 flags)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ PRUint32 reloadFlags = 0;
20829N/A+
20829N/A+ // map the external API to the internal web navigation API.
20829N/A+ switch (flags) {
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADNORMAL:
20829N/A+ reloadFlags = 0;
20829N/A+ break;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE;
20829N/A+ break;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
20829N/A+ break;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE:
20829N/A+ reloadFlags = (nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY |
20829N/A+ nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE);
20829N/A+ break;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE;
20829N/A+ break;
20829N/A+ default:
20829N/A+ reloadFlags = 0;
20829N/A+ break;
20829N/A+ }
20829N/A+
20829N/A+ embedPrivate->Reload(reloadFlags);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_set_chrome_mask(GtkMozEmbed *embed, guint32 flags)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ embedPrivate->SetChromeMask(flags);
20829N/A+}
20829N/A+
20829N/A+guint32
20829N/A+gtk_moz_embed_get_chrome_mask(GtkMozEmbed *embed)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), 0);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), 0);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ return embedPrivate->mChromeMask;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+gtk_moz_embed_get_nsIWebBrowser (GtkMozEmbed *embed, nsIWebBrowser **retval)
20829N/A+{
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ embedPrivate->mWindow->GetWebBrowser(retval);
20829N/A+}
20829N/A+
20829N/A+PRUnichar *
20829N/A+gtk_moz_embed_get_title_unichar (GtkMozEmbed *embed)
20829N/A+{
20829N/A+ PRUnichar *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mTitle);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+PRUnichar *
20829N/A+gtk_moz_embed_get_js_status_unichar (GtkMozEmbed *embed)
20829N/A+{
20829N/A+ PRUnichar *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mJSStatus);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+PRUnichar *
20829N/A+gtk_moz_embed_get_link_message_unichar (GtkMozEmbed *embed)
20829N/A+{
20829N/A+ PRUnichar *retval = nsnull;
20829N/A+ EmbedPrivate *embedPrivate;
20829N/A+
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+
20829N/A+ if (embedPrivate->mWindow)
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mLinkMessage);
20829N/A+
20829N/A+ return retval;
20829N/A+}
20829N/A+
20829N/A+// class and instance initialization
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_single_class_init(GtkMozEmbedSingleClass *klass);
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_single_init(GtkMozEmbedSingle *embed);
20829N/A+
20829N/A+GtkMozEmbedSingle *
20829N/A+gtk_moz_embed_single_new(void);
20829N/A+
20829N/A+enum {
20829N/A+ NEW_WINDOW_ORPHAN,
20829N/A+ SINGLE_LAST_SIGNAL
20829N/A+};
20829N/A+
20829N/A+guint moz_embed_single_signals[SINGLE_LAST_SIGNAL] = { 0 };
20829N/A+
20829N/A+// GtkObject + class-related functions
20829N/A+
20829N/A+GType
20829N/A+gtk_moz_embed_single_get_type(void)
20829N/A+{
20829N/A+ static GType moz_embed_single_type = 0;
20829N/A+ if (moz_embed_single_type == 0)
20829N/A+ {
20829N/A+ const GTypeInfo our_info =
20829N/A+ {
20829N/A+ sizeof(GtkMozEmbedClass),
20829N/A+ NULL, /* base_init */
20829N/A+ NULL, /* base_finalize */
20829N/A+ (GClassInitFunc)gtk_moz_embed_single_class_init,
20829N/A+ NULL,
20829N/A+ NULL, /* class_data */
20829N/A+ sizeof(GtkMozEmbed),
20829N/A+ 0, /* n_preallocs */
20829N/A+ (GInstanceInitFunc)gtk_moz_embed_single_init,
20829N/A+ };
20829N/A+
20829N/A+ moz_embed_single_type = g_type_register_static(GTK_TYPE_OBJECT,
20829N/A+ "GtkMozEmbedSingle",
20829N/A+ &our_info,
20829N/A+ (GTypeFlags)0);
20829N/A+ }
20829N/A+
20829N/A+ return moz_embed_single_type;
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_single_class_init(GtkMozEmbedSingleClass *klass)
20829N/A+{
20829N/A+ GtkObjectClass *object_class;
20829N/A+
20829N/A+ object_class = GTK_OBJECT_CLASS(klass);
20829N/A+
20829N/A+ // set up our signals
20829N/A+
20829N/A+ moz_embed_single_signals[NEW_WINDOW_ORPHAN] =
20829N/A+ g_signal_new("new_window_orphan",
20829N/A+ G_TYPE_FROM_CLASS(klass),
20829N/A+ G_SIGNAL_RUN_FIRST,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedSingleClass, new_window_orphan),
20829N/A+ NULL, NULL,
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+
20829N/A+}
20829N/A+
20829N/A+static void
20829N/A+gtk_moz_embed_single_init(GtkMozEmbedSingle *embed)
20829N/A+{
20829N/A+ // this is a placeholder for later in case we need to stash data at
20829N/A+ // a later data and maintain backwards compatibility.
20829N/A+ embed->data = nsnull;
20829N/A+}
20829N/A+
20829N/A+GtkMozEmbedSingle *
20829N/A+gtk_moz_embed_single_new(void)
20829N/A+{
20829N/A+ return (GtkMozEmbedSingle *)g_object_new(GTK_TYPE_MOZ_EMBED_SINGLE, NULL);
20829N/A+}
20829N/A+
20829N/A+GtkMozEmbedSingle *
20829N/A+gtk_moz_embed_single_get(void)
20829N/A+{
20829N/A+ static GtkMozEmbedSingle *singleton_object = nsnull;
20829N/A+ if (!singleton_object)
20829N/A+ {
20829N/A+ singleton_object = gtk_moz_embed_single_new();
20829N/A+ }
20829N/A+
20829N/A+ return singleton_object;
20829N/A+}
20829N/A+
20829N/A+// our callback from the window creator service
20829N/A+void
20829N/A+gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
20829N/A+ guint aChromeFlags)
20829N/A+{
20829N/A+ GtkMozEmbedSingle *single = gtk_moz_embed_single_get();
20829N/A+
20829N/A+ *aNewEmbed = nsnull;
20829N/A+
20829N/A+ if (!single)
20829N/A+ return;
20829N/A+
20829N/A+ g_signal_emit(G_OBJECT(single),
20829N/A+ moz_embed_single_signals[NEW_WINDOW_ORPHAN], 0,
20829N/A+ aNewEmbed, aChromeFlags);
20829N/A+
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembed_glue.cpp b/embedding/browser/gtk/src/gtkmozembed_glue.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembed_glue.cpp
20829N/A@@ -0,0 +1,116 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is Mozilla embedding.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Benjamin Smedberg <benjamin@smedbergs.us>.
20829N/A+ *
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2005
20829N/A+ * the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+// This file is an implementation file, meant to be #included in a
20829N/A+// single C++ file of an embedding application. It is called after
20829N/A+// XPCOMGlueStartup to glue the gtkmozembed functions.
20829N/A+
20829N/A+#include "gtkmozembed.h"
20829N/A+#include "gtkmozembed_internal.h"
20829N/A+#include "nsXPCOMGlue.h"
20829N/A+
20829N/A+#ifndef XPCOM_GLUE
20829N/A+#error This file only makes sense when XPCOM_GLUE is defined.
20829N/A+#endif
20829N/A+
20829N/A+#define GTKMOZEMBED_FUNCTIONS \
20829N/A+ GTKF(gtk_moz_embed_get_type) \
20829N/A+ GTKF(gtk_moz_embed_new) \
20829N/A+ GTKF(gtk_moz_embed_push_startup) \
20829N/A+ GTKF(gtk_moz_embed_pop_startup) \
20829N/A+ GTKF(gtk_moz_embed_set_path) \
20829N/A+ GTKF(gtk_moz_embed_set_comp_path) \
20829N/A+ GTKF(gtk_moz_embed_set_profile_path) \
20829N/A+ GTKF(gtk_moz_embed_load_url) \
20829N/A+ GTKF(gtk_moz_embed_stop_load) \
20829N/A+ GTKF(gtk_moz_embed_can_go_back) \
20829N/A+ GTKF(gtk_moz_embed_can_go_forward) \
20829N/A+ GTKF(gtk_moz_embed_go_back) \
20829N/A+ GTKF(gtk_moz_embed_go_forward) \
20829N/A+ GTKF(gtk_moz_embed_render_data) \
20829N/A+ GTKF(gtk_moz_embed_open_stream) \
20829N/A+ GTKF(gtk_moz_embed_append_data) \
20829N/A+ GTKF(gtk_moz_embed_close_stream) \
20829N/A+ GTKF(gtk_moz_embed_get_link_message) \
20829N/A+ GTKF(gtk_moz_embed_get_js_status) \
20829N/A+ GTKF(gtk_moz_embed_get_title) \
20829N/A+ GTKF(gtk_moz_embed_get_location) \
20829N/A+ GTKF(gtk_moz_embed_reload) \
20829N/A+ GTKF(gtk_moz_embed_set_chrome_mask) \
20829N/A+ GTKF(gtk_moz_embed_get_chrome_mask) \
20829N/A+ GTKF(gtk_moz_embed_single_get_type) \
20829N/A+ GTKF(gtk_moz_embed_single_get)
20829N/A+
20829N/A+#define GTKMOZEMBED_FUNCTIONS_INTERNAL \
20829N/A+ GTKF(gtk_moz_embed_get_nsIWebBrowser) \
20829N/A+ GTKF(gtk_moz_embed_get_title_unichar) \
20829N/A+ GTKF(gtk_moz_embed_get_js_status_unichar) \
20829N/A+ GTKF(gtk_moz_embed_get_link_message_unichar) \
20829N/A+ GTKF(gtk_moz_embed_set_directory_service_provider)
20829N/A+
20829N/A+#define GTKF(fname) fname##Type fname;
20829N/A+
20829N/A+GTKMOZEMBED_FUNCTIONS
20829N/A+GTKMOZEMBED_FUNCTIONS_INTERNAL
20829N/A+
20829N/A+#undef GTKF
20829N/A+
20829N/A+#define GTKF(fname) { #fname, (NSFuncPtr*) &fname },
20829N/A+
20829N/A+static const nsDynamicFunctionLoad GtkSymbols[] = {
20829N/A+GTKMOZEMBED_FUNCTIONS
20829N/A+ { nsnull, nsnull }
20829N/A+};
20829N/A+
20829N/A+static const nsDynamicFunctionLoad GtkSymbolsInternal[] = {
20829N/A+GTKMOZEMBED_FUNCTIONS_INTERNAL
20829N/A+ { nsnull, nsnull }
20829N/A+};
20829N/A+#undef GTKF
20829N/A+
20829N/A+static nsresult
20829N/A+GTKEmbedGlueStartup()
20829N/A+{
20829N/A+ return XPCOMGlueLoadXULFunctions(GtkSymbols);
20829N/A+}
20829N/A+
20829N/A+static nsresult
20829N/A+GTKEmbedGlueStartupInternal()
20829N/A+{
20829N/A+ return XPCOMGlueLoadXULFunctions(GtkSymbolsInternal);
20829N/A+}
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembed_internal.h b/embedding/browser/gtk/src/gtkmozembed_internal.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembed_internal.h
20829N/A@@ -0,0 +1,70 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef gtkmozembed_internal_h
20829N/A+#define gtkmozembed_internal_h
20829N/A+
20829N/A+#include "nsIWebBrowser.h"
20829N/A+#include "nsXPCOM.h"
20829N/A+
20829N/A+struct nsModuleComponentInfo;
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+extern "C" {
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+GTKMOZEMBED_API(void,
20829N/A+ gtk_moz_embed_get_nsIWebBrowser, (GtkMozEmbed *embed,
20829N/A+ nsIWebBrowser **retval))
20829N/A+GTKMOZEMBED_API(PRUnichar*,
20829N/A+ gtk_moz_embed_get_title_unichar, (GtkMozEmbed *embed))
20829N/A+
20829N/A+GTKMOZEMBED_API(PRUnichar*,
20829N/A+ gtk_moz_embed_get_js_status_unichar, (GtkMozEmbed *embed))
20829N/A+
20829N/A+GTKMOZEMBED_API(PRUnichar*,
20829N/A+ gtk_moz_embed_get_link_message_unichar, (GtkMozEmbed *embed))
20829N/A+
20829N/A+GTKMOZEMBED_API(void,
20829N/A+ gtk_moz_embed_set_directory_service_provider, (nsIDirectoryServiceProvider *appFileLocProvider))
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+}
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+#endif /* gtkmozembed_internal_h */
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembedmarshal.list b/embedding/browser/gtk/src/gtkmozembedmarshal.list
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembedmarshal.list
20829N/A@@ -0,0 +1,34 @@
20829N/A+BOOL:STRING
20829N/A+BOOL:STRING,STRING
20829N/A+BOOL:STRING,STRING,POINTER
20829N/A+BOOL:STRING,STRING,POINTER,INT
20829N/A+BOOL:STRING,STRING,POINTER,POINTER,STRING,POINTER
20829N/A+BOOL:STRING,STRING,POINTER,STRING,POINTER
20829N/A+BOOL:STRING,STRING,STRING,POINTER
20829N/A+INT:STRING,INT,INT,INT,INT,INT
20829N/A+INT:STRING,STRING,INT,INT,INT,INT
20829N/A+INT:STRING,STRING,UINT,STRING,STRING,STRING,STRING,POINTER
20829N/A+INT:VOID
20829N/A+STRING:STRING,STRING
20829N/A+VOID:BOOL
20829N/A+VOID:INT,INT
20829N/A+VOID:INT,INT,BOOL
20829N/A+VOID:INT,STRING
20829N/A+VOID:INT,STRING,STRING
20829N/A+VOID:INT,UINT
20829N/A+VOID:POINTER,INT,POINTER
20829N/A+VOID:POINTER,INT,STRING,STRING,STRING,STRING,STRING,BOOLEAN,INT
20829N/A+VOID:POINTER,STRING,BOOL,BOOL
20829N/A+VOID:STRING,INT,INT
20829N/A+VOID:STRING,INT,UINT
20829N/A+VOID:STRING,STRING
20829N/A+VOID:STRING,STRING,POINTER
20829N/A+VOID:STRING,STRING,STRING,ULONG,INT
20829N/A+VOID:STRING,STRING,STRING,POINTER
20829N/A+VOID:UINT,INT,INT,STRING,STRING,STRING,STRING
20829N/A+VOID:ULONG,ULONG,ULONG
20829N/A+VOID:POINTER,UINT
20829N/A+BOOL:POINTER,UINT
20829N/A+BOOL:POINTER
20829N/A+VOID:POINTER
20829N/A+BOOL:STRING,STRING,POINTER
20829N/Adiff --git a/embedding/browser/gtk/src/gtkmozembedprivate.h b/embedding/browser/gtk/src/gtkmozembedprivate.h
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/src/gtkmozembedprivate.h
20829N/A@@ -0,0 +1,91 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#ifndef gtkmozembedprivate_h
20829N/A+#define gtkmozembedprivate_h
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+extern "C" {
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+#include "gtkmozembed.h"
20829N/A+
20829N/A+/* signals */
20829N/A+
20829N/A+enum {
20829N/A+ LINK_MESSAGE,
20829N/A+ JS_STATUS,
20829N/A+ LOCATION,
20829N/A+ TITLE,
20829N/A+ PROGRESS,
20829N/A+ PROGRESS_ALL,
20829N/A+ NET_STATE,
20829N/A+ NET_STATE_ALL,
20829N/A+ NET_START,
20829N/A+ NET_STOP,
20829N/A+ NEW_WINDOW,
20829N/A+ VISIBILITY,
20829N/A+ DESTROY_BROWSER,
20829N/A+ OPEN_URI,
20829N/A+ SIZE_TO,
20829N/A+ DOM_KEY_DOWN,
20829N/A+ DOM_KEY_PRESS,
20829N/A+ DOM_KEY_UP,
20829N/A+ DOM_MOUSE_DOWN,
20829N/A+ DOM_MOUSE_UP,
20829N/A+ DOM_MOUSE_CLICK,
20829N/A+ DOM_MOUSE_DBL_CLICK,
20829N/A+ DOM_MOUSE_OVER,
20829N/A+ DOM_MOUSE_OUT,
20829N/A+ SECURITY_CHANGE,
20829N/A+ STATUS_CHANGE,
20829N/A+ DOM_ACTIVATE,
20829N/A+ DOM_FOCUS_IN,
20829N/A+ DOM_FOCUS_OUT,
20829N/A+ EMBED_LAST_SIGNAL
20829N/A+};
20829N/A+
20829N/A+extern guint moz_embed_signals[EMBED_LAST_SIGNAL];
20829N/A+
20829N/A+extern void gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
20829N/A+ guint aChromeFlags);
20829N/A+
20829N/A+#ifdef __cplusplus
20829N/A+}
20829N/A+#endif /* __cplusplus */
20829N/A+
20829N/A+#endif /* gtkmozembedprivate_h */
20829N/Adiff --git a/embedding/browser/gtk/tests/Makefile.in b/embedding/browser/gtk/tests/Makefile.in
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/Makefile.in
20829N/A@@ -0,0 +1,101 @@
20829N/A+#
20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+#
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# http://www.mozilla.org/MPL/
20829N/A+#
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# License.
20829N/A+#
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+#
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Christopher Blizzard.
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+#
20829N/A+# Contributor(s):
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+#
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+#
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+
20829N/A+DEPTH = ../../../..
20829N/A+topsrcdir = @top_srcdir@
20829N/A+srcdir = @srcdir@
20829N/A+VPATH = @srcdir@
20829N/A+
20829N/A+include $(DEPTH)/config/autoconf.mk
20829N/A+
20829N/A+MODULE = gtkembedmoz
20829N/A+
20829N/A+CPPSRCS = \
20829N/A+ TestGtkEmbed.cpp \
20829N/A+ TestGtkEmbedNotebook.cpp
20829N/A+
20829N/A+ifdef MOZ_X11
20829N/A+CPPSRCS += TestGtkEmbedSocket.cpp \
20829N/A+ TestGtkEmbedChild.cpp
20829N/A+endif
20829N/A+
20829N/A+SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=)
20829N/A+
20829N/A+# ENABLE_GNOME=1
20829N/A+
20829N/A+ifdef ENABLE_GNOME
20829N/A+CPPSRCS += TestGtkEmbedMDI.cpp
20829N/A+endif
20829N/A+
20829N/A+ifdef MOZ_ENABLE_GTK2
20829N/A+LIBS += \
20829N/A+ $(XLDFLAGS) \
20829N/A+ $(XLIBS) \
20829N/A+ $(NULL)
20829N/A+endif
20829N/A+
20829N/A+include $(topsrcdir)/config/config.mk
20829N/A+
20829N/A+include $(topsrcdir)/config/rules.mk
20829N/A+
20829N/A+LIBS += $(XPCOM_STANDALONE_GLUE_LDOPTS)
20829N/A+
20829N/A+DEFINES += -DXPCOM_GLUE
20829N/A+STL_FLAGS =
20829N/A+
20829N/A+CXXFLAGS += $(MOZ_GTK2_CFLAGS)
20829N/A+
20829N/A+ifdef ENABLE_GNOME
20829N/A+CXXFLAGS += `gnome-config --cflags gnomeui`
20829N/A+EXTRA_LIBS += `gnome-config --libs gnomeui`
20829N/A+endif
20829N/A+
20829N/A+EXTRA_LIBS += \
20829N/A+ $(TK_LIBS) \
20829N/A+ $(NULL)
20829N/A+
20829N/A+ifeq ($(OS_ARCH), SunOS)
20829N/A+ifndef GNU_CC
20829N/A+# When using Sun's WorkShop compiler, including
20829N/A+# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
20829N/A+# causes most of these compiles to fail with:
20829N/A+# line 29: Error: Multiple declaration for std::tm.
20829N/A+# So, this gets around the problem.
20829N/A+DEFINES += -D_TIME_H=1
20829N/A+endif
20829N/A+endif
20829N/Adiff --git a/embedding/browser/gtk/tests/TestGtkEmbed.cpp b/embedding/browser/gtk/tests/TestGtkEmbed.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/TestGtkEmbed.cpp
20829N/A@@ -0,0 +1,1145 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "gtkmozembed.h"
20829N/A+#include <gtk/gtk.h>
20829N/A+#include <stdio.h>
20829N/A+#include <string.h>
20829N/A+#include <stdlib.h>
20829N/A+
20829N/A+// mozilla specific headers
20829N/A+#include "nsIDOMKeyEvent.h"
20829N/A+#include "nsIDOMMouseEvent.h"
20829N/A+#include "nsIDOMUIEvent.h"
20829N/A+
20829N/A+#include "nsCOMPtr.h"
20829N/A+#include "nsISupportsUtils.h"
20829N/A+#include "nsServiceManagerUtils.h"
20829N/A+#include "nsIObserverService.h"
20829N/A+
20829N/A+#include "nsStringAPI.h"
20829N/A+#include "gtkmozembed_glue.cpp"
20829N/A+
20829N/A+typedef struct _TestGtkBrowser {
20829N/A+ GtkWidget *topLevelWindow;
20829N/A+ GtkWidget *topLevelVBox;
20829N/A+ GtkWidget *menuBar;
20829N/A+ GtkWidget *fileMenuItem;
20829N/A+ GtkWidget *fileMenu;
20829N/A+ GtkWidget *fileOpenNewBrowser;
20829N/A+ GtkWidget *fileStream;
20829N/A+ GtkWidget *fileMemory;
20829N/A+ GtkWidget *fileClose;
20829N/A+ GtkWidget *fileQuit;
20829N/A+ GtkWidget *toolbarHBox;
20829N/A+ GtkWidget *toolbar;
20829N/A+ GtkWidget *backButton;
20829N/A+ GtkWidget *stopButton;
20829N/A+ GtkWidget *forwardButton;
20829N/A+ GtkWidget *reloadButton;
20829N/A+ GtkWidget *urlEntry;
20829N/A+ GtkWidget *mozEmbed;
20829N/A+ GtkWidget *progressAreaHBox;
20829N/A+ GtkWidget *progressBar;
20829N/A+ GtkWidget *statusAlign;
20829N/A+ GtkWidget *statusBar;
20829N/A+ const char *statusMessage;
20829N/A+ int loadPercent;
20829N/A+ int bytesLoaded;
20829N/A+ int maxBytesLoaded;
20829N/A+ char *tempMessage;
20829N/A+ gboolean menuBarOn;
20829N/A+ gboolean toolBarOn;
20829N/A+ gboolean locationBarOn;
20829N/A+ gboolean statusBarOn;
20829N/A+
20829N/A+} TestGtkBrowser;
20829N/A+
20829N/A+// the list of browser windows currently open
20829N/A+GList *browser_list = g_list_alloc();
20829N/A+
20829N/A+static TestGtkBrowser *new_gtk_browser (guint32 chromeMask);
20829N/A+static void set_browser_visibility (TestGtkBrowser *browser,
20829N/A+ gboolean visibility);
20829N/A+
20829N/A+static int num_browsers = 0;
20829N/A+
20829N/A+// callbacks from the UI
20829N/A+static void back_clicked_cb (GtkButton *button,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void stop_clicked_cb (GtkButton *button,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void forward_clicked_cb (GtkButton *button,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void reload_clicked_cb (GtkButton *button,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void url_activate_cb (GtkEditable *widget,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void menu_open_new_cb (GtkMenuItem *menuitem,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void menu_stream_cb (GtkMenuItem *menuitem,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void menu_memory_cb (GtkMenuItem *menuitem,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void menu_close_cb (GtkMenuItem *menuitem,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void menu_quit_cb (GtkMenuItem *menuitem,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gboolean delete_cb (GtkWidget *widget, GdkEventAny *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void destroy_cb (GtkWidget *widget,
20829N/A+ TestGtkBrowser *browser);
20829N/A+
20829N/A+// callbacks from the widget
20829N/A+static void location_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void title_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void load_started_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void load_finished_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void net_state_change_cb (GtkMozEmbed *embed, gint flags,
20829N/A+ guint status, TestGtkBrowser *browser);
20829N/A+static void net_state_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ gint flags, guint status,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void progress_change_cb (GtkMozEmbed *embed, gint cur, gint max,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void progress_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ gint cur, gint max,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void link_message_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void js_status_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void new_window_cb (GtkMozEmbed *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void visibility_cb (GtkMozEmbed *embed,
20829N/A+ gboolean visibility,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void destroy_brsr_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static gint open_uri_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static void size_to_cb (GtkMozEmbed *embed, gint width,
20829N/A+ gint height, TestGtkBrowser *browser);
20829N/A+static gint dom_key_down_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_key_press_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_key_up_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_down_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_up_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_dbl_click_cb (GtkMozEmbed *embed,
20829N/A+ nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_over_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_mouse_out_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_activate_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_focus_in_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+static gint dom_focus_out_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser);
20829N/A+
20829N/A+// callbacks from the singleton object
20829N/A+static void new_window_orphan_cb (GtkMozEmbedSingle *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+ gpointer data);
20829N/A+
20829N/A+// some utility functions
20829N/A+static void update_status_bar_text (TestGtkBrowser *browser);
20829N/A+static void update_temp_message (TestGtkBrowser *browser,
20829N/A+ const char *message);
20829N/A+static void update_nav_buttons (TestGtkBrowser *browser);
20829N/A+
20829N/A+int
20829N/A+main(int argc, char **argv)
20829N/A+{
20829N/A+ gtk_set_locale();
20829N/A+ gtk_init(&argc, &argv);
20829N/A+
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ "1.9a", PR_TRUE,
20829N/A+ "2", PR_TRUE
20829N/A+ };
20829N/A+
20829N/A+ char xpcomPath[PATH_MAX];
20829N/A+
20829N/A+ nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = GTKEmbedGlueStartup();
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ if (lastSlash)
20829N/A+ *lastSlash = '\0';
20829N/A+
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+
20829N/A+ char *home_path;
20829N/A+ char *full_path;
20829N/A+ home_path = getenv("HOME");
20829N/A+ if (!home_path) {
20829N/A+ fprintf(stderr, "Failed to get HOME\n");
20829N/A+ exit(1);
20829N/A+ }
20829N/A+
20829N/A+ full_path = g_strdup_printf("%s/%s", home_path, ".TestGtkEmbed");
20829N/A+
20829N/A+ gtk_moz_embed_set_profile_path(full_path, "TestGtkEmbed");
20829N/A+
20829N/A+ TestGtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
20829N/A+
20829N/A+ // set our minimum size
20829N/A+ gtk_widget_set_size_request(browser->mozEmbed, 400, 400);
20829N/A+
20829N/A+ set_browser_visibility(browser, TRUE);
20829N/A+
20829N/A+ if (argc > 1)
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), argv[1]);
20829N/A+
20829N/A+ // get the singleton object and hook up to its new window callback
20829N/A+ // so we can create orphaned windows.
20829N/A+
20829N/A+ GtkMozEmbedSingle *single;
20829N/A+
20829N/A+ single = gtk_moz_embed_single_get();
20829N/A+ if (!single) {
20829N/A+ fprintf(stderr, "Failed to get singleton embed object!\n");
20829N/A+ exit(1);
20829N/A+ }
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(single), "new_window_orphan",
20829N/A+ G_CALLBACK(new_window_orphan_cb), NULL);
20829N/A+
20829N/A+ gtk_moz_embed_push_startup();
20829N/A+ gtk_main();
20829N/A+ gtk_moz_embed_pop_startup();
20829N/A+}
20829N/A+
20829N/A+static TestGtkBrowser *
20829N/A+new_gtk_browser(guint32 chromeMask)
20829N/A+{
20829N/A+ guint32 actualChromeMask = chromeMask;
20829N/A+ TestGtkBrowser *browser = 0;
20829N/A+
20829N/A+ num_browsers++;
20829N/A+
20829N/A+ browser = g_new0(TestGtkBrowser, 1);
20829N/A+
20829N/A+ browser_list = g_list_prepend(browser_list, browser);
20829N/A+
20829N/A+ browser->menuBarOn = FALSE;
20829N/A+ browser->toolBarOn = FALSE;
20829N/A+ browser->locationBarOn = FALSE;
20829N/A+ browser->statusBarOn = FALSE;
20829N/A+
20829N/A+ g_print("new_gtk_browser\n");
20829N/A+
20829N/A+ if (chromeMask == GTK_MOZ_EMBED_FLAG_DEFAULTCHROME)
20829N/A+ actualChromeMask = GTK_MOZ_EMBED_FLAG_ALLCHROME;
20829N/A+
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_MENUBARON)
20829N/A+ {
20829N/A+ browser->menuBarOn = TRUE;
20829N/A+ g_print("\tmenu bar\n");
20829N/A+ }
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_TOOLBARON)
20829N/A+ {
20829N/A+ browser->toolBarOn = TRUE;
20829N/A+ g_print("\ttool bar\n");
20829N/A+ }
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_LOCATIONBARON)
20829N/A+ {
20829N/A+ browser->locationBarOn = TRUE;
20829N/A+ g_print("\tlocation bar\n");
20829N/A+ }
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_STATUSBARON)
20829N/A+ {
20829N/A+ browser->statusBarOn = TRUE;
20829N/A+ g_print("\tstatus bar\n");
20829N/A+ }
20829N/A+
20829N/A+ // create our new toplevel window
20829N/A+ browser->topLevelWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ // new vbox
20829N/A+ browser->topLevelVBox = gtk_vbox_new(FALSE, 0);
20829N/A+ // add it to the toplevel window
20829N/A+ gtk_container_add(GTK_CONTAINER(browser->topLevelWindow),
20829N/A+ browser->topLevelVBox);
20829N/A+ // create our menu bar
20829N/A+ browser->menuBar = gtk_menu_bar_new();
20829N/A+ // create the file menu
20829N/A+ browser->fileMenuItem = gtk_menu_item_new_with_label("File");
20829N/A+ browser->fileMenu = gtk_menu_new();
20829N/A+ gtk_menu_item_set_submenu (GTK_MENU_ITEM(browser->fileMenuItem),
20829N/A+ browser->fileMenu);
20829N/A+
20829N/A+ browser->fileOpenNewBrowser =
20829N/A+ gtk_menu_item_new_with_label("Open New Browser");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ browser->fileOpenNewBrowser);
20829N/A+
20829N/A+ browser->fileStream =
20829N/A+ gtk_menu_item_new_with_label("Test Stream");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ browser->fileStream);
20829N/A+
20829N/A+ browser->fileMemory =
20829N/A+ gtk_menu_item_new_with_label("Release Memory");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ browser->fileMemory);
20829N/A+
20829N/A+ browser->fileClose =
20829N/A+ gtk_menu_item_new_with_label("Close");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ browser->fileClose);
20829N/A+
20829N/A+ browser->fileQuit =
20829N/A+ gtk_menu_item_new_with_label("Quit");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ browser->fileQuit);
20829N/A+
20829N/A+ // append it
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU_BAR(browser->menuBar),
20829N/A+ browser->fileMenuItem);
20829N/A+
20829N/A+ // add it to the vbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox),
20829N/A+ browser->menuBar,
20829N/A+ FALSE, // expand
20829N/A+ FALSE, // fill
20829N/A+ 0); // padding
20829N/A+ // create the hbox that will contain the toolbar and the url text entry bar
20829N/A+ browser->toolbarHBox = gtk_hbox_new(FALSE, 0);
20829N/A+ // add that hbox to the vbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox),
20829N/A+ browser->toolbarHBox,
20829N/A+ FALSE, // expand
20829N/A+ FALSE, // fill
20829N/A+ 0); // padding
20829N/A+ // new horiz toolbar with buttons + icons
20829N/A+ browser->toolbar = gtk_toolbar_new();
20829N/A+ gtk_toolbar_set_orientation(GTK_TOOLBAR(browser->toolbar),
20829N/A+ GTK_ORIENTATION_HORIZONTAL);
20829N/A+ gtk_toolbar_set_style(GTK_TOOLBAR(browser->toolbar),
20829N/A+ GTK_TOOLBAR_BOTH);
20829N/A+
20829N/A+ // add it to the hbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->toolbar,
20829N/A+ FALSE, // expand
20829N/A+ FALSE, // fill
20829N/A+ 0); // padding
20829N/A+ // new back button
20829N/A+ browser->backButton =
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ "Back",
20829N/A+ "Go Back",
20829N/A+ "Go Back",
20829N/A+ 0, // XXX replace with icon
20829N/A+ G_CALLBACK(back_clicked_cb),
20829N/A+ browser);
20829N/A+ // new stop button
20829N/A+ browser->stopButton =
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ "Stop",
20829N/A+ "Stop",
20829N/A+ "Stop",
20829N/A+ 0, // XXX replace with icon
20829N/A+ G_CALLBACK(stop_clicked_cb),
20829N/A+ browser);
20829N/A+ // new forward button
20829N/A+ browser->forwardButton =
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ "Forward",
20829N/A+ "Forward",
20829N/A+ "Forward",
20829N/A+ 0, // XXX replace with icon
20829N/A+ G_CALLBACK(forward_clicked_cb),
20829N/A+ browser);
20829N/A+ // new reload button
20829N/A+ browser->reloadButton =
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ "Reload",
20829N/A+ "Reload",
20829N/A+ "Reload",
20829N/A+ 0, // XXX replace with icon
20829N/A+ G_CALLBACK(reload_clicked_cb),
20829N/A+ browser);
20829N/A+ // create the url text entry
20829N/A+ browser->urlEntry = gtk_entry_new();
20829N/A+ // add it to the hbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->urlEntry,
20829N/A+ TRUE, // expand
20829N/A+ TRUE, // fill
20829N/A+ 0); // padding
20829N/A+ // create our new gtk moz embed widget
20829N/A+ browser->mozEmbed = gtk_moz_embed_new();
20829N/A+ gtk_moz_embed_push_startup();
20829N/A+ // add it to the toplevel vbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->mozEmbed,
20829N/A+ TRUE, // expand
20829N/A+ TRUE, // fill
20829N/A+ 0); // padding
20829N/A+ // create the new hbox for the progress area
20829N/A+ browser->progressAreaHBox = gtk_hbox_new(FALSE, 0);
20829N/A+ // add it to the vbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->progressAreaHBox,
20829N/A+ FALSE, // expand
20829N/A+ FALSE, // fill
20829N/A+ 0); // padding
20829N/A+ // create our new progress bar
20829N/A+ browser->progressBar = gtk_progress_bar_new();
20829N/A+ // add it to the hbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->progressBar,
20829N/A+ FALSE, // expand
20829N/A+ FALSE, // fill
20829N/A+ 0); // padding
20829N/A+
20829N/A+ // create our status area and the alignment object that will keep it
20829N/A+ // from expanding
20829N/A+ browser->statusAlign = gtk_alignment_new(0, 0, 1, 1);
20829N/A+ gtk_widget_set_size_request(browser->statusAlign, 1, -1);
20829N/A+ // create the status bar
20829N/A+ browser->statusBar = gtk_statusbar_new();
20829N/A+ gtk_container_add(GTK_CONTAINER(browser->statusAlign), browser->statusBar);
20829N/A+ // add it to the hbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->statusAlign,
20829N/A+ TRUE, // expand
20829N/A+ TRUE, // fill
20829N/A+ 0); // padding
20829N/A+ // by default none of the buttons are marked as sensitive.
20829N/A+ gtk_widget_set_sensitive(browser->backButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, FALSE);
20829N/A+
20829N/A+ // catch the destruction of the toplevel window
20829N/A+ g_signal_connect(GTK_OBJECT(browser->topLevelWindow), "delete_event",
20829N/A+ G_CALLBACK(delete_cb), browser);
20829N/A+
20829N/A+ // hook up the activate signal to the right callback
20829N/A+ g_signal_connect(GTK_OBJECT(browser->urlEntry), "activate",
20829N/A+ G_CALLBACK(url_activate_cb), browser);
20829N/A+
20829N/A+ // hook up to the open new browser activation
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileOpenNewBrowser), "activate",
20829N/A+ G_CALLBACK(menu_open_new_cb), browser);
20829N/A+ // hook up to the stream test
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileStream), "activate",
20829N/A+ G_CALLBACK(menu_stream_cb), browser);
20829N/A+ // hook up the memory pressure release function
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileMemory), "activate",
20829N/A+ G_CALLBACK(menu_memory_cb), browser);
20829N/A+ // close this window
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileClose), "activate",
20829N/A+ G_CALLBACK(menu_close_cb), browser);
20829N/A+ // quit the application
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileQuit), "activate",
20829N/A+ G_CALLBACK(menu_quit_cb), browser);
20829N/A+
20829N/A+ // hook up the location change to update the urlEntry
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "location",
20829N/A+ G_CALLBACK(location_changed_cb), browser);
20829N/A+ // hook up the title change to update the window title
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "title",
20829N/A+ G_CALLBACK(title_changed_cb), browser);
20829N/A+ // hook up the start and stop signals
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_start",
20829N/A+ G_CALLBACK(load_started_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_stop",
20829N/A+ G_CALLBACK(load_finished_cb), browser);
20829N/A+ // hook up to the change in network status
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state",
20829N/A+ G_CALLBACK(net_state_change_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state_all",
20829N/A+ G_CALLBACK(net_state_change_all_cb), browser);
20829N/A+ // hookup to changes in progress
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress",
20829N/A+ G_CALLBACK(progress_change_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress_all",
20829N/A+ G_CALLBACK(progress_change_all_cb), browser);
20829N/A+ // hookup to changes in over-link message
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "link_message",
20829N/A+ G_CALLBACK(link_message_cb), browser);
20829N/A+ // hookup to changes in js status message
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "js_status",
20829N/A+ G_CALLBACK(js_status_cb), browser);
20829N/A+ // hookup to see whenever a new window is requested
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "new_window",
20829N/A+ G_CALLBACK(new_window_cb), browser);
20829N/A+ // hookup to any requested visibility changes
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "visibility",
20829N/A+ G_CALLBACK(visibility_cb), browser);
20829N/A+ // hookup to the signal that says that the browser requested to be
20829N/A+ // destroyed
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy_browser",
20829N/A+ G_CALLBACK(destroy_brsr_cb), browser);
20829N/A+ // hookup to the signal that is called when someone clicks on a link
20829N/A+ // to load a new uri
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "open_uri",
20829N/A+ G_CALLBACK(open_uri_cb), browser);
20829N/A+ // this signal is emitted when there's a request to change the
20829N/A+ // containing browser window to a certain height, like with width
20829N/A+ // and height args for a window.open in javascript
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "size_to",
20829N/A+ G_CALLBACK(size_to_cb), browser);
20829N/A+ // key event signals
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_down",
20829N/A+ G_CALLBACK(dom_key_down_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_press",
20829N/A+ G_CALLBACK(dom_key_press_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_up",
20829N/A+ G_CALLBACK(dom_key_up_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_down",
20829N/A+ G_CALLBACK(dom_mouse_down_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_up",
20829N/A+ G_CALLBACK(dom_mouse_up_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_click",
20829N/A+ G_CALLBACK(dom_mouse_click_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_dbl_click",
20829N/A+ G_CALLBACK(dom_mouse_dbl_click_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_over",
20829N/A+ G_CALLBACK(dom_mouse_over_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_out",
20829N/A+ G_CALLBACK(dom_mouse_out_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_activate",
20829N/A+ G_CALLBACK(dom_activate_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_focus_in",
20829N/A+ G_CALLBACK(dom_focus_in_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_focus_out",
20829N/A+ G_CALLBACK(dom_focus_out_cb), browser);
20829N/A+ // hookup to when the window is destroyed
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy",
20829N/A+ G_CALLBACK(destroy_cb), browser);
20829N/A+
20829N/A+ // set the chrome type so it's stored in the object
20829N/A+ gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ actualChromeMask);
20829N/A+
20829N/A+ return browser;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+set_browser_visibility (TestGtkBrowser *browser, gboolean visibility)
20829N/A+{
20829N/A+ if (!visibility)
20829N/A+ {
20829N/A+ gtk_widget_hide(browser->topLevelWindow);
20829N/A+ return;
20829N/A+ }
20829N/A+
20829N/A+ if (browser->menuBarOn)
20829N/A+ gtk_widget_show_all(browser->menuBar);
20829N/A+ else
20829N/A+ gtk_widget_hide_all(browser->menuBar);
20829N/A+
20829N/A+ // since they are on the same line here...
20829N/A+ if (browser->toolBarOn || browser->locationBarOn)
20829N/A+ gtk_widget_show_all(browser->toolbarHBox);
20829N/A+ else
20829N/A+ gtk_widget_hide_all(browser->toolbarHBox);
20829N/A+
20829N/A+ if (browser->statusBarOn)
20829N/A+ gtk_widget_show_all(browser->progressAreaHBox);
20829N/A+ else
20829N/A+ gtk_widget_hide_all(browser->progressAreaHBox);
20829N/A+
20829N/A+ gtk_widget_show(browser->mozEmbed);
20829N/A+ gtk_widget_show(browser->topLevelVBox);
20829N/A+ gtk_widget_show(browser->topLevelWindow);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+back_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ gtk_moz_embed_go_back(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+stop_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("stop_clicked_cb\n");
20829N/A+ gtk_moz_embed_stop_load(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+forward_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("forward_clicked_cb\n");
20829N/A+ gtk_moz_embed_go_forward(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+reload_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("reload_clicked_cb\n");
20829N/A+ GdkModifierType state = (GdkModifierType)0;
20829N/A+ gint x, y;
20829N/A+ gdk_window_get_pointer(NULL, &x, &y, &state);
20829N/A+
20829N/A+ gtk_moz_embed_reload(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ (state & GDK_SHIFT_MASK) ?
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE :
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+stream_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ const char *data;
20829N/A+ const char *data2;
20829N/A+ data = "<html>Hi";
20829N/A+ data2 = " there</html>\n";
20829N/A+ g_print("stream_clicked_cb\n");
20829N/A+ gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ "file://", "text/html");
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ data, strlen(data));
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ data2, strlen(data2));
20829N/A+ gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+url_activate_cb (GtkEditable *widget, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ gchar *text = gtk_editable_get_chars(widget, 0, -1);
20829N/A+ g_print("loading url %s\n", text);
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), text);
20829N/A+ g_free(text);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+menu_open_new_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("opening new browser.\n");
20829N/A+ TestGtkBrowser *newBrowser =
20829N/A+ new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
20829N/A+ gtk_widget_set_size_request(newBrowser->mozEmbed, 400, 400);
20829N/A+ set_browser_visibility(newBrowser, TRUE);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("menu_stream_cb\n");
20829N/A+ const char *data;
20829N/A+ const char *data2;
20829N/A+ data = "<html>Hi";
20829N/A+ data2 = " <a href='foo.html'>there</a></html>\n";
20829N/A+ g_print("stream_clicked_cb\n");
20829N/A+ gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ "file://", "text/html");
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ data, strlen(data));
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ data2, strlen(data2));
20829N/A+ gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+menu_memory_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("menu_memory_cb\n");
20829N/A+ nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
20829N/A+ if (!os)
20829N/A+ return;
20829N/A+
20829N/A+ // Compact like you mean it. We do this three times to give the
20829N/A+ // cycle collector a chance to try and reclaim as much as we can.
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ gtk_widget_destroy(browser->topLevelWindow);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+menu_quit_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ TestGtkBrowser *tmpBrowser;
20829N/A+ GList *tmp_list = browser_list;
20829N/A+ tmpBrowser = (TestGtkBrowser *)tmp_list->data;
20829N/A+ while (tmpBrowser) {
20829N/A+ tmp_list = tmp_list->next;
20829N/A+ gtk_widget_destroy(tmpBrowser->topLevelWindow);
20829N/A+ tmpBrowser = (TestGtkBrowser *)tmp_list->data;
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+gboolean
20829N/A+delete_cb(GtkWidget *widget, GdkEventAny *event, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("delete_cb\n");
20829N/A+ gtk_widget_destroy(widget);
20829N/A+ return TRUE;
20829N/A+}
20829N/A+
20829N/A+static gboolean
20829N/A+idle_quit(void*)
20829N/A+{
20829N/A+ gtk_main_quit();
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+static gboolean
20829N/A+idle_pop(void*)
20829N/A+{
20829N/A+ gtk_moz_embed_pop_startup();
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+destroy_cb (GtkWidget *widget, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ GList *tmp_list;
20829N/A+ g_print("destroy_cb\n");
20829N/A+ num_browsers--;
20829N/A+ tmp_list = g_list_find(browser_list, browser);
20829N/A+ browser_list = g_list_remove_link(browser_list, tmp_list);
20829N/A+ if (browser->tempMessage)
20829N/A+ g_free(browser->tempMessage);
20829N/A+ g_idle_add(idle_pop, NULL);
20829N/A+ if (num_browsers == 0)
20829N/A+ g_idle_add (idle_quit, NULL);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+location_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ char *newLocation;
20829N/A+ int newPosition = 0;
20829N/A+ g_print("location_changed_cb\n");
20829N/A+ newLocation = gtk_moz_embed_get_location(embed);
20829N/A+ if (newLocation)
20829N/A+ {
20829N/A+ gtk_editable_delete_text(GTK_EDITABLE(browser->urlEntry), 0, -1);
20829N/A+ gtk_editable_insert_text(GTK_EDITABLE(browser->urlEntry),
20829N/A+ newLocation, strlen(newLocation), &newPosition);
20829N/A+ g_free(newLocation);
20829N/A+ }
20829N/A+ else
20829N/A+ g_print("failed to get location!\n");
20829N/A+ // always make sure to clear the tempMessage. it might have been
20829N/A+ // set from the link before a click and we wouldn't have gotten the
20829N/A+ // callback to unset it.
20829N/A+ update_temp_message(browser, 0);
20829N/A+ // update the nav buttons on a location change
20829N/A+ update_nav_buttons(browser);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+title_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ char *newTitle;
20829N/A+ g_print("title_changed_cb\n");
20829N/A+ newTitle = gtk_moz_embed_get_title(embed);
20829N/A+ if (newTitle)
20829N/A+ {
20829N/A+ gtk_window_set_title(GTK_WINDOW(browser->topLevelWindow), newTitle);
20829N/A+ g_free(newTitle);
20829N/A+ }
20829N/A+
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+load_started_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("load_started_cb\n");
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, TRUE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, FALSE);
20829N/A+ browser->loadPercent = 0;
20829N/A+ browser->bytesLoaded = 0;
20829N/A+ browser->maxBytesLoaded = 0;
20829N/A+ update_status_bar_text(browser);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+load_finished_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("load_finished_cb\n");
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, TRUE);
20829N/A+ browser->loadPercent = 0;
20829N/A+ browser->bytesLoaded = 0;
20829N/A+ browser->maxBytesLoaded = 0;
20829N/A+ update_status_bar_text(browser);
20829N/A+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progressBar), 0);
20829N/A+}
20829N/A+
20829N/A+
20829N/A+void
20829N/A+net_state_change_cb (GtkMozEmbed *embed, gint flags, guint status,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("net_state_change_cb %d\n", flags);
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_REDIRECTING)
20829N/A+ browser->statusMessage = "Redirecting to site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_TRANSFERRING)
20829N/A+ browser->statusMessage = "Transferring data from site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_NEGOTIATING)
20829N/A+ browser->statusMessage = "Waiting for authorization...";
20829N/A+ }
20829N/A+
20829N/A+ if (status == GTK_MOZ_EMBED_STATUS_FAILED_DNS)
20829N/A+ browser->statusMessage = "Site not found.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_CONNECT)
20829N/A+ browser->statusMessage = "Failed to connect to site.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT)
20829N/A+ browser->statusMessage = "Failed due to connection timeout.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED)
20829N/A+ browser->statusMessage = "User canceled connecting to site.";
20829N/A+
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT) {
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_START)
20829N/A+ browser->statusMessage = "Loading site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_STOP)
20829N/A+ browser->statusMessage = "Done.";
20829N/A+ }
20829N/A+
20829N/A+ update_status_bar_text(browser);
20829N/A+
20829N/A+}
20829N/A+
20829N/A+void net_state_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ gint flags, guint status,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ // g_print("net_state_change_all_cb %s %d %d\n", uri, flags, status);
20829N/A+}
20829N/A+
20829N/A+void progress_change_cb (GtkMozEmbed *embed, gint cur, gint max,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("progress_change_cb cur %d max %d\n", cur, max);
20829N/A+
20829N/A+ // avoid those pesky divide by zero errors
20829N/A+ if (max < 1)
20829N/A+ {
20829N/A+ browser->loadPercent = 0;
20829N/A+ browser->bytesLoaded = cur;
20829N/A+ browser->maxBytesLoaded = 0;
20829N/A+ update_status_bar_text(browser);
20829N/A+ }
20829N/A+ else
20829N/A+ {
20829N/A+ browser->bytesLoaded = cur;
20829N/A+ browser->maxBytesLoaded = max;
20829N/A+ if (cur > max)
20829N/A+ browser->loadPercent = 100;
20829N/A+ else
20829N/A+ browser->loadPercent = (cur * 100) / max;
20829N/A+ update_status_bar_text(browser);
20829N/A+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progressBar),
20829N/A+ browser->loadPercent / 100.0);
20829N/A+ }
20829N/A+
20829N/A+}
20829N/A+
20829N/A+void progress_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ gint cur, gint max,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("progress_change_all_cb %s cur %d max %d\n", uri, cur, max);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+link_message_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ char *message;
20829N/A+ g_print("link_message_cb\n");
20829N/A+ message = gtk_moz_embed_get_link_message(embed);
20829N/A+ if (!message || !*message)
20829N/A+ update_temp_message(browser, 0);
20829N/A+ else
20829N/A+ update_temp_message(browser, message);
20829N/A+ if (message)
20829N/A+ g_free(message);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+js_status_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ char *message;
20829N/A+ g_print("js_status_cb\n");
20829N/A+ message = gtk_moz_embed_get_js_status(embed);
20829N/A+ if (!message || !*message)
20829N/A+ update_temp_message(browser, 0);
20829N/A+ else
20829N/A+ update_temp_message(browser, message);
20829N/A+ if (message)
20829N/A+ g_free(message);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+new_window_cb (GtkMozEmbed *embed, GtkMozEmbed **newEmbed, guint chromemask, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("new_window_cb\n");
20829N/A+ g_print("embed is %p chromemask is %d\n", (void *)embed, chromemask);
20829N/A+ TestGtkBrowser *newBrowser = new_gtk_browser(chromemask);
20829N/A+ gtk_widget_set_size_request(newBrowser->mozEmbed, 400, 400);
20829N/A+ *newEmbed = GTK_MOZ_EMBED(newBrowser->mozEmbed);
20829N/A+ g_print("new browser is %p\n", (void *)*newEmbed);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+visibility_cb (GtkMozEmbed *embed, gboolean visibility, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("visibility_cb %d\n", visibility);
20829N/A+ set_browser_visibility(browser, visibility);
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+destroy_brsr_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("destroy_brsr_cb\n");
20829N/A+ gtk_widget_destroy(browser->topLevelWindow);
20829N/A+}
20829N/A+
20829N/A+gint
20829N/A+open_uri_cb (GtkMozEmbed *embed, const char *uri, TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("open_uri_cb %s\n", uri);
20829N/A+
20829N/A+ // interrupt this test load
20829N/A+ if (!strcmp(uri, "http://people.redhat.com/blizzard/monkeys.txt"))
20829N/A+ return TRUE;
20829N/A+ // don't interrupt anything
20829N/A+ return FALSE;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+size_to_cb (GtkMozEmbed *embed, gint width, gint height,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ g_print("*** size_to_cb %d %d\n", width, height);
20829N/A+ gtk_widget_set_size_request(browser->mozEmbed, width, height);
20829N/A+}
20829N/A+
20829N/A+gint dom_key_down_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ PRUint32 keyCode = 0;
20829N/A+ // g_print("dom_key_down_cb\n");
20829N/A+ event->GetKeyCode(&keyCode);
20829N/A+ // g_print("key code is %d\n", keyCode);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_key_press_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ PRUint32 keyCode = 0;
20829N/A+ // g_print("dom_key_press_cb\n");
20829N/A+ event->GetCharCode(&keyCode);
20829N/A+ // g_print("char code is %d\n", keyCode);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_key_up_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ PRUint32 keyCode = 0;
20829N/A+ // g_print("dom_key_up_cb\n");
20829N/A+ event->GetKeyCode(&keyCode);
20829N/A+ // g_print("key code is %d\n", keyCode);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_mouse_down_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ // g_print("dom_mouse_down_cb\n");
20829N/A+ return NS_OK;
20829N/A+ }
20829N/A+
20829N/A+gint dom_mouse_up_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ // g_print("dom_mouse_up_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_mouse_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ // g_print("dom_mouse_click_cb\n");
20829N/A+ PRUint16 button;
20829N/A+ event->GetButton(&button);
20829N/A+ printf("button was %d\n", button);
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_mouse_dbl_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ // g_print("dom_mouse_dbl_click_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_mouse_over_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("dom_mouse_over_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_mouse_out_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("dom_mouse_out_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_activate_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("dom_activate_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_focus_in_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("dom_focus_in_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+gint dom_focus_out_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ TestGtkBrowser *browser)
20829N/A+{
20829N/A+ //g_print("dom_focus_out_cb\n");
20829N/A+ return NS_OK;
20829N/A+}
20829N/A+
20829N/A+void new_window_orphan_cb (GtkMozEmbedSingle *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+ gpointer data)
20829N/A+{
20829N/A+ g_print("new_window_orphan_cb\n");
20829N/A+ g_print("chromemask is %d\n", chromemask);
20829N/A+ TestGtkBrowser *newBrowser = new_gtk_browser(chromemask);
20829N/A+ *retval = GTK_MOZ_EMBED(newBrowser->mozEmbed);
20829N/A+ g_print("new browser is %p\n", (void *)*retval);
20829N/A+}
20829N/A+
20829N/A+// utility functions
20829N/A+
20829N/A+void
20829N/A+update_status_bar_text(TestGtkBrowser *browser)
20829N/A+{
20829N/A+ gchar message[256];
20829N/A+
20829N/A+ gtk_statusbar_pop(GTK_STATUSBAR(browser->statusBar), 1);
20829N/A+ if (browser->tempMessage)
20829N/A+ gtk_statusbar_push(GTK_STATUSBAR(browser->statusBar), 1, browser->tempMessage);
20829N/A+ else
20829N/A+ {
20829N/A+ if (browser->loadPercent)
20829N/A+ {
20829N/A+ g_snprintf(message, 255, "%s (%d%% complete, %d bytes of %d loaded)", browser->statusMessage, browser->loadPercent, browser->bytesLoaded, browser->maxBytesLoaded);
20829N/A+ }
20829N/A+ else if (browser->bytesLoaded)
20829N/A+ {
20829N/A+ g_snprintf(message, 255, "%s (%d bytes loaded)", browser->statusMessage, browser->bytesLoaded);
20829N/A+ }
20829N/A+ else if (browser->statusMessage == NULL)
20829N/A+ {
20829N/A+ g_snprintf(message, 255, " ");
20829N/A+ }
20829N/A+ else
20829N/A+ {
20829N/A+ g_snprintf(message, 255, "%s", browser->statusMessage);
20829N/A+ }
20829N/A+ gtk_statusbar_push(GTK_STATUSBAR(browser->statusBar), 1, message);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+update_temp_message(TestGtkBrowser *browser, const char *message)
20829N/A+{
20829N/A+ if (browser->tempMessage)
20829N/A+ g_free(browser->tempMessage);
20829N/A+ if (message)
20829N/A+ browser->tempMessage = g_strdup(message);
20829N/A+ else
20829N/A+ browser->tempMessage = 0;
20829N/A+ // now that we've updated the temp message, redraw the status bar
20829N/A+ update_status_bar_text(browser);
20829N/A+}
20829N/A+
20829N/A+
20829N/A+void
20829N/A+update_nav_buttons (TestGtkBrowser *browser)
20829N/A+{
20829N/A+ gboolean can_go_back;
20829N/A+ gboolean can_go_forward;
20829N/A+ can_go_back = gtk_moz_embed_can_go_back(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+ can_go_forward = gtk_moz_embed_can_go_forward(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+ if (can_go_back)
20829N/A+ gtk_widget_set_sensitive(browser->backButton, TRUE);
20829N/A+ else
20829N/A+ gtk_widget_set_sensitive(browser->backButton, FALSE);
20829N/A+ if (can_go_forward)
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, TRUE);
20829N/A+ else
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, FALSE);
20829N/A+ }
20829N/A+
20829N/Adiff --git a/embedding/browser/gtk/tests/TestGtkEmbedChild.cpp b/embedding/browser/gtk/tests/TestGtkEmbedChild.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/TestGtkEmbedChild.cpp
20829N/A@@ -0,0 +1,185 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include "gtkmozembed.h"
20829N/A+#include <gtk/gtk.h>
20829N/A+#include <gdk/gdkx.h>
20829N/A+#include <stdio.h>
20829N/A+#include <stdlib.h>
20829N/A+
20829N/A+#include "nsStringAPI.h"
20829N/A+#include "gtkmozembed_glue.cpp"
20829N/A+
20829N/A+int (*old_handler) (Display *, XErrorEvent *);
20829N/A+
20829N/A+int error_handler (Display *d, XErrorEvent *e)
20829N/A+{
20829N/A+ if ((e->error_code == BadWindow) || (e->error_code == BadDrawable))
20829N/A+ {
20829N/A+ XID resourceid = e->resourceid;
20829N/A+ GdkWindow *window = gdk_window_lookup (resourceid);
20829N/A+
20829N/A+ if (window)
20829N/A+ {
20829N/A+ if (!g_dataset_get_data (window, "bonobo-error"))
20829N/A+ {
20829N/A+ g_dataset_set_data_full (window, "bonobo-error",
20829N/A+ g_new (gint, 1),
20829N/A+ (GDestroyNotify)g_free);
20829N/A+
20829N/A+ g_warning ("Error accessing window %ld", resourceid);
20829N/A+ }
20829N/A+ }
20829N/A+ return 0;
20829N/A+ }
20829N/A+ else
20829N/A+ {
20829N/A+ return (*old_handler)(d, e);
20829N/A+ }
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+load_page(gpointer data);
20829N/A+
20829N/A+GtkWidget *embed = 0;
20829N/A+GtkWidget *entry = 0;
20829N/A+
20829N/A+int
20829N/A+main(int argc, char **argv)
20829N/A+{
20829N/A+ guint32 xid;
20829N/A+
20829N/A+ GtkWidget *window;
20829N/A+ GtkWidget *hbox;
20829N/A+ GtkWidget *vbox;
20829N/A+ GtkWidget *button;
20829N/A+
20829N/A+ gtk_init(&argc, &argv);
20829N/A+
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ "1.9a", PR_TRUE,
20829N/A+ "2", PR_TRUE
20829N/A+ };
20829N/A+
20829N/A+ char xpcomPath[PATH_MAX];
20829N/A+
20829N/A+ nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = GTKEmbedGlueStartup();
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ if (lastSlash)
20829N/A+ *lastSlash = '\0';
20829N/A+
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+
20829N/A+ old_handler = XSetErrorHandler (error_handler);
20829N/A+
20829N/A+ if (argc < 2) {
20829N/A+ fprintf(stderr, "Usage: TestGtkEmbedChild WINDOW_ID\n");
20829N/A+ exit(1);
20829N/A+ }
20829N/A+
20829N/A+ xid = strtol (argv[1], (char **)NULL, 0);
20829N/A+
20829N/A+ if (xid == 0) {
20829N/A+ fprintf(stderr, "Invalid window id '%s'\n", argv[1]);
20829N/A+ exit(1);
20829N/A+ }
20829N/A+
20829N/A+ window = gtk_plug_new(xid);
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(window), "destroy",
20829N/A+ G_CALLBACK(gtk_main_quit), NULL);
20829N/A+
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(window), 0);
20829N/A+
20829N/A+ vbox = gtk_vbox_new (FALSE, 0);
20829N/A+ gtk_container_add(GTK_CONTAINER(window), vbox);
20829N/A+ gtk_widget_show(vbox);
20829N/A+
20829N/A+ hbox = gtk_hbox_new (FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
20829N/A+ gtk_widget_show (hbox);
20829N/A+
20829N/A+ entry = gtk_entry_new ();
20829N/A+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
20829N/A+ gtk_widget_show (entry);
20829N/A+
20829N/A+ button = gtk_button_new_with_label("Load");
20829N/A+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
20829N/A+ gtk_widget_show(button);
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(load_page), NULL);
20829N/A+
20829N/A+ embed = gtk_moz_embed_new();
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), embed, TRUE, TRUE, 0);
20829N/A+ gtk_widget_set_size_request(embed, 200, 200);
20829N/A+ gtk_widget_show(embed);
20829N/A+
20829N/A+ gtk_widget_show(window);
20829N/A+
20829N/A+ gtk_main();
20829N/A+
20829N/A+ fprintf(stderr, "exiting.\n");
20829N/A+
20829N/A+ return 0;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+load_page(gpointer data)
20829N/A+{
20829N/A+ gchar *text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
20829N/A+ g_print("load url %s\n", text);
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(embed), text);
20829N/A+ g_free(text);
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/tests/TestGtkEmbedMDI.cpp b/embedding/browser/gtk/tests/TestGtkEmbedMDI.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/TestGtkEmbedMDI.cpp
20829N/A@@ -0,0 +1,142 @@
20829N/A+/** simplemdi.c **/
20829N/A+/*
20829N/A+ * Sample code from "GNOME/GTK+ Programming Bible" by Arthur Griffith
20829N/A+ * Modified by Kevin Gibbs (kgibbs@stanford.edu) to provide sample of
20829N/A+ * GtkMozEmbed realization/unrealization crashes.
20829N/A+ *
20829N/A+ * To get a fatal crash, simply run the program, click on the "Mozilla"
20829N/A+ * tab to display the MozEmbed widget, and then try to drag that MDI tab
20829N/A+ * off to a new window.
20829N/A+ *
20829N/A+ * Although this test might seem elaborate, it is really only a convenient
20829N/A+ * to create a situation where the widget is realized, unrealized, and
20829N/A+ * realized again at some point. (Dragging the MDI tab off to a new window
20829N/A+ * causes all widgets to be unrealized in the old window, and then realized
20829N/A+ * again in the new window.)
20829N/A+ */
20829N/A+
20829N/A+#include <gnome.h>
20829N/A+#include "gtkmozembed.h"
20829N/A+
20829N/A+// Testing flags
20829N/A+//
20829N/A+
20829N/A+// Define this flag to have the test program use the gtkmozembed widget.
20829N/A+// Without this flag, mozilla is never loaded in the program, and a simple
20829N/A+// widget is used in place of the mozembed widget.
20829N/A+#define USE_MOZILLA_TEST
20829N/A+
20829N/A+// Define this flag to have a simpler test than the usual one. The normal
20829N/A+// test builds a notebook inside of each MDI view, with one page being a label
20829N/A+// and the other page being a browser widget. The simpler test does not
20829N/A+// build a notebook and simply puts the browser widget in the MDI view itself.
20829N/A+// Currently, this test is not very interesting, since for some reason all
20829N/A+// the webshells just create and destroy themselves. (???)
20829N/A+//#define SIMPLER_TEST
20829N/A+
20829N/A+// Define this flag to use a GnomePixmap instead of a GtkLabel as the
20829N/A+// replacement for the gtkmozembed widget when USE_MOZILLA_TEST is
20829N/A+// undefined. This is to stress test the program a bit more by providing a
20829N/A+// replacement widget slightly more complex than GtkLabel.
20829N/A+// (Has no effect when USE_MOZILLA_TEST is defined.)
20829N/A+#define SAMPLE_PIXMAP
20829N/A+
20829N/A+
20829N/A+gint eventDelete(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data);
20829N/A+gint eventDestroy(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data);
20829N/A+
20829N/A+static void addChild(GtkObject *mdi,gchar *name);
20829N/A+static GtkWidget *setLabel(GnomeMDIChild *child,
20829N/A+ GtkWidget *currentLabel,gpointer data);
20829N/A+static GtkWidget *createView(GnomeMDIChild *child,
20829N/A+ gpointer data);
20829N/A+
20829N/A+int main(int argc,char *argv[])
20829N/A+{
20829N/A+ GtkObject *mdi;
20829N/A+
20829N/A+ gnome_init("simplemdi","1.0",argc,argv);
20829N/A+ mdi = gnome_mdi_new("simplemdi","Simple MDI");
20829N/A+ gtk_signal_connect(mdi,"destroy",
20829N/A+ GTK_SIGNAL_FUNC(eventDestroy),NULL);
20829N/A+
20829N/A+ addChild(mdi,"First");
20829N/A+ addChild(mdi,"Second");
20829N/A+ addChild(mdi,"Third");
20829N/A+ addChild(mdi,"Last");
20829N/A+
20829N/A+ gnome_mdi_set_mode(GNOME_MDI(mdi),GNOME_MDI_NOTEBOOK);
20829N/A+ //gnome_mdi_open_toplevel(GNOME_MDI(mdi));
20829N/A+
20829N/A+ gtk_main();
20829N/A+ exit(0);
20829N/A+}
20829N/A+static void addChild(GtkObject *mdi,gchar *name)
20829N/A+{
20829N/A+ GnomeMDIGenericChild *child;
20829N/A+
20829N/A+ child = gnome_mdi_generic_child_new(name);
20829N/A+ gnome_mdi_add_child(GNOME_MDI(mdi),
20829N/A+ GNOME_MDI_CHILD(child));
20829N/A+
20829N/A+ gnome_mdi_generic_child_set_view_creator(child,
20829N/A+ createView,name);
20829N/A+ gnome_mdi_generic_child_set_label_func(child,setLabel,
20829N/A+ NULL);
20829N/A+ gnome_mdi_add_view(GNOME_MDI(mdi),
20829N/A+ GNOME_MDI_CHILD(child));
20829N/A+}
20829N/A+static GtkWidget *createView(GnomeMDIChild *child,
20829N/A+ gpointer data)
20829N/A+{
20829N/A+#ifdef USE_MOZILLA_TEST
20829N/A+ GtkWidget *browser = gtk_moz_embed_new();
20829N/A+#else
20829N/A+#ifndef SAMPLE_PIXMAP
20829N/A+ GtkWidget *browser = gtk_label_new("lynx 0.01a");
20829N/A+#else
20829N/A+ /* Another example -- */
20829N/A+ GtkWidget *browser =
20829N/A+ gnome_pixmap_new_from_file("/usr/share/pixmaps/emacs.png");
20829N/A+#endif /* SAMPLE_PIXMAP */
20829N/A+#endif /* USE_MOZILLA_TEST */
20829N/A+
20829N/A+ GtkWidget *notebook = gtk_notebook_new();
20829N/A+ char str[80];
20829N/A+
20829N/A+ sprintf(str,"View of the\n%s widget",(gchar *)data);
20829N/A+
20829N/A+#ifdef USE_MOZILLA_TEST
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser), "http://www.mozilla.org");
20829N/A+#endif /* USE_MOZILLA_TEST */
20829N/A+
20829N/A+#ifndef SIMPLER_TEST
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), gtk_label_new(str),
20829N/A+ gtk_label_new("Label"));
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), browser,
20829N/A+ gtk_label_new("Mozilla"));
20829N/A+ gtk_widget_show_all(notebook);
20829N/A+ return (notebook);
20829N/A+#else
20829N/A+ gtk_widget_show(browser);
20829N/A+ return (browser);
20829N/A+#endif /* SIMPLER_TEST */
20829N/A+}
20829N/A+
20829N/A+static GtkWidget *setLabel(GnomeMDIChild *child,
20829N/A+ GtkWidget *currentLabel,gpointer data)
20829N/A+{
20829N/A+ if(currentLabel == NULL)
20829N/A+ return(gtk_label_new(child->name));
20829N/A+
20829N/A+ gtk_label_set_text(GTK_LABEL(currentLabel),
20829N/A+ child->name);
20829N/A+ return(currentLabel);
20829N/A+}
20829N/A+gint eventDestroy(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data) {
20829N/A+ gtk_main_quit();
20829N/A+ return(0);
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/tests/TestGtkEmbedNotebook.cpp b/embedding/browser/gtk/tests/TestGtkEmbedNotebook.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/TestGtkEmbedNotebook.cpp
20829N/A@@ -0,0 +1,86 @@
20829N/A+#include <gtk/gtk.h>
20829N/A+#include <gtkmozembed.h>
20829N/A+#include <stdio.h>
20829N/A+#include "nsStringAPI.h"
20829N/A+#include "gtkmozembed_glue.cpp"
20829N/A+
20829N/A+int main(int argc, char *argv[])
20829N/A+{
20829N/A+ GtkWidget *window;
20829N/A+ GtkWidget *label;
20829N/A+ GtkWidget *mozembed;
20829N/A+ GtkWidget *container;
20829N/A+ char *url;
20829N/A+
20829N/A+ gtk_init(&argc, &argv);
20829N/A+
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ "1.9a", PR_TRUE,
20829N/A+ "2", PR_TRUE
20829N/A+ };
20829N/A+
20829N/A+ char xpcomPath[PATH_MAX];
20829N/A+
20829N/A+ nsresult rv =
20829N/A+ GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ rv = GTKEmbedGlueStartup();
20829N/A+ if (NS_FAILED(rv)) {
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ return 1;
20829N/A+ }
20829N/A+
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ if (lastSlash)
20829N/A+ *lastSlash = '\0';
20829N/A+
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+
20829N/A+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+
20829N/A+ container = gtk_notebook_new();
20829N/A+ mozembed = gtk_moz_embed_new();
20829N/A+ label = gtk_label_new("Can you see this message?\n"
20829N/A+ "Once you switch to mozembed page "
20829N/A+ "you never see this message.");
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(mozembed), "destroy",
20829N/A+ G_CALLBACK(gtk_main_quit),
20829N/A+NULL);
20829N/A+
20829N/A+ gtk_container_add(GTK_CONTAINER(window), container);
20829N/A+
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(container),
20829N/A+ label,
20829N/A+ gtk_label_new("gtk label"));
20829N/A+
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(container),
20829N/A+ mozembed,
20829N/A+ gtk_label_new("mozembed"));
20829N/A+
20829N/A+
20829N/A+
20829N/A+
20829N/A+ gtk_widget_set_size_request(window, 400, 300);
20829N/A+ gtk_widget_show(mozembed);
20829N/A+ gtk_widget_show(label);
20829N/A+ gtk_widget_show_all(window);
20829N/A+
20829N/A+ url = (argc > 1) ? argv[1] : (char *)"localhost";
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(mozembed), url);
20829N/A+
20829N/A+ gtk_main();
20829N/A+
20829N/A+ return 0;
20829N/A+}
20829N/Adiff --git a/embedding/browser/gtk/tests/TestGtkEmbedSocket.cpp b/embedding/browser/gtk/tests/TestGtkEmbedSocket.cpp
20829N/Anew file mode 100644
20829N/A--- /dev/null
20829N/A+++ b/embedding/browser/gtk/tests/TestGtkEmbedSocket.cpp
20829N/A@@ -0,0 +1,109 @@
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ *
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * http://www.mozilla.org/MPL/
20829N/A+ *
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * License.
20829N/A+ *
20829N/A+ * The Original Code is mozilla.org code.
20829N/A+ *
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ *
20829N/A+ * Contributor(s):
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ *
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ *
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+
20829N/A+#include <gtk/gtk.h>
20829N/A+#include <gdk/gdkx.h>
20829N/A+#include <stdio.h>
20829N/A+#include <stdlib.h>
20829N/A+#include <sys/types.h>
20829N/A+#include <unistd.h>
20829N/A+
20829N/A+GtkWidget *toplevel_window = 0;
20829N/A+GtkWidget *button = 0;
20829N/A+GtkWidget *vbox = 0;
20829N/A+GtkWidget *gtk_socket = 0;
20829N/A+
20829N/A+void
20829N/A+insert_mozilla(gpointer data);
20829N/A+
20829N/A+int
20829N/A+main(int argc, char **argv)
20829N/A+{
20829N/A+ gtk_init(&argc, &argv);
20829N/A+
20829N/A+ toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(toplevel_window), "destroy",
20829N/A+ G_CALLBACK(exit), NULL);
20829N/A+
20829N/A+ vbox = gtk_vbox_new(FALSE, 0);
20829N/A+ gtk_container_add(GTK_CONTAINER(toplevel_window), vbox);
20829N/A+ gtk_widget_show(vbox);
20829N/A+
20829N/A+ button = gtk_button_new_with_label("Insert Mozilla");
20829N/A+
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
20829N/A+ gtk_widget_show(button);
20829N/A+
20829N/A+ g_signal_connect(GTK_OBJECT(button), "clicked",
20829N/A+ G_CALLBACK(insert_mozilla), NULL);
20829N/A+
20829N/A+ gtk_widget_show(toplevel_window);
20829N/A+
20829N/A+ gtk_main();
20829N/A+
20829N/A+ return 0;
20829N/A+}
20829N/A+
20829N/A+void
20829N/A+insert_mozilla(gpointer data)
20829N/A+{
20829N/A+ char buffer[20];
20829N/A+ int pid;
20829N/A+
20829N/A+ if (gtk_socket)
20829N/A+ return;
20829N/A+
20829N/A+ gtk_socket = gtk_socket_new();
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), gtk_socket, TRUE, TRUE, 0);
20829N/A+ gtk_widget_show(gtk_socket);
20829N/A+
20829N/A+ sprintf(buffer, "%#lx", GDK_WINDOW_XWINDOW(gtk_socket->window));
20829N/A+
20829N/A+ gdk_flush();
20829N/A+
20829N/A+ if ((pid = fork()) == 0) { /* child */
20829N/A+ execl("./TestGtkEmbedChild", "./TestGtkEmbedChild", buffer, NULL);
20829N/A+ fprintf(stderr, "can't exec child\n");
20829N/A+ _exit(1);
20829N/A+ }
20829N/A+ else if (pid > 0) { /* parent */
20829N/A+ }
20829N/A+ else {
20829N/A+ fprintf(stderr, "Can't fork.\n");
20829N/A+ }
20829N/A+}
20829N/Adiff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh
20829N/A--- a/toolkit/toolkit-makefiles.sh
20829N/A+++ b/toolkit/toolkit-makefiles.sh
20829N/A@@ -547,16 +547,19 @@ MAKEFILES_embedding="
20829N/A embedding/browser/Makefile
20829N/A embedding/browser/activex/src/Makefile
20829N/A embedding/browser/activex/src/common/Makefile
20829N/A embedding/browser/activex/src/control/Makefile
20829N/A embedding/browser/activex/src/control_kicker/Makefile
20829N/A embedding/browser/activex/src/plugin/Makefile
20829N/A embedding/browser/build/Makefile
20829N/A embedding/browser/webBrowser/Makefile
20829N/A+ embedding/browser/gtk/Makefile
20829N/A+ embedding/browser/gtk/src/Makefile
20829N/A+ embedding/browser/gtk/tests/Makefile
20829N/A embedding/components/Makefile
20829N/A embedding/components/appstartup/Makefile
20829N/A embedding/components/appstartup/src/Makefile
20829N/A embedding/components/build/Makefile
20829N/A embedding/components/commandhandler/Makefile
20829N/A embedding/components/commandhandler/public/Makefile
20829N/A embedding/components/commandhandler/src/Makefile
20829N/A embedding/components/find/Makefile
20829N/Adiff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in
20829N/A--- a/toolkit/library/Makefile.in
20829N/A+++ b/toolkit/library/Makefile.in
20829N/A@@ -80,6 +80,13 @@
20829N/A DEFINES += -DMOZ_ENABLE_GTK2
20829N/A endif
20829N/A
20829N/A+# dependent libraries
20829N/A+ifneq (,$(MOZ_ENABLE_GTK2))
20829N/A+SHARED_LIBRARY_LIBS += \
20829N/A+ $(DEPTH)/embedding/browser/gtk/src/$(LIB_PREFIX)gtkembedmoz.$(LIB_SUFFIX)
20829N/A+DEFINES += -DMOZ_ENABLE_GTK2
20829N/A+endif
20829N/A+
20829N/A SHARED_LIBRARY_LIBS += \
20829N/A $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX) \
20829N/A $(NULL)
20829N/Adiff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk
20829N/A--- a/toolkit/toolkit-tiers.mk
20829N/A+++ b/toolkit/toolkit-tiers.mk
20829N/A@@ -223,6 +223,12 @@
20829N/A
20829N/A tier_platform_dirs += services/crypto/component
20829N/A
20829N/A+ifndef BUILD_STATIC_LIBS
20829N/A+ifneq (,$(MOZ_ENABLE_GTK2))
20829N/A+tier_platform_dirs += embedding/browser/gtk
20829N/A+endif
20829N/A+endif
20829N/A+
20829N/A tier_platform_dirs += startupcache
20829N/A
20829N/A ifdef APP_LIBXUL_STATICDIRS