Landing MICROB_20061031_BRANCH
This is an experiment, and I'm sorry that the code isn't perfect. Patches Wanted, Work will be on the MICROB_20061204_BRANCH git-svn-id: svn://10.0.0.236/trunk@216392 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b979daf5a5
commit
7e663e4f9e
366
mozilla/embedding/browser/gtk/src/EmbedCertificates.cpp
Normal file
366
mozilla/embedding/browser/gtk/src/EmbedCertificates.cpp
Normal file
@ -0,0 +1,366 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Terry Hayes <thayes@netscape.com>
|
||||
* Javier Delgadillo <javi@netscape.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/**
|
||||
* Derived from nsNSSDialogs http://landfill.mozilla.org/mxr-test/seamonkey/source/security/manager/pki/src/nsNSSDialogs.cpp
|
||||
*/
|
||||
#include <strings.h>
|
||||
#include "nsIURI.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#include <nsXPIDLString.h>
|
||||
#include "nsReadableUtils.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIX509Cert.h"
|
||||
#include "nsIX509CertDB.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "EmbedCertificates.h"
|
||||
#include "nsIKeygenThread.h"
|
||||
#include "nsIX509CertValidity.h"
|
||||
#include "nsICRLInfo.h"
|
||||
#include "gtkmozembed.h"
|
||||
|
||||
#define PIPSTRING_BUNDLE_URL "chrome://pippki/locale/pippki.properties"
|
||||
|
||||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
EmbedCertificates::EmbedCertificates(void)
|
||||
{
|
||||
}
|
||||
|
||||
EmbedCertificates::~EmbedCertificates()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS9(
|
||||
#else
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS8(
|
||||
#endif
|
||||
EmbedCertificates,
|
||||
nsITokenPasswordDialogs,
|
||||
nsIBadCertListener,
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
nsIBadCertListener2,
|
||||
#endif
|
||||
nsICertificateDialogs,
|
||||
nsIClientAuthDialogs,
|
||||
nsICertPickDialogs,
|
||||
nsITokenDialogs,
|
||||
nsIDOMCryptoDialogs,
|
||||
nsIGeneratingKeypairInfoDialogs)
|
||||
|
||||
nsresult
|
||||
EmbedCertificates::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIStringBundleService> service = do_GetService(kCStringBundleServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
rv = service->CreateBundle(PIPSTRING_BUNDLE_URL,
|
||||
getter_AddRefs(mPIPStringBundle));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedCertificates::SetPassword(nsIInterfaceRequestor *ctx,
|
||||
const PRUnichar *tokenName, PRBool* _canceled)
|
||||
{
|
||||
*_canceled = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedCertificates::GetPassword(nsIInterfaceRequestor *ctx,
|
||||
const PRUnichar *tokenName,
|
||||
PRUnichar **_password,
|
||||
PRBool* _canceled)
|
||||
{
|
||||
*_canceled = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo,
|
||||
nsIX509Cert *cert, PRInt16 *outAddType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*outAddType = ADD_TRUSTED_FOR_SESSION;
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmMismatchDomain(nsIInterfaceRequestor *socketInfo,
|
||||
const nsACString &targetURL,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmCertExpired(nsIInterfaceRequestor *socketInfo,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::NotifyCrlNextupdate(nsIInterfaceRequestor *socketInfo,
|
||||
const nsACString &targetURL, nsIX509Cert *cert)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::CrlImportStatusDialog(nsIInterfaceRequestor *ctx, nsICRLInfo *crl)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
|
||||
nsIX509Cert *cert,
|
||||
PRUint32 *_trust,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*_trust |= nsIX509CertDB::TRUSTED_SSL;
|
||||
*_trust |= nsIX509CertDB::TRUSTED_EMAIL;
|
||||
*_trust |= nsIX509CertDB::TRUSTED_OBJSIGN;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::NotifyCACertExists(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ChooseCertificate(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
const PRUnichar *cn,
|
||||
const PRUnichar *organization,
|
||||
const PRUnichar *issuer,
|
||||
const PRUnichar **certNickList,
|
||||
const PRUnichar **certDetailsList,
|
||||
PRUint32 count,
|
||||
PRInt32 *selectedIndex,
|
||||
PRBool *canceled)
|
||||
{
|
||||
*canceled = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::PickCertificate(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
const PRUnichar **certNickList,
|
||||
const PRUnichar **certDetailsList,
|
||||
PRUint32 count,
|
||||
PRInt32 *selectedIndex,
|
||||
PRBool *canceled)
|
||||
{
|
||||
*canceled = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::SetPKCS12FilePassword(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
nsAString &_password,
|
||||
PRBool *_retval)
|
||||
{
|
||||
/* The person who wrote this method implementation did
|
||||
* not read the contract.
|
||||
*/
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::GetPKCS12FilePassword(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
nsAString &_password,
|
||||
PRBool *_retval)
|
||||
{
|
||||
/* The person who wrote this method implementation did
|
||||
* not read the contract.
|
||||
*/
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void viewCert (in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ViewCert(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
nsIX509Cert *cert)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *aCtx, nsIKeygenThread *runnable)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ChooseToken(
|
||||
nsIInterfaceRequestor *aCtx,
|
||||
const PRUnichar **aTokenList,
|
||||
PRUint32 aCount,
|
||||
PRUnichar **aTokenChosen,
|
||||
PRBool *aCanceled)
|
||||
{
|
||||
*aCanceled = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean ConfirmKeyEscrow (in nsIX509Cert escrowAuthority); */
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmKeyEscrow(nsIX509Cert *escrowAuthority, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
NS_IMETHODIMP
|
||||
EmbedCertificates::ConfirmBadCertificate(
|
||||
nsIInterfaceRequestor *ctx,
|
||||
nsIX509Cert *cert,
|
||||
PRBool aSecSuccess,
|
||||
PRUint32 aError,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
gpointer pCert = NULL;
|
||||
guint messint = 0;
|
||||
nsCOMPtr<nsIDOMWindow> parent (do_GetInterface (ctx));
|
||||
|
||||
GtkMozEmbedCommon * common = nsnull;
|
||||
GtkMozEmbed *parentWidget = GTK_MOZ_EMBED(GetGtkWidgetForDOMWindow(parent));
|
||||
|
||||
if (!parentWidget) {
|
||||
EmbedCommon * embedcommon = EmbedCommon::GetInstance();
|
||||
if (embedcommon)
|
||||
common = embedcommon->mCommon;
|
||||
}
|
||||
|
||||
if (!(aError & nsIX509Cert::VERIFIED_OK)) {
|
||||
pCert = (gpointer)cert;
|
||||
messint = GTK_MOZ_EMBED_CERT_VERIFIED_OK;
|
||||
if (aError & nsIX509Cert::NOT_VERIFIED_UNKNOWN) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_NOT_VERIFIED_UNKNOWN;
|
||||
}
|
||||
if (aError & nsIX509Cert::CERT_EXPIRED || aError & nsIX509Cert::CERT_REVOKED) {
|
||||
nsCOMPtr<nsIX509CertValidity> validity;
|
||||
rv = cert->GetValidity(getter_AddRefs(validity));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRTime notBefore, notAfter, timeToUse;
|
||||
PRTime now = PR_Now();
|
||||
rv = validity->GetNotBefore(¬Before);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = validity->GetNotAfter(¬After);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (LL_CMP(now, >, notAfter)) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_EXPIRED;
|
||||
timeToUse = notAfter;
|
||||
} else {
|
||||
messint |= GTK_MOZ_EMBED_CERT_REVOKED;
|
||||
timeToUse = notBefore;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aError & nsIX509Cert::CERT_NOT_TRUSTED) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_UNTRUSTED;
|
||||
}
|
||||
if (aError & nsIX509Cert::ISSUER_UNKNOWN) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_ISSUER_UNKNOWN;
|
||||
}
|
||||
if (aError & nsIX509Cert::ISSUER_NOT_TRUSTED) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_ISSUER_UNTRUSTED;
|
||||
}
|
||||
if (aError & nsIX509Cert::INVALID_CA) {
|
||||
messint |= GTK_MOZ_EMBED_CERT_INVALID_CA;
|
||||
}
|
||||
if (aError & nsIX509Cert::USAGE_NOT_ALLOWED) {
|
||||
}
|
||||
PRBool retVal = PR_FALSE;
|
||||
if (common) {
|
||||
g_signal_emit_by_name(common, "certificate-error", pCert, messint, &retVal);
|
||||
}
|
||||
if (retVal == PR_TRUE) {
|
||||
*_retval = PR_FALSE;
|
||||
rv = NS_ERROR_FAILURE;
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
pCert = NULL;
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
96
mozilla/embedding/browser/gtk/src/EmbedCertificates.h
Normal file
96
mozilla/embedding/browser/gtk/src/EmbedCertificates.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Terry Hayes <thayes@netscape.com>
|
||||
* Javier Delgadillo <javi@netscape.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/**
|
||||
* Derived from nsNSSDialogs http://landfill.mozilla.org/mxr-test/seamonkey/source/security/manager/pki/src/nsNSSDialogs.h
|
||||
*/
|
||||
#ifndef __EmbedCertificates_h
|
||||
#define __EmbedCertificates_h
|
||||
#include "nsITokenPasswordDialogs.h"
|
||||
#include "nsIBadCertListener.h"
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
#include "nsIBadCertListener2.h"
|
||||
#endif
|
||||
#include "nsICertificateDialogs.h"
|
||||
#include "nsIClientAuthDialogs.h"
|
||||
#include "nsICertPickDialogs.h"
|
||||
#include "nsITokenDialogs.h"
|
||||
#include "nsIDOMCryptoDialogs.h"
|
||||
#include "nsIGenKeypairInfoDlg.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#define EMBED_CERTIFICATES_CID \
|
||||
{ 0x518e071f, 0x1dd2, 0x11b2, \
|
||||
{ 0x93, 0x7e, 0xc4, 0x5f, 0x14, 0xde, 0xf7, 0x78 }}
|
||||
#define EMBED_CERTIFICATES_DESCRIPTION "Certificates Listener Impl"
|
||||
class EmbedPrivate;
|
||||
class EmbedCertificates
|
||||
: public nsITokenPasswordDialogs,
|
||||
public nsIBadCertListener,
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
public nsIBadCertListener2,
|
||||
#endif
|
||||
public nsICertificateDialogs,
|
||||
public nsIClientAuthDialogs,
|
||||
public nsICertPickDialogs,
|
||||
public nsITokenDialogs,
|
||||
public nsIDOMCryptoDialogs,
|
||||
public nsIGeneratingKeypairInfoDialogs
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITOKENPASSWORDDIALOGS
|
||||
NS_DECL_NSIBADCERTLISTENER
|
||||
#ifdef BAD_CERT_LISTENER2
|
||||
NS_DECL_NSIBADCERTLISTENER2
|
||||
#endif
|
||||
NS_DECL_NSICERTIFICATEDIALOGS
|
||||
NS_DECL_NSICLIENTAUTHDIALOGS
|
||||
NS_DECL_NSICERTPICKDIALOGS
|
||||
NS_DECL_NSITOKENDIALOGS
|
||||
NS_DECL_NSIDOMCRYPTODIALOGS
|
||||
NS_DECL_NSIGENERATINGKEYPAIRINFODIALOGS
|
||||
EmbedCertificates();
|
||||
virtual ~EmbedCertificates();
|
||||
nsresult Init(void);
|
||||
protected:
|
||||
nsCOMPtr<nsIStringBundle> mPIPStringBundle;
|
||||
};
|
||||
#endif /* __EmbedCertificates_h */
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -36,7 +38,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <strings.h>
|
||||
#include <nsXPIDLString.h>
|
||||
|
||||
#include "nsIURI.h"
|
||||
|
||||
@ -69,10 +70,15 @@ EmbedContentListener::Init(EmbedPrivate *aOwner)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
PRBool *aAbortOpen)
|
||||
PRBool *aAbortOpen)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (mOwner->mOpenBlock) {
|
||||
*aAbortOpen = mOwner->mOpenBlock;
|
||||
mOwner->mOpenBlock = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsCAutoString specString;
|
||||
rv = aURI->GetSpec(specString);
|
||||
|
||||
@ -80,9 +86,26 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
return rv;
|
||||
|
||||
gint return_val = FALSE;
|
||||
|
||||
/* checks if URI scheme is mailto */
|
||||
aURI->SchemeIs("mailto", &return_val);
|
||||
if (return_val) {
|
||||
/* stops URI opening to emit "mailto" signal */
|
||||
*aAbortOpen = TRUE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[MAILTO],
|
||||
specString.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// otherwise ...
|
||||
return_val = FALSE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[OPEN_URI],
|
||||
specString.get(), &return_val);
|
||||
moz_embed_signals[OPEN_URI],
|
||||
specString.get(), &return_val);
|
||||
|
||||
*aAbortOpen = return_val;
|
||||
|
||||
@ -91,41 +114,41 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::DoContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::IsPreferred(const char *aContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
if (webNavInfo) {
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation.get() : nsnull,
|
||||
&canHandle);
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation.get() : nsnull,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
||||
578
mozilla/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
Normal file
578
mozilla/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
Normal file
@ -0,0 +1,578 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Oleg Romashin. Portions created by Oleg Romashin are Copyright (C) Oleg Romashin. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "EmbedContextMenuInfo.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "imgILoader.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMHTMLLinkElement.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMAbstractView.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIDOM3Document.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
//*****************************************************************************
|
||||
// class EmbedContextMenuInfo
|
||||
//*****************************************************************************
|
||||
EmbedContextMenuInfo::EmbedContextMenuInfo(EmbedPrivate *aOwner) : mCtxFrameNum(-1), mEmbedCtxType(0)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mEventNode = nsnull;
|
||||
mCtxDocument = nsnull;
|
||||
mNSHHTMLElement = nsnull;
|
||||
mNSHHTMLElementSc = nsnull;
|
||||
mFormRect = nsRect(0,0,0,0);
|
||||
}
|
||||
|
||||
EmbedContextMenuInfo::~EmbedContextMenuInfo(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(EmbedContextMenuInfo)
|
||||
NS_IMPL_RELEASE(EmbedContextMenuInfo)
|
||||
NS_INTERFACE_MAP_BEGIN(EmbedContextMenuInfo)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::SetFrameIndex()
|
||||
{
|
||||
nsCOMPtr <nsIDOMWindowCollection> frames;
|
||||
mCtxDomWindow->GetFrames (getter_AddRefs (frames));
|
||||
nsCOMPtr <nsIDOMWindow> currentWindow;
|
||||
PRUint32 frameCount = 0;
|
||||
frames->GetLength (&frameCount);
|
||||
for (unsigned int i= 0; i < frameCount; i++) {
|
||||
frames->Item(i, getter_AddRefs (currentWindow));
|
||||
nsCOMPtr<nsIDOMDocument> currentDoc;
|
||||
currentWindow->GetDocument (getter_AddRefs(currentDoc));
|
||||
if (currentDoc == mCtxDocument) {
|
||||
mCtxFrameNum = i;
|
||||
mCtxDomWindow = currentWindow;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::GetFormControlType(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (!aEvent)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
nsevent->GetOriginalTarget(getter_AddRefs(target));
|
||||
// mOrigTarget = target;
|
||||
if (SetFormControlType(target)) {
|
||||
nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(target);
|
||||
if (!eventNode)
|
||||
return NS_OK;
|
||||
eventNode->GetNodeName(mSEventNode);
|
||||
//Frame Stuff
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
nsresult rv = eventNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!NS_SUCCEEDED (rv) || !domDoc) {
|
||||
return NS_OK;
|
||||
}
|
||||
mEventNode = eventNode;
|
||||
mCtxDocument = domDoc;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
|
||||
if (!doc)
|
||||
return NS_OK;
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if (!presShell)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
nsIFrame* frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(tgContent, &frame);
|
||||
#else
|
||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(tgContent);
|
||||
#endif
|
||||
if (frame)
|
||||
mFormRect = frame->GetScreenRectExternal();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::SetFormControlType(nsIDOMEventTarget *originalTarget)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(originalTarget);
|
||||
mCtxFormType = 0;
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
if (targetContent && targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
#else
|
||||
if (targetContent && targetContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
#endif
|
||||
nsCOMPtr<nsIFormControl> formControl (do_QueryInterface(targetContent));
|
||||
if (formControl) {
|
||||
mCtxFormType = formControl->GetType();
|
||||
rv = NS_OK;
|
||||
//#ifdef MOZ_LOGGING
|
||||
switch (mCtxFormType) {
|
||||
case NS_FORM_BUTTON_BUTTON:
|
||||
break;
|
||||
case NS_FORM_BUTTON_RESET:
|
||||
break;
|
||||
case NS_FORM_BUTTON_SUBMIT:
|
||||
break;
|
||||
case NS_FORM_FIELDSET:
|
||||
break;
|
||||
case NS_FORM_INPUT_BUTTON:
|
||||
break;
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
break;
|
||||
case NS_FORM_INPUT_FILE:
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
|
||||
break;
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
break;
|
||||
case NS_FORM_INPUT_RESET:
|
||||
break;
|
||||
case NS_FORM_INPUT_IMAGE:
|
||||
break;
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IPASSWORD;
|
||||
break;
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
break;
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
break;
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
|
||||
break;
|
||||
case NS_FORM_LABEL:
|
||||
break;
|
||||
case NS_FORM_OPTION:
|
||||
break;
|
||||
case NS_FORM_OPTGROUP:
|
||||
break;
|
||||
case NS_FORM_LEGEND:
|
||||
break;
|
||||
case NS_FORM_SELECT:
|
||||
break;
|
||||
case NS_FORM_TEXTAREA:
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
|
||||
break;
|
||||
case NS_FORM_OBJECT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
|
||||
PRBool rdonly = PR_FALSE;
|
||||
if (mCtxFormType == NS_FORM_TEXTAREA) {
|
||||
nsCOMPtr <nsIDOMHTMLTextAreaElement> input;
|
||||
input = do_QueryInterface(mEventNode, &rv);
|
||||
if (!NS_FAILED(rv) && input)
|
||||
rv = input->GetReadOnly(&rdonly);
|
||||
if (!NS_FAILED(rv) && rdonly) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr <nsIDOMHTMLInputElement> input;
|
||||
input = do_QueryInterface(mEventNode, &rv);
|
||||
if (!NS_FAILED(rv) && input)
|
||||
rv = input->GetReadOnly(&rdonly);
|
||||
if (!NS_FAILED(rv) && rdonly) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
const char*
|
||||
EmbedContextMenuInfo::GetSelectedText()
|
||||
{
|
||||
nsString cString;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (mCtxFormType != 0 && mEventNode) {
|
||||
PRInt32 TextLength = 0, selStart = 0, selEnd = 0;
|
||||
if (mCtxFormType == NS_FORM_INPUT_TEXT || mCtxFormType == NS_FORM_INPUT_FILE) {
|
||||
nsCOMPtr<nsIDOMNSHTMLInputElement> nsinput = do_QueryInterface(mEventNode, &rv);
|
||||
if (NS_SUCCEEDED(rv) && nsinput)
|
||||
nsinput->GetTextLength(&TextLength);
|
||||
if (TextLength > 0) {
|
||||
nsinput->GetSelectionEnd(&selEnd);
|
||||
nsinput->GetSelectionStart(&selStart);
|
||||
if (selStart < selEnd || mCtxFormType == NS_FORM_INPUT_FILE) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface (mEventNode, &rv);
|
||||
rv = input->GetValue(cString);
|
||||
}
|
||||
}
|
||||
} else if (mCtxFormType == NS_FORM_TEXTAREA) {
|
||||
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> nsinput = do_QueryInterface(mEventNode, &rv);
|
||||
if (NS_SUCCEEDED(rv) && nsinput)
|
||||
nsinput->GetTextLength(&TextLength);
|
||||
if (TextLength > 0) {
|
||||
nsinput->GetSelectionStart(&selStart);
|
||||
nsinput->GetSelectionEnd(&selEnd);
|
||||
if (selStart < selEnd) {
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> input = do_QueryInterface (mEventNode, &rv);
|
||||
rv = input->GetValue(cString);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && cString.Length()) {
|
||||
if (selStart < selEnd) {
|
||||
cString.Cut(0, selStart);
|
||||
cString.Cut(selEnd-selStart, TextLength);
|
||||
}
|
||||
rv = NS_OK;
|
||||
}
|
||||
} else if (mCtxDocument) {
|
||||
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument);
|
||||
htmlDoc->GetSelection(cString);
|
||||
if ( cString.Length() > 0) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
if (rv == NS_OK) {
|
||||
return NS_ConvertUTF16toUTF8(cString).get();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
|
||||
PRInt32 *aWidth, PRInt32 *aHeight)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr <nsIDOMHTMLImageElement> image =
|
||||
do_QueryInterface(node, &rv);
|
||||
if (image) {
|
||||
rv = image->GetSrc (aHref);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = image->GetWidth (aWidth);
|
||||
rv = image->GetHeight (aHeight);
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::CheckDomHtmlNode(nsIDOMNode *node)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsString uTag;
|
||||
PRUint16 dnode_type;
|
||||
rv = node->GetNodeType(&dnode_type);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(node);
|
||||
if (!((nsIDOMNode::ELEMENT_NODE == dnode_type) && element)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr <nsIDOMNSHTMLElement> nodeElement = do_QueryInterface(node, &rv);
|
||||
if (NS_SUCCEEDED(rv) && nodeElement) {
|
||||
mNSHHTMLElement = nodeElement;
|
||||
} else {
|
||||
mNSHHTMLElement = nsnull;
|
||||
}
|
||||
rv = element->GetLocalName(uTag);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (uTag.LowerCaseEqualsLiteral("object")) {
|
||||
}
|
||||
else if (uTag.LowerCaseEqualsLiteral("html")) {
|
||||
}
|
||||
else if (uTag.LowerCaseEqualsLiteral("a")) {
|
||||
nsCOMPtr <nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(node);
|
||||
anchor->GetHref (mCtxHref);
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
|
||||
if (anchor && !mCtxHref.IsEmpty()) {
|
||||
if (mCtxHref.LowerCaseEqualsLiteral("text/smartbookmark")) {
|
||||
nsCOMPtr<nsIDOMNode> childNode;
|
||||
node->GetFirstChild (getter_AddRefs(childNode));
|
||||
if (childNode) {
|
||||
PRInt32 width, height;
|
||||
rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
|
||||
}
|
||||
} else if (StringBeginsWith(mCtxHref, NS_LITERAL_STRING("mailto:"))) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_EMAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (uTag.LowerCaseEqualsLiteral("area")) {
|
||||
nsCOMPtr <nsIDOMHTMLAreaElement> area = do_QueryInterface(node, &rv);
|
||||
if (NS_SUCCEEDED(rv) && area) {
|
||||
PRBool aNoHref = PR_FALSE;
|
||||
rv = area->GetNoHref (&aNoHref);
|
||||
if (aNoHref == PR_FALSE)
|
||||
rv = area->GetHref (mCtxHref);
|
||||
else
|
||||
rv = area->GetTarget (mCtxHref);
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
else if (uTag.LowerCaseEqualsLiteral("img")) {
|
||||
PRInt32 width, height;
|
||||
rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::UpdateContextData(void *aEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEvent);
|
||||
return UpdateContextData((nsIDOMEvent *)aEvent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::GetElementForScroll(nsIDOMEvent *aEvent)
|
||||
{
|
||||
if (!aEvent) return NS_ERROR_UNEXPECTED;
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent (do_QueryInterface(aEvent));
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
nsevent->GetOriginalTarget(getter_AddRefs(target));
|
||||
if (!target) return NS_ERROR_UNEXPECTED;
|
||||
nsCOMPtr<nsIDOMNode> targetDOMNode (do_QueryInterface (target));
|
||||
if (!targetDOMNode) return NS_ERROR_UNEXPECTED;
|
||||
nsCOMPtr <nsIDOMDocument> targetDOMDocument;
|
||||
targetDOMNode->GetOwnerDocument (getter_AddRefs (targetDOMDocument));
|
||||
if (!targetDOMDocument) return NS_ERROR_UNEXPECTED;
|
||||
return GetElementForScroll(targetDOMDocument);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::GetElementForScroll(nsIDOMDocument *targetDOMDocument)
|
||||
{
|
||||
nsCOMPtr <nsIDOMElement> targetDOMElement;
|
||||
targetDOMDocument->GetDocumentElement (getter_AddRefs (targetDOMElement));
|
||||
if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
|
||||
nsString bodyName (NS_LITERAL_STRING ("body"));
|
||||
nsCOMPtr <nsIDOMNodeList> bodyList;
|
||||
targetDOMElement->GetElementsByTagName(bodyName, getter_AddRefs (bodyList));
|
||||
PRUint32 i = 0;
|
||||
bodyList->GetLength (&i);
|
||||
if (i) {
|
||||
nsCOMPtr<nsIDOMNode> domBodyNode;
|
||||
bodyList->Item(0, getter_AddRefs(domBodyNode));
|
||||
if (!domBodyNode) return NS_ERROR_UNEXPECTED;
|
||||
mNSHHTMLElementSc = do_QueryInterface(domBodyNode);
|
||||
if (!mNSHHTMLElementSc) return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedContextMenuInfo::UpdateContextData(nsIDOMEvent *aDOMEvent)
|
||||
{
|
||||
if (mCtxEvent == aDOMEvent)
|
||||
return NS_OK;
|
||||
mCtxEvent = aDOMEvent;
|
||||
NS_ENSURE_ARG_POINTER(mCtxEvent);
|
||||
nsresult res = nsnull;
|
||||
nsresult rv = nsnull;
|
||||
nsCOMPtr<nsIDOMEventTarget> originalTarget = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> originalNode = nsnull;
|
||||
nsCOMPtr<nsIDOMNSEvent> aEvent = do_QueryInterface(mCtxEvent);
|
||||
if (!aEvent) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent (do_QueryInterface( mCtxEvent ));
|
||||
if(mouseEvent) {
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetClientX(&mX);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetClientY(&mY);
|
||||
}
|
||||
res = aEvent->GetOriginalTarget(getter_AddRefs(originalTarget));
|
||||
originalNode = do_QueryInterface(originalTarget);
|
||||
if (NS_FAILED(res) || !originalNode) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// nsresult SelText = mOwner->ClipBoardAction(GTK_MOZ_EMBED_CAN_COPY);
|
||||
if (originalNode == mOrigNode) {
|
||||
return NS_OK;
|
||||
}
|
||||
mEmbedCtxType = GTK_MOZ_EMBED_CTX_NONE;
|
||||
mOrigNode = originalNode;
|
||||
originalNode->GetNodeName(mSOrigNode);
|
||||
if (mSOrigNode.EqualsLiteral ("#document"))
|
||||
return NS_OK;
|
||||
if (mSOrigNode.EqualsLiteral ("xul:thumb")
|
||||
|| mSOrigNode.EqualsLiteral ("xul:slider")
|
||||
|| mSOrigNode.EqualsLiteral ("xul:scrollbarbutton")
|
||||
|| mSOrigNode.EqualsLiteral ("xul:vbox")
|
||||
|| mSOrigNode.EqualsLiteral ("xul:spacer")) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_XUL;
|
||||
return NS_OK;
|
||||
}
|
||||
res = mCtxEvent->GetTarget(getter_AddRefs(mEventTarget));
|
||||
if (NS_FAILED(res) || !mEventTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(mEventTarget);
|
||||
if (eventNode == mEventNode) {
|
||||
// return NS_OK;
|
||||
}
|
||||
mEventNode = eventNode;
|
||||
eventNode->GetNodeName(mSEventNode);
|
||||
//Frame Stuff
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = mEventNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!NS_SUCCEEDED (rv) || !domDoc) {
|
||||
// return NS_OK;
|
||||
}
|
||||
if (NS_SUCCEEDED (rv) && domDoc && mCtxDocument != domDoc) {
|
||||
mCtxDocument = domDoc;
|
||||
mNSHHTMLElementSc = nsnull;
|
||||
// rv = GetElementForScroll(mCtxDocument);
|
||||
// if (NS_ERROR_UNEXPECTED == rv) {
|
||||
// }
|
||||
nsCOMPtr<nsIDOM3Document> docuri = do_QueryInterface(mCtxDocument);
|
||||
docuri->GetDocumentURI (mCtxURI);
|
||||
NS_ENSURE_ARG_POINTER(mOwner);
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mOwner->mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(mCtxDomWindow));
|
||||
nsCOMPtr<nsIDOMDocument> mainDocument;
|
||||
mCtxDomWindow->GetDocument (getter_AddRefs(mainDocument));
|
||||
if (!mainDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
mCtxFrameNum = -1;
|
||||
if (mainDocument != domDoc) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IFRAME;
|
||||
SetFrameIndex();
|
||||
}
|
||||
}
|
||||
nsCOMPtr <nsIDOMElement> targetDOMElement;
|
||||
mCtxDocument->GetDocumentElement (getter_AddRefs (targetDOMElement));
|
||||
if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
|
||||
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument);
|
||||
if (htmlDoc) {
|
||||
nsString DMode;
|
||||
htmlDoc->GetDesignMode(DMode);
|
||||
if (DMode.EqualsLiteral ("on")) {
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_RICHEDIT;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
|
||||
if (!doc)
|
||||
return NS_OK;
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if (!presShell)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
|
||||
nsIFrame* frame = nsnull;
|
||||
if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_RICHEDIT)
|
||||
frame = presShell->GetRootFrame();
|
||||
else {
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
nsIFrame* frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(tgContent, &frame);
|
||||
#else
|
||||
frame = presShell->GetPrimaryFrameFor(tgContent);
|
||||
#endif
|
||||
}
|
||||
if (frame) {
|
||||
mFormRect = frame->GetScreenRectExternal();
|
||||
printf("Prim frame FormRect1: y:%i, x:%i, h:%i, w:%i\n", mFormRect.y, mFormRect.x, mFormRect.height, mFormRect.width);
|
||||
}
|
||||
if (NS_SUCCEEDED(SetFormControlType(mEventTarget))) {
|
||||
return NS_OK;
|
||||
}
|
||||
CheckDomHtmlNode(mEventNode);
|
||||
nsCOMPtr<nsIDOMNode> node = mEventNode;
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
node->GetParentNode (getter_AddRefs(parentNode));
|
||||
node = parentNode;
|
||||
while (node) {
|
||||
if (NS_FAILED(CheckDomHtmlNode(node))) {
|
||||
break;
|
||||
}
|
||||
node->GetParentNode (getter_AddRefs(parentNode));
|
||||
node = parentNode;
|
||||
}
|
||||
mEmbedCtxType |= GTK_MOZ_EMBED_CTX_DOCUMENT;
|
||||
return NS_OK;
|
||||
}
|
||||
99
mozilla/embedding/browser/gtk/src/EmbedContextMenuInfo.h
Normal file
99
mozilla/embedding/browser/gtk/src/EmbedContextMenuInfo.h
Normal file
@ -0,0 +1,99 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Oleg Romashin. Portions created by Oleg Romashin are Copyright (C) Oleg Romashin. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef EmbedContextMenuInfo_h__
|
||||
#define EmbedContextMenuInfo_h__
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIFrame.h"
|
||||
// for strings
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsXPIDLString.h>
|
||||
#include <nsReadableUtils.h>
|
||||
#endif
|
||||
#include "EmbedWindow.h"
|
||||
#include "nsIDOMNSHTMLElement.h"
|
||||
//*****************************************************************************
|
||||
// class EmbedContextMenuInfo
|
||||
//
|
||||
//*****************************************************************************
|
||||
class EmbedContextMenuInfo : public nsISupports
|
||||
{
|
||||
public:
|
||||
EmbedContextMenuInfo(EmbedPrivate *aOwner);
|
||||
virtual ~EmbedContextMenuInfo(void);
|
||||
NS_DECL_ISUPPORTS
|
||||
nsresult GetFormControlType(nsIDOMEvent *aDOMEvent);
|
||||
nsresult UpdateContextData(nsIDOMEvent *aDOMEvent);
|
||||
nsresult UpdateContextData(void *aEvent);
|
||||
const char* GetSelectedText();
|
||||
nsresult GetElementForScroll(nsIDOMDocument *targetDOMDocument);
|
||||
nsresult GetElementForScroll(nsIDOMEvent *aEvent);
|
||||
nsresult CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
|
||||
PRInt32 *aWidth, PRInt32 *aHeight);
|
||||
|
||||
PRInt32 mX, mY, mObjWidth, mObjHeight, mCtxFrameNum;
|
||||
nsString mCtxURI, mCtxHref, mCtxImgHref;
|
||||
PRUint32 mEmbedCtxType;
|
||||
PRInt32 mCtxFormType;
|
||||
nsCOMPtr<nsIDOMNode> mEventNode;
|
||||
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
|
||||
nsCOMPtr<nsIDOMDocument>mCtxDocument;
|
||||
nsIntRect mFormRect;
|
||||
nsCOMPtr<nsIDOMWindow> mCtxDomWindow;
|
||||
nsCOMPtr<nsIDOMEvent> mCtxEvent;
|
||||
nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElement;
|
||||
nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElementSc;
|
||||
private:
|
||||
nsresult SetFrameIndex();
|
||||
nsresult SetFormControlType(nsIDOMEventTarget *originalTarget);
|
||||
nsresult CheckDomHtmlNode(nsIDOMNode *node);
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
nsCOMPtr<nsIDOMNode> mOrigNode;
|
||||
nsString mSOrigNode;
|
||||
nsString mSEventNode;
|
||||
}; // class EmbedContextMenuInfo
|
||||
#endif // EmbedContextMenuInfo_h__
|
||||
298
mozilla/embedding/browser/gtk/src/EmbedDownloadMgr.cpp
Normal file
298
mozilla/embedding/browser/gtk/src/EmbedDownloadMgr.cpp
Normal file
@ -0,0 +1,298 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/**
|
||||
* Derived from GContentHandler http://landfill.mozilla.org/mxr-test/gnome/source/galeon/mozilla/ContentHandler.cpp
|
||||
*/
|
||||
#include "EmbedDownloadMgr.h"
|
||||
#include "EmbedGtkTools.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsXPIDLString.h>
|
||||
#else
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#endif
|
||||
#include <nsIChannel.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include <nsIPromptService.h>
|
||||
#include <nsIWebProgressListener2.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIServiceManager.h>
|
||||
#include <nsIInterfaceRequestorUtils.h>
|
||||
#include <nsIURI.h>
|
||||
#include <nsIURL.h>
|
||||
#include <nsIFile.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
#include <nsIExternalHelperAppService.h>
|
||||
#include <nsCExternalHandlerService.h>
|
||||
#include <nsMemory.h>
|
||||
#include <nsNetError.h>
|
||||
#include <nsIStreamListener.h>
|
||||
#include <nsIFile.h>
|
||||
#include <nsILocalFile.h>
|
||||
#include <nsNetCID.h>
|
||||
#include <unistd.h>
|
||||
#include <gtkmozembed_download.h>
|
||||
class EmbedDownloadMgr;
|
||||
class ProgressListener : public nsIWebProgressListener2
|
||||
{
|
||||
public:
|
||||
ProgressListener(EmbedDownload *aDownload, nsCAutoString aFilename, nsISupports *aContext) : mFilename (aFilename)
|
||||
{
|
||||
mDownload = aDownload;
|
||||
mContext = aContext;
|
||||
};
|
||||
~ProgressListener()
|
||||
{
|
||||
};
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER2
|
||||
EmbedDownload *mDownload;
|
||||
nsISupports *mContext; /** < The context object */
|
||||
nsCOMPtr<nsILocalFile> mDestFile;
|
||||
nsCAutoString mFilename;
|
||||
nsCAutoString mLocalSaveFileName;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(ProgressListener, nsIWebProgressListener2, nsIWebProgressListener)
|
||||
NS_IMPL_ISUPPORTS1(EmbedDownloadMgr, nsIHelperAppLauncherDialog)
|
||||
|
||||
EmbedDownloadMgr::EmbedDownloadMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
EmbedDownloadMgr::~EmbedDownloadMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedDownloadMgr::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedDownloadMgr::Show(nsIHelperAppLauncher *aLauncher, nsISupports *aContext, PRUint32 aForced)
|
||||
{
|
||||
nsresult rv;
|
||||
mContext = aContext;
|
||||
mLauncher = aLauncher;
|
||||
rv = GetDownloadInfo();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD EmbedDownloadMgr::GetDownloadInfo (void)
|
||||
{
|
||||
nsresult rv;
|
||||
// create a Download object
|
||||
GtkObject* instance = gtk_moz_embed_download_new ();
|
||||
EmbedDownload *download = (EmbedDownload *) GTK_MOZ_EMBED_DOWNLOAD(instance)->data;
|
||||
// get file mimetype
|
||||
rv = mLauncher->GetMIMEInfo (getter_AddRefs(mMIMEInfo));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
nsCAutoString aMimeType;
|
||||
rv = mMIMEInfo->GetMIMEType (aMimeType);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
// get file name
|
||||
nsCAutoString aTempFileName;
|
||||
nsAutoString aSuggestedFileName;
|
||||
rv = mLauncher->GetSuggestedFileName (aSuggestedFileName);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
aTempFileName = NS_ConvertUTF16toUTF8 (aSuggestedFileName);
|
||||
// get source url (concatened to file name)
|
||||
rv = mLauncher->GetSource (getter_AddRefs(mUri));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
rv = mUri->Resolve(NS_LITERAL_CSTRING("."), mSpec);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
rv = mLauncher->GetTargetFile(getter_AddRefs(mDestFileTemp));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
download->file_target = mDestFileTemp;
|
||||
// creating a progress listener to follow the download and connecting it to the launcher which controls the download.
|
||||
nsCOMPtr<nsIWebProgressListener2> listener = new ProgressListener(download, aTempFileName, mContext);
|
||||
rv = mLauncher->SetWebProgressListener(listener);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
// setting download vars to keep control of each download.
|
||||
download->parent = instance;
|
||||
download->started = 0;
|
||||
download->downloaded_size = -1;
|
||||
download->launcher = mLauncher;
|
||||
download->file_name = g_strdup ((gchar *) aTempFileName.get());
|
||||
download->server = g_strconcat(mSpec.get(), (gchar *) download->file_name, NULL);
|
||||
download->file_type = g_strdup (aMimeType.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// it should be used... but it's not possible to do it according ui flow
|
||||
NS_IMETHODIMP EmbedDownloadMgr::PromptForSaveToFile (nsIHelperAppLauncher *aLauncher,
|
||||
nsISupports *aWindowContext,
|
||||
const PRUnichar *aDefaultFile,
|
||||
const PRUnichar *aSuggestedFileExtension,
|
||||
nsILocalFile **_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIWebProgressListener Functions
|
||||
// all these methods must be here due to nsIWebProgressListenr/2 inheritance
|
||||
NS_IMETHODIMP ProgressListener::OnStatusChange (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
{
|
||||
if (NS_SUCCEEDED (aStatus))
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ProgressListener::OnStateChange (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
if (NS_SUCCEEDED (aStatus))
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ProgressListener::OnProgressChange (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ProgressListener::OnLocationChange (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsIURI *location)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ProgressListener::OnSecurityChange (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRUint32 state)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIWebProgressListener 2
|
||||
NS_IMETHODIMP ProgressListener::OnProgressChange64 (nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRInt64 aCurSelfProgress,
|
||||
PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress,
|
||||
PRInt64 aMaxTotalProgress)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDownload) return NS_OK;
|
||||
if (mDownload->started == 0) {
|
||||
mDownload->request = aRequest;
|
||||
mDownload->started = 1;
|
||||
// it might not work when there is more than one browser window opened
|
||||
mDownload->file_size = aMaxSelfProgress;
|
||||
nsCOMPtr<nsIDOMWindow> parentDOMWindow = do_GetInterface (mContext);
|
||||
mDownload->gtkMozEmbedParentWidget = GetGtkWidgetForDOMWindow(parentDOMWindow);
|
||||
if (mDownload->gtkMozEmbedParentWidget) {
|
||||
gtk_signal_emit(GTK_OBJECT(mDownload->gtkMozEmbedParentWidget),
|
||||
moz_embed_signals[DOWNLOAD_REQUEST],
|
||||
mDownload->server,
|
||||
mDownload->file_name,
|
||||
mDownload->file_type,
|
||||
(gulong) mDownload->file_size,
|
||||
1);
|
||||
}
|
||||
}
|
||||
if (mDownload->started == 1) {
|
||||
// emit signal to get download progress and displays on download list dialog
|
||||
gtk_signal_emit(GTK_OBJECT(mDownload->parent),
|
||||
moz_embed_download_signals[DOWNLOAD_STARTED_SIGNAL], &mDownload->file_name_with_path);
|
||||
// in this case, user has canceled download from UI.
|
||||
if (!mDownload->file_name_with_path) {
|
||||
gtk_moz_embed_download_do_command (GTK_MOZ_EMBED_DOWNLOAD (mDownload->parent), GTK_MOZ_EMBED_DOWNLOAD_CANCEL);
|
||||
return NS_OK;
|
||||
}
|
||||
// FIXME: Clean up this code bellow, please :)
|
||||
gchar *localUrl = nsnull, *localFileName = nsnull;
|
||||
// second step - the target file will be created
|
||||
if (g_str_has_prefix (mDownload->file_name_with_path, FILE_SCHEME)) {
|
||||
// if user has chosen to save file (contains file:// prefix)
|
||||
gchar *localUrlWithFileName = (g_strsplit (mDownload->file_name_with_path, FILE_SCHEME, -1))[1];
|
||||
gint i;
|
||||
gchar **localUrlSplitted = (char **) (g_strsplit(localUrlWithFileName, SLASH, -1));
|
||||
for(i = 0; localUrlSplitted[i]; i++);
|
||||
localFileName = localUrlSplitted[i-1];
|
||||
localUrl = (gchar *) (g_strsplit(localUrlWithFileName, localFileName, -1))[0];
|
||||
} else {
|
||||
// if user has chosen to open with application (in /var/tmp)
|
||||
localUrl = (char *) (g_strsplit (mDownload->file_name_with_path, mFilename.get(), -1))[0];
|
||||
localFileName = g_strdup ((gchar *) mFilename.get());
|
||||
}
|
||||
nsCAutoString localSavePath;
|
||||
if (localUrl) {
|
||||
localSavePath.Assign(localUrl);
|
||||
g_free (localUrl);
|
||||
localUrl = nsnull;
|
||||
}
|
||||
if (localFileName) {
|
||||
mLocalSaveFileName.Assign(localFileName);
|
||||
g_free (localFileName);
|
||||
localFileName = nsnull;
|
||||
}
|
||||
// create the file where the download will be moved to
|
||||
mDestFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
mDestFile->InitWithNativePath(localSavePath);
|
||||
mDestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
|
||||
mDownload->started = 2;
|
||||
}
|
||||
// when download finishes (bytes downloaded = total file size), emit completed signal
|
||||
// FIXME: if you don't have aMaxSelfProgress available, the signal won't be emitted
|
||||
if (aCurSelfProgress == aMaxSelfProgress) {
|
||||
// signal to confirm that download has finished
|
||||
gtk_signal_emit(GTK_OBJECT(mDownload->parent),
|
||||
moz_embed_download_signals[DOWNLOAD_COMPLETED_SIGNAL]);
|
||||
} else {
|
||||
// emit signal to get download progress and displays on download list dialog
|
||||
gtk_signal_emit(GTK_OBJECT(mDownload->parent),
|
||||
moz_embed_download_signals[DOWNLOAD_PROGRESS_SIGNAL],
|
||||
(gulong) aCurSelfProgress, (gulong) aMaxSelfProgress, 1);
|
||||
}
|
||||
// storing current downloaded size.
|
||||
mDownload->downloaded_size = (gulong) aCurSelfProgress;
|
||||
// moving the target file to the right place.
|
||||
rv = mDownload->file_target->MoveToNative (mDestFile, mLocalSaveFileName);
|
||||
return NS_OK;
|
||||
}
|
||||
96
mozilla/embedding/browser/gtk/src/EmbedDownloadMgr.h
Normal file
96
mozilla/embedding/browser/gtk/src/EmbedDownloadMgr.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/**
|
||||
* Derived from GContentHandler http://landfill.mozilla.org/mxr-test/gnome/source/galeon/mozilla/ContentHandler.h
|
||||
*/
|
||||
#ifndef __EmbedDownloadMgr_h
|
||||
#define __EmbedDownloadMgr_h
|
||||
#include "EmbedPrivate.h"
|
||||
#include <nsIHelperAppLauncherDialog.h>
|
||||
#include <nsIMIMEInfo.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIExternalHelperAppService.h>
|
||||
#include <nsIRequest.h>
|
||||
#include <nsILocalFile.h>
|
||||
#include "nsWeakReference.h"
|
||||
#define EMBED_DOWNLOADMGR_DESCRIPTION "MicroB Download Manager"
|
||||
#define EMBED_DOWNLOADMGR_CID {0x53df12a2, 0x1f4a, 0x4382, {0x99, 0x4e, 0xed, 0x62, 0xcf, 0x0d, 0x6b, 0x3a}}
|
||||
#define FILE_SCHEME "file://"
|
||||
#define SLASH "/"
|
||||
class nsIURI;
|
||||
class nsIFile;
|
||||
class nsIFactory;
|
||||
typedef struct _EmbedDownload EmbedDownload;
|
||||
struct _EmbedDownload
|
||||
{
|
||||
GtkObject * parent;
|
||||
GtkWidget* gtkMozEmbedParentWidget;/** Associated gtkmozembed widget */
|
||||
char* file_name; /** < The file's name */
|
||||
const char *file_name_with_path; /** < The file's name */
|
||||
const char* server; /** < The server's name */
|
||||
PRInt64 file_size; /** < The file's size */
|
||||
const char* file_type; /** < The file's type */
|
||||
const char* handler_app; /** < The application's name */
|
||||
PRInt64 downloaded_size; /** < The download's size */
|
||||
gboolean isPaused; /** < If download is paused or not */
|
||||
gboolean open_with; /** < If the file can be opened by other application */
|
||||
gboolean started; /** < If the download has started or not */
|
||||
nsIHelperAppLauncher* launcher; /** < The mozilla's download dialog */
|
||||
nsIRequest* request; /** < The download request */
|
||||
nsIFile* file_dest; /** < The final file's name */
|
||||
nsIFile* file_target; /** < The target file's name */
|
||||
};
|
||||
class EmbedDownloadMgr : public nsIHelperAppLauncherDialog
|
||||
{
|
||||
public:
|
||||
EmbedDownloadMgr();
|
||||
virtual ~EmbedDownloadMgr();
|
||||
nsresult Init(void);
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIHELPERAPPLAUNCHERDIALOG
|
||||
private:
|
||||
/** Gets all informations about a file which is being downloaded.
|
||||
*/
|
||||
NS_METHOD GetDownloadInfo (void);
|
||||
nsCOMPtr<nsIHelperAppLauncher> mLauncher; /** < Download dialog */
|
||||
nsCOMPtr<nsISupports> mContext; /** < The context object */
|
||||
nsCOMPtr<nsIURI> mUri; /** < The source URL */
|
||||
nsCOMPtr<nsIFile> mDestFileTemp; /** < The temporary file (destiny) */
|
||||
nsCOMPtr<nsIMIMEInfo> mMIMEInfo; /** < MIME information */
|
||||
nsCAutoString mSpec; /** < The URL without file name */
|
||||
};
|
||||
#endif /* __EmbedDownloadMgr_h */
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -20,6 +22,8 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
* Tomaz Noleto <tnoleto@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,11 +42,20 @@
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIDOMMouseEvent.h>
|
||||
|
||||
#include <nsIDOMNSEvent.h>
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "EmbedEventListener.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "gtkmozembed_internal.h"
|
||||
|
||||
static PRInt32 sLongPressTimer = 0, mLongMPressDelay = 1000;
|
||||
static PRInt32 sX = 0, sY = 0;
|
||||
static PRBool sMPressed = PR_FALSE, sIsScrolling = PR_FALSE;
|
||||
static char* gFavLocation = NULL;
|
||||
|
||||
EmbedEventListener::EmbedEventListener(void)
|
||||
{
|
||||
@ -61,18 +74,136 @@ NS_INTERFACE_MAP_BEGIN(EmbedEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMUIListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::Init(EmbedPrivate *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mCtxInfo = new EmbedContextMenuInfo(aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleLink (nsIDOMNode* node)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> linkElement;
|
||||
linkElement = do_QueryInterface (node);
|
||||
if (!linkElement) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString name;
|
||||
result = GetLinkAttribute(linkElement, "rel", &name);
|
||||
if (NS_FAILED(result)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString link;
|
||||
result = GetLinkAttribute(linkElement, "href", &link);
|
||||
if (NS_FAILED (result) || !link.Length()) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = node->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOM3Node> domnode = do_QueryInterface(domDoc);
|
||||
if(!domnode) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString spec;
|
||||
domnode->GetBaseURI(spec);
|
||||
|
||||
nsCString cSpec;
|
||||
NS_UTF16ToCString(spec, NS_CSTRING_ENCODING_UTF8, cSpec);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
result = NewURI(getter_AddRefs(baseURI), cSpec.get());
|
||||
if (NS_FAILED(result) || !baseURI) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString linkstring;
|
||||
NS_UTF16ToCString(link, NS_CSTRING_ENCODING_UTF8, linkstring);
|
||||
nsCString url;
|
||||
result = baseURI->Resolve (linkstring, url);
|
||||
if (NS_FAILED (result)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString type;
|
||||
result = GetLinkAttribute(linkElement, "type", &type);
|
||||
if (NS_FAILED(result)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString cType;
|
||||
NS_UTF16ToCString(type, NS_CSTRING_ENCODING_UTF8, cType);
|
||||
|
||||
nsString title;
|
||||
result = GetLinkAttribute(linkElement, "title", &title);
|
||||
if (NS_FAILED(result)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString cTitle;
|
||||
NS_UTF16ToCString(title, NS_CSTRING_ENCODING_UTF8, cTitle);
|
||||
|
||||
nsCString cName;
|
||||
NS_UTF16ToCString(name, NS_CSTRING_ENCODING_UTF8, cName);
|
||||
|
||||
if (!g_ascii_strcasecmp(cName.get(),"SHORTCUT ICON") ||
|
||||
!g_ascii_strcasecmp(cName.get(),"ICON")) {
|
||||
|
||||
mOwner->mNeedFav = PR_FALSE;
|
||||
this->GetFaviconFromURI(url.get());
|
||||
}
|
||||
else {
|
||||
|
||||
const gchar *navi_title = cTitle.get();
|
||||
if (*navi_title == '\0')
|
||||
navi_title = NULL;
|
||||
|
||||
const gchar *navi_type = cType.get();
|
||||
if (*navi_type == '\0')
|
||||
navi_type = NULL;
|
||||
|
||||
if (!g_ascii_strcasecmp(cName.get(), "ALTERNATE") &&
|
||||
!g_ascii_strcasecmp(cType.get(), "application/rss+xml")) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsString eventType;
|
||||
aDOMEvent->GetType(eventType);
|
||||
if (eventType.EqualsLiteral ("focus"))
|
||||
if (mCtxInfo->GetFormControlType(aDOMEvent)) {
|
||||
if (mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_FOCUS],
|
||||
(void *)aDOMEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (eventType.EqualsLiteral ("DOMLinkAdded") && mOwner->mNeedFav) {
|
||||
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIDOMEventTarget> eventTarget;
|
||||
|
||||
aDOMEvent->GetTarget(getter_AddRefs(eventTarget));
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(eventTarget, &result);
|
||||
if (NS_FAILED(result) || !node)
|
||||
return NS_ERROR_FAILURE;
|
||||
HandleLink (node);
|
||||
}
|
||||
else if (mOwner->mNeedFav) {
|
||||
mOwner->mNeedFav = PR_FALSE;
|
||||
nsCString favicon_url = mOwner->mPrePath + nsCString("/favicon.ico");
|
||||
this->GetFaviconFromURI(favicon_url.get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -87,8 +218,8 @@ EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
|
||||
// consumed...
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_DOWN],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_DOWN],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -107,11 +238,13 @@ EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
|
||||
// consumed...
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_UP],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_UP],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
} else {
|
||||
//mCtxInfo->UpdateContextData(aDOMEvent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -126,8 +259,8 @@ EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_PRESS],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_PRESS],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -135,6 +268,23 @@ EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sLongMPress(void *aOwningWidget)
|
||||
{
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (!sMPressed || sIsScrolling)
|
||||
return FALSE;
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(aOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_LONG_PRESS],
|
||||
(void *)0, &return_val);
|
||||
if (return_val) {
|
||||
sMPressed = PR_FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseDown(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
@ -142,14 +292,29 @@ EmbedEventListener::MouseDown(nsIDOMEvent* aDOMEvent)
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
|
||||
// handling event internally, first.
|
||||
HandleSelection(mouseEvent);
|
||||
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
sMPressed = PR_TRUE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_DOWN],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_DOWN],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
sMPressed = PR_FALSE;
|
||||
#if 1
|
||||
if (sLongPressTimer)
|
||||
g_source_remove (sLongPressTimer);
|
||||
#else
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
#endif
|
||||
} else {
|
||||
sLongPressTimer = g_timeout_add(mLongMPressDelay, sLongMPress, mOwner->mOwningWidget);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenX(&sX);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenY(&sY);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -161,11 +326,20 @@ EmbedEventListener::MouseUp(nsIDOMEvent* aDOMEvent)
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
|
||||
// handling event internally, first.
|
||||
HandleSelection(mouseEvent);
|
||||
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (sLongPressTimer)
|
||||
g_source_remove (sLongPressTimer);
|
||||
sMPressed = PR_FALSE;
|
||||
mOwner->mOpenBlock = sIsScrolling;
|
||||
sIsScrolling = sMPressed;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_UP],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_UP],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -181,10 +355,11 @@ EmbedEventListener::MouseClick(nsIDOMEvent* aDOMEvent)
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -200,14 +375,17 @@ EmbedEventListener::MouseDblClick(nsIDOMEvent* aDOMEvent)
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (sLongPressTimer)
|
||||
g_source_remove (sLongPressTimer);
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_DBL_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_DBL_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -221,11 +399,13 @@ EmbedEventListener::MouseOver(nsIDOMEvent* aDOMEvent)
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_OVER],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_OVER],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
} else {
|
||||
//mCtxInfo->UpdateContextData(aDOMEvent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -240,8 +420,8 @@ EmbedEventListener::MouseOut(nsIDOMEvent* aDOMEvent)
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_OUT],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_OUT],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -302,3 +482,410 @@ EmbedEventListener::FocusOut(nsIDOMEvent* aDOMEvent)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseMove(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
if (mCurSelCon)
|
||||
mCurSelCon->SetDisplaySelection (nsISelectionController::SELECTION_ON);
|
||||
|
||||
if (sMPressed &&
|
||||
gtk_signal_handler_pending(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_SCROLL], TRUE)) {
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
PRInt32 newX, newY, subX, subY;
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenX(&newX);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenY(&newY);
|
||||
subX = newX - sX;
|
||||
subY = newY - sY;
|
||||
nsresult rv = NS_OK;
|
||||
if (ABS(subX) > 10 || ABS(subY) > 10 || (sIsScrolling && sMPressed)) {
|
||||
if (!sIsScrolling) {
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_SCROLL],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (!return_val) {
|
||||
sIsScrolling = PR_TRUE;
|
||||
if (mCtxInfo)
|
||||
rv = mCtxInfo->GetElementForScroll(aDOMEvent);
|
||||
} else {
|
||||
sMPressed = PR_FALSE;
|
||||
sIsScrolling = PR_FALSE;
|
||||
}
|
||||
}
|
||||
if (sIsScrolling)
|
||||
{
|
||||
if (sLongPressTimer)
|
||||
g_source_remove (sLongPressTimer);
|
||||
if (mCtxInfo->mNSHHTMLElementSc) {
|
||||
PRInt32 x, y;
|
||||
mCtxInfo->mNSHHTMLElementSc->GetScrollTop(&y);
|
||||
mCtxInfo->mNSHHTMLElementSc->GetScrollLeft(&x);
|
||||
#ifdef MOZ_SCROLL_TOP_LEFT_HACK
|
||||
rv = mCtxInfo->mNSHHTMLElementSc->ScrollTopLeft (y - subY, x - subX);
|
||||
#endif
|
||||
} else {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (rv == NS_ERROR_UNEXPECTED) {
|
||||
nsCOMPtr<nsIDOMWindow> DOMWindow;
|
||||
nsIWebBrowser *webBrowser = nsnull;
|
||||
gtk_moz_embed_get_nsIWebBrowser(mOwner->mOwningWidget, &webBrowser);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(DOMWindow));
|
||||
DOMWindow->ScrollBy(-subX, -subY);
|
||||
}
|
||||
}
|
||||
sX = newX;
|
||||
sY = newY;
|
||||
sIsScrolling = sMPressed;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::DragMove(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::Blur(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mFocusInternalFrame = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleSelection(nsIDOMMouseEvent* aDOMMouseEvent)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
/* This function gets called everytime that a mousedown or a mouseup
|
||||
* event occurs.
|
||||
*/
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDOMMouseEvent));
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
rv = nsevent->GetOriginalTarget(getter_AddRefs(target));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(target);
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = eventNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
|
||||
/* Gets nsISelectionController interface for the current context */
|
||||
mCurSelCon = do_QueryInterface(presShell);
|
||||
if (!mCurSelCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/* Gets event type */
|
||||
nsString eventType;
|
||||
rv = aDOMMouseEvent->GetType(eventType);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
/* Updates context to check which context is being clicked on */
|
||||
mCtxInfo->UpdateContextData(aDOMMouseEvent);
|
||||
|
||||
/* If a mousedown after 1 click is done (and if clicked context is not a XUL
|
||||
* one (e.g. scrollbar), the selection is disabled for that context.
|
||||
*/
|
||||
if (!(mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_XUL)) {
|
||||
|
||||
if (eventType.EqualsLiteral("mousedown")) {
|
||||
|
||||
/* Gets number of clicks done for event */
|
||||
rv = aDOMMouseEvent->GetDetail(&mClickCount);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (mClickCount == 1)
|
||||
rv = mCurSelCon->SetDisplaySelection(nsISelectionController::SELECTION_OFF);
|
||||
|
||||
} // mousedown
|
||||
|
||||
/* If a mouseup occurs, the selection for context is enabled again (despite of
|
||||
* number of clicks). If this event occurs after 1 click, the selection of
|
||||
* both last and current context is cleaned up.
|
||||
*/
|
||||
if (eventType.EqualsLiteral("mouseup")) {
|
||||
|
||||
/* Selection controller of current event context */
|
||||
if (mCurSelCon) {
|
||||
rv = mCurSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
if (mClickCount == 1) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
mCurSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(domSel));
|
||||
rv = domSel->RemoveAllRanges();
|
||||
}
|
||||
}
|
||||
/* Selection controller of previous event context */
|
||||
if (mLastSelCon) {
|
||||
rv = mLastSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
if (mClickCount == 1) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
mLastSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(domSel));
|
||||
rv = domSel->RemoveAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
/* If 1 click was done (despite the event type), sets the last context's
|
||||
* selection controller with current one
|
||||
*/
|
||||
if (mClickCount == 1)
|
||||
mLastSelCon = mCurSelCon;
|
||||
} // mouseup
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::GetLinkAttribute (nsCOMPtr<nsIDOMElement>& linkElement,
|
||||
const char *name,
|
||||
nsString *value)
|
||||
{
|
||||
nsString n_name;
|
||||
nsCString c_name(name);
|
||||
NS_CStringToUTF16(c_name, NS_CSTRING_ENCODING_UTF8, n_name);
|
||||
|
||||
return linkElement->GetAttribute(n_name, *value);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::NewURI (nsIURI **result,
|
||||
const char *spec)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCString cSpec(spec);
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
rv = GetIOService (getter_AddRefs (ioService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = ioService->NewURI (cSpec, nsnull, nsnull, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::GetIOService(nsIIOService **ioService)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
NS_GetServiceManager (getter_AddRefs (mgr));
|
||||
if (!mgr) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mgr->GetServiceByContractID ("@mozilla.org/network/io-service;1",
|
||||
NS_GET_IID (nsIIOService),
|
||||
(void **)ioService);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmbedEventListener::GeneratePixBuf()
|
||||
{
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
pixbuf = gdk_pixbuf_new_from_file(::gFavLocation, NULL);
|
||||
if(!pixbuf) {
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[ICON_CHANGED],
|
||||
NULL );
|
||||
|
||||
// remove the wrong favicon
|
||||
// FIXME: need better impl...
|
||||
nsCOMPtr<nsILocalFile> faviconFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
|
||||
if (!faviconFile) {
|
||||
NS_Free(::gFavLocation);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString faviconLocation(::gFavLocation);
|
||||
faviconFile->InitWithNativePath(faviconLocation);
|
||||
faviconFile->Remove(FALSE);
|
||||
NS_Free(::gFavLocation);
|
||||
return;
|
||||
}
|
||||
|
||||
// now send the signal to eal then eal send another signal to UI
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[ICON_CHANGED],
|
||||
pixbuf );
|
||||
//mOwner->mNeedFav = PR_FALSE;
|
||||
NS_Free(::gFavLocation);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedEventListener::GetFaviconFromURI(const char* aURI)
|
||||
{
|
||||
gchar *file_name = NS_strdup(aURI);
|
||||
gchar *favicon_uri = NS_strdup(aURI);
|
||||
|
||||
gint i = 0;
|
||||
gint rv = 0;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist = do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID);
|
||||
if (!persist) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
persist->SetProgressListener(this);
|
||||
|
||||
while (file_name[i] != '\0') {
|
||||
if (file_name[i] == '/' || file_name[i] == ':')
|
||||
file_name[i] = '_';
|
||||
i++;
|
||||
}
|
||||
|
||||
nsCString fileName(file_name);
|
||||
|
||||
nsCOMPtr<nsILocalFile> favicon_dir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
|
||||
if (!favicon_dir) {
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString faviconDir("~/.mozilla/favicon");
|
||||
favicon_dir->InitWithNativePath(faviconDir);
|
||||
|
||||
PRBool isExist;
|
||||
rv = favicon_dir->Exists(&isExist);
|
||||
if (NS_SUCCEEDED(rv) && !isExist) {
|
||||
rv = favicon_dir->Create(nsIFile::DIRECTORY_TYPE,0775);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCAutoString favicon_path("~/.mozilla/favicon");
|
||||
nsCOMPtr<nsILocalFile> target_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
if (!target_file) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
target_file->InitWithNativePath(favicon_path);
|
||||
target_file->Append(NS_ConvertUTF8toUTF16(fileName));
|
||||
|
||||
nsString path;
|
||||
target_file->GetPath(path);
|
||||
::gFavLocation = NS_strdup(NS_ConvertUTF16toUTF8(path).get());
|
||||
nsCOMPtr<nsIIOService> ios (do_GetService(NS_IOSERVICE_CONTRACTID));
|
||||
if (!ios) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(::gFavLocation);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
rv = ios->NewURI(nsDependentCString(favicon_uri), "", nsnull, getter_AddRefs(uri));
|
||||
if (!uri) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(::gFavLocation);
|
||||
return;
|
||||
}
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
|
||||
// save the favicon if the icon does not exist
|
||||
rv = target_file->Exists(&isExist);
|
||||
if (NS_SUCCEEDED(rv) && !isExist) {
|
||||
rv = persist->SaveURI(uri, nsnull, nsnull, nsnull, "", target_file);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
GeneratePixBuf();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
/* if (!(aStateFlags & (STATE_STOP | STATE_IS_NETWORK | STATE_IS_DOCUMENT))){*/
|
||||
if(aStateFlags & STATE_STOP)
|
||||
{
|
||||
/* FINISH DOWNLOADING */
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
GeneratePixBuf();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -20,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -42,11 +45,42 @@
|
||||
#include <nsIDOMMouseListener.h>
|
||||
#include <nsIDOMUIListener.h>
|
||||
|
||||
#include <nsIDOMMouseMotionListener.h>
|
||||
#include <nsIDOMEventListener.h>
|
||||
#include <nsIDOMFocusListener.h>
|
||||
#include "EmbedContextMenuInfo.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIWebBrowserPersist.h"
|
||||
#include "nsCWebBrowserPersist.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsXPCOMStrings.h"
|
||||
#include "nsCRTGlue.h"
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
class EmbedEventListener : public nsIDOMKeyListener,
|
||||
public nsIDOMMouseListener,
|
||||
public nsIDOMUIListener
|
||||
public nsIDOMUIListener,
|
||||
public nsIDOMMouseMotionListener,
|
||||
public nsIWebProgressListener,
|
||||
public nsIDOMFocusListener
|
||||
{
|
||||
public:
|
||||
|
||||
@ -57,10 +91,11 @@ class EmbedEventListener : public nsIDOMKeyListener,
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// NS_DECL_NSIDOMEVENTLISTENER
|
||||
// nsIDOMEventListener
|
||||
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_IMETHOD HandleLink (nsIDOMNode* node);
|
||||
// nsIDOMKeyListener
|
||||
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aDOMEvent);
|
||||
@ -82,9 +117,37 @@ class EmbedEventListener : public nsIDOMKeyListener,
|
||||
NS_IMETHOD FocusIn(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD FocusOut(nsIDOMEvent* aDOMEvent);
|
||||
|
||||
// nsIDOMMouseMotionListener
|
||||
NS_IMETHOD MouseMove(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent);
|
||||
EmbedContextMenuInfo* GetContextInfo() { return mCtxInfo; };
|
||||
|
||||
// nsIDOMFocusListener
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD HandleSelection(nsIDOMMouseEvent* aDOMMouseEvent);
|
||||
|
||||
// FIXME: dont not use nsCOMPtr<...> as param !! and how to ?
|
||||
nsresult GetLinkAttribute (nsCOMPtr <nsIDOMElement>& linkElement,
|
||||
const char *name,
|
||||
nsString *value);
|
||||
nsresult NewURI (nsIURI **result,
|
||||
const char *spec);
|
||||
nsresult GetIOService (nsIIOService **ioService);
|
||||
|
||||
void GeneratePixBuf ();
|
||||
|
||||
void GetFaviconFromURI (const char* aURI);
|
||||
private:
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
EmbedContextMenuInfo *mCtxInfo;
|
||||
|
||||
// Selection and some clipboard stuff
|
||||
nsCOMPtr <nsISelectionController> mCurSelCon;
|
||||
nsCOMPtr <nsISelectionController> mLastSelCon;
|
||||
PRBool mFocusInternalFrame;
|
||||
PRInt32 mClickCount;
|
||||
};
|
||||
|
||||
#endif /* __EmbedEventListener_h */
|
||||
|
||||
215
mozilla/embedding/browser/gtk/src/EmbedFilePicker.cpp
Normal file
215
mozilla/embedding/browser/gtk/src/EmbedFilePicker.cpp
Normal file
@ -0,0 +1,215 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
// local includes
|
||||
#include "EmbedFilePicker.h"
|
||||
#include "EmbedGtkTools.h"
|
||||
#include "gtkmozembed.h"
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIServiceManager.h>
|
||||
#include <nsIURI.h>
|
||||
#include <nsIFileURL.h>
|
||||
#include <nsILocalFile.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
#include <nsNetCID.h>
|
||||
#include <nsIDOMWindowInternal.h>
|
||||
#ifndef MOZILLA_INTERNAL_API
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#endif
|
||||
#ifdef MOZ_LOGGING
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS1(EmbedFilePicker, nsIFilePicker)
|
||||
EmbedFilePicker::EmbedFilePicker()
|
||||
: mParent (nsnull),
|
||||
mMode(nsIFilePicker::modeOpen),
|
||||
mFilename (nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
EmbedFilePicker::~EmbedFilePicker()
|
||||
{
|
||||
if (mFilename)
|
||||
g_free (mFilename);
|
||||
}
|
||||
|
||||
/* void init (in nsIDOMWindowInternal parent, in wstring title, in short mode); */
|
||||
NS_IMETHODIMP EmbedFilePicker::Init(nsIDOMWindow *parent, const nsAString &title, PRInt16 mode)
|
||||
{
|
||||
mParent = parent;
|
||||
mMode = mode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void appendFilters (in long filterMask); */
|
||||
NS_IMETHODIMP EmbedFilePicker::AppendFilters(PRInt32 filterMask)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void appendFilter (in wstring title, in wstring filter); */
|
||||
NS_IMETHODIMP EmbedFilePicker::AppendFilter(const nsAString &title, const nsAString &filter)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute wstring defaultString; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetDefaultString(nsAString &aDefaultString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EmbedFilePicker::SetDefaultString(const nsAString &aDefaultString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute wstring defaultExtension; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetDefaultExtension(nsAString &aDefaultExtension)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EmbedFilePicker::SetDefaultExtension(const nsAString &aDefaultExtension)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute long filterIndex; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetFilterIndex(PRInt32 *aFilterIndex)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EmbedFilePicker::SetFilterIndex(PRInt32 aFilterIndex)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute nsILocalFile displayDirectory; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetDisplayDirectory(nsILocalFile **aDisplayDirectory)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EmbedFilePicker::SetDisplayDirectory(nsILocalFile *aDisplayDirectory)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute nsILocalFile file; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetFile(nsILocalFile **aFile)
|
||||
{
|
||||
if (!mFilename) return NS_OK;
|
||||
/* NOTE: we have to take out any prefix (file:// or obex://)
|
||||
* from file name to make it work in mozilla.
|
||||
*/
|
||||
gchar *strippedFileName = nsnull;
|
||||
if (!strncmp (mFilename, GTK_MOZ_EMBED_COMMON_FILE_SCHEME, 7))
|
||||
strippedFileName = (g_strsplit(mFilename, GTK_MOZ_EMBED_COMMON_FILE_SCHEME, -1))[1];
|
||||
else if (!strncmp (mFilename, GTK_MOZ_EMBED_BLUETOOTH_FILE_SCHEME, 7))
|
||||
strippedFileName = (g_strsplit(mFilename, GTK_MOZ_EMBED_BLUETOOTH_FILE_SCHEME, -1))[1];
|
||||
else {
|
||||
if (!mParent) return NS_OK;
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow (mParent);
|
||||
if (!parentWidget) return NS_OK;
|
||||
g_signal_emit_by_name(GTK_OBJECT (parentWidget), "alert", "File protocol not supported." ,NULL);
|
||||
// FIXME: clean/free parentWidget
|
||||
return NS_OK;
|
||||
}
|
||||
if (strippedFileName)
|
||||
{
|
||||
nsCAutoString localSavePath (strippedFileName);
|
||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID);
|
||||
if (!file) return NS_OK;
|
||||
file->InitWithNativePath (localSavePath);
|
||||
NS_ADDREF (*aFile = file);
|
||||
g_free (strippedFileName);
|
||||
strippedFileName = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIFileURL fileURL; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetFileURL(nsIFileURL **aFileURL)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
GetFile (getter_AddRefs(file));
|
||||
if (!file) return NS_OK;
|
||||
NS_ENSURE_TRUE (file, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_CreateInstance (NS_STANDARDURL_CONTRACTID);
|
||||
if (!fileURL) return NS_OK;
|
||||
fileURL->SetFile(file);
|
||||
NS_ADDREF(*aFileURL = fileURL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISimpleEnumerator files; */
|
||||
NS_IMETHODIMP EmbedFilePicker::GetFiles(nsISimpleEnumerator * *aFiles)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* short show (); */
|
||||
NS_IMETHODIMP EmbedFilePicker::Show(PRInt16 *_retval)
|
||||
{
|
||||
if (!mParent)
|
||||
return NS_OK;
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow (mParent);
|
||||
if (!parentWidget)
|
||||
return NS_OK;
|
||||
if (mFilename) {
|
||||
g_free (mFilename);
|
||||
mFilename = nsnull;
|
||||
}
|
||||
int response;
|
||||
g_signal_emit_by_name (
|
||||
GTK_OBJECT (parentWidget),
|
||||
"upload_dialog",
|
||||
"/home/user", // XXX please use genenv("HOME") instead of this.
|
||||
"",
|
||||
&mFilename,
|
||||
&response,
|
||||
NULL);
|
||||
if (response == 1 && mFilename != NULL)
|
||||
*_retval = nsIFilePicker::returnOK;
|
||||
else
|
||||
*_retval = nsIFilePicker::returnCancel;
|
||||
return NS_OK;
|
||||
}
|
||||
64
mozilla/embedding/browser/gtk/src/EmbedFilePicker.h
Normal file
64
mozilla/embedding/browser/gtk/src/EmbedFilePicker.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __EmbedFilePicker_h
|
||||
#define __EmbedFilePicker_h
|
||||
|
||||
#include <nsIFilePicker.h>
|
||||
#include <nsISupports.h>
|
||||
|
||||
#define EMBED_FILEPICKER_CID \
|
||||
{ /* f097d33b-1c97-48a6-af4c-07022857eb7c */ \
|
||||
0xf097d33b, \
|
||||
0x1c97, \
|
||||
0x48a6, \
|
||||
{0xaf, 0x4c, 0x07, 0x02, 0x28, 0x57, 0xeb, 0x7c} \
|
||||
}
|
||||
|
||||
#define EMBED_FILEPICKER_CONTRACTID "@mozilla.org/filepicker;1"
|
||||
#define EMBED_FILEPICKER_CLASSNAME "File Picker Implementation"
|
||||
|
||||
class EmbedFilePicker : public nsIFilePicker
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFILEPICKER
|
||||
EmbedFilePicker ();
|
||||
virtual ~EmbedFilePicker();
|
||||
private:
|
||||
nsIDOMWindow *mParent;
|
||||
PRInt16 mMode;
|
||||
char *mFilename;
|
||||
};
|
||||
#endif
|
||||
920
mozilla/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
Normal file
920
mozilla/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
Normal file
@ -0,0 +1,920 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Conrad Carlen <ccarlen@netscape.com>
|
||||
* (from original mozilla/embedding/lite/nsEmbedGlobalHistory.cpp)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* XXX This file is probably out of sync with its original.
|
||||
* This is a bad thing
|
||||
*/
|
||||
#include "EmbedGlobalHistory.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include <nsIURI.h>
|
||||
#include <nsInt64.h>
|
||||
#include <nsIIOService.h>
|
||||
#include <nsNetUtil.h>
|
||||
#include "gtkmozembed_common.h"
|
||||
#ifndef MOZILLA_INTERNAL_API
|
||||
#include "nsCRT.h"
|
||||
#endif
|
||||
// Constants
|
||||
#define defaultSeparator 1
|
||||
// Number of changes in history before automatic flush
|
||||
static const PRInt32 kNewEntriesBetweenFlush = 10;
|
||||
// Default expiration interval: used if can't get preference service value
|
||||
static const PRUint32 kDefaultExpirationIntervalDays = 7;
|
||||
// Mozilla and EAL standard are different each other
|
||||
static const PRInt64 kMSecsPerDay = LL_INIT(0, 60 * 60 * 24 * 1000);
|
||||
static const PRInt64 kOneThousand = LL_INIT(0, 1000);
|
||||
// The history list and the entries counter
|
||||
static GList *mURLList; /** < The history list */
|
||||
static PRInt64 mExpirationInterval; /** < Expiration interval time */
|
||||
static EmbedGlobalHistory *sEmbedGlobalHistory = nsnull;
|
||||
|
||||
//*****************************************************************************
|
||||
// HistoryEntryOld: an entry object and its methods
|
||||
//*****************************************************************************
|
||||
typedef struct _HistoryEntry {
|
||||
PRInt64 mLastVisitTime; // Millisecs
|
||||
PRPackedBool mWritten; // TRUE if ever persisted
|
||||
nsAutoString mTitle; // The entry title
|
||||
char *url; // The url itself
|
||||
} HistoryEntry;
|
||||
|
||||
static void close_file_handle(void *file_handle)
|
||||
{
|
||||
g_return_if_fail(file_handle);
|
||||
gnome_vfs_close((GnomeVFSHandle*) file_handle);
|
||||
}
|
||||
|
||||
static bool file_handle_uri_exists(const void *uri)
|
||||
{
|
||||
g_return_val_if_fail(uri, false);
|
||||
return gnome_vfs_uri_exists((GnomeVFSURI*)uri);
|
||||
}
|
||||
|
||||
static void* file_handle_uri_new(const char *uri)
|
||||
{
|
||||
g_return_val_if_fail(uri, nsnull);
|
||||
return gnome_vfs_uri_new(uri);
|
||||
}
|
||||
|
||||
static bool file_handle_create_uri(void *file_handle, const void *uri)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, false);
|
||||
return gnome_vfs_create_uri(
|
||||
(GnomeVFSHandle**)file_handle,
|
||||
(GnomeVFSURI*)uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
1,
|
||||
0600
|
||||
) == GNOME_VFS_OK;
|
||||
}
|
||||
|
||||
static bool file_handle_open_uri(void *file_handle, const void *uri)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, false);
|
||||
return gnome_vfs_open_uri(
|
||||
(GnomeVFSHandle**)file_handle,
|
||||
(GnomeVFSURI*)uri,
|
||||
(GnomeVFSOpenMode)(GNOME_VFS_OPEN_WRITE
|
||||
| GNOME_VFS_OPEN_RANDOM
|
||||
| GNOME_VFS_OPEN_READ));
|
||||
}
|
||||
|
||||
static bool file_handle_seek(void *file_handle, gboolean end)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, false);
|
||||
|
||||
return gnome_vfs_seek((GnomeVFSHandle*)file_handle,
|
||||
end ? GNOME_VFS_SEEK_END : GNOME_VFS_SEEK_START, 0);
|
||||
}
|
||||
|
||||
static bool file_handle_truncate(void *file_handle)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, false);
|
||||
return gnome_vfs_truncate_handle ((GnomeVFSHandle*)file_handle, 0);
|
||||
}
|
||||
|
||||
static int file_handle_file_info_block_size(void *file_handle)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, 0);
|
||||
GnomeVFSFileInfo info;
|
||||
gnome_vfs_get_file_info_from_handle ((GnomeVFSHandle *)file_handle,
|
||||
&info,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT);
|
||||
return info.io_block_size;
|
||||
}
|
||||
|
||||
static int64 file_handle_read(void *file_handle, gpointer buffer, guint64 bytes)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, false);
|
||||
GnomeVFSResult vfs_result = GNOME_VFS_OK;
|
||||
GnomeVFSFileSize read_bytes;
|
||||
vfs_result = gnome_vfs_read((GnomeVFSHandle *)file_handle,
|
||||
(gpointer) buffer, (GnomeVFSFileSize)bytes-1, &read_bytes);
|
||||
if (vfs_result!=GNOME_VFS_OK)
|
||||
return -1;
|
||||
|
||||
return (int64)read_bytes;
|
||||
}
|
||||
|
||||
static guint64 file_handle_write(void *file_handle, gpointer line)
|
||||
{
|
||||
g_return_val_if_fail(file_handle, 0);
|
||||
GnomeVFSFileSize written;
|
||||
gnome_vfs_write ((GnomeVFSHandle *)file_handle,
|
||||
(gpointer)line,
|
||||
strlen((const char*)line),
|
||||
&written);
|
||||
return written;
|
||||
}
|
||||
|
||||
// Static Routine Prototypes
|
||||
//GnomeVFSHandle
|
||||
static nsresult writeEntry(void *file_handle, HistoryEntry *entry);
|
||||
// when an entry is visited
|
||||
nsresult OnVisited(HistoryEntry *entry)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
entry->mLastVisitTime = PR_Now();
|
||||
LL_DIV(entry->mLastVisitTime, entry->mLastVisitTime, kOneThousand);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Return the last time an entry was visited
|
||||
PRInt64 GetLastVisitTime(HistoryEntry *entry)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
return entry->mLastVisitTime;
|
||||
}
|
||||
|
||||
// Change the last time an entry was visited
|
||||
nsresult SetLastVisitTime(HistoryEntry *entry, const PRInt64& aTime)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
NS_ENSURE_ARG_POINTER(aTime);
|
||||
entry->mLastVisitTime = aTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Return TRUE if an entry has been written
|
||||
PRBool GetIsWritten(HistoryEntry *entry)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
return entry->mWritten;
|
||||
}
|
||||
|
||||
// Set TRUE when an entry is visited
|
||||
nsresult SetIsWritten(HistoryEntry *entry)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
entry->mWritten = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Change the entry title
|
||||
#define SET_TITLE(entry, aTitle) entry->mTitle.Assign (aTitle);
|
||||
|
||||
// Change the entry title
|
||||
nsresult SetURL(HistoryEntry *entry, const char *url)
|
||||
{
|
||||
NS_ENSURE_ARG(entry);
|
||||
NS_ENSURE_ARG(url);
|
||||
if (entry->url)
|
||||
g_free(entry->url);
|
||||
entry->url = g_strdup(url);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Return the entry title
|
||||
#define GET_TITLE(entry) (entry->mTitle)
|
||||
|
||||
// Return the entry url
|
||||
char* GetURL(HistoryEntry *entry)
|
||||
{
|
||||
return entry->url;
|
||||
}
|
||||
|
||||
// Traverse the history list trying to find a frame
|
||||
int history_entry_find_exist (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return g_ascii_strcasecmp(GetURL((HistoryEntry *) a), (char *) b);
|
||||
}
|
||||
|
||||
// Traverse the history list looking for the correct place to add a new item
|
||||
int find_insertion_place (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
PRInt64 lastVisitTime = GetLastVisitTime((HistoryEntry *) a);
|
||||
PRInt64 tempTime = GetLastVisitTime((HistoryEntry *) b);
|
||||
return LL_CMP(lastVisitTime, <, tempTime);
|
||||
}
|
||||
|
||||
// Check whether an entry has expired
|
||||
PRBool entryHasExpired(HistoryEntry *entry)
|
||||
{
|
||||
// convert "now" from microsecs to millisecs
|
||||
PRInt64 nowInMilliSecs = PR_Now();
|
||||
LL_DIV(nowInMilliSecs, nowInMilliSecs, kOneThousand);
|
||||
// determine when the entry would have expired
|
||||
PRInt64 expirationIntervalAgo;
|
||||
LL_SUB(expirationIntervalAgo, nowInMilliSecs, mExpirationInterval);
|
||||
PRInt64 lastVisitTime = GetLastVisitTime(entry);
|
||||
return (LL_CMP(lastVisitTime, <, expirationIntervalAgo));
|
||||
}
|
||||
|
||||
// Traverse the history list to get all the entries data and set the EAL history list
|
||||
void history_entry_foreach_to_remove (gpointer data, gpointer user_data)
|
||||
{
|
||||
HistoryEntry *entry = (HistoryEntry *) data;
|
||||
if (entry) {
|
||||
entry->url = NULL;
|
||||
entry->mLastVisitTime = 0;
|
||||
g_free(entry);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// EmbedGlobalHistory - Creation/Destruction
|
||||
//*****************************************************************************
|
||||
NS_IMPL_ISUPPORTS3(EmbedGlobalHistory, nsIGlobalHistory2, nsIBrowserHistory, nsIObserver)
|
||||
/* static */
|
||||
EmbedGlobalHistory*
|
||||
EmbedGlobalHistory::GetInstance()
|
||||
{
|
||||
if (!sEmbedGlobalHistory)
|
||||
{
|
||||
sEmbedGlobalHistory = new EmbedGlobalHistory();
|
||||
if (!sEmbedGlobalHistory)
|
||||
return nsnull;
|
||||
sEmbedGlobalHistory->handle = NULL;
|
||||
NS_ADDREF(sEmbedGlobalHistory); // addref the global
|
||||
if (NS_FAILED(sEmbedGlobalHistory->Init()))
|
||||
{
|
||||
NS_RELEASE(sEmbedGlobalHistory);
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
NS_ADDREF(sEmbedGlobalHistory); // addref the return result
|
||||
return sEmbedGlobalHistory;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
EmbedGlobalHistory::DeleteInstance()
|
||||
{
|
||||
if (sEmbedGlobalHistory)
|
||||
{
|
||||
delete sEmbedGlobalHistory;
|
||||
sEmbedGlobalHistory = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
// The global history component constructor
|
||||
EmbedGlobalHistory::EmbedGlobalHistory()
|
||||
{
|
||||
if (!mURLList) {
|
||||
mDataIsLoaded = PR_FALSE;
|
||||
mEntriesAddedSinceFlush = 0;
|
||||
LL_I2L(mExpirationInterval, kDefaultExpirationIntervalDays);
|
||||
LL_MUL(mExpirationInterval, mExpirationInterval, kMSecsPerDay);
|
||||
}
|
||||
}
|
||||
|
||||
// The global history component destructor
|
||||
EmbedGlobalHistory::~EmbedGlobalHistory()
|
||||
{
|
||||
LoadData();
|
||||
FlushData();
|
||||
if (mURLList) {
|
||||
g_list_foreach(mURLList, (GFunc) history_entry_foreach_to_remove, NULL);
|
||||
g_list_free(mURLList);
|
||||
}
|
||||
if (handle) {
|
||||
close_file_handle(handle);
|
||||
handle = NULL;
|
||||
}
|
||||
if (mHistoryFile) {
|
||||
g_free(mHistoryFile);
|
||||
mHistoryFile = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the global history component
|
||||
NS_IMETHODIMP EmbedGlobalHistory::Init()
|
||||
{
|
||||
if (mURLList) return NS_OK;
|
||||
// Get Pref and convert to millisecs
|
||||
PRInt32 expireDays;
|
||||
int success = gtk_moz_embed_common_get_pref(G_TYPE_INT, EMBED_HISTORY_PREF_EXPIRE_DAYS, &expireDays);
|
||||
if (success) {
|
||||
LL_I2L(mExpirationInterval, expireDays);
|
||||
LL_MUL(mExpirationInterval, mExpirationInterval, kMSecsPerDay);
|
||||
}
|
||||
// register to observe profile changes
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(observerService, "failed to get observer service");
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, "quit-application", PR_FALSE);
|
||||
nsresult rv = InitFile();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = LoadData();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define BROKEN_RV_HANDLING_CODE(rv) PR_BEGIN_MACRO \
|
||||
if (NS_FAILED(rv)) { \
|
||||
/* OOPS the coder (not timeless) didn't handle this case well at all. \
|
||||
* unfortunately the coder will remain anonymous. \
|
||||
* XXX please fix me. \
|
||||
*/ \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#define BROKEN_STRING_GETTER(out) PR_BEGIN_MACRO \
|
||||
/* OOPS the coder (not timeless) decided not to do anything in this \
|
||||
* method, but to return NS_OK anyway. That's not very polite. \
|
||||
*/ \
|
||||
out.Truncate(); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define BROKEN_STRING_BUILDER(var) PR_BEGIN_MACRO \
|
||||
/* This is just wrong */ \
|
||||
PR_END_MACRO
|
||||
|
||||
//*****************************************************************************
|
||||
// EmbedGlobalHistory::nsIGlobalHistory
|
||||
//*****************************************************************************
|
||||
// Add a new URI to the history
|
||||
NS_IMETHODIMP EmbedGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aToplevel, nsIURI *aReferrer)
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
nsCAutoString URISpec;
|
||||
aURI->GetSpec(URISpec);
|
||||
const char *aURL = URISpec.get();
|
||||
if (!aToplevel)
|
||||
return NS_OK;
|
||||
PRBool isHTTP, isHTTPS;
|
||||
nsresult rv = NS_OK;
|
||||
rv |= aURI->SchemeIs("http", &isHTTP);
|
||||
rv |= aURI->SchemeIs("https", &isHTTPS);
|
||||
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
|
||||
// Only get valid uri schemes
|
||||
if (!isHTTP && !isHTTPS)
|
||||
{
|
||||
/* the following blacklist is silly.
|
||||
* if there's some need to whitelist http(s) + ftp,
|
||||
* that's what we should do.
|
||||
*/
|
||||
PRBool isAbout, isImap, isNews, isMailbox, isViewSource, isChrome, isData, isJavascript;
|
||||
rv = aURI->SchemeIs("about", &isAbout);
|
||||
rv |= aURI->SchemeIs("imap", &isImap);
|
||||
rv |= aURI->SchemeIs("news", &isNews);
|
||||
rv |= aURI->SchemeIs("mailbox", &isMailbox);
|
||||
rv |= aURI->SchemeIs("view-source", &isViewSource);
|
||||
rv |= aURI->SchemeIs("chrome", &isChrome);
|
||||
rv |= aURI->SchemeIs("data", &isData);
|
||||
rv |= aURI->SchemeIs("javascript", &isJavascript);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
if (isAbout ||
|
||||
isImap ||
|
||||
isNews ||
|
||||
isMailbox ||
|
||||
isViewSource ||
|
||||
isChrome ||
|
||||
isData ||
|
||||
isJavascript) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
g_print("[HISTORY] Visited URL: %s\n", aURL);
|
||||
#endif
|
||||
rv = LoadData();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
GList *node = g_list_find_custom(mURLList, aURL, (GCompareFunc) history_entry_find_exist);
|
||||
HistoryEntry *entry = NULL;
|
||||
if (node && node->data)
|
||||
entry = (HistoryEntry *)(node->data);
|
||||
nsCAutoString hostname;
|
||||
aURI->GetHost(hostname);
|
||||
|
||||
// It is not in the history
|
||||
if (!entry) {
|
||||
entry = g_new0(HistoryEntry, 1);
|
||||
rv |= OnVisited(entry);
|
||||
SET_TITLE(entry, hostname);
|
||||
rv |= SetURL(entry, aURL);
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
unsigned int listSize = g_list_length(mURLList);
|
||||
if (listSize+1 > kDefaultMaxSize) {
|
||||
GList *last = g_list_last (mURLList);
|
||||
mURLList = g_list_remove (mURLList, last->data);
|
||||
mEntriesAddedSinceFlush++;
|
||||
}
|
||||
mURLList = g_list_insert_sorted(mURLList, entry,
|
||||
(GCompareFunc) find_insertion_place);
|
||||
// Flush after kNewEntriesBetweenFlush changes
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
if (++mEntriesAddedSinceFlush >= kNewEntriesBetweenFlush)
|
||||
rv |= FlushData(kFlushModeAppend);
|
||||
// emit signal to let EAL knows a new item was added
|
||||
//FIXME REIMP g_signal_emit_by_name (g_mozilla_get_current_web(),
|
||||
//"global-history-item-added", aURL);
|
||||
} else {
|
||||
// update the last visited time
|
||||
rv |= OnVisited(entry);
|
||||
SET_TITLE(entry, hostname);
|
||||
// Move the element to the start of the list
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
mURLList = g_list_remove (mURLList, entry);
|
||||
mURLList = g_list_insert_sorted(mURLList, entry, (GCompareFunc) find_insertion_place);
|
||||
// Flush after kNewEntriesBetweenFlush changes
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
if (++mEntriesAddedSinceFlush >= kNewEntriesBetweenFlush)
|
||||
rv |= FlushData(kFlushModeFullWrite);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Return TRUE if the url is already in history
|
||||
NS_IMETHODIMP EmbedGlobalHistory::IsVisited(nsIURI *aURI, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
nsCAutoString URISpec;
|
||||
aURI->GetSpec(URISpec);
|
||||
const char *aURL = URISpec.get();
|
||||
nsresult rv = LoadData();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
GList *node = g_list_find_custom(mURLList, aURL,
|
||||
(GCompareFunc) history_entry_find_exist);
|
||||
*_retval = (node && node->data);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// It is called when Mozilla get real name of a URL
|
||||
NS_IMETHODIMP EmbedGlobalHistory::SetPageTitle(nsIURI *aURI,
|
||||
const nsAString & aTitle)
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
nsresult rv;
|
||||
// skip about: URIs to avoid reading in the db (about:blank, especially)
|
||||
PRBool isAbout;
|
||||
rv = aURI->SchemeIs("about", &isAbout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isAbout)
|
||||
return NS_OK;
|
||||
nsCAutoString URISpec;
|
||||
aURI->GetSpec(URISpec);
|
||||
const char *aURL = URISpec.get();
|
||||
rv |= LoadData();
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
GList *node = g_list_find_custom(mURLList, aURL,
|
||||
(GCompareFunc) history_entry_find_exist);
|
||||
HistoryEntry *entry = NULL;
|
||||
if (node)
|
||||
entry = (HistoryEntry *)(node->data);
|
||||
if (entry) {
|
||||
nsCString title;
|
||||
CopyUTF16toUTF8(aTitle, title);
|
||||
SET_TITLE(entry, title);
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
if (++mEntriesAddedSinceFlush >= kNewEntriesBetweenFlush)
|
||||
rv |= FlushData(kFlushModeAppend);
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// EmbedGlobalHistory::nsIBrowserHistory
|
||||
//*****************************************************************************
|
||||
// Add a page with url, title and last visit time
|
||||
NS_IMETHODIMP EmbedGlobalHistory::AddPageWithDetails(nsIURI *aURI,
|
||||
const PRUnichar *aTitle,
|
||||
PRInt64 aLastVisited)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the last page visited
|
||||
NS_IMETHODIMP EmbedGlobalHistory::GetLastPageVisited(nsACString & aLastPageVisited)
|
||||
{
|
||||
BROKEN_STRING_GETTER(aLastPageVisited);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the number of items in the history
|
||||
NS_IMETHODIMP EmbedGlobalHistory::GetCount(PRUint32 *aCount)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Remove a page from history
|
||||
NS_IMETHODIMP EmbedGlobalHistory::RemovePage(nsIURI *aURI)
|
||||
{
|
||||
nsCAutoString URISpec;
|
||||
nsresult rv = aURI->GetSpec(URISpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = LoadData();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
const char *aURL = URISpec.get();
|
||||
GList *node = g_list_find_custom(mURLList, aURL,
|
||||
(GCompareFunc) history_entry_find_exist);
|
||||
if (node && node->data) {
|
||||
mURLList = g_list_remove(mURLList, node->data);
|
||||
#ifdef DEBUG
|
||||
g_print("[HISTORY] Removed URL: %s\n", aURL);
|
||||
#endif
|
||||
if (++mEntriesAddedSinceFlush >= kNewEntriesBetweenFlush)
|
||||
rv |= FlushData(kFlushModeFullWrite);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Remove all the pages from a host
|
||||
NS_IMETHODIMP EmbedGlobalHistory::RemovePagesFromHost(const nsACString & aHost,
|
||||
PRBool aEntireDomain)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Remove all pages from history
|
||||
NS_IMETHODIMP EmbedGlobalHistory::RemoveAllPages()
|
||||
{
|
||||
nsresult rv;
|
||||
if (mURLList) {
|
||||
g_list_foreach (mURLList, (GFunc) history_entry_foreach_to_remove, NULL);
|
||||
g_list_free(mURLList);
|
||||
mURLList = NULL;
|
||||
}
|
||||
mDataIsLoaded = PR_FALSE;
|
||||
rv = FlushData(kFlushModeFullWrite);
|
||||
mEntriesAddedSinceFlush = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Hide a page
|
||||
NS_IMETHODIMP EmbedGlobalHistory::HidePage(nsIURI *aURI)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
NS_IMETHODIMP EmbedGlobalHistory::MarkPageAsTyped(nsIURI *aURI)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// EmbedGlobalHistory::nsIObserver
|
||||
//*****************************************************************************
|
||||
NS_IMETHODIMP EmbedGlobalHistory::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// used when the browser is closed and the EmbedGlobalHistory destructor is not called
|
||||
if (strcmp(aTopic, "quit-application") == 0) {
|
||||
rv = LoadData();
|
||||
// we have to sort the list before flush it
|
||||
rv |= FlushData();
|
||||
if (mURLList) {
|
||||
g_list_foreach(mURLList, (GFunc) history_entry_foreach_to_remove, NULL);
|
||||
g_list_free(mURLList);
|
||||
}
|
||||
if (handle)
|
||||
close_file_handle(handle);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// EmbedGlobalHistory
|
||||
//*****************************************************************************
|
||||
// Open/Create the history.dat file if it does not exist
|
||||
nsresult EmbedGlobalHistory::InitFile()
|
||||
{
|
||||
// Get the history file in our profile dir.
|
||||
// Notice we are not just getting NS_APP_HISTORY_50_FILE
|
||||
// because it is used by the "real" global history component.
|
||||
if (EmbedPrivate::sProfileDir) {
|
||||
nsString path;
|
||||
EmbedPrivate::sProfileDir->GetPath(path);
|
||||
mHistoryFile = g_strdup_printf("%s/history.dat", NS_ConvertUTF16toUTF8(path).get());
|
||||
BROKEN_STRING_BUILDER(mHistoryFile);
|
||||
} else {
|
||||
mHistoryFile = g_strdup_printf("%s/history.dat", g_get_tmp_dir());
|
||||
}
|
||||
void *uri = file_handle_uri_new(mHistoryFile);
|
||||
gboolean rs = FALSE;
|
||||
if (!file_handle_uri_exists(uri)) {
|
||||
if (file_handle_create_uri(&handle, uri)) {
|
||||
g_print("Could not create a history file\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
close_file_handle(handle);
|
||||
}
|
||||
rs = file_handle_open_uri(&handle, uri);
|
||||
if (rs) {
|
||||
//g_print("Could not open history URI. Result: %s\n", gnome_vfs_result_to_string(rs));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the data from history.dat file
|
||||
nsresult EmbedGlobalHistory::LoadData()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mDataIsLoaded) {
|
||||
mDataIsLoaded = PR_TRUE;
|
||||
void *uri = file_handle_uri_new(mHistoryFile);
|
||||
if (!file_handle_uri_exists(uri)) {
|
||||
rv = InitFile();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
file_handle_seek(handle, FALSE);
|
||||
rv |= ReadEntries(handle);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Call a function to write each entry in the history hash table
|
||||
nsresult EmbedGlobalHistory::WriteEntryIfWritten(GList *list, void *file_handle)
|
||||
{
|
||||
if (!file_handle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
unsigned int counter = g_list_length(list);
|
||||
while (counter > 0) {
|
||||
HistoryEntry *entry = NS_STATIC_CAST(HistoryEntry*, g_list_nth_data(list, counter-1));
|
||||
counter--;
|
||||
if (!entry || entryHasExpired(entry)) {
|
||||
continue;
|
||||
}
|
||||
writeEntry(file_handle, entry);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Call a function to write each unwritten entry in the history hash table
|
||||
nsresult EmbedGlobalHistory::WriteEntryIfUnwritten(GList *list, void *file_handle)
|
||||
{
|
||||
if (!file_handle)
|
||||
return NS_ERROR_FAILURE;
|
||||
unsigned int counter = g_list_length(list);
|
||||
while (counter > 0) {
|
||||
HistoryEntry *entry = NS_STATIC_CAST(HistoryEntry*, g_list_nth_data(list, counter-1));
|
||||
if (!entry || entryHasExpired(entry)) {
|
||||
counter--;
|
||||
continue;
|
||||
}
|
||||
if (!GetIsWritten(entry))
|
||||
writeEntry(file_handle, entry);
|
||||
counter--;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Write the history in history.dat file
|
||||
nsresult EmbedGlobalHistory::FlushData(PRIntn mode)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mEntriesAddedSinceFlush == 0)
|
||||
return NS_OK;
|
||||
if (!mHistoryFile)
|
||||
{
|
||||
rv |= InitFile();
|
||||
rv |= FlushData(kFlushModeFullWrite);
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
return rv;
|
||||
}
|
||||
void *uri = file_handle_uri_new(mHistoryFile);
|
||||
if (!file_handle_uri_exists(uri)) {
|
||||
rv = InitFile();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
rv |= InitFile();
|
||||
rv |= FlushData(kFlushModeFullWrite);
|
||||
|
||||
return rv;
|
||||
}
|
||||
mEntriesAddedSinceFlush = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Split an entry in last visit time, title and url.
|
||||
// Add a stored entry in the history.dat file in the history hash table
|
||||
nsresult EmbedGlobalHistory::GetEntry(char *entry)
|
||||
{
|
||||
char separator = (char) defaultSeparator;
|
||||
int pos = 0;
|
||||
nsInt64 outValue = 0;
|
||||
while (PR_TRUE) {
|
||||
PRInt32 digit;
|
||||
if (entry[pos] == separator) {
|
||||
pos++;
|
||||
break;
|
||||
}
|
||||
if (entry[pos] == '\0' || !isdigit(entry[pos]))
|
||||
return NS_ERROR_FAILURE;
|
||||
digit = entry[pos] - '0';
|
||||
outValue *= nsInt64(10);
|
||||
outValue += nsInt64(digit);
|
||||
pos++;
|
||||
}
|
||||
char url[1024], title[1024];
|
||||
int urlLength= 0, titleLength= 0, numStrings=1;
|
||||
// get the url and title
|
||||
// FIXME
|
||||
while(PR_TRUE) {
|
||||
if (entry[pos] == separator) {
|
||||
numStrings++;
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
if (numStrings > 2)
|
||||
break;
|
||||
if (numStrings==1) {
|
||||
url[urlLength++] = entry[pos];
|
||||
} else {
|
||||
title[titleLength++] = entry[pos];
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
url[urlLength]='\0';
|
||||
title[titleLength]='\0';
|
||||
HistoryEntry *newEntry = g_new0(HistoryEntry, 1);
|
||||
if (!newEntry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
SET_TITLE(newEntry, title);
|
||||
rv |= SetLastVisitTime(newEntry, outValue);
|
||||
rv |= SetIsWritten(newEntry);
|
||||
rv |= SetURL(newEntry, url);
|
||||
BROKEN_RV_HANDLING_CODE(rv);
|
||||
// Check wheter the entry has expired
|
||||
if (!entryHasExpired(newEntry)) {
|
||||
mURLList = g_list_prepend(mURLList, newEntry);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the history entries from history.dat file
|
||||
nsresult EmbedGlobalHistory::ReadEntries(void *file_handle)
|
||||
{
|
||||
if (!file_handle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
guint64 bytes;
|
||||
int64 read_bytes;
|
||||
char separator = (char) defaultSeparator;
|
||||
int pos = 0;
|
||||
int numStrings = 0;
|
||||
bytes = file_handle_file_info_block_size (file_handle);
|
||||
/* Optimal buffer size for reading/writing the file. */
|
||||
char line[bytes];
|
||||
char buffer[bytes];
|
||||
do {
|
||||
read_bytes = file_handle_read(file_handle, (gpointer) buffer, bytes-1);
|
||||
if (read_bytes < 0)
|
||||
break;
|
||||
buffer[read_bytes] = '\0';
|
||||
unsigned int buf_pos = 0;
|
||||
while (buf_pos< read_bytes) {
|
||||
if (buffer[buf_pos]== separator)
|
||||
numStrings++;
|
||||
if (buffer[buf_pos]!= '\n')
|
||||
line[pos] = buffer[buf_pos];
|
||||
else
|
||||
buf_pos++;
|
||||
if (numStrings==3) {
|
||||
line[pos+1] = '\0';
|
||||
rv = GetEntry(line);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
pos = -1;
|
||||
numStrings = 0;
|
||||
}
|
||||
pos++;
|
||||
buf_pos++;
|
||||
}
|
||||
} while (read_bytes != -1);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// Static Functions
|
||||
//*****************************************************************************
|
||||
// Get last visit time from a string
|
||||
static nsresult writePRInt64(char time[14], const PRInt64& inValue)
|
||||
{
|
||||
nsInt64 value(inValue);
|
||||
if (value == nsInt64(0)) {
|
||||
strcpy(time, "0");
|
||||
return NS_OK;
|
||||
}
|
||||
nsCAutoString tempString;
|
||||
while (value != nsInt64(0)) {
|
||||
PRInt32 ones = PRInt32(value % nsInt64(10));
|
||||
value /= nsInt64(10);
|
||||
tempString.Insert(char('0' + ones), 0);
|
||||
}
|
||||
strcpy(time,(char *) tempString.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Write an entry in the history.dat file
|
||||
nsresult writeEntry(void *file_handle, HistoryEntry *entry)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char sep = (char) defaultSeparator;
|
||||
char time[14];
|
||||
writePRInt64(time, GetLastVisitTime(entry));
|
||||
char *line = g_strdup_printf("%s%c%s%c%s%c\n", time, sep, GetURL(entry), sep, GET_TITLE(entry).get(), sep);
|
||||
BROKEN_STRING_BUILDER(line);
|
||||
guint64 size = file_handle_write (file_handle, (gpointer)line);
|
||||
if (size != strlen(line))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
rv |= SetIsWritten(entry);
|
||||
g_free(line);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult EmbedGlobalHistory::GetContentList(GtkMozHistoryItem **GtkHI, int *count)
|
||||
{
|
||||
if (!mURLList) return NS_ERROR_FAILURE;
|
||||
|
||||
unsigned int num_items = 0;
|
||||
*GtkHI = g_new0(GtkMozHistoryItem, g_list_length(mURLList));
|
||||
GtkMozHistoryItem * item = (GtkMozHistoryItem *)*GtkHI;
|
||||
while (num_items < g_list_length(mURLList)) {
|
||||
HistoryEntry *entry = NS_STATIC_CAST(HistoryEntry*,
|
||||
g_list_nth_data(mURLList, num_items));
|
||||
// verify if the entry has expired and discard it
|
||||
if (entryHasExpired(entry)) {
|
||||
break;
|
||||
}
|
||||
glong accessed;
|
||||
PRInt64 temp, outValue;
|
||||
LL_MUL(outValue, GetLastVisitTime(entry), kOneThousand);
|
||||
LL_DIV(temp, outValue, PR_USEC_PER_SEC);
|
||||
LL_L2I(accessed, temp);
|
||||
// Set the EAL history list
|
||||
item[num_items].title = g_strdup(GET_TITLE(entry).get());
|
||||
BROKEN_STRING_BUILDER(item[num_items].title);
|
||||
item[num_items].url = GetURL(entry);
|
||||
item[num_items].accessed = accessed;
|
||||
num_items++;
|
||||
}
|
||||
*count = num_items;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
124
mozilla/embedding/browser/gtk/src/EmbedGlobalHistory.h
Normal file
124
mozilla/embedding/browser/gtk/src/EmbedGlobalHistory.h
Normal file
@ -0,0 +1,124 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Conrad Carlen <ccarlen@netscape.com>
|
||||
* Changes: andre.pedralho@indt.org.br (from original: mozilla/embedding/lite/nsEmbedGlobalHistory.h)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __EMBEDGLOBALHISTORY_h
|
||||
#define __EMBEDGLOBALHISTORY_h
|
||||
#include <nsIGlobalHistory2.h>
|
||||
#include <nsIBrowserHistory.h>
|
||||
#include <nsIObserver.h>
|
||||
#include "EmbedPrivate.h"
|
||||
#include <prenv.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <nsDocShellCID.h>
|
||||
//#include "gtkmozembed_common.h"
|
||||
/* {2f977d51-5485-11d4-87e2-0010a4e75ef2} */
|
||||
#define NS_EMBEDGLOBALHISTORY_CID \
|
||||
{ 0x2f977d51, 0x5485, 0x11d4, \
|
||||
{ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
|
||||
#define EMBED_HISTORY_PREF_EXPIRE_DAYS "browser.history_expire_days"
|
||||
/** The Mozilla History Class
|
||||
* This class is responsible for handling the history stuff.
|
||||
*/
|
||||
class EmbedGlobalHistory: public nsIBrowserHistory,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
EmbedGlobalHistory();
|
||||
virtual ~EmbedGlobalHistory();
|
||||
static EmbedGlobalHistory* GetInstance();
|
||||
static void DeleteInstance();
|
||||
NS_IMETHOD Init();
|
||||
nsresult GetContentList(GtkMozHistoryItem**, int *count);
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGLOBALHISTORY2
|
||||
NS_DECL_NSIBROWSERHISTORY
|
||||
NS_DECL_NSIOBSERVER
|
||||
protected:
|
||||
enum {
|
||||
kFlushModeAppend, /** < Add a new entry in the history file */
|
||||
kFlushModeFullWrite /** < Rewrite all history file */
|
||||
};
|
||||
/** Initiates the history file
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult InitFile();
|
||||
/** Loads the history file
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult LoadData();
|
||||
/** Writes entries in the history file
|
||||
* @param list The internal history list.
|
||||
* @param handle A Gnome VFS handle.
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult WriteEntryIfWritten(GList *list, void *file_handle);
|
||||
/** Writes entries in the history file
|
||||
* @param list The internal history list.
|
||||
* @param handle A Gnome VFS handle.
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult WriteEntryIfUnwritten(GList *list, void *file_handle);
|
||||
/** Writes entries in the history file
|
||||
* @param mode How to write in the history file
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult FlushData(PRIntn mode = kFlushModeFullWrite);
|
||||
/** Remove entries from the URL table
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult ResetData();
|
||||
/** Reads the history entries using GnomeVFS
|
||||
* @param vfs_handle A Gnome VFS handle.
|
||||
* @return NS_OK on the success.
|
||||
*/
|
||||
nsresult ReadEntries(void *file_handle);
|
||||
/** Gets a history entry
|
||||
* @param name The history entry name.
|
||||
* @return NS_OK if the history entry name was gotten.
|
||||
*/
|
||||
nsresult GetEntry(gchar *);
|
||||
protected:
|
||||
void *handle; /** < The GnomeVFS handler */
|
||||
PRBool mDataIsLoaded; /** < If the data is loaded */
|
||||
PRInt32 mEntriesAddedSinceFlush; /** < Number of entries added since flush */
|
||||
gchar* mHistoryFile; /** < The history file path */
|
||||
};
|
||||
// Default maximum history entries
|
||||
static const PRUint32 kDefaultMaxSize = 1000;
|
||||
#endif
|
||||
105
mozilla/embedding/browser/gtk/src/EmbedGtkTools.cpp
Normal file
105
mozilla/embedding/browser/gtk/src/EmbedGtkTools.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Oleg Romashin. Portions created by Oleg Romashin are Copyright (C) Oleg Romashin. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "EmbedGtkTools.h"
|
||||
#ifndef MOZILLA_INTERNAL_API
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#endif
|
||||
#include "EmbedPrivate.h"
|
||||
|
||||
GtkWidget * GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
|
||||
if (!aDOMWindow)
|
||||
return NULL;
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
|
||||
if (!chrome) {
|
||||
return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = nsnull;
|
||||
siteWindow = do_QueryInterface(chrome);
|
||||
|
||||
if (!siteWindow) {
|
||||
return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
|
||||
}
|
||||
|
||||
GtkWidget* parentWidget;
|
||||
siteWindow->GetSiteWindow((void**)&parentWidget);
|
||||
if (GTK_IS_WIDGET(parentWidget))
|
||||
return parentWidget;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkWindow * GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aDOMWindow);
|
||||
if (!parentWidget)
|
||||
return NULL;
|
||||
GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
|
||||
if (GTK_WIDGET_TOPLEVEL(gtkWin))
|
||||
return GTK_WINDOW(gtkWin);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsresult GetContentViewer (nsIWebBrowser *webBrowser, nsIContentViewer **aViewer)
|
||||
{
|
||||
g_return_val_if_fail(webBrowser, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDocShell> docShell(do_GetInterface((nsISupports*)webBrowser));
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
return docShell->GetContentViewer(aViewer);
|
||||
}
|
||||
|
||||
PRUnichar *LocaleToUnicode (const char *locStr)
|
||||
{
|
||||
if (!locStr)
|
||||
return (NULL);
|
||||
|
||||
nsAutoString autoStr;
|
||||
#ifdef MOZILLA_INTERNAL_API //FIXME?
|
||||
|
||||
autoStr.AssignWithConversion (locStr);
|
||||
#else
|
||||
autoStr.AssignLiteral (locStr);
|
||||
#endif
|
||||
PRUnichar *uniStr = ToNewUnicode(autoStr);
|
||||
|
||||
return (uniStr);
|
||||
}
|
||||
69
mozilla/embedding/browser/gtk/src/EmbedGtkTools.h
Normal file
69
mozilla/embedding/browser/gtk/src/EmbedGtkTools.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Oleg Romashin. Portions created by Oleg Romashin are Copyright (C) Oleg Romashin. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <nsCOMPtr.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include <nsIDOMWindow.h>
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIEmbeddingSiteWindow.h>
|
||||
#include <nsIServiceManager.h>
|
||||
#include <nsIContentViewer.h>
|
||||
#include <nsIDocShell.h>
|
||||
#include <nsIInterfaceRequestorUtils.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifndef __EmbedTools_h
|
||||
#define __EmbedTools_h
|
||||
|
||||
GtkWidget*
|
||||
GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow);
|
||||
|
||||
GtkWindow*
|
||||
GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
|
||||
|
||||
nsresult
|
||||
GetContentViewer (nsIWebBrowser *webBrowser, nsIContentViewer **aViewer);
|
||||
|
||||
PRUnichar*
|
||||
LocaleToUnicode (const char *locStr);
|
||||
|
||||
#endif /* __EmbedTools_h */
|
||||
2134
mozilla/embedding/browser/gtk/src/EmbedPasswordMgr.cpp
Normal file
2134
mozilla/embedding/browser/gtk/src/EmbedPasswordMgr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
193
mozilla/embedding/browser/gtk/src/EmbedPasswordMgr.h
Normal file
193
mozilla/embedding/browser/gtk/src/EmbedPasswordMgr.h
Normal file
@ -0,0 +1,193 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Password Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Brian Ryner.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Changes: romaxa@gmail.com (from original: mozilla/toolkit/components/passwordmgr/base/nsPasswordManager.h)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCPasswordManager.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIFormSubmitObserver.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIAuthPromptWrapper.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#define EMBED_PASSWORDMANAGER_DESCRIPTION "MicroB PSM Dialog Impl"
|
||||
/* 360565c4-2ef3-4f6a-bab9-94cca891b2a7 */
|
||||
#define EMBED_PASSWORDMANAGER_CID \
|
||||
{0x360565c4, 0x2ef3, 0x4f6a, {0xba, 0xb9, 0x94, 0xcc, 0xa8, 0x91, 0xb2, 0xa7}}
|
||||
class nsIFile;
|
||||
class nsIStringBundle;
|
||||
class nsIComponentManager;
|
||||
class nsIContent;
|
||||
class nsIDOMWindowInternal;
|
||||
class nsIURI;
|
||||
class nsIDOMHTMLInputElement;
|
||||
struct nsModuleComponentInfo;
|
||||
class EmbedPasswordMgr : public nsIPasswordManager,
|
||||
public nsIPasswordManagerInternal,
|
||||
public nsIObserver,
|
||||
public nsIFormSubmitObserver,
|
||||
public nsIWebProgressListener,
|
||||
public nsIDOMFocusListener,
|
||||
public nsIDOMLoadListener,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
class SignonDataEntry;
|
||||
class SignonHashEntry;
|
||||
class PasswordEntry;
|
||||
EmbedPasswordMgr();
|
||||
virtual ~EmbedPasswordMgr();
|
||||
static EmbedPasswordMgr* GetInstance();
|
||||
static EmbedPasswordMgr* GetInstance(EmbedPrivate *aOwner);
|
||||
nsresult Init();
|
||||
static PRBool SingleSignonEnabled();
|
||||
static NS_METHOD Register(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const char* aComponentType,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
static NS_METHOD Unregister(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
static void Shutdown();
|
||||
static void GetLocalizedString(const nsAString& key,
|
||||
nsAString& aResult,
|
||||
PRBool aFormatted = PR_FALSE,
|
||||
const PRUnichar** aFormatArgs = nsnull,
|
||||
PRUint32 aFormatArgsLength = 0);
|
||||
static nsresult DecryptData(const nsAString& aData, nsAString& aPlaintext);
|
||||
static nsresult EncryptData(const nsAString& aPlaintext,
|
||||
nsACString& aEncrypted);
|
||||
static nsresult EncryptDataUCS2(const nsAString& aPlaintext,
|
||||
nsAString& aEncrypted);
|
||||
nsresult InsertLogin(const char* username, const char* password = nsnull);
|
||||
nsresult RemovePasswords(const char *aHostName, const char *aUserName);
|
||||
nsresult RemovePasswordsByIndex(PRUint32 aIndex);
|
||||
nsresult GetNumberOfSavedPassword(PRInt32 *aNum);
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPASSWORDMANAGER
|
||||
NS_DECL_NSIPASSWORDMANAGERINTERNAL
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
// nsIFormSubmitObserver
|
||||
NS_IMETHOD Notify(nsIContent* aFormNode,
|
||||
nsIDOMWindowInternal* aWindow,
|
||||
nsIURI* aActionURL,
|
||||
PRBool* aCancelSubmit);
|
||||
// nsIDOMFocusListener
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
// nsIDOMLoadListener
|
||||
NS_IMETHOD Load(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
protected:
|
||||
void WritePasswords(nsIFile* aPasswordFile);
|
||||
void AddSignonData(const nsACString& aRealm, SignonDataEntry* aEntry);
|
||||
nsresult FindPasswordEntryInternal(const SignonDataEntry* aEntry,
|
||||
const nsAString& aUser,
|
||||
const nsAString& aPassword,
|
||||
const nsAString& aUserField,
|
||||
SignonDataEntry** aResult);
|
||||
nsresult FillPassword(nsIDOMEvent* aEvent = nsnull);
|
||||
void AttachToInput(nsIDOMHTMLInputElement* aElement);
|
||||
PRBool GetPasswordRealm(nsIURI* aURI, nsACString& aRealm);
|
||||
static PLDHashOperator PR_CALLBACK FindEntryEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
static PLDHashOperator PR_CALLBACK WriteRejectEntryEnumerator(const nsACString& aKey,
|
||||
PRInt32 aEntry,
|
||||
void* aUserData);
|
||||
static PLDHashOperator PR_CALLBACK WriteSignonEntryEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
static PLDHashOperator PR_CALLBACK BuildArrayEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
static PLDHashOperator PR_CALLBACK BuildRejectArrayEnumerator(const nsACString& aKey,
|
||||
PRInt32 aEntry,
|
||||
void* aUserData);
|
||||
static PLDHashOperator PR_CALLBACK RemoveForDOMDocumentEnumerator(nsISupports* aKey,
|
||||
PRInt32& aEntry,
|
||||
void* aUserData);
|
||||
static void EnsureDecoderRing();
|
||||
nsClassHashtable<nsCStringHashKey,SignonHashEntry> mSignonTable;
|
||||
nsDataHashtable<nsCStringHashKey,PRInt32> mRejectTable;
|
||||
nsDataHashtable<nsISupportsHashKey,PRInt32> mAutoCompleteInputs;
|
||||
nsCOMPtr<nsIFile> mSignonFile;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsIDOMHTMLInputElement* mAutoCompletingField;
|
||||
nsIDOMHTMLInputElement* mGlobalUserField;
|
||||
nsIDOMHTMLInputElement* mGlobalPassField;
|
||||
SignonHashEntry * mLastSignonHashEntry;
|
||||
int lastIndex;
|
||||
nsCAutoString mLastHostQuery;
|
||||
EmbedCommon* mCommonObject;
|
||||
// nsAString mLastHostQuery;
|
||||
};
|
||||
/* 1baf3398-f759-4a72-a21f-0abdc9cc9960 */
|
||||
#define NS_SINGLE_SIGNON_PROMPT_CID \
|
||||
{0x1baf3398, 0xf759, 0x4a72, {0xa2, 0x1f, 0x0a, 0xbd, 0xc9, 0xcc, 0x99, 0x60}}
|
||||
// Our wrapper for username/password prompts - this allows us to prefill
|
||||
// the password dialog and add a "remember this password" checkbox.
|
||||
class EmbedSignonPrompt : public nsIAuthPromptWrapper
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUTHPROMPT
|
||||
NS_DECL_NSIAUTHPROMPTWRAPPER
|
||||
EmbedSignonPrompt() { }
|
||||
virtual ~EmbedSignonPrompt() { }
|
||||
protected:
|
||||
void GetLocalizedString(const nsAString& aKey, nsAString& aResult);
|
||||
nsCOMPtr<nsIPrompt> mPrompt;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -39,7 +41,11 @@
|
||||
#define __EmbedPrivate_h
|
||||
|
||||
#include <nsCOMPtr.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsString.h>
|
||||
#else
|
||||
#include <nsStringAPI.h>
|
||||
#endif
|
||||
#include <nsIWebNavigation.h>
|
||||
#include <nsISHistory.h>
|
||||
// for our one function that gets the EmbedPrivate via the chrome
|
||||
@ -48,12 +54,27 @@
|
||||
#include <nsIAppShell.h>
|
||||
#include <nsIDOMEventReceiver.h>
|
||||
#include <nsVoidArray.h>
|
||||
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
// for profiles
|
||||
#include <nsIPref.h>
|
||||
#endif
|
||||
|
||||
// app component registration
|
||||
#include <nsIGenericFactory.h>
|
||||
#include <nsIComponentRegistrar.h>
|
||||
|
||||
#include <nsIDocCharset.h>
|
||||
#include <nsIMarkupDocumentViewer.h>
|
||||
#include <nsIInterfaceRequestorUtils.h>
|
||||
#include <nsIWebBrowserFind.h>
|
||||
// for the focus hacking we need to do
|
||||
#include <nsIFocusController.h>
|
||||
// for frames
|
||||
#include <nsIDOMWindowCollection.h>
|
||||
#include "gtkmozembedprivate.h"
|
||||
|
||||
#include "EmbedGtkTools.h"
|
||||
class EmbedProgress;
|
||||
class EmbedWindow;
|
||||
class EmbedContentListener;
|
||||
@ -61,7 +82,22 @@ class EmbedEventListener;
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIDirectoryServiceProvider;
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
class nsProfileDirServiceProvider;
|
||||
#endif
|
||||
|
||||
class EmbedCommon {
|
||||
public:
|
||||
EmbedCommon() {
|
||||
};
|
||||
~EmbedCommon() { };
|
||||
static EmbedCommon* GetInstance();
|
||||
static void DeleteInstance();
|
||||
nsresult Init (void);
|
||||
bool mFormAttachCount;
|
||||
GtkMozEmbedCommon* mCommon;
|
||||
static GtkMozEmbed* GetAnyLiveWidget();
|
||||
};
|
||||
class EmbedPrivate {
|
||||
|
||||
public:
|
||||
@ -87,6 +123,12 @@ class EmbedPrivate {
|
||||
static void PopStartup (void);
|
||||
static void SetPath (const char *aPath);
|
||||
static void SetCompPath (const char *aPath);
|
||||
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
static nsresult StartupProfile (void);
|
||||
static void ShutdownProfile(void);
|
||||
#endif
|
||||
|
||||
static void SetAppComponents (const nsModuleComponentInfo* aComps,
|
||||
int aNumComponents);
|
||||
static void SetProfilePath (const char *aDir, const char *aName);
|
||||
@ -122,6 +164,19 @@ class EmbedPrivate {
|
||||
// events
|
||||
void ChildFocusIn (void);
|
||||
void ChildFocusOut(void);
|
||||
PRBool ClipBoardAction(GtkMozEmbedClipboard type);
|
||||
char* GetEncoding ();
|
||||
nsresult SetEncoding (const char *encoding);
|
||||
PRBool FindText(const char *exp, PRBool reverse,
|
||||
PRBool whole_word, PRBool case_sensitive,
|
||||
PRBool restart);
|
||||
nsresult ScrollToSelectedNode(nsIDOMNode *aDOMNode);
|
||||
nsresult InsertTextToNode(nsIDOMNode *aDOMNode, const char *string);
|
||||
nsresult GetFocusController(nsIFocusController **controller);
|
||||
nsresult GetZoom (gint *zoomLevel, gint *compareFramesZoomLevel);
|
||||
nsresult SetZoom (gint zoomLevel);
|
||||
nsresult HasFrames (PRUint32 *numberOfFrames);
|
||||
nsresult GetMIMEInfo (nsString& info);
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
void *GetAtkObjectForCurrentDocument();
|
||||
@ -147,6 +202,7 @@ class EmbedPrivate {
|
||||
|
||||
// the currently loaded uri
|
||||
nsString mURI;
|
||||
nsCString mPrePath;
|
||||
|
||||
// the number of widgets that have been created
|
||||
static PRUint32 sWidgetCount;
|
||||
@ -165,6 +221,15 @@ class EmbedPrivate {
|
||||
static nsILocalFile *sProfileDir;
|
||||
static nsISupports *sProfileLock;
|
||||
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
// what is our profile path?
|
||||
static char *sProfileDirS;
|
||||
static char *sProfileName;
|
||||
// for profiles
|
||||
static nsProfileDirServiceProvider *sProfileDirServiceProvider;
|
||||
static nsIPref *sPrefs;
|
||||
#endif
|
||||
|
||||
static nsIDirectoryServiceProvider * sAppFileLocProvider;
|
||||
|
||||
// chrome mask
|
||||
@ -173,15 +238,24 @@ class EmbedPrivate {
|
||||
PRBool mIsChrome;
|
||||
// has the chrome finished loading?
|
||||
PRBool mChromeLoaded;
|
||||
|
||||
// has the network finished loading?
|
||||
PRBool mLoadFinished;
|
||||
|
||||
// saved window ID for reparenting later
|
||||
GtkWidget *mMozWindowWidget;
|
||||
// has someone called Destroy() on us?
|
||||
PRBool mIsDestroyed;
|
||||
|
||||
//Open Blocker for Create Window class //Fixme...
|
||||
//I just tried to block it on earlier moment
|
||||
PRBool mOpenBlock;
|
||||
PRBool mNeedFav;
|
||||
private:
|
||||
|
||||
// is the chrome listener attached yet?
|
||||
PRBool mListenersAttached;
|
||||
PRBool mDoResizeEmbed;
|
||||
|
||||
void GetListener (void);
|
||||
void AttachListeners(void);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -20,6 +22,8 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Antonio Gomes <tonikitoo@gmail.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -37,14 +41,31 @@
|
||||
|
||||
#include "EmbedProgress.h"
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsXPIDLString.h>
|
||||
#endif
|
||||
#include <nsIChannel.h>
|
||||
#include <nsIHttpChannel.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static PRInt32 sStopSignalTimer = 0;
|
||||
static gboolean
|
||||
progress_emit_stop(void * data)
|
||||
{
|
||||
g_return_val_if_fail(data, FALSE);
|
||||
EmbedPrivate *owner = (EmbedPrivate*)data;
|
||||
if (!owner->mLoadFinished) {
|
||||
owner->mLoadFinished = PR_TRUE;
|
||||
gtk_signal_emit(GTK_OBJECT(owner->mOwningWidget),
|
||||
moz_embed_signals[NET_STOP]);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
EmbedProgress::EmbedProgress(void)
|
||||
{
|
||||
mOwner = nsnull;
|
||||
@ -55,100 +76,173 @@ EmbedProgress::~EmbedProgress()
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(EmbedProgress,
|
||||
nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
nsresult
|
||||
EmbedProgress::Init(EmbedPrivate *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mStopLevel = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
// give the widget a chance to attach any listeners
|
||||
mOwner->ContentStateChange();
|
||||
EmbedCommon * common = EmbedCommon::GetInstance();
|
||||
|
||||
if (sStopSignalTimer &&
|
||||
(
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_TRANSFERRING)
|
||||
|| (aStateFlags & GTK_MOZ_EMBED_FLAG_REDIRECTING)
|
||||
|| (aStateFlags & GTK_MOZ_EMBED_FLAG_NEGOTIATING)
|
||||
)
|
||||
) {
|
||||
g_source_remove(sStopSignalTimer);
|
||||
mStopLevel = 0;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_START]);
|
||||
mOwner->mLoadFinished = PR_FALSE;
|
||||
}
|
||||
|
||||
// if we've got the start flag, emit the signal
|
||||
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_START))
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_START]);
|
||||
// FIXME: workaround for broken progress values.
|
||||
mOwner->mOwningWidget->current_number_of_requests = 0;
|
||||
mOwner->mOwningWidget->total_number_of_requests = 0;
|
||||
|
||||
if (mOwner->mLoadFinished) {
|
||||
mOwner->mLoadFinished = PR_FALSE;
|
||||
mStopLevel = 0;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_START]);
|
||||
}
|
||||
if (common)
|
||||
common->mFormAttachCount = false;
|
||||
}
|
||||
|
||||
// get the uri for this request
|
||||
nsString tmpString;
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsXPIDLCString uriString;
|
||||
RequestToURIString(aRequest, getter_Copies(uriString));
|
||||
nsString tmpString;
|
||||
CopyUTF8toUTF16(uriString, tmpString);
|
||||
#else
|
||||
char *uriString = NULL;
|
||||
RequestToURIString(aRequest, &uriString);
|
||||
tmpString.AssignLiteral(uriString);
|
||||
#endif
|
||||
// FIXME: workaround for broken progress values.
|
||||
if (mOwner->mOwningWidget) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_START)
|
||||
mOwner->mOwningWidget->total_number_of_requests ++;
|
||||
else if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP)
|
||||
mOwner->mOwningWidget->current_number_of_requests++;
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS_ALL],
|
||||
(const gchar *) uriString,
|
||||
mOwner->mOwningWidget->current_number_of_requests,
|
||||
mOwner->mOwningWidget->total_number_of_requests);
|
||||
}
|
||||
// is it the same as the current URI?
|
||||
if (mOwner->mURI.Equals(tmpString))
|
||||
{
|
||||
if (mOwner->mURI.Equals(tmpString)) {
|
||||
// for people who know what they are doing
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STATE],
|
||||
aStateFlags, aStatus);
|
||||
}
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STATE_ALL],
|
||||
(const char *)uriString,
|
||||
(gint)aStateFlags, (gint)aStatus);
|
||||
// and for stop, too
|
||||
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_STOP))
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STOP]);
|
||||
// let our owner know that the load finished
|
||||
mOwner->ContentFinishedLoading();
|
||||
moz_embed_signals[NET_STATE],
|
||||
aStateFlags, aStatus);
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STATE_ALL],
|
||||
(const gchar *)uriString,
|
||||
(gint)aStateFlags, (gint)aStatus);
|
||||
|
||||
// and for stop, too
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_REQUEST)
|
||||
mStopLevel = 1;
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT)
|
||||
mStopLevel = mStopLevel == 1 ? 2 : 0;
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_WINDOW) {
|
||||
mStopLevel = mStopLevel == 2 ? 3 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) {
|
||||
if (sStopSignalTimer)
|
||||
g_source_remove(sStopSignalTimer);
|
||||
progress_emit_stop(mOwner);
|
||||
// let our owner know that the load finished
|
||||
mOwner->ContentFinishedLoading();
|
||||
|
||||
if (common && common->mFormAttachCount) {
|
||||
gtk_moz_embed_common_login(GTK_WIDGET(mOwner->mOwningWidget));
|
||||
common->mFormAttachCount = false;
|
||||
}
|
||||
} else if (mStopLevel == 3) {
|
||||
if (sStopSignalTimer)
|
||||
g_source_remove(sStopSignalTimer);
|
||||
mStopLevel = 0;
|
||||
sStopSignalTimer = g_timeout_add(1000, progress_emit_stop, mOwner);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
|
||||
nsString tmpString;
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsXPIDLCString uriString;
|
||||
RequestToURIString(aRequest, getter_Copies(uriString));
|
||||
|
||||
nsString tmpString;
|
||||
CopyUTF8toUTF16(uriString, tmpString);
|
||||
#else
|
||||
gchar *uriString = NULL;
|
||||
RequestToURIString(aRequest, &uriString);
|
||||
tmpString.AssignLiteral(uriString);
|
||||
#endif
|
||||
|
||||
// is it the same as the current uri?
|
||||
if (mOwner->mURI.Equals(tmpString)) {
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS],
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
moz_embed_signals[PROGRESS],
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS_ALL],
|
||||
(const char *)uriString,
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
// FIXME: workaround for broken progress values. This signal is being fired off above.
|
||||
/*gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS_ALL],
|
||||
(const char *)uriString,
|
||||
aCurTotalProgress, aMaxTotalProgress);*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
{
|
||||
nsCAutoString newURI;
|
||||
nsCAutoString prePath;
|
||||
NS_ENSURE_ARG_POINTER(aLocation);
|
||||
aLocation->GetSpec(newURI);
|
||||
aLocation->GetPrePath(prePath);
|
||||
|
||||
// Make sure that this is the primary frame change and not
|
||||
// just a subframe.
|
||||
@ -167,64 +261,87 @@ EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
isSubFrameLoad = PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest, &rv));
|
||||
if (NS_FAILED(rv) || !httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 responseCode = 0;
|
||||
|
||||
rv = httpChannel->GetResponseStatus(&responseCode);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// it has to handle more http errors code ??? 401 ?
|
||||
if (responseCode >= 500 && responseCode <= 505) {
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[UNKNOWN_PROTOCOL],
|
||||
newURI.get());
|
||||
mOwner->mNeedFav = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!isSubFrameLoad) {
|
||||
mOwner->SetURI(newURI.get());
|
||||
mOwner->mPrePath.Assign(prePath.get());
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[LOCATION]);
|
||||
moz_embed_signals[LOCATION]);
|
||||
}
|
||||
mOwner->mNeedFav = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
{
|
||||
// need to make a copy so we can safely cast to a void *
|
||||
PRUnichar *tmpString = nsCRT::strdup(aMessage);
|
||||
PRUnichar *tmpString = NS_strdup(aMessage);
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[STATUS_CHANGE],
|
||||
NS_STATIC_CAST(void *, aRequest),
|
||||
NS_STATIC_CAST(int, aStatus),
|
||||
NS_STATIC_CAST(void *, tmpString));
|
||||
moz_embed_signals[STATUS_CHANGE],
|
||||
NS_STATIC_CAST(void *, aRequest),
|
||||
NS_STATIC_CAST(gint, aStatus),
|
||||
NS_STATIC_CAST(void *, tmpString));
|
||||
|
||||
nsMemory::Free(tmpString);
|
||||
NS_Free(tmpString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[SECURITY_CHANGE],
|
||||
NS_STATIC_CAST(void *, aRequest),
|
||||
aState);
|
||||
moz_embed_signals[SECURITY_CHANGE],
|
||||
NS_STATIC_CAST(void *, aRequest),
|
||||
aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
EmbedProgress::RequestToURIString(nsIRequest *aRequest, char **aString)
|
||||
EmbedProgress::RequestToURIString(nsIRequest *aRequest, gchar **aString)
|
||||
{
|
||||
// is it a channel
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
channel = do_QueryInterface(aRequest);
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
if (!uri)
|
||||
return;
|
||||
|
||||
|
||||
nsCAutoString uriString;
|
||||
uri->GetSpec(uriString);
|
||||
|
||||
*aString = strdup(uriString.get());
|
||||
*aString = g_strdup(uriString.get());
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -60,7 +62,7 @@ class EmbedProgress : public nsIWebProgressListener,
|
||||
static void RequestToURIString (nsIRequest *aRequest, char **aString);
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
|
||||
PRBool mStopLevel;
|
||||
};
|
||||
|
||||
#endif /* __EmbedProgress_h */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -41,369 +41,386 @@
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
enum {
|
||||
INCLUDE_USERNAME = 1 << 0,
|
||||
INCLUDE_PASSWORD = 1 << 1,
|
||||
INCLUDE_CHECKBOX = 1 << 2,
|
||||
INCLUDE_CANCEL = 1 << 3
|
||||
INCLUDE_USERNAME = 1 << 0,
|
||||
INCLUDE_PASSWORD = 1 << 1,
|
||||
INCLUDE_CHECKBOX = 1 << 2,
|
||||
INCLUDE_CANCEL = 1 << 3
|
||||
};
|
||||
|
||||
struct DialogDescription {
|
||||
int flags;
|
||||
gchar* icon;
|
||||
int flags;
|
||||
gchar* icon;
|
||||
};
|
||||
|
||||
// This table contains the optional widgets and icons associated with
|
||||
// each type of dialog.
|
||||
|
||||
static const DialogDescription DialogTable[] = {
|
||||
{ 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
|
||||
{ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
|
||||
{ INCLUDE_CHECKBOX |
|
||||
INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_USERNAME |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
|
||||
{ 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
|
||||
{ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
|
||||
{ INCLUDE_CHECKBOX |
|
||||
INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_USERNAME |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
|
||||
};
|
||||
|
||||
EmbedPrompter::EmbedPrompter(void)
|
||||
: mCheckValue(PR_FALSE),
|
||||
mItemList(nsnull),
|
||||
mItemCount(0),
|
||||
mButtonPressed(0),
|
||||
mConfirmResult(PR_FALSE),
|
||||
mSelectedItem(0),
|
||||
mWindow(NULL),
|
||||
mUserField(NULL),
|
||||
mPassField(NULL),
|
||||
mTextField(NULL),
|
||||
mOptionMenu(NULL),
|
||||
mCheckBox(NULL)
|
||||
: mCheckValue(PR_FALSE),
|
||||
mItemList(nsnull),
|
||||
mItemCount(0),
|
||||
mButtonPressed(0),
|
||||
mConfirmResult(PR_FALSE),
|
||||
mSelectedItem(0),
|
||||
mWindow(NULL),
|
||||
mUserField(NULL),
|
||||
mPassField(NULL),
|
||||
mTextField(NULL),
|
||||
mOptionMenu(NULL),
|
||||
mCheckBox(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
EmbedPrompter::~EmbedPrompter(void)
|
||||
{
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedPrompter::Create(PromptType aType, GtkWindow* aParentWindow)
|
||||
|
||||
{
|
||||
mWindow = gtk_dialog_new_with_buttons(mTitle.get(), aParentWindow,
|
||||
(GtkDialogFlags)0,
|
||||
NULL);
|
||||
mWindow = gtk_dialog_new_with_buttons(
|
||||
mTitle.get(),
|
||||
aParentWindow,
|
||||
(GtkDialogFlags)0,
|
||||
NULL);
|
||||
// only add the dialog to the window group if the parent already has a window group,
|
||||
// so as not to break app's expectations about modal dialogs.
|
||||
if (aParentWindow && aParentWindow->group) {
|
||||
gtk_window_group_add_window (aParentWindow->group, GTK_WINDOW (mWindow));
|
||||
}
|
||||
|
||||
// only add the dialog to the window group if the parent already has a window group,
|
||||
// so as not to break app's expectations about modal dialogs.
|
||||
if (aParentWindow && aParentWindow->group) {
|
||||
gtk_window_group_add_window (aParentWindow->group, GTK_WINDOW (mWindow));
|
||||
// gtk will resize this for us as necessary
|
||||
gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
|
||||
|
||||
// this HBox will contain the icon, and a vbox which contains the
|
||||
// dialog text and other widgets.
|
||||
GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
|
||||
|
||||
|
||||
// Set up dialog properties according to the GNOME HIG
|
||||
// (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows)
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
|
||||
gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
|
||||
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
|
||||
|
||||
|
||||
// This is the VBox which will contain the label and other controls.
|
||||
GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
|
||||
|
||||
// get the stock icon for this dialog and put it in the box
|
||||
const gchar* iconDesc = DialogTable[aType].icon;
|
||||
GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
|
||||
|
||||
// now pack the label into the vbox
|
||||
GtkWidget* label = gtk_label_new(mMessageText.get());
|
||||
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
||||
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
|
||||
|
||||
int widgetFlags = DialogTable[aType].flags;
|
||||
|
||||
if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
|
||||
|
||||
// If we're creating a username and/or password field, make an hbox
|
||||
// which will contain two vboxes, one for the labels and one for the
|
||||
// text fields. This will let us line up the textfields.
|
||||
|
||||
GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
|
||||
GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
|
||||
GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
|
||||
|
||||
if (widgetFlags & INCLUDE_USERNAME) {
|
||||
GtkWidget* userLabel = gtk_label_new("User Name:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mUserField = gtk_entry_new();
|
||||
|
||||
if (!mUser.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mUserField), mUser.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
|
||||
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassFields),
|
||||
mUserField,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
if (widgetFlags & INCLUDE_PASSWORD) {
|
||||
GtkWidget* passLabel = gtk_label_new("Password:");
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassLabels),
|
||||
passLabel,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
mPassField = gtk_entry_new();
|
||||
if (!mPass.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mPassField), mPass.get());
|
||||
gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassFields),
|
||||
mPassField,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassHBox),
|
||||
userPassLabels,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassHBox),
|
||||
userPassFields,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(contentsVBox),
|
||||
userPassHBox,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
if (aType == TYPE_PROMPT) {
|
||||
mTextField = gtk_entry_new();
|
||||
if (!mTextValue.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mTextField), mTextValue.get());
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
|
||||
}
|
||||
// Add a checkbox
|
||||
if ((widgetFlags & INCLUDE_CHECKBOX) && !mCheckMessage.IsEmpty()) {
|
||||
mCheckBox = gtk_check_button_new_with_label(mCheckMessage.get());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
gtk_label_set_line_wrap(
|
||||
GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
|
||||
TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
|
||||
}
|
||||
// Add a dropdown menu
|
||||
if (aType == TYPE_SELECT) {
|
||||
// Build up a GtkMenu containing the items
|
||||
GtkWidget* menu = gtk_menu_new();
|
||||
for (PRUint32 i = 0; i < mItemCount; ++i) {
|
||||
GtkWidget* item = gtk_menu_item_new_with_label(mItemList[i].get());
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||||
}
|
||||
|
||||
// gtk will resize this for us as necessary
|
||||
gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
|
||||
// Now create an OptionMenu and set this as the menu
|
||||
mOptionMenu = gtk_option_menu_new();
|
||||
|
||||
// this HBox will contain the icon, and a vbox which contains the
|
||||
// dialog text and other widgets.
|
||||
GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
|
||||
gtk_option_menu_set_menu(GTK_OPTION_MENU(mOptionMenu), menu);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mOptionMenu, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
|
||||
// Set up dialog properties according to the GNOME HIG
|
||||
// (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows)
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
|
||||
gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
|
||||
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
|
||||
|
||||
|
||||
// This is the VBox which will contain the label and other controls.
|
||||
GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
|
||||
|
||||
// get the stock icon for this dialog and put it in the box
|
||||
const gchar* iconDesc = DialogTable[aType].icon;
|
||||
GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
|
||||
|
||||
// now pack the label into the vbox
|
||||
GtkWidget* label = gtk_label_new(mMessageText.get());
|
||||
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
||||
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
|
||||
|
||||
int widgetFlags = DialogTable[aType].flags;
|
||||
|
||||
if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
|
||||
|
||||
// If we're creating a username and/or password field, make an hbox
|
||||
// which will contain two vboxes, one for the labels and one for the
|
||||
// text fields. This will let us line up the textfields.
|
||||
|
||||
GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
|
||||
GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
|
||||
GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
|
||||
|
||||
if (widgetFlags & INCLUDE_USERNAME) {
|
||||
GtkWidget* userLabel = gtk_label_new("User Name:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mUserField = gtk_entry_new();
|
||||
|
||||
if (!mUser.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mUserField), mUser.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassFields), mUserField, FALSE,
|
||||
FALSE, 0);
|
||||
}
|
||||
if (widgetFlags & INCLUDE_PASSWORD) {
|
||||
GtkWidget* passLabel = gtk_label_new("Password:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), passLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mPassField = gtk_entry_new();
|
||||
|
||||
if (!mPass.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mPassField), mPass.get());
|
||||
|
||||
gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassFields), mPassField, FALSE,
|
||||
FALSE, 0);
|
||||
}
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassHBox), userPassLabels, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(userPassHBox), userPassFields, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), userPassHBox, FALSE, FALSE, 0);
|
||||
if (aType == TYPE_UNIVERSAL) {
|
||||
// Create buttons based on the flags passed in.
|
||||
for (int i = EMBED_MAX_BUTTONS; i >= 0; --i) {
|
||||
if (!mButtonLabels[i].IsEmpty())
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
mButtonLabels[i].get(), i);
|
||||
}
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
|
||||
} else {
|
||||
// Create standard ok and cancel buttons
|
||||
if (widgetFlags & INCLUDE_CANCEL)
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
|
||||
if (aType == TYPE_PROMPT) {
|
||||
mTextField = gtk_entry_new();
|
||||
|
||||
if (!mTextValue.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mTextField), mTextValue.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
// Add a checkbox
|
||||
if ((widgetFlags & INCLUDE_CHECKBOX) && !mCheckMessage.IsEmpty()) {
|
||||
mCheckBox = gtk_check_button_new_with_label(mCheckMessage.get());
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
|
||||
TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
// Add a dropdown menu
|
||||
if (aType == TYPE_SELECT) {
|
||||
// Build up a GtkMenu containing the items
|
||||
GtkWidget* menu = gtk_menu_new();
|
||||
for (PRUint32 i = 0; i < mItemCount; ++i) {
|
||||
GtkWidget* item = gtk_menu_item_new_with_label(mItemList[i].get());
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||||
}
|
||||
|
||||
// Now create an OptionMenu and set this as the menu
|
||||
mOptionMenu = gtk_option_menu_new();
|
||||
|
||||
gtk_option_menu_set_menu(GTK_OPTION_MENU(mOptionMenu), menu);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mOptionMenu, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
if (aType == TYPE_UNIVERSAL) {
|
||||
// Create buttons based on the flags passed in.
|
||||
for (int i = EMBED_MAX_BUTTONS; i >= 0; --i) {
|
||||
if (!mButtonLabels[i].IsEmpty())
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
mButtonLabels[i].get(), i);
|
||||
}
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
|
||||
} else {
|
||||
// Create standard ok and cancel buttons
|
||||
if (widgetFlags & INCLUDE_CANCEL)
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
|
||||
GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
gtk_widget_grab_default(okButton);
|
||||
}
|
||||
|
||||
// Pack the contentsVBox into the dialogHBox and the dialog.
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mWindow)->vbox), dialogHBox, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
return NS_OK;
|
||||
GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
gtk_widget_grab_default(okButton);
|
||||
}
|
||||
// Pack the contentsVBox into the dialogHBox and the dialog.
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(GTK_DIALOG(mWindow)->vbox),
|
||||
dialogHBox,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetTitle(const PRUnichar *aTitle)
|
||||
{
|
||||
CopyUTF16toUTF8(aTitle, mTitle);
|
||||
CopyUTF16toUTF8(aTitle, mTitle);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetTextValue(const PRUnichar *aTextValue)
|
||||
{
|
||||
CopyUTF16toUTF8(aTextValue, mTextValue);
|
||||
CopyUTF16toUTF8(aTextValue, mTextValue);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetCheckMessage(const PRUnichar *aMessage)
|
||||
{
|
||||
CopyUTF16toUTF8(aMessage, mCheckMessage);
|
||||
CopyUTF16toUTF8(aMessage, mCheckMessage);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetMessageText(const PRUnichar *aMessageText)
|
||||
{
|
||||
CopyUTF16toUTF8(aMessageText, mMessageText);
|
||||
CopyUTF16toUTF8(aMessageText, mMessageText);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetUser(const PRUnichar *aUser)
|
||||
{
|
||||
CopyUTF16toUTF8(aUser, mUser);
|
||||
CopyUTF16toUTF8(aUser, mUser);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetPassword(const PRUnichar *aPass)
|
||||
{
|
||||
CopyUTF16toUTF8(aPass, mPass);
|
||||
CopyUTF16toUTF8(aPass, mPass);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetCheckValue(const PRBool aValue)
|
||||
{
|
||||
mCheckValue = aValue;
|
||||
mCheckValue = aValue;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetItems(const PRUnichar** aItemArray, PRUint32 aCount)
|
||||
{
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
|
||||
mItemCount = aCount;
|
||||
mItemList = new nsCString[aCount];
|
||||
for (PRUint32 i = 0; i < aCount; ++i)
|
||||
CopyUTF16toUTF8(aItemArray[i], mItemList[i]);
|
||||
mItemCount = aCount;
|
||||
mItemList = new nsCString[aCount];
|
||||
for (PRUint32 i = 0; i < aCount; ++i)
|
||||
CopyUTF16toUTF8(aItemArray[i], mItemList[i]);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetButtons(const PRUnichar* aButton0Label,
|
||||
const PRUnichar* aButton1Label,
|
||||
const PRUnichar* aButton2Label)
|
||||
const PRUnichar* aButton1Label,
|
||||
const PRUnichar* aButton2Label)
|
||||
{
|
||||
CopyUTF16toUTF8(aButton0Label, mButtonLabels[0]);
|
||||
CopyUTF16toUTF8(aButton1Label, mButtonLabels[1]);
|
||||
CopyUTF16toUTF8(aButton2Label, mButtonLabels[2]);
|
||||
CopyUTF16toUTF8(aButton0Label, mButtonLabels[0]);
|
||||
CopyUTF16toUTF8(aButton1Label, mButtonLabels[1]);
|
||||
CopyUTF16toUTF8(aButton2Label, mButtonLabels[2]);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetCheckValue(PRBool *aValue)
|
||||
{
|
||||
*aValue = mCheckValue;
|
||||
*aValue = mCheckValue;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue)
|
||||
{
|
||||
*aConfirmValue = mConfirmResult;
|
||||
*aConfirmValue = mConfirmResult;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmbedPrompter::GetTextValue(PRUnichar **aTextValue)
|
||||
{
|
||||
*aTextValue = UTF8ToNewUnicode(mTextValue);
|
||||
*aTextValue = UTF8ToNewUnicode(mTextValue);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetUser(PRUnichar **aUser)
|
||||
{
|
||||
*aUser = UTF8ToNewUnicode(mUser);
|
||||
*aUser = UTF8ToNewUnicode(mUser);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetPassword(PRUnichar **aPass)
|
||||
{
|
||||
*aPass = UTF8ToNewUnicode(mPass);
|
||||
*aPass = UTF8ToNewUnicode(mPass);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetSelectedItem(PRInt32 *aIndex)
|
||||
{
|
||||
*aIndex = mSelectedItem;
|
||||
*aIndex = mSelectedItem;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetButtonPressed(PRInt32 *aButton)
|
||||
{
|
||||
*aButton = mButtonPressed;
|
||||
*aButton = mButtonPressed;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::Run(void)
|
||||
{
|
||||
gtk_widget_show_all(mWindow);
|
||||
gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
|
||||
switch (response) {
|
||||
case GTK_RESPONSE_NONE:
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
mConfirmResult = PR_FALSE;
|
||||
break;
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
mConfirmResult = PR_TRUE;
|
||||
SaveDialogValues();
|
||||
break;
|
||||
default:
|
||||
mButtonPressed = response;
|
||||
SaveDialogValues();
|
||||
}
|
||||
gtk_widget_show_all(mWindow);
|
||||
gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
|
||||
switch (response) {
|
||||
case GTK_RESPONSE_NONE:
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
mConfirmResult = PR_FALSE;
|
||||
break;
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
mConfirmResult = PR_TRUE;
|
||||
SaveDialogValues();
|
||||
break;
|
||||
default:
|
||||
mButtonPressed = response;
|
||||
SaveDialogValues();
|
||||
}
|
||||
|
||||
gtk_widget_destroy(mWindow);
|
||||
gtk_widget_destroy(mWindow);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SaveDialogValues()
|
||||
{
|
||||
if (mUserField)
|
||||
mUser.Assign(gtk_entry_get_text(GTK_ENTRY(mUserField)));
|
||||
if (mUserField)
|
||||
mUser.Assign(gtk_entry_get_text(GTK_ENTRY(mUserField)));
|
||||
|
||||
if (mPassField)
|
||||
mPass.Assign(gtk_entry_get_text(GTK_ENTRY(mPassField)));
|
||||
if (mPassField)
|
||||
mPass.Assign(gtk_entry_get_text(GTK_ENTRY(mPassField)));
|
||||
|
||||
if (mCheckBox)
|
||||
mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
|
||||
if (mCheckBox)
|
||||
mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
|
||||
|
||||
if (mTextField)
|
||||
mTextValue.Assign(gtk_entry_get_text(GTK_ENTRY(mTextField)));
|
||||
if (mTextField)
|
||||
mTextValue.Assign(gtk_entry_get_text(GTK_ENTRY(mTextField)));
|
||||
|
||||
if (mOptionMenu)
|
||||
mSelectedItem = gtk_option_menu_get_history(GTK_OPTION_MENU(mOptionMenu));
|
||||
if (mOptionMenu)
|
||||
mSelectedItem = gtk_option_menu_get_history(GTK_OPTION_MENU(mOptionMenu));
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -38,9 +38,14 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <nsString.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#define EMBED_MAX_BUTTONS 3
|
||||
|
||||
class EmbedPrompter {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/*
|
||||
* vim:ts=2:et:sw=2
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -42,8 +42,11 @@
|
||||
#include <nsIComponentManager.h>
|
||||
#include <nsIDocShellTreeItem.h>
|
||||
#include "nsIWidget.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#else
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#endif
|
||||
#include "EmbedWindow.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "EmbedPrompter.h"
|
||||
@ -91,10 +94,10 @@ EmbedWindow::CreateWindow(void)
|
||||
// create the window.
|
||||
mBaseWindow = do_QueryInterface(mWebBrowser);
|
||||
rv = mBaseWindow->InitWindow(GTK_WIDGET(mOwner->mOwningWidget),
|
||||
nsnull,
|
||||
0, 0,
|
||||
ownerAsWidget->allocation.width,
|
||||
ownerAsWidget->allocation.height);
|
||||
nsnull,
|
||||
0, 0,
|
||||
ownerAsWidget->allocation.width,
|
||||
ownerAsWidget->allocation.height);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -125,7 +128,7 @@ NS_INTERFACE_MAP_BEGIN(EmbedWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@ -135,21 +138,21 @@ NS_IMETHODIMP
|
||||
EmbedWindow::SetStatus(PRUint32 aStatusType, const PRUnichar *aStatus)
|
||||
{
|
||||
switch (aStatusType) {
|
||||
case STATUS_SCRIPT:
|
||||
case STATUS_SCRIPT:
|
||||
{
|
||||
mJSStatus = aStatus;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[JS_STATUS]);
|
||||
moz_embed_signals[JS_STATUS]);
|
||||
}
|
||||
break;
|
||||
case STATUS_SCRIPT_DEFAULT:
|
||||
case STATUS_SCRIPT_DEFAULT:
|
||||
// Gee, that's nice.
|
||||
break;
|
||||
case STATUS_LINK:
|
||||
case STATUS_LINK:
|
||||
{
|
||||
mLinkMessage = aStatus;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[LINK_MESSAGE]);
|
||||
moz_embed_signals[LINK_MESSAGE]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -192,7 +195,7 @@ EmbedWindow::DestroyBrowserWindow(void)
|
||||
mOwner->mIsDestroyed = PR_TRUE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DESTROY_BROWSER]);
|
||||
moz_embed_signals[DESTROY_BROWSER]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -200,7 +203,7 @@ NS_IMETHODIMP
|
||||
EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[SIZE_TO], aCX, aCY);
|
||||
moz_embed_signals[SIZE_TO], aCX, aCY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -255,7 +258,7 @@ EmbedWindow::FocusNextElement()
|
||||
return NS_OK;
|
||||
|
||||
g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
|
||||
GTK_DIR_TAB_FORWARD);
|
||||
GTK_DIR_TAB_FORWARD);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
@ -279,7 +282,7 @@ EmbedWindow::FocusPrevElement()
|
||||
return NS_OK;
|
||||
|
||||
g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
|
||||
GTK_DIR_TAB_BACKWARD);
|
||||
GTK_DIR_TAB_BACKWARD);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
@ -289,18 +292,18 @@ EmbedWindow::FocusPrevElement()
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aCX, PRInt32 aCY)
|
||||
PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
||||
(aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
return mBaseWindow->SetPositionAndSize(aX, aY, aCX, aCY, PR_TRUE);
|
||||
}
|
||||
else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
|
||||
return mBaseWindow->SetPosition(aX, aY);
|
||||
}
|
||||
else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
return mBaseWindow->SetSize(aCX, aCY, PR_TRUE);
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -308,18 +311,18 @@ EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::GetDimensions(PRUint32 aFlags, PRInt32 *aX,
|
||||
PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
|
||||
PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
|
||||
{
|
||||
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
||||
(aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
return mBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
||||
}
|
||||
else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
|
||||
return mBaseWindow->GetPosition(aX, aY);
|
||||
}
|
||||
else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
return mBaseWindow->GetSize(aCX, aCY);
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -344,7 +347,7 @@ EmbedWindow::SetTitle(const PRUnichar *aTitle)
|
||||
{
|
||||
mTitle = aTitle;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[TITLE]);
|
||||
moz_embed_signals[TITLE]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -359,14 +362,10 @@ EmbedWindow::GetSiteWindow(void **aSiteWindow)
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::GetVisibility(PRBool *aVisibility)
|
||||
{
|
||||
// XXX See bug 312998
|
||||
// Work around the problem that sometimes the window
|
||||
// is already visible even though mVisibility isn't true
|
||||
// yet.
|
||||
*aVisibility = mVisibility ||
|
||||
(!mOwner->mIsChrome &&
|
||||
mOwner->mOwningWidget &&
|
||||
GTK_WIDGET_MAPPED(mOwner->mOwningWidget));
|
||||
!mOwner->mIsChrome &&
|
||||
mOwner->mOwningWidget &&
|
||||
GTK_WIDGET_MAPPED(mOwner->mOwningWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -383,13 +382,14 @@ EmbedWindow::SetVisibility(PRBool aVisibility)
|
||||
return NS_OK;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[VISIBILITY],
|
||||
aVisibility);
|
||||
moz_embed_signals[VISIBILITY],
|
||||
aVisibility);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsITooltipListener
|
||||
|
||||
#if 0
|
||||
static gint
|
||||
tooltips_paint_window(GtkWidget *window)
|
||||
{
|
||||
@ -402,10 +402,10 @@ tooltips_paint_window(GtkWidget *window)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
const PRUnichar *aTipText)
|
||||
const PRUnichar *aTipText)
|
||||
{
|
||||
nsAutoString tipText ( aTipText );
|
||||
|
||||
@ -425,7 +425,7 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
||||
GdkWindow *window;
|
||||
window = NS_STATIC_CAST(GdkWindow *,
|
||||
mainWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
mainWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
gint root_x, root_y;
|
||||
gdk_window_get_origin(window, &root_x, &root_y);
|
||||
|
||||
@ -448,7 +448,7 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
gtk_window_set_transient_for(GTK_WINDOW(sTipWindow),
|
||||
GTK_WINDOW(toplevel_window));
|
||||
GTK_WINDOW(toplevel_window));
|
||||
|
||||
// realize the widget
|
||||
gtk_widget_realize(sTipWindow);
|
||||
@ -464,13 +464,13 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
gtk_container_set_border_width(GTK_CONTAINER(sTipWindow), 4);
|
||||
// set the coords for the widget
|
||||
gtk_widget_set_uposition(sTipWindow, aXCoords + root_x,
|
||||
aYCoords + root_y);
|
||||
aYCoords + root_y);
|
||||
|
||||
// and show it.
|
||||
gtk_widget_show_all(sTipWindow);
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
gtk_widget_popup(sTipWindow, aXCoords + root_x, aYCoords + root_y);
|
||||
gtk_widget_popup(sTipWindow, aXCoords + root_x, aYCoords + root_y); */
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
nsMemory::Free( (void*)tipString );
|
||||
@ -486,6 +486,7 @@ EmbedWindow::OnHideTooltip(void)
|
||||
sTipWindow = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -38,27 +40,30 @@
|
||||
#ifndef __EmbedWindow_h
|
||||
#define __EmbedWindow_h
|
||||
|
||||
#include <nsString.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIWebBrowserChromeFocus.h>
|
||||
#include <nsIEmbeddingSiteWindow.h>
|
||||
#include <nsITooltipListener.h>
|
||||
//#include <nsITooltipListener.h>
|
||||
#include <nsISupports.h>
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsIBaseWindow.h>
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include "nsString.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
class EmbedWindow : public nsIWebBrowserChrome,
|
||||
public nsIWebBrowserChromeFocus,
|
||||
public nsIWebBrowserChromeFocus,
|
||||
public nsIEmbeddingSiteWindow,
|
||||
public nsITooltipListener,
|
||||
public nsIInterfaceRequestor
|
||||
// public nsITooltipListener,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
|
||||
public:
|
||||
@ -78,7 +83,7 @@ class EmbedWindow : public nsIWebBrowserChrome,
|
||||
|
||||
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
||||
|
||||
NS_DECL_NSITOOLTIPLISTENER
|
||||
// NS_DECL_NSITOOLTIPLISTENER
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -14,7 +16,8 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -42,8 +45,9 @@
|
||||
// in order to create orphaned windows
|
||||
#include "gtkmozembedprivate.h"
|
||||
|
||||
EmbedWindowCreator::EmbedWindowCreator(void)
|
||||
EmbedWindowCreator::EmbedWindowCreator(PRBool *aOpenBlockPtr)
|
||||
{
|
||||
mOpenBlock = aOpenBlockPtr;
|
||||
}
|
||||
|
||||
EmbedWindowCreator::~EmbedWindowCreator()
|
||||
@ -54,19 +58,24 @@ NS_IMPL_ISUPPORTS1(EmbedWindowCreator, nsIWindowCreator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
if (mOpenBlock) {
|
||||
if (*mOpenBlock == PR_TRUE) {
|
||||
*mOpenBlock = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
GtkMozEmbed *newEmbed = nsnull;
|
||||
|
||||
// No parent? Ask via the singleton object instead.
|
||||
if (!aParent) {
|
||||
gtk_moz_embed_single_create_window(&newEmbed,
|
||||
(guint)aChromeFlags);
|
||||
}
|
||||
else {
|
||||
(guint)aChromeFlags);
|
||||
} else {
|
||||
// Find the EmbedPrivate object for this web browser chrome object.
|
||||
EmbedPrivate *embedPrivate = EmbedPrivate::FindPrivateForBrowser(aParent);
|
||||
|
||||
@ -74,8 +83,8 @@ EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(embedPrivate->mOwningWidget),
|
||||
moz_embed_signals[NEW_WINDOW],
|
||||
&newEmbed, (guint)aChromeFlags);
|
||||
moz_embed_signals[NEW_WINDOW],
|
||||
&newEmbed, (guint)aChromeFlags);
|
||||
|
||||
}
|
||||
|
||||
@ -90,14 +99,14 @@ EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
gtk_widget_realize(GTK_WIDGET(newEmbed));
|
||||
|
||||
EmbedPrivate *newEmbedPrivate = NS_STATIC_CAST(EmbedPrivate *,
|
||||
newEmbed->data);
|
||||
newEmbed->data);
|
||||
|
||||
// set the chrome flag on the new window if it's a chrome open
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
|
||||
newEmbedPrivate->mIsChrome = PR_TRUE;
|
||||
|
||||
*_retval = NS_STATIC_CAST(nsIWebBrowserChrome *,
|
||||
(newEmbedPrivate->mWindow));
|
||||
(newEmbedPrivate->mWindow));
|
||||
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -43,12 +45,14 @@
|
||||
class EmbedWindowCreator : public nsIWindowCreator
|
||||
{
|
||||
public:
|
||||
EmbedWindowCreator();
|
||||
EmbedWindowCreator(PRBool *aOpenBlockPtr);
|
||||
virtual ~EmbedWindowCreator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
|
||||
private:
|
||||
PRBool *mOpenBlock;
|
||||
};
|
||||
|
||||
#endif /* __EmbedWindowCreator_h */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -22,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,8 +39,16 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "GtkPromptService.h"
|
||||
#include "EmbedGtkTools.h"
|
||||
#include "gtkmozembedprivate.h"
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
#include "EmbedPrompter.h"
|
||||
#include <nsString.h>
|
||||
#endif
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIEmbeddingSiteWindow.h>
|
||||
@ -54,295 +63,534 @@ GtkPromptService::~GtkPromptService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(GtkPromptService, nsIPromptService)
|
||||
NS_IMPL_ISUPPORTS2(GtkPromptService, nsIPromptService, nsICookiePromptService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Alert(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText)
|
||||
GtkPromptService::Alert(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[ALERT], TRUE)) {
|
||||
nsCString dialogTitle, dialogText;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[ALERT],
|
||||
(const gchar *) dialogTitle.get(), (const gchar *) dialogText.get());
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::AlertCheck(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue)
|
||||
GtkPromptService::AlertCheck(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[ALERT_CHECK], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[ALERT_CHECK],
|
||||
dialogTitle.get(), dialogTitle.get(), checkMsg.get(), aCheckValue);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Confirm(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM], TRUE)) {
|
||||
nsCString dialogTitle, dialogText;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM],
|
||||
dialogTitle.get(), dialogText.get(), aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmCheck(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM_CHECK], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM_CHECK],
|
||||
dialogTitle.get(),
|
||||
dialogTitle.get(),
|
||||
checkMsg.get(),
|
||||
aCheckValue,
|
||||
aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmEx(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aButtonFlags,
|
||||
const PRUnichar* aButton0Title,
|
||||
const PRUnichar* aButton1Title,
|
||||
const PRUnichar* aButton2Title,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRInt32* aRetVal)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM_EX], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg;
|
||||
nsCString button0,button1,button2;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
CopyUTF16toUTF8(aButton0Title, button0);
|
||||
CopyUTF16toUTF8(aButton1Title, button1);
|
||||
CopyUTF16toUTF8(aButton2Title, button2);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM_EX],
|
||||
dialogTitle.get(),
|
||||
dialogTitle.get(),
|
||||
aButtonFlags,
|
||||
button0.get(),
|
||||
button1.get(),
|
||||
button2.get(),
|
||||
checkMsg.get(),
|
||||
aCheckValue,
|
||||
aRetVal);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
|
||||
nsAutoString button0Label, button1Label, button2Label;
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
|
||||
prompter.SetButtons(button0Label.get(),
|
||||
button1Label.get(),
|
||||
button2Label.get());
|
||||
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_UNIVERSAL,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
return NS_OK;
|
||||
|
||||
prompter.GetButtonPressed(aRetVal);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Confirm(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRBool* aConfirm)
|
||||
GtkPromptService::Prompt(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aValue,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg, retValue;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
CopyUTF16toUTF8(*aValue, retValue);
|
||||
gchar * aGValue = g_strdup(retValue.get());
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT],
|
||||
dialogTitle.get(),
|
||||
dialogText.get(),
|
||||
&aGValue,
|
||||
checkMsg.get(),
|
||||
aCheckValue,
|
||||
aConfirm,
|
||||
NULL);
|
||||
if (*aConfirm) {
|
||||
if (*aValue)
|
||||
NS_Free(*aValue);
|
||||
retValue.Assign(aGValue);
|
||||
*aValue = UTF8ToNewUnicode(retValue);
|
||||
}
|
||||
g_free(aGValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmCheck(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetTextValue(*aValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
return NS_OK;
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aValue)
|
||||
NS_Free(*aValue);
|
||||
prompter.GetTextValue(aValue);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmEx(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aButtonFlags,
|
||||
const PRUnichar* aButton0Title,
|
||||
const PRUnichar* aButton1Title,
|
||||
const PRUnichar* aButton2Title,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue,
|
||||
PRInt32* aRetVal)
|
||||
GtkPromptService::PromptUsernameAndPassword(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aUsername,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
|
||||
nsAutoString button0Label, button1Label, button2Label;
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
|
||||
prompter.SetButtons(button0Label.get(), button1Label.get(),
|
||||
button2Label.get());
|
||||
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_UNIVERSAL,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
|
||||
prompter.GetButtonPressed(aRetVal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Prompt(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRUnichar** aValue,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetTextValue(*aValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT_AUTH], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg, retUsername, retPassword;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
CopyUTF16toUTF8(*aUsername, retUsername);
|
||||
CopyUTF16toUTF8(*aPassword, retPassword);
|
||||
gchar * aGUsername = g_strdup(retUsername.get());
|
||||
gchar * aGPassword = g_strdup(retPassword.get());
|
||||
// FIXME: it is not working. CheckValue has no effect.
|
||||
if (!aCheckValue)
|
||||
aCheckValue = (PRBool *) malloc (sizeof (PRBool));
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT_AUTH],
|
||||
dialogTitle.get(), dialogText.get(), &aGUsername,
|
||||
&aGPassword, checkMsg.get(), aCheckValue, aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aValue)
|
||||
nsMemory::Free(*aValue);
|
||||
prompter.GetTextValue(aValue);
|
||||
if (*aUsername)
|
||||
NS_Free(*aUsername);
|
||||
retUsername.Assign(aGUsername);
|
||||
*aUsername = UTF8ToNewUnicode(retUsername);
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
retPassword.Assign(aGPassword);
|
||||
*aPassword = UTF8ToNewUnicode(retPassword);
|
||||
}
|
||||
g_free(aGUsername);
|
||||
g_free(aGPassword);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetUser(*aUsername);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aUsername)
|
||||
NS_Free(*aUsername);
|
||||
prompter.GetUser(aUsername);
|
||||
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::PromptUsernameAndPassword(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aUsername,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
GtkPromptService::PromptPassword(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetUser(*aUsername);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT_AUTH], TRUE)) {
|
||||
nsCString dialogTitle, dialogText, checkMsg, retPassword;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
CopyUTF16toUTF8(aCheckMsg, checkMsg);
|
||||
CopyUTF16toUTF8(*aPassword, retPassword);
|
||||
gchar * aGPassword = g_strdup(retPassword.get());
|
||||
gtk_signal_emit(
|
||||
GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT_AUTH],
|
||||
dialogTitle.get(),
|
||||
dialogText.get(),
|
||||
NULL,
|
||||
&aGPassword,
|
||||
checkMsg.get(),
|
||||
aCheckValue,
|
||||
aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aUsername)
|
||||
nsMemory::Free(*aUsername);
|
||||
prompter.GetUser(aUsername);
|
||||
|
||||
if (*aPassword)
|
||||
nsMemory::Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
retPassword.Assign(aGPassword);
|
||||
*aPassword = UTF8ToNewUnicode(retPassword);
|
||||
}
|
||||
g_free(aGPassword);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::PromptPassword(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
GtkPromptService::Select(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aCount,
|
||||
const PRUnichar** aSelectList,
|
||||
PRInt32* outSelection,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aPassword)
|
||||
nsMemory::Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[SELECT], TRUE)) {
|
||||
nsCString dialogTitle, dialogText;
|
||||
CopyUTF16toUTF8(aDialogTitle, dialogTitle);
|
||||
CopyUTF16toUTF8(aDialogText, dialogText);
|
||||
GList * list = NULL;
|
||||
nsCString *itemList = new nsCString[aCount];
|
||||
NS_ENSURE_TRUE(itemList, NS_ERROR_OUT_OF_MEMORY);
|
||||
for (PRUint32 i = 0; i < aCount; ++i) {
|
||||
CopyUTF16toUTF8(aSelectList[i], itemList[i]);
|
||||
list = g_list_append(list, (gpointer)itemList[i].get());
|
||||
}
|
||||
gtk_signal_emit(
|
||||
GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[SELECT],
|
||||
dialogTitle.get(),
|
||||
dialogText.get(),
|
||||
(const GList**)&list,
|
||||
outSelection,
|
||||
aConfirm);
|
||||
delete[] itemList;
|
||||
g_list_free(list);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Select").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetItems(aSelectList, aCount);
|
||||
prompter.Create(EmbedPrompter::TYPE_SELECT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetSelectedItem(outSelection);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsCookiePromptService */
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Select(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRUint32 aCount,
|
||||
const PRUnichar** aSelectList, PRInt32* outSelection,
|
||||
PRBool* aConfirm)
|
||||
GtkPromptService::CookieDialog(
|
||||
nsIDOMWindow *aParent,
|
||||
nsICookie *aCookie,
|
||||
const nsACString &aHostname,
|
||||
PRInt32 aCookiesFromHost,
|
||||
PRBool aChangingCookie,
|
||||
PRBool *aRememberDecision,
|
||||
PRInt32 *aAccept)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Select").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetItems(aSelectList, aCount);
|
||||
prompter.Create(EmbedPrompter::TYPE_SELECT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetSelectedItem(outSelection);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
GtkWindow*
|
||||
GtkPromptService::GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
|
||||
|
||||
if (!aDOMWindow)
|
||||
return NULL;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
|
||||
nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = do_QueryInterface(chrome);
|
||||
|
||||
if (!siteWindow)
|
||||
return NULL;
|
||||
|
||||
GtkWidget* parentWidget;
|
||||
siteWindow->GetSiteWindow((void**)&parentWidget);
|
||||
|
||||
if (!parentWidget)
|
||||
return NULL;
|
||||
|
||||
GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
|
||||
if (GTK_WIDGET_TOPLEVEL(gtkWin))
|
||||
return GTK_WINDOW(gtkWin);
|
||||
|
||||
return NULL;
|
||||
/* FIXME - missing gint actions and gboolean illegal_path */
|
||||
gint actions = 1;
|
||||
nsCString hostName (aHostname);
|
||||
nsCString aName;
|
||||
aCookie->GetName(aName);
|
||||
nsCString aValue;
|
||||
aCookie->GetValue(aValue);
|
||||
nsCString aDomain;
|
||||
aCookie->GetHost(aDomain);
|
||||
nsCString aPath;
|
||||
aCookie->GetPath(aPath);
|
||||
/* We have to investigate a value to use here */
|
||||
gboolean illegal_path = FALSE;
|
||||
PRUint64 aExpires;
|
||||
aCookie->GetExpires(&aExpires);
|
||||
nsCOMPtr<nsIDOMWindow> domWindow (do_QueryInterface (aParent));
|
||||
GtkMozEmbed *parentWidget = GTK_MOZ_EMBED(GetGtkWidgetForDOMWindow(domWindow));
|
||||
GtkMozEmbedCookie *cookie_struct = g_new0(GtkMozEmbedCookie, 1);
|
||||
if (parentWidget && cookie_struct) {
|
||||
g_signal_emit_by_name(
|
||||
GTK_OBJECT(parentWidget->common),
|
||||
"ask-cookie",
|
||||
cookie_struct,
|
||||
actions,
|
||||
(const gchar *) hostName.get (),
|
||||
(const gchar *) aName.get(),
|
||||
(const gchar *) aValue.get(),
|
||||
(const gchar *) aDomain.get(),
|
||||
(const gchar *) aPath.get(),
|
||||
illegal_path,
|
||||
aExpires,
|
||||
NULL);
|
||||
}
|
||||
*aRememberDecision = cookie_struct->remember_decision;
|
||||
*aAccept = cookie_struct->accept;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
void
|
||||
GtkPromptService::GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
|
||||
const PRUnichar* aStringValue,
|
||||
nsAString& aLabel)
|
||||
GtkPromptService::GetButtonLabel(
|
||||
PRUint32 aFlags,
|
||||
PRUint32 aPos,
|
||||
const PRUnichar* aStringValue,
|
||||
nsAString& aLabel)
|
||||
{
|
||||
PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
|
||||
switch (posFlag) {
|
||||
case 0:
|
||||
break;
|
||||
case BUTTON_TITLE_OK:
|
||||
aLabel.AssignLiteral(GTK_STOCK_OK);
|
||||
break;
|
||||
case BUTTON_TITLE_CANCEL:
|
||||
aLabel.AssignLiteral(GTK_STOCK_CANCEL);
|
||||
break;
|
||||
case BUTTON_TITLE_YES:
|
||||
aLabel.AssignLiteral(GTK_STOCK_YES);
|
||||
break;
|
||||
case BUTTON_TITLE_NO:
|
||||
aLabel.AssignLiteral(GTK_STOCK_NO);
|
||||
break;
|
||||
case BUTTON_TITLE_SAVE:
|
||||
aLabel.AssignLiteral(GTK_STOCK_SAVE);
|
||||
break;
|
||||
case BUTTON_TITLE_DONT_SAVE:
|
||||
aLabel.AssignLiteral("Don't Save");
|
||||
break;
|
||||
case BUTTON_TITLE_REVERT:
|
||||
aLabel.AssignLiteral("Revert");
|
||||
break;
|
||||
case BUTTON_TITLE_IS_STRING:
|
||||
aLabel = aStringValue;
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unexpected button flags");
|
||||
}
|
||||
PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
|
||||
switch (posFlag) {
|
||||
case 0:
|
||||
break;
|
||||
case BUTTON_TITLE_OK:
|
||||
aLabel.AssignLiteral(GTK_STOCK_OK);
|
||||
break;
|
||||
case BUTTON_TITLE_CANCEL:
|
||||
aLabel.AssignLiteral(GTK_STOCK_CANCEL);
|
||||
break;
|
||||
case BUTTON_TITLE_YES:
|
||||
aLabel.AssignLiteral(GTK_STOCK_YES);
|
||||
break;
|
||||
case BUTTON_TITLE_NO:
|
||||
aLabel.AssignLiteral(GTK_STOCK_NO);
|
||||
break;
|
||||
case BUTTON_TITLE_SAVE:
|
||||
aLabel.AssignLiteral(GTK_STOCK_SAVE);
|
||||
break;
|
||||
case BUTTON_TITLE_DONT_SAVE:
|
||||
aLabel.AssignLiteral("Don't Save");
|
||||
break;
|
||||
case BUTTON_TITLE_REVERT:
|
||||
aLabel.AssignLiteral("Revert");
|
||||
break;
|
||||
case BUTTON_TITLE_IS_STRING:
|
||||
aLabel = aStringValue;
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unexpected button flags");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -22,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,12 +39,22 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <nsIPromptService.h>
|
||||
#include <nsString.h>
|
||||
#include <nsICookiePromptService.h>
|
||||
#include <nsICookie.h>
|
||||
#include <nsNetCID.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0x95611356, 0xf583, 0x46f5, {0x81, 0xff, 0x4b, 0x3e, 0x01, 0x62, 0xc6, 0x19}}
|
||||
|
||||
class nsIDOMWindow;
|
||||
|
||||
class GtkPromptService : public nsIPromptService
|
||||
class GtkPromptService : public nsIPromptService,
|
||||
public nsICookiePromptService
|
||||
{
|
||||
public:
|
||||
GtkPromptService();
|
||||
@ -51,9 +62,11 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSICOOKIEPROMPTSERVICE
|
||||
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
private:
|
||||
GtkWindow* GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
|
||||
void GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
|
||||
const PRUnichar* aStringValue, nsAString &aLabel);
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -47,23 +47,73 @@ MODULE = gtkembedmoz
|
||||
LIBRARY_NAME = gtkembedmoz
|
||||
LIBXUL_LIBRARY = 1
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
#Define for building GtkmozEmbed with MOZILLA_1_8_BRANCH
|
||||
#MOZILLA_1_8_BRANCH = 1
|
||||
|
||||
ifdef MOZILLA_1_8_BRANCH
|
||||
MOZ_GTKEMBED_DYN = 1
|
||||
DEFINES += -DMOZILLA_1_8_BRANCH
|
||||
endif
|
||||
|
||||
ifdef MOZ_MICROBEMBED_DYN
|
||||
MOZ_GTKEMBED_DYN = 1
|
||||
endif
|
||||
|
||||
ifdef MOZ_GTKEMBED_DYN
|
||||
FORCE_SHARED_LIB = 1
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
DEFINES += -DMOZILLA_INTERNAL_API
|
||||
endif
|
||||
|
||||
DEFINES += -DIMPL_XREAPI
|
||||
|
||||
# New Stuff in GtkMozEmbed
|
||||
ifdef MOZ_MICROBEMBED
|
||||
DEFINES += -DBAD_CERT_LISTENER2
|
||||
#Probably scrolling can be fixed without this hack
|
||||
DEFINES += -DMOZ_SCROLL_TOP_LEFT_HACK
|
||||
|
||||
MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT = 1
|
||||
DEFINES += -DMOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
|
||||
MOZ_GTKPASSWORD_INTERFACE = 1
|
||||
DEFINES += -DMOZ_GTKPASSWORD_INTERFACE
|
||||
endif
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
content \
|
||||
docshell \
|
||||
necko \
|
||||
widget \
|
||||
dom \
|
||||
gfx \
|
||||
intl \
|
||||
imglib2 \
|
||||
layout \
|
||||
locale \
|
||||
unicharutil \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
shistory \
|
||||
composer \
|
||||
editor \
|
||||
embed_base \
|
||||
windowwatcher \
|
||||
webshell \
|
||||
pipnss \
|
||||
history \
|
||||
profdirserviceprovider \
|
||||
pref \
|
||||
nspr \
|
||||
xulapp \
|
||||
exthandler \
|
||||
mimetype \
|
||||
chardet \
|
||||
find \
|
||||
webbrowserpersist \
|
||||
cookie \
|
||||
$(NULL)
|
||||
|
||||
ifdef ACCESSIBILITY
|
||||
@ -72,29 +122,75 @@ endif
|
||||
|
||||
CPPSRCS = \
|
||||
gtkmozembed2.cpp \
|
||||
gtkmozembed_common.cpp \
|
||||
gtkmozembed_download.cpp \
|
||||
EmbedPrivate.cpp \
|
||||
EmbedWindow.cpp \
|
||||
EmbedProgress.cpp \
|
||||
EmbedContentListener.cpp \
|
||||
EmbedEventListener.cpp \
|
||||
EmbedContextMenuInfo.cpp \
|
||||
EmbedWindowCreator.cpp \
|
||||
EmbedCertificates.cpp \
|
||||
EmbedDownloadMgr.cpp \
|
||||
EmbedGlobalHistory.cpp \
|
||||
EmbedFilePicker.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
CPPSRCS += \
|
||||
EmbedPasswordMgr.cpp \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS += \
|
||||
nsIPassword.idl \
|
||||
nsIPasswordInternal.idl \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
CSRCS = \
|
||||
gtkmozembedmarshal.c
|
||||
|
||||
CPPSRCS += \
|
||||
EmbedGtkTools.cpp \
|
||||
GtkPromptService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
CPPSRCS += \
|
||||
EmbedPrompter.cpp \
|
||||
GtkPromptService.cpp
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
ifdef MOZILLA_1_8_BRANCH
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libprofdirserviceprovider_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
gtkmozembed.h \
|
||||
gtkmozembed_common.h \
|
||||
gtkmozembed_download.h \
|
||||
gtkmozembed_glue.cpp \
|
||||
gtkmozembed_internal.h
|
||||
|
||||
ifdef MOZ_GTKEMBED_DYN
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
EXTRA_DSO_LDOPTS += -L$(DIST)/lib -lgtksuperwin
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gtk gtk2 qt xlib,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_GTK_LDFLAGS) $(MOZ_XFT_LIBS) $(MOZ_GTK2_LIBS) $(XT_LIBS) $(MOZ_COMPONENT_LIBS) $(MOZ_GNOMEVFS_LIBS) $(DIST)/lib/libxpcom_core.a
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
@ -108,8 +204,22 @@ DEFINES += -D_TIME_H=1
|
||||
endif
|
||||
endif
|
||||
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS) $(MOZ_GNOMEVFS_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS) $(MOZ_GNOMEVFS_CFLAGS)
|
||||
DEFINES += -D_IMPL_GTKMOZEMBED
|
||||
|
||||
|
||||
MARSHAL_FILE = gtkmozembedmarshal
|
||||
MARSHAL_PREFIX = gtkmozembed
|
||||
|
||||
$(MARSHAL_FILE).h: $(MARSHAL_FILE).list
|
||||
( glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --header > $(srcdir)/$(MARSHAL_FILE).htmp \
|
||||
&& mv $(srcdir)/$(MARSHAL_FILE).htmp $(srcdir)/$(MARSHAL_FILE).h && cp -f $(srcdir)/$(MARSHAL_FILE).h $(MARSHAL_FILE).h ) \
|
||||
|| ( rm -f $(srcdir)/$(MARSHAL_FILE).htmp && exit 1 )
|
||||
|
||||
$(MARSHAL_FILE).c: $(MARSHAL_FILE).list $(MARSHAL_FILE).h
|
||||
( glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --body > $(srcdir)/$(MARSHAL_FILE).ctmp \
|
||||
&& mv $(srcdir)/$(MARSHAL_FILE).ctmp $(srcdir)/$(MARSHAL_FILE).c && cp -f $(srcdir)/$(MARSHAL_FILE).c $(MARSHAL_FILE).c ) \
|
||||
|| ( rm -f $(srcdir)/$(MARSHAL_FILE).ctmp && exit 1 )
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -21,6 +23,8 @@
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
* Antonio Gomes <tonikitoo@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -45,6 +49,7 @@ extern "C" {
|
||||
|
||||
#include <stddef.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "nscore.h"
|
||||
@ -81,19 +86,35 @@ extern "C" {
|
||||
|
||||
#endif // XPCOM_GLUE
|
||||
|
||||
#include "gtkmozembed_common.h"
|
||||
#define GTK_TYPE_MOZ_EMBED (gtk_moz_embed_get_type())
|
||||
#define GTK_MOZ_EMBED(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED, GtkMozEmbed)
|
||||
#define GTK_MOZ_EMBED_CLASS(klass) GTK_CHECK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED, GtkMozEmbedClass)
|
||||
#define GTK_IS_MOZ_EMBED(obj) GTK_CHECK_TYPE((obj), GTK_TYPE_MOZ_EMBED)
|
||||
#define GTK_IS_MOZ_EMBED_CLASS(klass) GTK_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ZOOM_SIMPLE,
|
||||
ZOOM_AROUND_POINT,
|
||||
ZOOM_STEPS,
|
||||
ZOOM_FRAME
|
||||
} GtkMozEmbedZoomType;
|
||||
|
||||
typedef struct _GtkMozEmbed GtkMozEmbed;
|
||||
typedef struct _GtkMozEmbedClass GtkMozEmbedClass;
|
||||
|
||||
struct _GtkMozEmbed
|
||||
{
|
||||
GtkBin bin;
|
||||
void *data;
|
||||
GtkBin bin;
|
||||
void *data;
|
||||
GtkMozEmbedCommon *common;
|
||||
// FIXME: This is a temporary solution for wrong progress values
|
||||
// being passed up. Oleg has mentioned something about a bug in JS.
|
||||
gint current_number_of_requests;
|
||||
gint total_number_of_requests;
|
||||
gint number_of_frames_loaded;
|
||||
|
||||
};
|
||||
|
||||
struct _GtkMozEmbedClass
|
||||
@ -106,10 +127,10 @@ struct _GtkMozEmbedClass
|
||||
void (* title) (GtkMozEmbed *embed);
|
||||
void (* progress) (GtkMozEmbed *embed, gint curprogress,
|
||||
gint maxprogress);
|
||||
void (* progress_all) (GtkMozEmbed *embed, const char *aURI,
|
||||
void (* progress_all) (GtkMozEmbed *embed, const gchar *aURI,
|
||||
gint curprogress, gint maxprogress);
|
||||
void (* net_state) (GtkMozEmbed *embed, gint state, guint status);
|
||||
void (* net_state_all) (GtkMozEmbed *embed, const char *aURI,
|
||||
void (* net_state_all) (GtkMozEmbed *embed, const gchar *aURI,
|
||||
gint state, guint status);
|
||||
void (* net_start) (GtkMozEmbed *embed);
|
||||
void (* net_stop) (GtkMozEmbed *embed);
|
||||
@ -128,6 +149,11 @@ struct _GtkMozEmbedClass
|
||||
gint (* dom_mouse_dbl_click) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_over) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_out) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
// gint (* dom_mouse_move) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_scroll) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_long_press)(GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_blur) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
void (* security_change) (GtkMozEmbed *embed, gpointer request,
|
||||
guint state);
|
||||
void (* status_change) (GtkMozEmbed *embed, gpointer request,
|
||||
@ -135,49 +161,121 @@ struct _GtkMozEmbedClass
|
||||
gint (* dom_activate) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus_in) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus_out) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
void (* alert) (GtkMozEmbed *embed, const char *title, const char *text);
|
||||
void (* alert_check) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gboolean (* confirm) (GtkMozEmbed *embed, const char *title, const char *text);
|
||||
gboolean (* confirm_check) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gint (* confirm_ex) (GtkMozEmbed *embed, const char *title, const char *text, guint bt_flags,
|
||||
const char *button1, const char *button2, const char *button3,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gboolean (* prompt) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
char **value, const char *check_msg, gboolean *check_val);
|
||||
gboolean (* prompt_auth) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
char **user, char **pass, const char *check_msg, gboolean *check_val);
|
||||
gboolean (* select) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
GList *list, gint *selected_item);
|
||||
void (* download_request)(GtkMozEmbed *, const char *, const char *, const char *, long, int, gpointer);
|
||||
gboolean (* upload_dialog) (GtkMozEmbed *, const char *, const char *, char **);
|
||||
void (* icon_changed) (GtkMozEmbed *, gpointer*);
|
||||
void (* mailto) (GtkMozEmbed *, gchar *);
|
||||
void (* unknown_protocol)(GtkMozEmbed *, gchar *);
|
||||
};
|
||||
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
|
||||
|
||||
/* Tell gtkmozembed where the gtkmozembed libs live. If this is not specified,
|
||||
The MOZILLA_FIVE_HOME environment variable is checked. */
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
|
||||
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir,
|
||||
const char *aName))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed,
|
||||
const char *url))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed,
|
||||
const char *data,
|
||||
guint32 len,
|
||||
const char *base_uri,
|
||||
const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
|
||||
const char *base_uri,
|
||||
const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
|
||||
const char *data,
|
||||
guint32 len))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed,
|
||||
gint32 flags))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed,
|
||||
guint32 flags))
|
||||
GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir,
|
||||
const char *aName))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed,
|
||||
const char *url))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed, const char *data, guint32 len,
|
||||
const char *base_uri, const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
|
||||
const char *base_uri, const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
|
||||
const char *data, guint32 len))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed, gint32 flags))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed, guint32 flags))
|
||||
GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_get_zoom_level, (GtkMozEmbed *embed, GtkMozEmbedZoomType, gint*))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_set_zoom_level, (GtkMozEmbed *embed, GtkMozEmbedZoomType, gint, gint, gint, guint*, gint))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_load_image, (GtkMozEmbed *embed, const gchar*))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_find_text, (GtkMozEmbed *embed, const gchar*, gboolean, gboolean, gboolean, gboolean, gint))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_clipboard, (GtkMozEmbed *embed, guint, gint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_notify_plugins, (GtkMozEmbed *embed, guint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_check_logins, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_encoding, (GtkMozEmbed *embed, gint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_encoding, (GtkMozEmbed *embed, const gchar *, gint))
|
||||
GTKMOZEMBED_API(guint, gtk_moz_embed_get_context_info, (GtkMozEmbed *embed, gpointer event, gpointer *node,
|
||||
gint *x, gint *y, gint *docindex,
|
||||
const gchar **url, const gchar **objurl, const gchar **docurl))
|
||||
GTKMOZEMBED_API(const gchar*, gtk_moz_embed_get_selection, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_get_doc_info, (GtkMozEmbed *embed, gint docindex, const gchar**title,
|
||||
const gchar**location, const gchar **file_type, guint *file_size))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_insert_text, (GtkMozEmbed *embed, const gchar*, gpointer node))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_save_target, (GtkMozEmbed *embed, gchar*, gchar*, gint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_get_image_dimensions,(GtkMozEmbed *embed, gint*, gint*, gpointer))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_mime_type, (GtkMozEmbed *embed))
|
||||
|
||||
/* Defines used by download and upload components */
|
||||
#define GTK_MOZ_EMBED_COMMON_FILE_SCHEME "file://"
|
||||
#define GTK_MOZ_EMBED_BLUETOOTH_FILE_SCHEME "obex://"
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_SELECT_ALL,
|
||||
GTK_MOZ_EMBED_CAN_SELECT,
|
||||
GTK_MOZ_EMBED_CUT,
|
||||
GTK_MOZ_EMBED_COPY,
|
||||
GTK_MOZ_EMBED_PASTE,
|
||||
GTK_MOZ_EMBED_CAN_CUT,
|
||||
GTK_MOZ_EMBED_CAN_PASTE,
|
||||
GTK_MOZ_EMBED_CAN_COPY
|
||||
} GtkMozEmbedClipboard;
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_CTX_NONE = 0,
|
||||
GTK_MOZ_EMBED_CTX_XUL = 1 << 1,
|
||||
GTK_MOZ_EMBED_CTX_SIDEBAR = 1 << 2,
|
||||
GTK_MOZ_EMBED_CTX_DOCUMENT = 1 << 3,
|
||||
GTK_MOZ_EMBED_CTX_LINK = 1 << 4,
|
||||
GTK_MOZ_EMBED_CTX_IMAGE = 1 << 5,
|
||||
GTK_MOZ_EMBED_CTX_IFRAME = 1 << 6,
|
||||
GTK_MOZ_EMBED_CTX_INPUT = 1 << 7,
|
||||
GTK_MOZ_EMBED_CTX_IPASSWORD = 1 << 8,
|
||||
GTK_MOZ_EMBED_CTX_EMAIL = 1 << 9,
|
||||
GTK_MOZ_EMBED_CTX_RICHEDIT = 1 << 10,
|
||||
GTK_MOZ_EMBED_CTX_ROINPUT = 1 << 11
|
||||
} GtkMozEmbedContext;
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_OK,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_CANCEL,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_YES,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_NO,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_SAVE,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_DONT_SAVE,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_REVERT,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_STRING
|
||||
} GtkMozEmbedDialogButtons;
|
||||
/* These are straight out of nsIWebProgressListener.h */
|
||||
|
||||
typedef enum
|
||||
@ -207,7 +305,9 @@ typedef enum
|
||||
/* NS_ERROR_NET_TIMEOUT */
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT = 2152398862U,
|
||||
/* NS_BINDING_ABORTED */
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U,
|
||||
/* NS_ERROR_PROXY_CONNECTION_REFUSED */
|
||||
GTK_MOZ_EMBED_STATUS_PROXY_FAILED = 2152398920U
|
||||
} GtkMozEmbedStatusFlags;
|
||||
|
||||
/* These used to be straight out of nsIWebNavigation.h until the API
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
665
mozilla/embedding/browser/gtk/src/gtkmozembed_common.cpp
Normal file
665
mozilla/embedding/browser/gtk/src/gtkmozembed_common.cpp
Normal file
@ -0,0 +1,665 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gtkmozembed.h"
|
||||
#include "gtkmozembed_common.h"
|
||||
#include "gtkmozembedprivate.h"
|
||||
#include "gtkmozembed_internal.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "EmbedWindow.h"
|
||||
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
#include "EmbedPasswordMgr.h"
|
||||
#include "nsIPassword.h"
|
||||
#endif
|
||||
|
||||
#include "EmbedGlobalHistory.h"
|
||||
//#include "EmbedDownloadMgr.h"
|
||||
// so we can do our get_nsIWebBrowser later...
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsIComponentManager.h>
|
||||
#include <nsIServiceManager.h>
|
||||
#include "nsIPref.h"
|
||||
#include <nsICookieManager.h>
|
||||
#include <nsIPermissionManager.h>
|
||||
#include <nsNetCID.h>
|
||||
#include <nsICookie.h>
|
||||
#include <nsIX509Cert.h>
|
||||
// for strings
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsXPIDLString.h>
|
||||
#include <nsReadableUtils.h>
|
||||
#else
|
||||
#include <nsStringAPI.h>
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#endif
|
||||
// for plugins
|
||||
#include <nsIDOMNavigator.h>
|
||||
#include <nsIDOMPluginArray.h>
|
||||
#include <nsIDOMPlugin.h>
|
||||
#include <plugin/nsIPluginHost.h>
|
||||
#include <nsString.h>
|
||||
#include <nsIDOMMimeType.h>
|
||||
|
||||
//for security
|
||||
#include <nsIWebProgressListener.h>
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "gtkmozembedmarshal.h"
|
||||
#define NEW_TOOLKIT_STRING(x) g_strdup(NS_ConvertUTF16toUTF8(x).get())
|
||||
#define GET_TOOLKIT_STRING(x) NS_ConvertUTF16toUTF8(x).get()
|
||||
#define GET_OBJECT_CLASS_TYPE(x) G_OBJECT_CLASS_TYPE(x)
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// so we can get callbacks from the mozarea
|
||||
#include <gtkmozarea.h>
|
||||
// so we get the right marshaler for gtk 1.2
|
||||
#define gtkmozembed_VOID__INT_UINT \
|
||||
gtk_marshal_NONE__INT_INT
|
||||
#define gtkmozembed_VOID__STRING_INT_INT \
|
||||
gtk_marshal_NONE__POINTER_INT_INT
|
||||
#define gtkmozembed_VOID__STRING_INT_UINT \
|
||||
gtk_marshal_NONE__POINTER_INT_INT
|
||||
#define gtkmozembed_VOID__POINTER_INT_POINTER \
|
||||
gtk_marshal_NONE__POINTER_INT_POINTER
|
||||
#define gtkmozembed_BOOL__STRING \
|
||||
gtk_marshal_BOOL__POINTER
|
||||
#define gtkmozembed_VOID__INT_INT_BOOLEAN \
|
||||
gtk_marshal_NONE__INT_INT_BOOLEAN
|
||||
|
||||
#define G_SIGNAL_TYPE_STATIC_SCOPE 0
|
||||
#define NEW_TOOLKIT_STRING(x) g_strdup(NS_LossyConvertUTF16toASCII(x).get())
|
||||
#define GET_TOOLKIT_STRING(x) NS_LossyConvertUTF16toASCII(x).get()
|
||||
#define GET_OBJECT_CLASS_TYPE(x) (GTK_OBJECT_CLASS(x)->type)
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
// CID used to get the plugin manager
|
||||
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
// class and instance initialization
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_class_init(GtkMozEmbedCommonClass *klass);
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_init(GtkMozEmbedCommon *embed);
|
||||
|
||||
static GtkObjectClass *common_parent_class = NULL;
|
||||
|
||||
// GtkObject methods
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_destroy(GtkObject *object);
|
||||
|
||||
guint moz_embed_common_signals[COMMON_LAST_SIGNAL] = { 0 };
|
||||
|
||||
// GtkObject + class-related functions
|
||||
GtkType
|
||||
gtk_moz_embed_common_get_type(void)
|
||||
{
|
||||
static GtkType moz_embed_common_type = 0;
|
||||
if (!moz_embed_common_type)
|
||||
{
|
||||
static const GtkTypeInfo moz_embed_common_info =
|
||||
{
|
||||
"GtkMozEmbedCommon",
|
||||
sizeof(GtkMozEmbedCommon),
|
||||
sizeof(GtkMozEmbedCommonClass),
|
||||
(GtkClassInitFunc)gtk_moz_embed_common_class_init,
|
||||
(GtkObjectInitFunc)gtk_moz_embed_common_init,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
moz_embed_common_type = gtk_type_unique(GTK_TYPE_BIN, &moz_embed_common_info);
|
||||
}
|
||||
return moz_embed_common_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_class_init(GtkMozEmbedCommonClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
common_parent_class = (GtkObjectClass *)gtk_type_class(gtk_object_get_type());
|
||||
object_class->destroy = gtk_moz_embed_common_destroy;
|
||||
moz_embed_common_signals[COMMON_CERT_ERROR] =
|
||||
gtk_signal_new("certificate-error",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
certificate_error),
|
||||
gtkmozembed_BOOL__POINTER_UINT,
|
||||
G_TYPE_BOOLEAN,
|
||||
2,
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_TYPE_UINT);
|
||||
moz_embed_common_signals[COMMON_SELECT_LOGIN] =
|
||||
gtk_signal_new("select-login",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
select_login),
|
||||
gtk_marshal_INT__POINTER,
|
||||
G_TYPE_INT,
|
||||
1,
|
||||
G_TYPE_POINTER);
|
||||
moz_embed_common_signals[COMMON_REMEMBER_LOGIN] =
|
||||
gtk_signal_new("remember-login",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
remember_login),
|
||||
gtkmozembed_INT__VOID,
|
||||
G_TYPE_INT, 0);
|
||||
// set up our signals
|
||||
moz_embed_common_signals[COMMON_ASK_COOKIE] =
|
||||
gtk_signal_new("ask-cookie",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass, ask_cookie),
|
||||
gtkmozembed_VOID__POINTER_INT_STRING_STRING_STRING_STRING_STRING_BOOLEAN_INT,
|
||||
G_TYPE_NONE, 9,
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_BOOL,
|
||||
GTK_TYPE_INT);
|
||||
/*
|
||||
moz_embed_common_signals[COMMON_CERT_DIALOG] =
|
||||
gtk_signal_new("certificate-dialog",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
certificate_dialog),
|
||||
gtk_marshal_BOOL__POINTER,
|
||||
G_TYPE_BOOLEAN, 1, GTK_TYPE_POINTER);
|
||||
moz_embed_common_signals[COMMON_CERT_PASSWD_DIALOG] =
|
||||
gtk_signal_new("certificate-password-dialog",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
certificate_password_dialog),
|
||||
gtkmozembed_VOID__STRING_STRING_POINTER,
|
||||
G_TYPE_NONE,
|
||||
3,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GTK_TYPE_POINTER);
|
||||
moz_embed_common_signals[COMMON_CERT_DETAILS_DIALOG] =
|
||||
gtk_signal_new("certificate-details",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
certificate_details),
|
||||
gtk_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_POINTER);
|
||||
moz_embed_common_signals[COMMON_HISTORY_ADDED] =
|
||||
gtk_signal_new("global-history-item-added",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
history_added),
|
||||
gtk_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
|
||||
moz_embed_common_signals[COMMON_ON_SUBMIT_SIGNAL] =
|
||||
gtk_signal_new("on-submit",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
on_submit),
|
||||
gtkmozembed_INT__VOID,
|
||||
G_TYPE_INT, 0);
|
||||
moz_embed_common_signals[COMMON_MODAL_DIALOG] =
|
||||
gtk_signal_new("modal_dialog",
|
||||
GTK_RUN_LAST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedCommonClass,
|
||||
modal_dialog),
|
||||
gtkmozembed_INT__STRING_STRING_INT_INT_INT_INT,
|
||||
G_TYPE_INT,
|
||||
6,
|
||||
G_TYPE_STRING, G_TYPE_STRING,
|
||||
G_TYPE_INT, G_TYPE_INT,
|
||||
G_TYPE_INT, G_TYPE_INT);
|
||||
*/
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
gtk_object_class_add_signals(object_class, moz_embed_common_signals,
|
||||
COMMON_LAST_SIGNAL);
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_init(GtkMozEmbedCommon *common)
|
||||
{
|
||||
// this is a placeholder for later in case we need to stash data at
|
||||
// a later data and maintain backwards compatibility.
|
||||
common->data = nsnull;
|
||||
EmbedCommon *priv = EmbedCommon::GetInstance();
|
||||
priv->mCommon = common;
|
||||
common->data = priv;
|
||||
EmbedGlobalHistory::GetInstance();
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_moz_embed_common_destroy(GtkObject *object)
|
||||
{
|
||||
g_return_if_fail(object != NULL);
|
||||
g_return_if_fail(GTK_IS_MOZ_EMBED_COMMON(object));
|
||||
GtkMozEmbedCommon *embed = nsnull;
|
||||
EmbedCommon *commonPrivate = nsnull;
|
||||
embed = GTK_MOZ_EMBED_COMMON(object);
|
||||
commonPrivate = (EmbedCommon *)embed->data;
|
||||
if (commonPrivate) {
|
||||
delete commonPrivate;
|
||||
embed->data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_moz_embed_common_new(void)
|
||||
{
|
||||
GtkWidget *widget = (GtkWidget*) gtk_type_new(gtk_moz_embed_common_get_type());
|
||||
gtk_widget_set_name (widget, "gtkmozembedcommon");
|
||||
return (GtkWidget *) widget;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_set_pref(GtkType type, gchar *name, gpointer value)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
|
||||
|
||||
if (pref) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
switch (type) {
|
||||
case GTK_TYPE_BOOL:
|
||||
{
|
||||
/* I doubt this cast pair is correct */
|
||||
rv = pref->SetBoolPref (name, (int)(int*)value != 0 ? PR_TRUE : PR_FALSE);
|
||||
break;
|
||||
}
|
||||
case GTK_TYPE_INT:
|
||||
{
|
||||
/* I doubt this cast pair is correct */
|
||||
rv = pref->SetIntPref (name, (int)(int*)value);
|
||||
break;
|
||||
}
|
||||
case GTK_TYPE_STRING:
|
||||
{
|
||||
g_return_val_if_fail (value, FALSE);
|
||||
rv = pref->SetCharPref (name, (gchar*)value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ( NS_SUCCEEDED (rv) ? TRUE : FALSE );
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_get_pref(GtkType type, gchar *name, gpointer value)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (pref){
|
||||
switch (type) {
|
||||
case GTK_TYPE_BOOL:
|
||||
{
|
||||
rv = pref->GetBoolPref (name, (gboolean*)value);
|
||||
break;
|
||||
}
|
||||
case GTK_TYPE_INT:
|
||||
{
|
||||
rv = pref->GetIntPref (name, (gint*)value);
|
||||
break;
|
||||
}
|
||||
case GTK_TYPE_STRING:
|
||||
{
|
||||
rv = pref->GetCharPref (name, (gchar**)value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ( NS_SUCCEEDED (rv) ? TRUE : FALSE );
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_save_prefs()
|
||||
{
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREF_CONTRACTID);
|
||||
g_return_val_if_fail (prefService != nsnull, FALSE);
|
||||
if (prefService == nsnull)
|
||||
return FALSE;
|
||||
nsresult rv = prefService->SavePrefFile (nsnull);
|
||||
return NS_SUCCEEDED (rv) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
static GList *
|
||||
gtk_moz_embed_common_get_logins(const char* uri, nsIPasswordManager *passwordManager)
|
||||
{
|
||||
GList *logins = NULL;
|
||||
nsCOMPtr<nsISimpleEnumerator> passwordEnumerator;
|
||||
nsresult result = passwordManager->GetEnumerator(getter_AddRefs(passwordEnumerator));
|
||||
PRBool enumResult;
|
||||
for (passwordEnumerator->HasMoreElements(&enumResult) ;
|
||||
enumResult == PR_TRUE ;
|
||||
passwordEnumerator->HasMoreElements(&enumResult))
|
||||
{
|
||||
nsCOMPtr<nsIPassword> nsPassword;
|
||||
result = passwordEnumerator->GetNext
|
||||
(getter_AddRefs(nsPassword));
|
||||
if (NS_FAILED(result)) {
|
||||
/* this almost certainly leaks logins */
|
||||
return NULL;
|
||||
}
|
||||
nsCString transfer;
|
||||
nsPassword->GetHost (transfer);
|
||||
if (uri && !g_str_has_prefix(uri, transfer.get()))
|
||||
continue;
|
||||
nsString unicodeName;
|
||||
nsPassword->GetUser (unicodeName);
|
||||
logins = g_list_append(logins, ToNewUTF8String(unicodeName));
|
||||
}
|
||||
return logins;
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_login(GtkWidget *embed)
|
||||
{
|
||||
gint retval = -1;
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
EmbedPasswordMgr *passwordManager = EmbedPasswordMgr::GetInstance();
|
||||
GList * list = gtk_moz_embed_common_get_logins(gtk_moz_embed_get_location(GTK_MOZ_EMBED(embed)), passwordManager);
|
||||
gtk_signal_emit(
|
||||
GTK_OBJECT(GTK_MOZ_EMBED(embed)->common),
|
||||
moz_embed_common_signals[COMMON_SELECT_LOGIN],
|
||||
list,
|
||||
&retval);
|
||||
if (retval != -1) {
|
||||
passwordManager->InsertLogin((const gchar*)g_list_nth_data(list, retval));
|
||||
}
|
||||
g_list_free(list);
|
||||
#endif
|
||||
return retval != -1;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_remove_passwords(const gchar *host, const gchar *user)
|
||||
{
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
EmbedPasswordMgr *passwordManager = EmbedPasswordMgr::GetInstance();
|
||||
passwordManager->RemovePasswords(host, user);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_moz_embed_common_remove_passwords_by_index (gint index)
|
||||
{
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
EmbedPasswordMgr *passwordManager = EmbedPasswordMgr::GetInstance();
|
||||
passwordManager->RemovePasswordsByIndex(index);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_moz_embed_common_get_number_of_saved_passwords ()
|
||||
{
|
||||
gint saved_passwd_num = 0;
|
||||
#ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
EmbedPasswordMgr *passwordManager = EmbedPasswordMgr::GetInstance();
|
||||
passwordManager->GetNumberOfSavedPassword ( &saved_passwd_num);
|
||||
#endif
|
||||
return saved_passwd_num;
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_moz_embed_common_get_history_list (GtkMozHistoryItem **GtkHI)
|
||||
{
|
||||
gint count = 0;
|
||||
EmbedGlobalHistory *history = EmbedGlobalHistory::GetInstance();
|
||||
history->GetContentList(GtkHI, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_moz_embed_common_clean_all_history () {
|
||||
nsresult rv;
|
||||
// The global history service
|
||||
nsCOMPtr<nsIGlobalHistory2> globalHistory(do_GetService("@mozilla.org/browser/global-history;2"));
|
||||
if (!globalHistory) return NS_ERROR_NULL_POINTER;
|
||||
// The browser history interface
|
||||
nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(globalHistory, &rv);
|
||||
if (!myHistory) return NS_ERROR_NULL_POINTER ;
|
||||
myHistory->RemoveAllPages();
|
||||
return 1;
|
||||
}
|
||||
|
||||
GSList*
|
||||
gtk_moz_embed_common_get_cookie_list(void)
|
||||
{
|
||||
GSList *cookies = NULL;
|
||||
nsresult result;
|
||||
nsCOMPtr<nsICookieManager> cookieManager =
|
||||
do_GetService(NS_COOKIEMANAGER_CONTRACTID);
|
||||
nsCOMPtr<nsISimpleEnumerator> cookieEnumerator;
|
||||
result = cookieManager->GetEnumerator(getter_AddRefs(cookieEnumerator));
|
||||
g_return_val_if_fail(NS_SUCCEEDED(result), NULL);
|
||||
PRBool enumResult;
|
||||
for (cookieEnumerator->HasMoreElements(&enumResult);
|
||||
enumResult == PR_TRUE;
|
||||
cookieEnumerator->HasMoreElements(&enumResult))
|
||||
{
|
||||
GtkMozCookieList *c;
|
||||
nsCOMPtr<nsICookie> nsCookie;
|
||||
result = cookieEnumerator->GetNext(getter_AddRefs(nsCookie));
|
||||
g_return_val_if_fail(NS_SUCCEEDED(result), NULL);
|
||||
c = g_new0(GtkMozCookieList, 1);
|
||||
nsCAutoString transfer;
|
||||
nsCookie->GetHost(transfer);
|
||||
c->domain = g_strdup(transfer.get());
|
||||
nsCookie->GetName(transfer);
|
||||
c->name = g_strdup(transfer.get());
|
||||
nsCookie->GetValue(transfer);
|
||||
c->value = g_strdup(transfer.get());
|
||||
nsCookie->GetPath(transfer);
|
||||
/* this almost certainly leaks g_strconcat */
|
||||
if (strchr(c->domain,'.'))
|
||||
c->path = g_strdup(g_strconcat("http://*",c->domain,"/",NULL));
|
||||
else
|
||||
c->path = g_strdup(g_strconcat("http://",c->domain,"/",NULL));
|
||||
cookies = g_slist_prepend(cookies, c);
|
||||
}
|
||||
cookies = g_slist_reverse(cookies);
|
||||
return cookies;
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_moz_embed_common_delete_all_cookies (GSList *deletedCookies)
|
||||
{
|
||||
if (!deletedCookies)
|
||||
return 1;
|
||||
|
||||
nsCOMPtr<nsICookieManager> cookieManager =
|
||||
do_GetService(NS_COOKIEMANAGER_CONTRACTID);
|
||||
|
||||
if (!cookieManager)
|
||||
return 1;
|
||||
cookieManager->RemoveAll();
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
|
||||
if (!permissionManager)
|
||||
return 1;
|
||||
|
||||
permissionManager->RemoveAll ();
|
||||
|
||||
g_slist_free (deletedCookies);
|
||||
return 0;//False in GWebStatus means OK, as opposed to gboolean in C
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
gtk_moz_embed_common_nsx509_to_raw(void *nsIX509Ptr, guint *len)
|
||||
{
|
||||
if (!nsIX509Ptr)
|
||||
return NULL;
|
||||
unsigned char *data;
|
||||
((nsIX509Cert*)nsIX509Ptr)->GetRawDER(len, (PRUint8 **)&data);
|
||||
if (!data)
|
||||
return NULL;
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_moz_embed_common_get_plugins_list (GtkMozPlugin **pluginArray, gint *num_plugins)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPluginManager> pluginMan =
|
||||
do_GetService(kPluginManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
g_print("Could not get the plugin manager\n");
|
||||
return;
|
||||
}
|
||||
pluginMan->ReloadPlugins(PR_TRUE);
|
||||
nsCOMPtr<nsIPluginHost> pluginHost =
|
||||
do_GetService(kPluginManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
PRUint32 aLength;
|
||||
nsIDOMPlugin **aItem;
|
||||
pluginHost->GetPluginCount(&aLength);
|
||||
*num_plugins = aLength;
|
||||
gint size = aLength;
|
||||
aItem = new nsIDOMPlugin*[aLength];
|
||||
pluginHost->GetPlugins(aLength, aItem);
|
||||
*pluginArray = (GtkMozPlugin*) g_try_malloc(size*sizeof(GtkMozPlugin));
|
||||
for (int aIndex = 0; aIndex < (gint) aLength; aIndex++)
|
||||
{
|
||||
nsAutoString aName;
|
||||
aItem[aIndex]->GetName(aName);
|
||||
NS_ConvertUTF16toUTF8 utf8ValueTitle(aName);
|
||||
(*pluginArray)[aIndex].title = g_strdup((gchar *)utf8ValueTitle.get());
|
||||
nsAutoString aFilename;
|
||||
aItem[aIndex]->GetFilename(aFilename);
|
||||
NS_ConvertUTF16toUTF8 utf8ValueFilename(aFilename);
|
||||
(*pluginArray)[aIndex].path =g_strdup((gchar *)utf8ValueFilename.get());
|
||||
nsCOMPtr<nsIDOMMimeType> mimeType;
|
||||
aItem[aIndex]->Item(aIndex, getter_AddRefs(mimeType));
|
||||
nsAutoString aDescription;
|
||||
mimeType->GetDescription(aDescription);
|
||||
NS_ConvertUTF16toUTF8 utf8ValueDescription(aDescription);
|
||||
(*pluginArray)[aIndex].type = g_strdup((gchar *)utf8ValueDescription.get());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_moz_embed_common_reload_plugins ()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPluginManager> pluginMan =
|
||||
do_GetService(kPluginManagerCID, &rv);
|
||||
pluginMan->ReloadPlugins(PR_TRUE);
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_moz_embed_common_get_security_mode (guint sec_state)
|
||||
{
|
||||
GtkMozEmbedSecurityMode sec_mode;
|
||||
|
||||
switch (sec_state) {
|
||||
case nsIWebProgressListener::STATE_IS_INSECURE:
|
||||
sec_mode = GTK_MOZ_EMBED_NO_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_NO_SECURITY\n");
|
||||
break;
|
||||
case nsIWebProgressListener::STATE_IS_BROKEN:
|
||||
sec_mode = GTK_MOZ_EMBED_NO_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_NO_SECURITY\n");
|
||||
break;
|
||||
case nsIWebProgressListener::STATE_IS_SECURE|
|
||||
nsIWebProgressListener::STATE_SECURE_HIGH:
|
||||
sec_mode = GTK_MOZ_EMBED_HIGH_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_HIGH_SECURITY");
|
||||
break;
|
||||
case nsIWebProgressListener::STATE_IS_SECURE|
|
||||
nsIWebProgressListener::STATE_SECURE_MED:
|
||||
sec_mode = GTK_MOZ_EMBED_MEDIUM_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_MEDIUM_SECURITY\n");
|
||||
break;
|
||||
case nsIWebProgressListener::STATE_IS_SECURE|
|
||||
nsIWebProgressListener::STATE_SECURE_LOW:
|
||||
sec_mode = GTK_MOZ_EMBED_LOW_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_LOW_SECURITY\n");
|
||||
break;
|
||||
default:
|
||||
sec_mode = GTK_MOZ_EMBED_UNKNOWN_SECURITY;
|
||||
//g_print("GTK_MOZ_EMBED_UNKNOWN_SECURITY\n");
|
||||
break;
|
||||
}
|
||||
return sec_mode;
|
||||
}
|
||||
|
||||
206
mozilla/embedding/browser/gtk/src/gtkmozembed_common.h
Normal file
206
mozilla/embedding/browser/gtk/src/gtkmozembed_common.h
Normal file
@ -0,0 +1,206 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef gtkmozembed_common_h
|
||||
#define gtkmozembed_common_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#include <stddef.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "nscore.h"
|
||||
#else // MOZILLA_CLIENT
|
||||
#ifndef nscore_h__
|
||||
/* Because this header may be included from files which not part of the mozilla
|
||||
build system, define macros from nscore.h */
|
||||
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
|
||||
#define NS_HIDDEN __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define NS_HIDDEN
|
||||
#endif
|
||||
#define NS_FROZENCALL
|
||||
#define NS_EXPORT_(type) type
|
||||
#define NS_IMPORT_(type) type
|
||||
#endif // nscore_h__
|
||||
#endif // MOZILLA_CLIENT
|
||||
#ifdef XPCOM_GLUE
|
||||
#define GTKMOZEMBED_API(type, name, params) \
|
||||
typedef type (NS_FROZENCALL * name##Type) params; \
|
||||
extern name##Type name NS_HIDDEN;
|
||||
#else // XPCOM_GLUE
|
||||
#ifdef _IMPL_GTKMOZEMBED
|
||||
#define GTKMOZEMBED_API(type, name, params) NS_EXPORT_(type) name params;
|
||||
#else
|
||||
#define GTKMOZEMBED_API(type,name, params) NS_IMPORT_(type) name params;
|
||||
#endif
|
||||
#endif // XPCOM_GLUE
|
||||
#define GTK_TYPE_MOZ_EMBED_COMMON (gtk_moz_embed_common_get_type())
|
||||
#define GTK_MOZ_EMBED_COMMON(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED_COMMON, GtkMozEmbedCommon)
|
||||
#define GTK_MOZ_EMBED_COMMON_CLASS(klass) GTK_CHECK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED_COMMON, GtkMozEmbedCommonClass)
|
||||
#define GTK_IS_MOZ_EMBED_COMMON(obj) GTK_CHECK_TYPE((obj), GTK_TYPE_MOZ_EMBED_COMMON)
|
||||
#define GTK_IS_MOZ_EMBED_COMMON_CLASS(klass) GTK_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED_COMMON)
|
||||
typedef struct _GtkMozEmbedCommon GtkMozEmbedCommon;
|
||||
typedef struct _GtkMozEmbedCommonClass GtkMozEmbedCommonClass;
|
||||
struct _GtkMozEmbedCommon
|
||||
{
|
||||
GtkBin object;
|
||||
void *data;
|
||||
};
|
||||
struct _GtkMozEmbedCommonClass
|
||||
{
|
||||
GtkBinClass parent_class;
|
||||
gboolean (* certificate_error) (GObject *, GObject*, guint);
|
||||
gint (* select_login) (GObject *, GList*);
|
||||
gint (* remember_login) (GObject *);
|
||||
void (* ask_cookie) (GObject * , gint , const gchar * , const gchar * , const gchar * ,
|
||||
const gchar *, const gchar * , gboolean , gint , GObject *);
|
||||
// void (* ask_cookie) (GObject * , gpointer , gint , const gchar * , const gchar * , const gchar * ,
|
||||
// const gchar *, const gchar * , gboolean , gint , GObject *);
|
||||
// gint (* modal_dialog) (GObject *, const gchar *, const gchar *, gint, gint, gint, gint);
|
||||
// gboolean (* certificate_dialog) (GObject * , GObject *);
|
||||
// void (*certificate_password_dialog) (GObject *, const gchar *, const gchar *, gchar **);
|
||||
// void (*certificate_details) (GObject *, gpointer );
|
||||
// gint (*on_submit) (GObject *);
|
||||
// gint (*select_match) (GObject *, gpointer);
|
||||
// void (*history_added) (GObject *, const gchar *, GObject*);
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_CERT_VERIFIED_OK = 0x0000,
|
||||
GTK_MOZ_EMBED_CERT_UNTRUSTED = 0x0001,
|
||||
GTK_MOZ_EMBED_CERT_NOT_VERIFIED_UNKNOWN = 0x0002,
|
||||
GTK_MOZ_EMBED_CERT_EXPIRED = 0x0004,
|
||||
GTK_MOZ_EMBED_CERT_REVOKED = 0x0008,
|
||||
GTK_MOZ_EMBED_UNKNOWN_CERT = 0x0010,
|
||||
GTK_MOZ_EMBED_CERT_ISSUER_UNTRUSTED = 0x0020,
|
||||
GTK_MOZ_EMBED_CERT_ISSUER_UNKNOWN = 0x0040,
|
||||
GTK_MOZ_EMBED_CERT_INVALID_CA = 0x0080
|
||||
} GtkMozEmbedCertificateType;
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_LOGIN_REMEMBER_FOR_THIS_SITE,
|
||||
GTK_MOZ_EMBED_LOGIN_REMEMBER_FOR_THIS_SERVER,
|
||||
GTK_MOZ_EMBED_LOGIN_NOT_NOW,
|
||||
GTK_MOZ_EMBED_LOGIN_NEVER_FOR_SITE,
|
||||
GTK_MOZ_EMBED_LOGIN_NEVER_FOR_SERVER
|
||||
} GtkMozEmbedLoginType;
|
||||
/* GTK_MOZ_EMBED_CERT_USAGE_NOT_ALLOWED,
|
||||
GTK_MOZ_EMBED_CA_CERT,
|
||||
GTK_MOZ_EMBED_USER_CERT,
|
||||
GTK_MOZ_EMBED_EMAIL_CERT,
|
||||
GTK_MOZ_EMBED_SERVER_CERT
|
||||
*/
|
||||
|
||||
/** GtkMozEmbedSecurityMode.
|
||||
* Enumerates security modes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_NO_SECURITY = 0,
|
||||
GTK_MOZ_EMBED_LOW_SECURITY,
|
||||
GTK_MOZ_EMBED_MEDIUM_SECURITY,
|
||||
GTK_MOZ_EMBED_HIGH_SECURITY,
|
||||
GTK_MOZ_EMBED_UNKNOWN_SECURITY
|
||||
} GtkMozEmbedSecurityMode;
|
||||
|
||||
/** @struct GtkWebHistoryItem.
|
||||
* Defines a web history item.
|
||||
*/
|
||||
typedef struct _GtkMozHistoryItem GtkMozHistoryItem;
|
||||
struct _GtkMozHistoryItem
|
||||
{
|
||||
gchar *title; /** < URL title */
|
||||
gchar *url; /** < URL */
|
||||
long accessed; /** < The last time that the URL was accessed */
|
||||
};
|
||||
typedef struct _GtkMozCookieList GtkMozCookieList;
|
||||
struct _GtkMozCookieList
|
||||
{
|
||||
gchar *domain; /** < The domain's name */
|
||||
gchar *name; /** < The cookie's name */
|
||||
gchar *value; /** < The cookie's value */
|
||||
gchar *path; /** < The cookie's path */
|
||||
};
|
||||
typedef struct _GtkMozEmbedCookie GtkMozEmbedCookie;
|
||||
struct _GtkMozEmbedCookie
|
||||
{
|
||||
gboolean remember_decision;
|
||||
gboolean accept;
|
||||
};
|
||||
/** @struct GtkMozPlugin.
|
||||
* Defines a Mozilla Plugin.
|
||||
*/
|
||||
typedef struct _GtkMozPlugin GtkMozPlugin;
|
||||
struct _GtkMozPlugin
|
||||
{
|
||||
const gchar *title; /** < Plugin title */
|
||||
const gchar *path; /** < Plugin path */
|
||||
const gchar *type; /** < Plugin type */
|
||||
gboolean isDisabled; /** < is plugin enabled */
|
||||
};
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_common_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_common_new, (void))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_set_pref, (GtkType type, gchar*, gpointer))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_get_pref, (GtkType type, gchar*, gpointer))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_save_prefs, (void))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_login, (GtkWidget *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_remove_passwords, (const gchar *host, const gchar *user))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_common_remove_passwords_by_index, (gint index))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_common_get_number_of_saved_passwords, (void))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_common_get_history_list, (GtkMozHistoryItem **GtkHI))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_common_clean_all_history, (void))
|
||||
GTKMOZEMBED_API(GSList*, gtk_moz_embed_common_get_cookie_list, (void))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_common_delete_all_cookies,(GSList *deletedCookies))
|
||||
GTKMOZEMBED_API(unsigned char*, gtk_moz_embed_common_nsx509_to_raw, (void *nsIX509Ptr, guint *len))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_common_get_plugins_list, (GtkMozPlugin **pluginArray, gint*))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_common_reload_plugins, (void))
|
||||
GTKMOZEMBED_API(guint, gtk_moz_embed_common_get_security_mode, (guint sec_state))
|
||||
|
||||
/*typedef struct _GtkMozEmbedCertContext GtkMozEmbedCertContext;
|
||||
struct _GtkMozEmbedCertContext
|
||||
{
|
||||
GObject * cert;
|
||||
guint message;
|
||||
GtkWidget *parent;
|
||||
};*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* gtkmozembed_common_h */
|
||||
260
mozilla/embedding/browser/gtk/src/gtkmozembed_download.cpp
Normal file
260
mozilla/embedding/browser/gtk/src/gtkmozembed_download.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <stdio.h>
|
||||
#include "gtkmozembed.h"
|
||||
#include "gtkmozembed_download.h"
|
||||
#include "gtkmozembedprivate.h"
|
||||
#include "gtkmozembed_internal.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "EmbedWindow.h"
|
||||
#include "EmbedDownloadMgr.h"
|
||||
// so we can do our get_nsIWebBrowser later...
|
||||
#include <nsIWebBrowser.h>
|
||||
// for strings
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsXPIDLString.h>
|
||||
#include <nsReadableUtils.h>
|
||||
#else
|
||||
#include <nsStringAPI.h>
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "gtkmozembedmarshal.h"
|
||||
#define NEW_TOOLKIT_STRING(x) g_strdup(NS_ConvertUTF16toUTF8(x).get())
|
||||
#define GET_TOOLKIT_STRING(x) NS_ConvertUTF16toUTF8(x).get()
|
||||
#define GET_OBJECT_CLASS_TYPE(x) G_OBJECT_CLASS_TYPE(x)
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// so we can get callbacks from the mozarea
|
||||
#include <gtkmozarea.h>
|
||||
// so we get the right marshaler for gtk 1.2
|
||||
#define gtkmozembed_VOID__INT_UINT \
|
||||
gtk_marshal_NONE__INT_INT
|
||||
#define gtkmozembed_VOID__STRING_INT_INT \
|
||||
gtk_marshal_NONE__POINTER_INT_INT
|
||||
#define gtkmozembed_VOID__STRING_INT_UINT \
|
||||
gtk_marshal_NONE__POINTER_INT_INT
|
||||
#define gtkmozembed_VOID__POINTER_INT_POINTER \
|
||||
gtk_marshal_NONE__POINTER_INT_POINTER
|
||||
#define gtkmozembed_BOOL__STRING \
|
||||
gtk_marshal_BOOL__POINTER
|
||||
#define gtkmozembed_VOID__INT_INT_BOOLEAN \
|
||||
gtk_marshal_NONE__INT_INT_BOOLEAN
|
||||
#define G_SIGNAL_TYPE_STATIC_SCOPE 0
|
||||
#define NEW_TOOLKIT_STRING(x) g_strdup(NS_LossyConvertUTF16toASCII(x).get())
|
||||
#define GET_TOOLKIT_STRING(x) NS_LossyConvertUTF16toASCII(x).get()
|
||||
#define GET_OBJECT_CLASS_TYPE(x) (GTK_OBJECT_CLASS(x)->type)
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
static void gtk_moz_embed_download_set_lastest_object (GtkObject *o);
|
||||
static GtkObject *latest_download_object = nsnull;
|
||||
// class and instance initialization
|
||||
guint moz_embed_download_signals[DOWNLOAD_LAST_SIGNAL] = { 0 };
|
||||
static void
|
||||
gtk_moz_embed_download_class_init(GtkMozEmbedDownloadClass *klass);
|
||||
static void
|
||||
gtk_moz_embed_download_init(GtkMozEmbedDownload *embed);
|
||||
static void
|
||||
gtk_moz_embed_download_destroy(GtkObject *object);
|
||||
GtkObject *
|
||||
gtk_moz_embed_download_new(void);
|
||||
// GtkObject + class-related functions
|
||||
GtkType
|
||||
gtk_moz_embed_download_get_type(void)
|
||||
{
|
||||
static GtkType moz_embed_download_type = 0;
|
||||
if (!moz_embed_download_type)
|
||||
{
|
||||
static const GtkTypeInfo moz_embed_download_info =
|
||||
{
|
||||
"GtkMozEmbedDownload",
|
||||
sizeof(GtkMozEmbedDownload),
|
||||
sizeof(GtkMozEmbedDownloadClass),
|
||||
(GtkClassInitFunc)gtk_moz_embed_download_class_init,
|
||||
(GtkObjectInitFunc)gtk_moz_embed_download_init,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
moz_embed_download_type = gtk_type_unique(GTK_TYPE_OBJECT, &moz_embed_download_info);
|
||||
}
|
||||
return moz_embed_download_type;
|
||||
}
|
||||
static void
|
||||
gtk_moz_embed_download_class_init(GtkMozEmbedDownloadClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
object_class->destroy = gtk_moz_embed_download_destroy;
|
||||
// set up our signals
|
||||
moz_embed_download_signals[DOWNLOAD_STARTED_SIGNAL] =
|
||||
gtk_signal_new("started",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedDownloadClass,
|
||||
started),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
moz_embed_download_signals[DOWNLOAD_COMPLETED_SIGNAL] =
|
||||
gtk_signal_new("completed",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedDownloadClass,
|
||||
completed),
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE, 0);
|
||||
moz_embed_download_signals[DOWNLOAD_FAILED_SIGNAL] =
|
||||
gtk_signal_new("error",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedDownloadClass,
|
||||
error),
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE, 0);
|
||||
moz_embed_download_signals[DOWNLOAD_DESTROYED_SIGNAL] =
|
||||
gtk_signal_new("aborted",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedDownloadClass,
|
||||
aborted),
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE, 0);
|
||||
moz_embed_download_signals[DOWNLOAD_PROGRESS_SIGNAL] =
|
||||
gtk_signal_new("progress",
|
||||
GTK_RUN_FIRST,
|
||||
GET_OBJECT_CLASS_TYPE(klass),
|
||||
GTK_SIGNAL_OFFSET(GtkMozEmbedDownloadClass,
|
||||
progress),
|
||||
gtkmozembed_VOID__ULONG_ULONG_ULONG,
|
||||
GTK_TYPE_NONE,
|
||||
3,
|
||||
G_TYPE_ULONG,
|
||||
G_TYPE_ULONG,
|
||||
G_TYPE_ULONG);
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
gtk_object_class_add_signals(object_class, moz_embed_download_signals,
|
||||
DOWNLOAD_LAST_SIGNAL);
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
}
|
||||
static void
|
||||
gtk_moz_embed_download_init(GtkMozEmbedDownload *download)
|
||||
{
|
||||
// this is a placeholder for later in case we need to stash data at
|
||||
// a later data and maintain backwards compatibility.
|
||||
download->data = nsnull;
|
||||
EmbedDownload *priv = new EmbedDownload();
|
||||
download->data = priv;
|
||||
}
|
||||
static void
|
||||
gtk_moz_embed_download_destroy(GtkObject *object)
|
||||
{
|
||||
GtkMozEmbedDownload *embed;
|
||||
EmbedDownload *downloadPrivate;
|
||||
g_return_if_fail(object != NULL);
|
||||
g_return_if_fail(GTK_IS_MOZ_EMBED_DOWNLOAD(object));
|
||||
embed = GTK_MOZ_EMBED_DOWNLOAD(object);
|
||||
downloadPrivate = (EmbedDownload *)embed->data;
|
||||
if (downloadPrivate) {
|
||||
delete downloadPrivate;
|
||||
embed->data = NULL;
|
||||
}
|
||||
}
|
||||
GtkObject *
|
||||
gtk_moz_embed_download_new(void)
|
||||
{
|
||||
GtkObject *instance = (GtkObject *) gtk_type_new (gtk_moz_embed_download_get_type());
|
||||
gtk_moz_embed_download_set_lastest_object (instance);
|
||||
return instance;
|
||||
}
|
||||
GtkObject *
|
||||
gtk_moz_embed_download_get_lastest_object (void)
|
||||
{
|
||||
return latest_download_object;
|
||||
}
|
||||
static void
|
||||
gtk_moz_embed_download_set_lastest_object (GtkObject *obj)
|
||||
{
|
||||
latest_download_object = obj;
|
||||
return ;
|
||||
}
|
||||
void gtk_moz_embed_download_do_command (GtkMozEmbedDownload *item, guint command)
|
||||
{
|
||||
EmbedDownload *download_priv = (EmbedDownload *) item->data;
|
||||
if (!download_priv) return ;
|
||||
if (command == GTK_MOZ_EMBED_DOWNLOAD_CANCEL) {
|
||||
// workaround to avoid crashs if download is 0%.
|
||||
if (download_priv->downloaded_size != -1)
|
||||
download_priv->launcher->Cancel (GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED);
|
||||
download_priv->launcher->SetWebProgressListener (nsnull);
|
||||
} else if (command == GTK_MOZ_EMBED_DOWNLOAD_RESUME) {
|
||||
download_priv->request->Resume ();
|
||||
download_priv->isPaused = FALSE;
|
||||
} else if (command == GTK_MOZ_EMBED_DOWNLOAD_PAUSE) {
|
||||
download_priv->request->Suspend ();
|
||||
download_priv->isPaused = TRUE;
|
||||
} else if (command == GTK_MOZ_EMBED_DOWNLOAD_RELOAD) {
|
||||
if (download_priv->gtkMozEmbedParentWidget) {}
|
||||
}
|
||||
// FIXME: missing GTK_MOZ_EMBED_DOWNLOAD_STORE and GTK_MOZ_EMBED_DOWNLOAD_RESTORE implementation.
|
||||
}
|
||||
gchar * gtk_moz_embed_download_get_file_name (GtkMozEmbedDownload *item)
|
||||
{
|
||||
EmbedDownload *download_priv = (EmbedDownload *) item->data;
|
||||
if (!download_priv) return nsnull;
|
||||
return (gchar *) download_priv->file_name;
|
||||
}
|
||||
gchar * gtk_moz_embed_download_get_url (GtkMozEmbedDownload *item)
|
||||
{
|
||||
EmbedDownload *download_priv = (EmbedDownload *) item->data;
|
||||
if (!download_priv) return nsnull;
|
||||
// FIXME : 'server' is storing the wrong value. See EmbedDownloadMgr.cpp l. 189.
|
||||
return (gchar *) download_priv->server;
|
||||
}
|
||||
glong gtk_moz_embed_download_get_progress (GtkMozEmbedDownload *item)
|
||||
{
|
||||
EmbedDownload *download_priv = (EmbedDownload *) item->data;
|
||||
if (!download_priv) return -1;
|
||||
return (glong) download_priv->downloaded_size;
|
||||
}
|
||||
glong gtk_moz_embed_download_get_file_size (GtkMozEmbedDownload *item)
|
||||
{
|
||||
EmbedDownload *download_priv = (EmbedDownload *) item->data;
|
||||
if (!download_priv) return -1;
|
||||
return (glong) download_priv->file_size;
|
||||
}
|
||||
116
mozilla/embedding/browser/gtk/src/gtkmozembed_download.h
Normal file
116
mozilla/embedding/browser/gtk/src/gtkmozembed_download.h
Normal file
@ -0,0 +1,116 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef gtkmozembed_download_h
|
||||
#define gtkmozembed_download_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#include <stddef.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "nscore.h"
|
||||
#else // MOZILLA_CLIENT
|
||||
#ifndef nscore_h__
|
||||
/* Because this header may be included from files which not part of the mozilla
|
||||
build system, define macros from nscore.h */
|
||||
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
|
||||
#define NS_HIDDEN __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define NS_HIDDEN
|
||||
#endif
|
||||
#define NS_FROZENCALL
|
||||
#define NS_EXPORT_(type) type
|
||||
#define NS_IMPORT_(type) type
|
||||
#endif // nscore_h__
|
||||
#endif // MOZILLA_CLIENT
|
||||
#ifdef XPCOM_GLUE
|
||||
#define GTKMOZEMBED_API(type, name, params) \
|
||||
typedef type (NS_FROZENCALL * name##Type) params; \
|
||||
extern name##Type name NS_HIDDEN;
|
||||
#else // XPCOM_GLUE
|
||||
#ifdef _IMPL_GTKMOZEMBED
|
||||
#define GTKMOZEMBED_API(type, name, params) NS_EXPORT_(type) name params;
|
||||
#else
|
||||
#define GTKMOZEMBED_API(type,name, params) NS_IMPORT_(type) name params;
|
||||
#endif
|
||||
#endif // XPCOM_GLUE
|
||||
#define GTK_TYPE_MOZ_EMBED_DOWNLOAD (gtk_moz_embed_download_get_type())
|
||||
#define GTK_MOZ_EMBED_DOWNLOAD(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED_DOWNLOAD, GtkMozEmbedDownload)
|
||||
#define GTK_MOZ_EMBED_DOWNLOAD_CLASS(klass) GTK_CHECK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED_DOWNLOAD, GtkMozEmbedDownloadClass)
|
||||
#define GTK_IS_MOZ_EMBED_DOWNLOAD(obj) GTK_CHECK_TYPE((obj), GTK_TYPE_MOZ_EMBED_DOWNLOAD)
|
||||
#define GTK_IS_MOZ_EMBED_DOWNLOAD_CLASS(klass) GTK_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED_DOWNLOAD)
|
||||
typedef struct _GtkMozEmbedDownload GtkMozEmbedDownload;
|
||||
typedef struct _GtkMozEmbedDownloadClass GtkMozEmbedDownloadClass;
|
||||
struct _GtkMozEmbedDownload
|
||||
{
|
||||
GtkObject object;
|
||||
void *data;
|
||||
};
|
||||
struct _GtkMozEmbedDownloadClass
|
||||
{
|
||||
GtkObjectClass parent_class;
|
||||
void (*started) (GtkMozEmbedDownload* item, gchar **file_name_with_path);
|
||||
void (*completed) (GtkMozEmbedDownload* item);
|
||||
void (*error) (GtkMozEmbedDownload* item);
|
||||
void (*aborted) (GtkMozEmbedDownload* item);
|
||||
void (*progress) (GtkMozEmbedDownload* item, gulong downloaded_bytes, gulong total_bytes, gdouble kbps);
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_DOWNLOAD_RESUME,
|
||||
GTK_MOZ_EMBED_DOWNLOAD_CANCEL,
|
||||
GTK_MOZ_EMBED_DOWNLOAD_PAUSE,
|
||||
GTK_MOZ_EMBED_DOWNLOAD_RELOAD,
|
||||
GTK_MOZ_EMBED_DOWNLOAD_STORE,
|
||||
GTK_MOZ_EMBED_DOWNLOAD_RESTORE
|
||||
} GtkMozEmbedDownloadActions;
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_download_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkObject *, gtk_moz_embed_download_new, (void))
|
||||
GTKMOZEMBED_API(GtkObject *, gtk_moz_embed_download_get_lastest_object, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_download_do_command , (GtkMozEmbedDownload *item, guint command))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_download_do_command , (GtkMozEmbedDownload *item, guint command))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_download_do_command , (GtkMozEmbedDownload *item, guint command))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_download_do_command , (GtkMozEmbedDownload *item, guint command))
|
||||
GTKMOZEMBED_API(gchar *, gtk_moz_embed_download_get_file_name , (GtkMozEmbedDownload *item))
|
||||
GTKMOZEMBED_API(gchar *, gtk_moz_embed_download_get_url , (GtkMozEmbedDownload *item))
|
||||
GTKMOZEMBED_API(glong , gtk_moz_embed_download_get_progress , (GtkMozEmbedDownload *item))
|
||||
GTKMOZEMBED_API(glong , gtk_moz_embed_download_get_file_size , (GtkMozEmbedDownload *item))
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* gtkmozembed_download_h */
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -40,6 +42,8 @@
|
||||
// XPCOMGlueStartup to glue the gtkmozembed functions.
|
||||
|
||||
#include "gtkmozembed.h"
|
||||
#include "gtkmozembed_common.h"
|
||||
#include "gtkmozembed_download.h"
|
||||
#include "nsXPCOMGlue.h"
|
||||
|
||||
#ifndef XPCOM_GLUE
|
||||
@ -72,7 +76,27 @@
|
||||
GTKF(gtk_moz_embed_set_chrome_mask) \
|
||||
GTKF(gtk_moz_embed_get_chrome_mask) \
|
||||
GTKF(gtk_moz_embed_single_get_type) \
|
||||
GTKF(gtk_moz_embed_single_get)
|
||||
GTKF(gtk_moz_embed_single_get) \
|
||||
GTKF(gtk_moz_embed_get_zoom_level) \
|
||||
GTKF(gtk_moz_embed_set_zoom_level) \
|
||||
GTKF(gtk_moz_embed_load_image) \
|
||||
GTKF(gtk_moz_embed_find_text) \
|
||||
GTKF(gtk_moz_embed_clipboard) \
|
||||
GTKF(gtk_moz_embed_notify_plugins) \
|
||||
GTKF(gtk_moz_embed_download_get_type) \
|
||||
GTKF(gtk_moz_embed_download_new) \
|
||||
GTKF(gtk_moz_embed_common_get_type) \
|
||||
GTKF(gtk_moz_embed_common_new) \
|
||||
GTKF(gtk_moz_embed_common_set_pref) \
|
||||
GTKF(gtk_moz_embed_common_get_pref) \
|
||||
GTKF(gtk_moz_embed_common_save_prefs) \
|
||||
GTKF(gtk_moz_embed_common_remove_passwords) \
|
||||
GTKF(gtk_moz_embed_common_get_history_list) \
|
||||
GTKF(gtk_moz_embed_get_context_info) \
|
||||
GTKF(gtk_moz_embed_get_selection) \
|
||||
GTKF(gtk_moz_embed_get_doc_info) \
|
||||
GTKF(gtk_moz_embed_insert_text) \
|
||||
GTKF(gtk_moz_embed_common_nsx509_to_raw)
|
||||
|
||||
#define GTKF(fname) fname##Type fname;
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -40,6 +42,7 @@
|
||||
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsXPCOM.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct nsModuleComponentInfo;
|
||||
|
||||
@ -50,6 +53,7 @@ extern "C" {
|
||||
GTKMOZEMBED_API(void,
|
||||
gtk_moz_embed_get_nsIWebBrowser, (GtkMozEmbed *embed,
|
||||
nsIWebBrowser **retval))
|
||||
|
||||
GTKMOZEMBED_API(PRUnichar*,
|
||||
gtk_moz_embed_get_title_unichar, (GtkMozEmbed *embed))
|
||||
|
||||
@ -69,6 +73,4 @@ GTKMOZEMBED_API(void,
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* gtkmozembed_internal_h */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* BOOL:STRING (types.txt:1) */
|
||||
/* BOOL:STRING */
|
||||
extern void gtkmozembed_BOOLEAN__STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
@ -15,15 +15,130 @@ extern void gtkmozembed_BOOLEAN__STRING (GClosure *closure,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING gtkmozembed_BOOLEAN__STRING
|
||||
|
||||
/* VOID:STRING,INT,INT (types.txt:2) */
|
||||
extern void gtkmozembed_VOID__STRING_INT_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
/* BOOL:STRING,STRING */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING gtkmozembed_BOOLEAN__STRING_STRING
|
||||
|
||||
/* VOID:INT,UINT (types.txt:3) */
|
||||
/* BOOL:STRING,STRING,POINTER */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING_POINTER gtkmozembed_BOOLEAN__STRING_STRING_POINTER
|
||||
|
||||
/* BOOL:STRING,STRING,POINTER,INT */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING_POINTER_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING_POINTER_INT gtkmozembed_BOOLEAN__STRING_STRING_POINTER_INT
|
||||
|
||||
/* BOOL:STRING,STRING,POINTER,POINTER,STRING,POINTER */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING_POINTER_POINTER_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING_POINTER_POINTER_STRING_POINTER gtkmozembed_BOOLEAN__STRING_STRING_POINTER_POINTER_STRING_POINTER
|
||||
|
||||
/* BOOL:STRING,STRING,POINTER,STRING,POINTER */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING_POINTER_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING_POINTER_STRING_POINTER gtkmozembed_BOOLEAN__STRING_STRING_POINTER_STRING_POINTER
|
||||
|
||||
/* BOOL:STRING,STRING,STRING,POINTER */
|
||||
extern void gtkmozembed_BOOLEAN__STRING_STRING_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__STRING_STRING_STRING_POINTER gtkmozembed_BOOLEAN__STRING_STRING_STRING_POINTER
|
||||
|
||||
/* INT:STRING,INT,INT,INT,INT,INT */
|
||||
extern void gtkmozembed_INT__STRING_INT_INT_INT_INT_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* INT:STRING,STRING,INT,INT,INT,INT */
|
||||
extern void gtkmozembed_INT__STRING_STRING_INT_INT_INT_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* INT:STRING,STRING,UINT,STRING,STRING,STRING,STRING,POINTER */
|
||||
extern void gtkmozembed_INT__STRING_STRING_UINT_STRING_STRING_STRING_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* INT:VOID */
|
||||
extern void gtkmozembed_INT__VOID (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* STRING:STRING,STRING */
|
||||
extern void gtkmozembed_STRING__STRING_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:BOOL */
|
||||
#define gtkmozembed_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN
|
||||
#define gtkmozembed_VOID__BOOL gtkmozembed_VOID__BOOLEAN
|
||||
|
||||
/* VOID:INT,INT,BOOL */
|
||||
extern void gtkmozembed_VOID__INT_INT_BOOLEAN (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_VOID__INT_INT_BOOL gtkmozembed_VOID__INT_INT_BOOLEAN
|
||||
|
||||
/* VOID:INT,STRING */
|
||||
extern void gtkmozembed_VOID__INT_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:INT,STRING,STRING */
|
||||
extern void gtkmozembed_VOID__INT_STRING_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:INT,UINT */
|
||||
extern void gtkmozembed_VOID__INT_UINT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
@ -31,15 +146,7 @@ extern void gtkmozembed_VOID__INT_UINT (GClosure *closure,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,INT,UINT (types.txt:4) */
|
||||
extern void gtkmozembed_VOID__STRING_INT_UINT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:POINTER,INT,POINTER (types.txt:5) */
|
||||
/* VOID:POINTER,INT,POINTER */
|
||||
extern void gtkmozembed_VOID__POINTER_INT_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
@ -47,6 +154,101 @@ extern void gtkmozembed_VOID__POINTER_INT_POINTER (GClosure *closure,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:POINTER,INT,STRING,STRING,STRING,STRING,STRING,BOOLEAN,INT */
|
||||
extern void gtkmozembed_VOID__POINTER_INT_STRING_STRING_STRING_STRING_STRING_BOOLEAN_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:POINTER,STRING,BOOL,BOOL */
|
||||
extern void gtkmozembed_VOID__POINTER_STRING_BOOLEAN_BOOLEAN (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_VOID__POINTER_STRING_BOOL_BOOL gtkmozembed_VOID__POINTER_STRING_BOOLEAN_BOOLEAN
|
||||
|
||||
/* VOID:STRING,INT,INT */
|
||||
extern void gtkmozembed_VOID__STRING_INT_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,INT,UINT */
|
||||
extern void gtkmozembed_VOID__STRING_INT_UINT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,STRING */
|
||||
extern void gtkmozembed_VOID__STRING_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,STRING,POINTER */
|
||||
extern void gtkmozembed_VOID__STRING_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,STRING,STRING,ULONG,INT */
|
||||
extern void gtkmozembed_VOID__STRING_STRING_STRING_ULONG_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:STRING,STRING,STRING,POINTER */
|
||||
extern void gtkmozembed_VOID__STRING_STRING_STRING_POINTER (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:UINT,INT,INT,STRING,STRING,STRING,STRING */
|
||||
extern void gtkmozembed_VOID__UINT_INT_INT_STRING_STRING_STRING_STRING (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* VOID:ULONG,ULONG,ULONG */
|
||||
extern void gtkmozembed_VOID__ULONG_ULONG_ULONG (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* BOOL:POINTER,UINT */
|
||||
extern void gtkmozembed_BOOLEAN__POINTER_UINT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
#define gtkmozembed_BOOL__POINTER_UINT gtkmozembed_BOOLEAN__POINTER_UINT
|
||||
|
||||
/* VOID:POINTER */
|
||||
#define gtkmozembed_VOID__POINTER g_cclosure_marshal_VOID__POINTER
|
||||
|
||||
/* BOOL:STRING,STRING,POINTER */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __gtkmozembed_MARSHAL_H__ */
|
||||
|
||||
31
mozilla/embedding/browser/gtk/src/gtkmozembedmarshal.list
Normal file
31
mozilla/embedding/browser/gtk/src/gtkmozembedmarshal.list
Normal file
@ -0,0 +1,31 @@
|
||||
BOOL:STRING
|
||||
BOOL:STRING,STRING
|
||||
BOOL:STRING,STRING,POINTER
|
||||
BOOL:STRING,STRING,POINTER,INT
|
||||
BOOL:STRING,STRING,POINTER,POINTER,STRING,POINTER
|
||||
BOOL:STRING,STRING,POINTER,STRING,POINTER
|
||||
BOOL:STRING,STRING,STRING,POINTER
|
||||
INT:STRING,INT,INT,INT,INT,INT
|
||||
INT:STRING,STRING,INT,INT,INT,INT
|
||||
INT:STRING,STRING,UINT,STRING,STRING,STRING,STRING,POINTER
|
||||
INT:VOID
|
||||
STRING:STRING,STRING
|
||||
VOID:BOOL
|
||||
VOID:INT,INT,BOOL
|
||||
VOID:INT,STRING
|
||||
VOID:INT,STRING,STRING
|
||||
VOID:INT,UINT
|
||||
VOID:POINTER,INT,POINTER
|
||||
VOID:POINTER,INT,STRING,STRING,STRING,STRING,STRING,BOOLEAN,INT
|
||||
VOID:POINTER,STRING,BOOL,BOOL
|
||||
VOID:STRING,INT,INT
|
||||
VOID:STRING,INT,UINT
|
||||
VOID:STRING,STRING
|
||||
VOID:STRING,STRING,POINTER
|
||||
VOID:STRING,STRING,STRING,ULONG,INT
|
||||
VOID:STRING,STRING,STRING,POINTER
|
||||
VOID:UINT,INT,INT,STRING,STRING,STRING,STRING
|
||||
VOID:ULONG,ULONG,ULONG
|
||||
BOOL:POINTER,UINT
|
||||
VOID:POINTER
|
||||
BOOL:STRING,STRING,POINTER
|
||||
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -76,16 +78,69 @@ enum {
|
||||
DOM_ACTIVATE,
|
||||
DOM_FOCUS_IN,
|
||||
DOM_FOCUS_OUT,
|
||||
ALERT,
|
||||
ALERT_CHECK,
|
||||
CONFIRM,
|
||||
CONFIRM_CHECK,
|
||||
CONFIRM_EX,
|
||||
PROMPT,
|
||||
PROMPT_AUTH,
|
||||
SELECT,
|
||||
DOWNLOAD_REQUEST,
|
||||
DOM_MOUSE_SCROLL,
|
||||
DOM_MOUSE_LONG_PRESS,
|
||||
DOM_FOCUS,
|
||||
DOM_BLUR,
|
||||
UPLOAD_DIALOG,
|
||||
ICON_CHANGED,
|
||||
MAILTO,
|
||||
UNKNOWN_PROTOCOL,
|
||||
EMBED_LAST_SIGNAL
|
||||
};
|
||||
|
||||
// DOM_MOUSE_MOVE,
|
||||
extern guint moz_embed_signals[EMBED_LAST_SIGNAL];
|
||||
|
||||
extern void gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
|
||||
guint aChromeFlags);
|
||||
#if 0
|
||||
enum {
|
||||
COMMON_CERT_DIALOG,
|
||||
COMMON_CERT_PASSWD_DIALOG,
|
||||
COMMON_CERT_DETAILS_DIALOG,
|
||||
COMMON_HISTORY_ADDED,
|
||||
COMMON_ON_SUBMIT_SIGNAL,
|
||||
COMMON_SELECT_MATCH_SIGNAL,
|
||||
COMMON_MODAL_DIALOG,
|
||||
COMMON_LAST_SIGNAL
|
||||
};
|
||||
#endif
|
||||
|
||||
enum {
|
||||
COMMON_CERT_ERROR,
|
||||
COMMON_SELECT_LOGIN,
|
||||
COMMON_REMEMBER_LOGIN,
|
||||
COMMON_ASK_COOKIE,
|
||||
COMMON_LAST_SIGNAL
|
||||
};
|
||||
|
||||
extern guint moz_embed_common_signals[COMMON_LAST_SIGNAL];
|
||||
|
||||
enum
|
||||
{
|
||||
DOWNLOAD_STARTED_SIGNAL,
|
||||
DOWNLOAD_STOPPED_SIGNAL,
|
||||
DOWNLOAD_COMPLETED_SIGNAL,
|
||||
DOWNLOAD_FAILED_SIGNAL,
|
||||
DOWNLOAD_DESTROYED_SIGNAL,
|
||||
DOWNLOAD_PROGRESS_SIGNAL,
|
||||
DOWNLOAD_LAST_SIGNAL
|
||||
};
|
||||
|
||||
extern guint moz_embed_download_signals[DOWNLOAD_LAST_SIGNAL];
|
||||
extern void gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
|
||||
guint aChromeFlags);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* gtkmozembedprivate_h */
|
||||
|
||||
|
||||
79
mozilla/embedding/browser/gtk/src/nsIPassword.idl
Normal file
79
mozilla/embedding/browser/gtk/src/nsIPassword.idl
Normal file
@ -0,0 +1,79 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(CF39C2B0-1E4B-11d5-A549-0010A401EB10)]
|
||||
|
||||
/**
|
||||
* An optional interface for clients wishing to access a
|
||||
* password object
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
interface nsIPassword : nsISupports {
|
||||
|
||||
/**
|
||||
* the name of the host corresponding to the login being saved
|
||||
*
|
||||
* The form of the host depends on how the nsIPassword object was created
|
||||
*
|
||||
* - if it was created as a result of submitting a form to a site, then the
|
||||
* host is the url of the site, as obtained from a call to GetSpec
|
||||
*
|
||||
* - if it was created as a result of another app (e.g., mailnews) calling a
|
||||
* prompt routine such at PromptUsernameAndPassword, then the host is whatever
|
||||
* arbitrary string the app decided to pass in.
|
||||
*
|
||||
* Whatever form it is in, it will be used by the password manager to uniquely
|
||||
* identify the login realm, so that "newsserver:119" is not the same thing as
|
||||
* "newsserver".
|
||||
*/
|
||||
readonly attribute AUTF8String host;
|
||||
|
||||
/**
|
||||
* the user name portion of the login
|
||||
*/
|
||||
readonly attribute AString user;
|
||||
|
||||
/**
|
||||
* the password portion of the login
|
||||
*/
|
||||
readonly attribute AString password;
|
||||
};
|
||||
57
mozilla/embedding/browser/gtk/src/nsIPasswordInternal.idl
Normal file
57
mozilla/embedding/browser/gtk/src/nsIPasswordInternal.idl
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIPassword.idl"
|
||||
|
||||
/**
|
||||
* This interface is supported by password manager entries to expose the
|
||||
* fieldnames passed to nsIPasswordManagerInternal's addUserFull method.
|
||||
*/
|
||||
[scriptable, uuid(2cc35c67-978f-42a9-a958-16e97ad2f4c8)]
|
||||
interface nsIPasswordInternal : nsIPassword
|
||||
{
|
||||
/**
|
||||
* The name of the field that contained the username.
|
||||
*/
|
||||
readonly attribute AString userFieldName;
|
||||
|
||||
/**
|
||||
* The name of the field that contained the password.
|
||||
*/
|
||||
readonly attribute AString passwordFieldName;
|
||||
};
|
||||
@ -1,5 +0,0 @@
|
||||
BOOL:STRING
|
||||
VOID:STRING,INT,INT
|
||||
VOID:INT,UINT
|
||||
VOID:STRING,INT,UINT
|
||||
VOID:POINTER,INT,POINTER
|
||||
Loading…
x
Reference in New Issue
Block a user