mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-24 00:24:14 +00:00
NOT PART OF BUILD - PHOTON ONLY
Adding the PtMozilla widget for the first time. Submited by briane@qnx.com r=kirkj
This commit is contained in:
parent
f3d3748b18
commit
92b71daf01
@ -31,4 +31,8 @@ ifdef MOZ_ENABLE_GTK
|
||||
DIRS += gtk
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
34
embedding/browser/photon/Makefile.in
Normal file
34
embedding/browser/photon/Makefile.in
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# 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 Initial Developer of the Original Code is Christopher
|
||||
# Blizzard. Portions created by Christopher Blizzard are
|
||||
# Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Christopher Blizzard <blizzard@mozilla.org>
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS=src
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
55
embedding/browser/photon/src/Makefile.in
Normal file
55
embedding/browser/photon/src/Makefile.in
Normal file
@ -0,0 +1,55 @@
|
||||
#
|
||||
# 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 Initial Developer of the Original Code is Christopher
|
||||
# Blizzard. Portions created by Christopher Blizzard are
|
||||
# Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Christopher Blizzard <blizzard@mozilla.org>
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = phembedmoz
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
MozEmbedChrome.cpp \
|
||||
MozEmbedStream.cpp \
|
||||
PtMozilla.cpp
|
||||
|
||||
SHARED_LIBRARY_LIBS= \
|
||||
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
PtMozilla.h
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_PH_LDFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(MOZ_PH_CFLAGS)
|
885
embedding/browser/photon/src/MozEmbedChrome.cpp
Normal file
885
embedding/browser/photon/src/MozEmbedChrome.cpp
Normal file
@ -0,0 +1,885 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#include "MozEmbedChrome.h"
|
||||
#include "MozEmbedStream.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
|
||||
// this is a define to make sure that we don't call certain function
|
||||
// before the object has been properly initialized
|
||||
|
||||
#define CHECK_IS_INIT() \
|
||||
PR_BEGIN_MACRO \
|
||||
if (!mIsInitialized) \
|
||||
return NS_ERROR_NOT_INITIALIZED; \
|
||||
PR_END_MACRO
|
||||
|
||||
static PRLogModuleInfo *mozEmbedLm = NULL;
|
||||
|
||||
nsVoidArray *MozEmbedChrome::sBrowsers = NULL;
|
||||
|
||||
// constructor and destructor
|
||||
MozEmbedChrome::MozEmbedChrome()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mOwningWidget = nsnull;
|
||||
mWebBrowser = nsnull;
|
||||
mNewBrowserCB = nsnull;
|
||||
mNewBrowserCBData = nsnull;
|
||||
mDestroyCB = nsnull;
|
||||
mDestroyCBData = nsnull;
|
||||
mVisibilityCB = nsnull;
|
||||
mVisibilityCBData = nsnull;
|
||||
mLinkCB = nsnull;
|
||||
mLinkCBData = nsnull;
|
||||
mJSStatusCB = nsnull;
|
||||
mJSStatusCBData = nsnull;
|
||||
mLocationCB = nsnull;
|
||||
mLocationCBData = nsnull;
|
||||
mTitleCB = nsnull;
|
||||
mTitleCBData = nsnull;
|
||||
mProgressCB = nsnull;
|
||||
mProgressCBData = nsnull;
|
||||
mNetCB = nsnull;
|
||||
mNetCBData = nsnull;
|
||||
mOpenCB = nsnull;
|
||||
mOpenCBData = nsnull;
|
||||
mBounds.x = 0;
|
||||
mBounds.y = 0;
|
||||
mBounds.width = 0;
|
||||
mBounds.height = 0;
|
||||
mVisibility = PR_FALSE;
|
||||
mLinkMessage = NULL;
|
||||
mJSStatus = NULL;
|
||||
mLocation = NULL;
|
||||
mTitle = NULL;
|
||||
mChromeMask = 0;
|
||||
mOffset = 0;
|
||||
mDoingStream = PR_FALSE;
|
||||
if (!mozEmbedLm)
|
||||
mozEmbedLm = PR_NewLogModule("MozEmbedChrome");
|
||||
if (!sBrowsers)
|
||||
sBrowsers = new nsVoidArray();
|
||||
sBrowsers->AppendElement((void *)this);
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::MozEmbedChrome %p\n", this));
|
||||
}
|
||||
|
||||
MozEmbedChrome::~MozEmbedChrome()
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::~MozEmbedChrome %p\n", this));
|
||||
sBrowsers->RemoveElement((void *)this);
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(MozEmbedChrome)
|
||||
NS_IMPL_RELEASE(MozEmbedChrome)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MozEmbedChrome)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPhEmbed)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPhEmbed)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// nsIPhEmbed interface
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::Init(PtWidget_t *aOwningWidget)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::Init\n"));
|
||||
mOwningWidget = aOwningWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetNewBrowserCallback(MozEmbedChromeCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetNewBrowserCallback\n"));
|
||||
mNewBrowserCB = aCallback;
|
||||
mNewBrowserCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetDestroyCallback(MozEmbedDestroyCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetDestroyCallback\n"));
|
||||
mDestroyCB = aCallback;
|
||||
mDestroyCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetVisibilityCallback(MozEmbedVisibilityCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetVisibilityCallback\n"));
|
||||
mVisibilityCB = aCallback;
|
||||
mVisibilityCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetLinkChangeCallback (MozEmbedLinkCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetLinkChangeCallback\n"));
|
||||
mLinkCB = aCallback;
|
||||
mLinkCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetJSStatusChangeCallback (MozEmbedJSStatusCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetJSStatusChangeCallback\n"));
|
||||
mJSStatusCB = aCallback;
|
||||
mJSStatusCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetLocationChangeCallback (MozEmbedLocationCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetLocationChangeCallback\n"));
|
||||
mLocationCB = aCallback;
|
||||
mLocationCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetTitleChangeCallback (MozEmbedTitleCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetTitleChangeCB\n"));
|
||||
mTitleCB = aCallback;
|
||||
mTitleCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetProgressCallback (MozEmbedProgressCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetProgressCallback\n"));
|
||||
mProgressCB = aCallback;
|
||||
mProgressCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetNetCallback (MozEmbedNetCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetNetCallback\n"));
|
||||
mNetCB = aCallback;
|
||||
mNetCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetStartOpenCallback (MozEmbedStartOpenCB *aCallback, void *aData)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetStartOpenCallback\n"));
|
||||
mOpenCB = aCallback;
|
||||
mOpenCBData = aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetLinkMessage (char **retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetLinkMessage\n"));
|
||||
NS_ENSURE_ARG_POINTER(retval);
|
||||
*retval = NULL;
|
||||
if (mLinkMessage)
|
||||
*retval = nsCRT::strdup(mLinkMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetJSStatus (char **retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetJSStatus\n"));
|
||||
NS_ENSURE_ARG_POINTER(retval);
|
||||
*retval = NULL;
|
||||
if (mJSStatus)
|
||||
*retval = nsCRT::strdup(mLinkMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetLocation (char **retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetLocation\n"));
|
||||
NS_ENSURE_ARG_POINTER(retval);
|
||||
*retval = NULL;
|
||||
if (mLocation)
|
||||
*retval = nsCRT::strdup(mLocation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetTitleChar (char **retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetTitleChar\n"));
|
||||
NS_ENSURE_ARG_POINTER(retval);
|
||||
*retval = NULL;
|
||||
if (mTitle)
|
||||
*retval = nsCRT::strdup(mTitle);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::OpenStream (const char *aBaseURI, const char *aContentType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
NS_ENSURE_ARG_POINTER(aContentType);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
MozEmbedStream *newStream = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsCOMPtr<nsIContentViewerContainer> viewerContainer;
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCAutoString docLoaderProgID;
|
||||
nsCAutoString spec(aBaseURI);
|
||||
|
||||
// check to see if we need to close the current stream
|
||||
if (mDoingStream)
|
||||
CloseStream();
|
||||
mDoingStream = PR_TRUE;
|
||||
// create our new stream object
|
||||
newStream = new MozEmbedStream();
|
||||
if (!newStream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
// we own this
|
||||
NS_ADDREF(newStream);
|
||||
// QI it to the right interface
|
||||
mStream = do_QueryInterface(newStream);
|
||||
if (!mStream)
|
||||
return NS_ERROR_FAILURE;
|
||||
// ok, now we're just using it for an nsIInputStream interface so
|
||||
// release our second reference to it.
|
||||
NS_RELEASE(newStream);
|
||||
|
||||
// get our hands on the docShell
|
||||
mWebBrowser->GetDocShell(getter_AddRefs(docShell));
|
||||
if (!docShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// QI that to a content viewer container
|
||||
viewerContainer = do_QueryInterface(docShell);
|
||||
if (!viewerContainer)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// create a new uri object
|
||||
uri = do_CreateInstance(kSimpleURICID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = uri->SetSpec(spec.GetBuffer());
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// create a new load group
|
||||
rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// create a new input stream channel
|
||||
rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri, mStream, aContentType,
|
||||
1024 /* len */);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// set the channel's load group
|
||||
rv = mChannel->SetLoadGroup(mLoadGroup);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// find a document loader for this command plus content type
|
||||
// combination
|
||||
|
||||
docLoaderProgID = NS_DOCUMENT_LOADER_FACTORY_PROGID_PREFIX;
|
||||
docLoaderProgID += "view";
|
||||
docLoaderProgID += "/";
|
||||
docLoaderProgID += aContentType;
|
||||
|
||||
docLoaderFactory = do_CreateInstance(docLoaderProgID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// ok, create an instance of the content viewer for that command and
|
||||
// mime type
|
||||
rv = docLoaderFactory->CreateInstance("view",
|
||||
mChannel,
|
||||
mLoadGroup,
|
||||
aContentType,
|
||||
viewerContainer,
|
||||
nsnull,
|
||||
getter_AddRefs(mStreamListener),
|
||||
getter_AddRefs(contentViewer));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// set the container viewer container for this content view
|
||||
rv = contentViewer->SetContainer(viewerContainer);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// embed this sucker.
|
||||
rv = viewerContainer->Embed(contentViewer, "view", nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// start our request
|
||||
rv = mStreamListener->OnStartRequest(mChannel, NULL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::AppendToStream (const char *aData, int32 aLen)
|
||||
{
|
||||
MozEmbedStream *embedStream = (MozEmbedStream *)mStream.get();
|
||||
nsresult rv;
|
||||
NS_ENSURE_STATE(mDoingStream);
|
||||
rv = embedStream->Append(aData, aLen);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = mStreamListener->OnDataAvailable(mChannel,
|
||||
NULL,
|
||||
mStream,
|
||||
mOffset, /* offset */
|
||||
aLen); /* len */
|
||||
mOffset += aLen;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::CloseStream (void)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_STATE(mDoingStream);
|
||||
mDoingStream = PR_FALSE;
|
||||
rv = mStreamListener->OnStopRequest(mChannel,
|
||||
NULL,
|
||||
NS_OK,
|
||||
NULL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
mStream = nsnull;
|
||||
mLoadGroup = nsnull;
|
||||
mChannel = nsnull;
|
||||
mStreamListener = nsnull;
|
||||
mContentViewer = nsnull;
|
||||
mOffset = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInterfaceRequestor interface
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetInterface\n"));
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIWebBrowserChrome interface
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetJSStatus(const PRUnichar *status)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetJSStatus\n"));
|
||||
nsString jsStatusString(status);
|
||||
mJSStatus = jsStatusString.ToNewCString();
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("js status is %s\n", (const char *)mJSStatus));
|
||||
// let any listeners know that the status has changed
|
||||
if (mJSStatusCB)
|
||||
mJSStatusCB(mJSStatusCBData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetJSDefaultStatus(const PRUnichar *status)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetJSDefaultStatus\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetOverLink(const PRUnichar *link)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetOverLink\n"));
|
||||
nsString linkMessageString(link);
|
||||
mLinkMessage = linkMessageString.ToNewCString();
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("message is %s\n", (const char *)mLinkMessage));
|
||||
// if there are any listeners, let them know about the change
|
||||
if (mLinkCB)
|
||||
mLinkCB(mLinkCBData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetWebBrowser(nsIWebBrowser * *aWebBrowser)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetWebBrowser\n"));
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
||||
*aWebBrowser = mWebBrowser;
|
||||
NS_IF_ADDREF(*aWebBrowser);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetWebBrowser(nsIWebBrowser * aWebBrowser)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetWebBrowser\n"));
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
||||
mWebBrowser = aWebBrowser;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetChromeMask(PRUint32 *aChromeMask)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetChromeMask\n"));
|
||||
NS_ENSURE_ARG_POINTER(aChromeMask);
|
||||
*aChromeMask = mChromeMask;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetChromeMask(PRUint32 aChromeMask)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetChromeMask\n"));
|
||||
mChromeMask = aChromeMask;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetNewBrowser(PRUint32 chromeMask,
|
||||
nsIWebBrowser **_retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetNewBrowser\n"));
|
||||
if (mNewBrowserCB)
|
||||
return mNewBrowserCB(chromeMask, _retval, mNewBrowserCBData);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::FindNamedBrowserItem(const PRUnichar *aName,
|
||||
nsIDocShellTreeItem **_retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::FindNamedBrowserItem\n"));
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = nsnull;
|
||||
|
||||
PRInt32 i = 0;
|
||||
PRInt32 numBrowsers = sBrowsers->Count();
|
||||
|
||||
for (i = 0; i < numBrowsers; i++)
|
||||
{
|
||||
MozEmbedChrome *chrome = (MozEmbedChrome *)sBrowsers->ElementAt(i);
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
NS_ENSURE_SUCCESS(chrome->GetWebBrowser(getter_AddRefs(webBrowser)), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(webBrowser));
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||
|
||||
docShellAsItem->FindItemWithName(aName, NS_STATIC_CAST(nsIWebBrowserChrome *, this), _retval);
|
||||
if (*_retval)
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SizeBrowserTo\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::ShowAsModal(void)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::ShowAsModal\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIURIContentListener
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::OnStartURIOpen\n"));
|
||||
NS_ENSURE_ARG_POINTER(aAbortOpen);
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
char *specString = NULL;
|
||||
nsCAutoString autoString;
|
||||
nsresult rv;
|
||||
|
||||
rv = aURI->GetSpec(&specString);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
autoString = specString;
|
||||
|
||||
if (mOpenCB)
|
||||
{
|
||||
*aAbortOpen = mOpenCB(autoString, mOpenCBData);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetProtocolHandler\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::DoContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, nsIChannel *aOpenedChannel,
|
||||
nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::DoContent\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::IsPreferred(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::IsPreferred\n"));
|
||||
NS_ENSURE_ARG_POINTER(aCanHandleContent);
|
||||
if (aContentType)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("checking content type %s\n", aContentType));
|
||||
if (nsCRT::strcasecmp(aContentType, "text/html") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/xul") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/rdf") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/xml") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/css") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/gif") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/jpeg") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/png") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/tiff") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "application/http-index-format") == 0)
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
}
|
||||
else
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::CanHandleContent\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetLoadCookie(nsISupports * *aLoadCookie)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetLoadCookie\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetLoadCookie\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetParentContentListener(nsIURIContentListener * *aParentContentListener)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetParentContentListener\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetParentContentListener(nsIURIContentListener * aParentContentListener)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetParentContentListener\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIWebProgressListener
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
|
||||
PRInt32 curSelfProgress,
|
||||
PRInt32 maxSelfProgress, PRInt32 curTotalProgress,
|
||||
PRInt32 maxTotalProgress)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::OnProgressChange\n"));
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("curTotalProgress is %d and maxTotalProgress is %d\n",
|
||||
curTotalProgress, maxTotalProgress));
|
||||
if (maxTotalProgress >= 0)
|
||||
{
|
||||
PRUint32 percentage = (curTotalProgress * 100) / maxTotalProgress;
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("%d%% percent\n", percentage));
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("Unknown percent\n"));
|
||||
}
|
||||
|
||||
// call our callback if it's been registered
|
||||
if (mProgressCB)
|
||||
mProgressCB(mProgressCBData, curTotalProgress, maxTotalProgress);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
|
||||
PRInt32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::OnStateChange\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_start)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_start\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_redirecting)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_redirecting\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_negotiating)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_negotiating\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_transferring)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_transferring\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_stop)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_stop\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_is_request)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_is_request\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_is_document)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_is_document\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_is_network)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_is_network\n"));
|
||||
if (aStateFlags & nsIWebProgressListener::flag_is_window)
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("flag_is_window\n"));
|
||||
|
||||
// if we have a callback registered, call it
|
||||
if (mNetCB)
|
||||
mNetCB(mNetCBData, aStateFlags, aStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::OnLocationChange(nsIURI *aLocation)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::OnLocationChange\n"));
|
||||
char *newURIString = NULL;
|
||||
NS_ENSURE_ARG_POINTER(aLocation);
|
||||
aLocation->GetSpec(&newURIString);
|
||||
mLocation = newURIString;
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("new location is %s\n", (const char *)mLocation));
|
||||
// if there are any listeners let them know about the location change
|
||||
if (mLocationCB)
|
||||
mLocationCB(mLocationCBData);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIBaseWindow interface
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::InitWindow(nativeWindow parentNativeWindow,
|
||||
nsIWidget * parentWidget,
|
||||
PRInt32 x, PRInt32 y,
|
||||
PRInt32 cx, PRInt32 cy)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::InitWindow\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::Create(void)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::Create\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::Destroy(void)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::Destory\n"));
|
||||
if (mDestroyCB)
|
||||
mDestroyCB(mDestroyCBData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetPosition(PRInt32 x, PRInt32 y)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetPosition\n"));
|
||||
mBounds.x = x;
|
||||
mBounds.y = y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetPosition(PRInt32 *x, PRInt32 *y)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetPosition\n"));
|
||||
NS_ENSURE_ARG_POINTER(x);
|
||||
NS_ENSURE_ARG_POINTER(y);
|
||||
*x = mBounds.x;
|
||||
*y = mBounds.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetSize\n"));
|
||||
mBounds.width = cx;
|
||||
mBounds.height = cy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetSize(PRInt32 *cx, PRInt32 *cy)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetSize\n"));
|
||||
NS_ENSURE_ARG_POINTER(cx);
|
||||
NS_ENSURE_ARG_POINTER(cy);
|
||||
*cx = mBounds.width;
|
||||
*cy = mBounds.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetPositionAndSize(PRInt32 x, PRInt32 y,
|
||||
PRInt32 cx, PRInt32 cy,
|
||||
PRBool fRepaint)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetPositionAndSize %d %d %d %d\n",
|
||||
x, y, cx, cy));
|
||||
mBounds.x = x;
|
||||
mBounds.y = y;
|
||||
mBounds.width = cx;
|
||||
mBounds.height = cy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetPositionAndSize(PRInt32 *x, PRInt32 *y,
|
||||
PRInt32 *cx, PRInt32 *cy)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetPositionAndSize %d %d %d %d\n",
|
||||
mBounds.x, mBounds.y, mBounds.width, mBounds.height));
|
||||
NS_ENSURE_ARG_POINTER(x);
|
||||
NS_ENSURE_ARG_POINTER(y);
|
||||
NS_ENSURE_ARG_POINTER(cx);
|
||||
NS_ENSURE_ARG_POINTER(cy);
|
||||
*x = mBounds.x;
|
||||
*y = mBounds.y;
|
||||
*cx = mBounds.width;
|
||||
*cy = mBounds.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::Repaint(PRBool force)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedCHrome::Repaint\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetParentWidget(nsIWidget * *aParentWidget)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetParentWidget\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetParentWidget(nsIWidget * aParentWidget)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetParentWidget\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetParentNativeWindow(nativeWindow *aParentNativeWindow)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetParentNativeWindow\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetParentNativeWindow\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetVisibility(PRBool *aVisibility)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetVisibility\n"));
|
||||
NS_ENSURE_ARG_POINTER(aVisibility);
|
||||
*aVisibility = mVisibility;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetVisibility(PRBool aVisibility)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetVisibility for %p\n", this));
|
||||
if (mVisibilityCB)
|
||||
mVisibilityCB(aVisibility, mVisibilityCBData);
|
||||
mVisibility = aVisibility;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetMainWidget(nsIWidget * *aMainWidget)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetMainWidget\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetFocus(void)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetFocus\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::FocusAvailable(nsIBaseWindow *aCurrentFocus,
|
||||
PRBool *aTookFocus)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::FocusAvailable\n"));
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::GetTitle(PRUnichar * *aTitle)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::GetTitle\n"));
|
||||
NS_ENSURE_ARG_POINTER(aTitle);
|
||||
*aTitle = nsnull;
|
||||
if (mTitle)
|
||||
*aTitle = mTitleUnicode.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedChrome::SetTitle(const PRUnichar * aTitle)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::SetTitle\n"));
|
||||
nsString newTitleString(aTitle);
|
||||
mTitleUnicode = aTitle;
|
||||
mTitle = newTitleString.ToNewCString();
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("title is %s\n", (const char *)mTitle));
|
||||
// if there's a callback, call it to let it know that the title has
|
||||
// changed.
|
||||
if (mTitleCB)
|
||||
mTitleCB(mTitleCBData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MozEmbedChrome::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
||||
PRBool aPersistCX, PRBool aPersistCY,
|
||||
PRBool aPersistSizeMode)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MozEmbedChrome::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
|
||||
PRBool* aPersistCX, PRBool* aPersistCY,
|
||||
PRBool* aPersistSizeMode)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
134
embedding/browser/photon/src/MozEmbedChrome.h
Normal file
134
embedding/browser/photon/src/MozEmbedChrome.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#ifndef __MozEmbedChrome_h
|
||||
#define __MozEmbedChrome_h
|
||||
|
||||
// needed for the ever helpful nsCOMPtr
|
||||
#include <nsCOMPtr.h>
|
||||
|
||||
// we will implement these interfaces
|
||||
#include "nsIPhEmbed.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
// utility classes
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class MozEmbedChrome : public nsIPhEmbed,
|
||||
public nsIWebBrowserChrome,
|
||||
public nsIBaseWindow,
|
||||
public nsIURIContentListener,
|
||||
public nsIWebProgressListener,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
|
||||
MozEmbedChrome();
|
||||
virtual ~MozEmbedChrome();
|
||||
|
||||
// nsIPhEmbed
|
||||
|
||||
NS_IMETHOD Init (PtWidget_t *aOwningWidget);
|
||||
NS_IMETHOD SetNewBrowserCallback (MozEmbedChromeCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetDestroyCallback (MozEmbedDestroyCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetVisibilityCallback (MozEmbedVisibilityCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetLinkChangeCallback (MozEmbedLinkCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetJSStatusChangeCallback (MozEmbedJSStatusCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetLocationChangeCallback (MozEmbedLocationCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetTitleChangeCallback (MozEmbedTitleCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetProgressCallback (MozEmbedProgressCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetNetCallback (MozEmbedNetCB *aCallback, void *aData);
|
||||
NS_IMETHOD SetStartOpenCallback (MozEmbedStartOpenCB *aCallback, void *aData);
|
||||
NS_IMETHOD GetLinkMessage (char **retval);
|
||||
NS_IMETHOD GetJSStatus (char **retval);
|
||||
NS_IMETHOD GetLocation (char **retval);
|
||||
NS_IMETHOD GetTitleChar (char **retval);
|
||||
NS_IMETHOD OpenStream (const char *aBaseURI, const char *aContentType);
|
||||
NS_IMETHOD AppendToStream (const char *aData,int32 aLen);
|
||||
NS_IMETHOD CloseStream (void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
NS_DECL_NSIWEBBROWSERCHROME
|
||||
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
|
||||
private:
|
||||
PtWidget_t *mOwningWidget;
|
||||
nsCOMPtr<nsIWebBrowser> mWebBrowser;
|
||||
MozEmbedChromeCB *mNewBrowserCB;
|
||||
void *mNewBrowserCBData;
|
||||
MozEmbedDestroyCB *mDestroyCB;
|
||||
void *mDestroyCBData;
|
||||
MozEmbedVisibilityCB *mVisibilityCB;
|
||||
void *mVisibilityCBData;
|
||||
MozEmbedLinkCB *mLinkCB;
|
||||
void *mLinkCBData;
|
||||
MozEmbedJSStatusCB *mJSStatusCB;
|
||||
void *mJSStatusCBData;
|
||||
MozEmbedLocationCB *mLocationCB;
|
||||
void *mLocationCBData;
|
||||
MozEmbedTitleCB *mTitleCB;
|
||||
void *mTitleCBData;
|
||||
MozEmbedProgressCB *mProgressCB;
|
||||
void *mProgressCBData;
|
||||
MozEmbedNetCB *mNetCB;
|
||||
void *mNetCBData;
|
||||
MozEmbedStartOpenCB *mOpenCB;
|
||||
void *mOpenCBData;
|
||||
nsRect mBounds;
|
||||
PRBool mVisibility;
|
||||
nsXPIDLCString mLinkMessage;
|
||||
nsXPIDLCString mJSStatus;
|
||||
nsXPIDLCString mLocation;
|
||||
nsXPIDLCString mTitle;
|
||||
nsString mTitleUnicode;
|
||||
PRUint32 mChromeMask;
|
||||
static nsVoidArray *sBrowsers;
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<nsIContentViewer> mContentViewer;
|
||||
nsCOMPtr<nsIStreamListener> mStreamListener;
|
||||
PRUint32 mOffset;
|
||||
PRBool mDoingStream;
|
||||
};
|
||||
|
||||
#endif /* __MozEmbedChrome_h */
|
||||
|
149
embedding/browser/photon/src/MozEmbedStream.cpp
Normal file
149
embedding/browser/photon/src/MozEmbedStream.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#include "MozEmbedStream.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
// nsIInputStream interface
|
||||
|
||||
NS_IMPL_ADDREF(MozEmbedStream)
|
||||
NS_IMPL_RELEASE(MozEmbedStream)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MozEmbedStream)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MozEmbedStream::MozEmbedStream()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mLength = 0;
|
||||
mBuffer = 0;
|
||||
}
|
||||
|
||||
MozEmbedStream::~MozEmbedStream()
|
||||
{
|
||||
if (mBuffer)
|
||||
nsMemory::Free(mBuffer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedStream::Available(PRUint32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MozEmbedStream::Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval)
|
||||
{
|
||||
PRUint32 bytesToRead;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aBuf);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = 0;
|
||||
|
||||
// shortcut?
|
||||
if (aCount == 0)
|
||||
return NS_OK;
|
||||
|
||||
// check to see how many bytes we can read
|
||||
if (aCount > mLength)
|
||||
bytesToRead = mLength;
|
||||
else
|
||||
bytesToRead = aCount;
|
||||
|
||||
// copy our data
|
||||
*_retval = bytesToRead;
|
||||
memcpy(aBuf, mBuffer, bytesToRead);
|
||||
|
||||
// see if we can truncate the buffer entirely
|
||||
if (bytesToRead == mBufLen)
|
||||
{
|
||||
mBuffer = nsnull;
|
||||
mLength = 0;
|
||||
mBufLen = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
// truncate it some, then
|
||||
memmove(mBuffer, &mBuffer[bytesToRead], (mLength - bytesToRead));
|
||||
mLength -= bytesToRead;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIBaseStream interface
|
||||
|
||||
NS_IMETHODIMP MozEmbedStream::Close(void)
|
||||
{
|
||||
if (mBuffer)
|
||||
nsMemory::Free(mBuffer);
|
||||
mLength = 0;
|
||||
mBufLen = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MozEmbedStream::Append(const char *aData, PRUint32 aLen)
|
||||
{
|
||||
// shortcut?
|
||||
if (aLen == 0 || aData == NULL)
|
||||
return NS_OK;
|
||||
mLength += aLen;
|
||||
// first time
|
||||
if (!mBuffer)
|
||||
{
|
||||
mBuffer = (char *)nsMemory::Alloc(mLength);
|
||||
mBufLen = mLength;
|
||||
if (!mBuffer)
|
||||
{
|
||||
mLength = 0;
|
||||
mBufLen = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(mBuffer, aData, aLen);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// see if we need to realloc
|
||||
if (mLength > mBufLen)
|
||||
{
|
||||
char *newBuffer;
|
||||
newBuffer = (char *)nsMemory::Realloc(mBuffer, mLength);
|
||||
if (!newBuffer)
|
||||
{
|
||||
mLength = 0;
|
||||
mBufLen = 0;
|
||||
nsMemory::Free(mBuffer);
|
||||
mBuffer = NULL;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mBuffer = newBuffer;
|
||||
mBufLen = mLength;
|
||||
memcpy(&mBuffer[mLength - aLen], aData, aLen);
|
||||
}
|
||||
else
|
||||
// no realloc required and don't have to update mBufLen, just
|
||||
// update
|
||||
memcpy(&mBuffer[mLength - aLen], aData, aLen);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
46
embedding/browser/photon/src/MozEmbedStream.h
Normal file
46
embedding/browser/photon/src/MozEmbedStream.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
class MozEmbedStream : public nsIInputStream
|
||||
{
|
||||
public:
|
||||
|
||||
MozEmbedStream();
|
||||
virtual ~MozEmbedStream();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
// nsIInputStream
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
// nsIBaseStream
|
||||
NS_DECL_NSIBASESTREAM
|
||||
|
||||
NS_METHOD Append(const char *aData, PRUint32 aLen);
|
||||
|
||||
private:
|
||||
|
||||
char * mBuffer;
|
||||
PRUint32 mLength;
|
||||
PRUint32 mBufLen;
|
||||
};
|
381
embedding/browser/photon/src/PtMozilla.cpp
Normal file
381
embedding/browser/photon/src/PtMozilla.cpp
Normal file
@ -0,0 +1,381 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "MozEmbedChrome.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#include <Pt.h>
|
||||
#include "PtMozilla.h"
|
||||
#include <photon/PtProto.h>
|
||||
|
||||
PtWidgetClass_t *PtCreateMozillaClass( void );
|
||||
#ifndef _PHSLIB
|
||||
PtWidgetClassRef_t __PtMozilla = { NULL, PtCreateMozillaClass };
|
||||
PtWidgetClassRef_t *PtMozilla = &__PtMozilla;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
|
||||
static PRBool NS_SetupRegistryCalled = PR_FALSE;
|
||||
static PRBool ThreadQueueSetup = PR_FALSE;
|
||||
|
||||
extern "C" void NS_SetupRegistry();
|
||||
|
||||
|
||||
int
|
||||
mozilla_handle_event_queue(int fd, void *data, unsigned mode)
|
||||
{
|
||||
nsIEventQueue *eventQueue = (nsIEventQueue *)data;
|
||||
eventQueue->ProcessPendingEvents();
|
||||
}
|
||||
|
||||
// connect function
|
||||
static void mozilla_init( PtWidget_t *widget )
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
int rv;
|
||||
char *component_path = NULL;
|
||||
|
||||
// --------- Mozilla related stuff ------------
|
||||
|
||||
#if 0
|
||||
// check to see if NS_SetupRegistry has been called
|
||||
if (!NS_SetupRegistryCalled)
|
||||
{
|
||||
NS_SetupRegistry();
|
||||
NS_SetupRegistryCalled = PR_TRUE;
|
||||
}
|
||||
#else
|
||||
// init our embedding
|
||||
NS_InitEmbedding(component_path);
|
||||
#endif
|
||||
|
||||
// check to see if we have to set up our thread event queue
|
||||
if (!ThreadQueueSetup)
|
||||
{
|
||||
nsIEventQueueService* eventQService;
|
||||
rv = nsServiceManager::GetService(kEventQueueServiceCID, NS_GET_IID(nsIEventQueueService), (nsISupports **)&eventQService);
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
nsIEventQueue *eventQueue;
|
||||
// create the event queue
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue);
|
||||
|
||||
PtAppAddFd(NULL, eventQueue->GetEventQueueSelectFD(), Pt_FD_READ|Pt_FD_NOPOLL, mozilla_handle_event_queue, eventQueue);
|
||||
NS_RELEASE(eventQService);
|
||||
NS_RELEASE(eventQueue);
|
||||
}
|
||||
ThreadQueueSetup = PR_TRUE;
|
||||
}
|
||||
|
||||
PtSuperClassConnect(PtContainer, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
mozilla_embed_handle_title_change(PtWidget_t *widget)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
char *retval = NULL;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaTitleCb_t t;
|
||||
|
||||
if (moz->title_cb)
|
||||
{
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.cbdata = &t;
|
||||
cbinfo.reason = Pt_CB_MOZ_TITLE;
|
||||
cb = moz->title_cb;
|
||||
|
||||
moz->embed_private->embed->GetTitleChar(&retval);
|
||||
t.title = retval;
|
||||
PtInvokeCallbackList(cb, widget, &cbinfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mozilla_embed_handle_location_change(PtWidget_t *widget)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
char *retval = NULL;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaUrlCb_t u;
|
||||
|
||||
if (moz->url_cb)
|
||||
{
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.cbdata = &u;
|
||||
cbinfo.reason = Pt_CB_MOZ_URL;
|
||||
cb = moz->url_cb;
|
||||
|
||||
moz->embed_private->embed->GetLocation(&retval);
|
||||
u.url = retval;
|
||||
PtInvokeCallbackList(cb, widget, &cbinfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mozilla_embed_handle_link_change(PtWidget_t *widget)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
char *retval = NULL;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaStatusCb_t s;
|
||||
|
||||
if (moz->status_cb)
|
||||
{
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.cbdata = &s;
|
||||
cbinfo.reason = Pt_CB_MOZ_STATUS;
|
||||
cb = moz->status_cb;
|
||||
|
||||
moz->embed_private->embed->GetLinkMessage(&retval);
|
||||
s.message = retval;
|
||||
PtInvokeCallbackList(cb, widget, &cbinfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mozilla_embed_handle_progress(PtWidget_t *widget, int32 curprogress, int32 maxprogress)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaProgressCb_t p;
|
||||
|
||||
if (moz->progress_cb)
|
||||
{
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.cbdata = &p;
|
||||
cbinfo.reason = Pt_CB_MOZ_PROGRESS;
|
||||
cb = moz->progress_cb;
|
||||
p.max = maxprogress;
|
||||
p.cur = curprogress;
|
||||
PtInvokeCallbackList(cb, widget, &cbinfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mozilla_embed_handle_net(PtWidget_t *widget,int32 flags, _uint32 status)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
PtCallbackList_t *cb = NULL;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
// if we've got the start flag, emit the signal
|
||||
if ((flags & MOZ_EMBED_FLAG_IS_NETWORK) && (flags & MOZ_EMBED_FLAG_START))
|
||||
{
|
||||
if (moz->start_cb)
|
||||
{
|
||||
cbinfo.reason = Pt_CB_MOZ_START;
|
||||
cb = moz->start_cb;
|
||||
}
|
||||
fprintf(stderr, "start\n");
|
||||
}
|
||||
// and for stop, too
|
||||
if ((flags & MOZ_EMBED_FLAG_IS_NETWORK) && (flags & MOZ_EMBED_FLAG_STOP))
|
||||
{
|
||||
if (moz->complete_cb)
|
||||
{
|
||||
cbinfo.reason = Pt_CB_MOZ_COMPLETE;
|
||||
cb = moz->complete_cb;
|
||||
}
|
||||
fprintf(stderr, "stop\n");
|
||||
}
|
||||
fprintf(stderr, "other %d\n", flags);
|
||||
if (cb)
|
||||
PtInvokeCallbackList(cb, widget, &cbinfo);
|
||||
}
|
||||
|
||||
static void mozilla_defaults( PtWidget_t *widget )
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
PtBasicWidget_t *basic = (PtBasicWidget_t *)widget;
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
||||
nsresult rv;
|
||||
char *component_path = NULL;
|
||||
|
||||
rv = NS_InitEmbedding(component_path);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
// set up the thread event queue
|
||||
nsIEventQueueService* eventQService;
|
||||
rv = nsServiceManager::GetService(kEventQueueServiceCID, NS_GET_IID(nsIEventQueueService), (nsISupports **)&eventQService);
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
// get our hands on the thread event queue
|
||||
nsIEventQueue *eventQueue;
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
PtAppAddFd(NULL, eventQueue->GetEventQueueSelectFD(), Pt_FD_READ|Pt_FD_NOPOLL, mozilla_handle_event_queue, eventQueue);
|
||||
NS_RELEASE(eventQService);
|
||||
NS_RELEASE(eventQueue);
|
||||
}
|
||||
|
||||
basic->flags = Pt_ALL_OUTLINES | Pt_ALL_BEVELS | Pt_FLAT_FILL;
|
||||
widget->resize_flags &= ~Pt_RESIZE_XY_BITS; // fixed size.
|
||||
widget->anchor_flags = Pt_TOP_ANCHORED_TOP | Pt_LEFT_ANCHORED_LEFT | \
|
||||
Pt_BOTTOM_ANCHORED_TOP | Pt_RIGHT_ANCHORED_LEFT | Pt_ANCHORS_INVALID;
|
||||
|
||||
strcpy(moz->url, "www.mozilla.org");
|
||||
moz->embed_private = new MozEmbedPrivate();
|
||||
// create an nsIWebBrowser object
|
||||
moz->embed_private->webBrowser = do_CreateInstance(NS_WEBBROWSER_PROGID);
|
||||
// create our glue widget
|
||||
moz->chrome = new MozEmbedChrome();
|
||||
moz->embed_private->embed = do_QueryInterface((nsISupports *)(nsIPhEmbed *) moz->chrome);
|
||||
|
||||
// get our hands on the browser chrome
|
||||
browserChrome = do_QueryInterface(moz->embed_private->embed);
|
||||
// set the toplevel window
|
||||
moz->embed_private->webBrowser->SetTopLevelWindow(browserChrome);
|
||||
// set the widget as the owner of the object
|
||||
moz->embed_private->embed->Init(widget);
|
||||
|
||||
// so the embedding widget can find it's owning nsIWebBrowser object
|
||||
browserChrome->SetWebBrowser(moz->embed_private->webBrowser);
|
||||
|
||||
// track the window changes
|
||||
moz->embed_private->embed->SetLinkChangeCallback((void (*)(void *))mozilla_embed_handle_link_change, widget);
|
||||
moz->embed_private->embed->SetTitleChangeCallback((void (*)(void *))mozilla_embed_handle_title_change, widget);
|
||||
moz->embed_private->embed->SetProgressCallback((void (*)(void *, int, int))mozilla_embed_handle_progress, widget);
|
||||
moz->embed_private->embed->SetNetCallback((void (*)(void *, int, uint))mozilla_embed_handle_net, widget);
|
||||
moz->embed_private->embed->SetLocationChangeCallback((void (*)(void *))mozilla_embed_handle_location_change, widget);
|
||||
|
||||
// get our hands on a copy of the nsIWebNavigation interface for later
|
||||
moz->embed_private->navigation = do_QueryInterface(moz->embed_private->webBrowser);
|
||||
|
||||
browserChrome->SetChromeMask(1);
|
||||
}
|
||||
|
||||
void
|
||||
mozilla_embed_load_url(PtWidget_t *widget, const char *url)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
nsString URLString;
|
||||
|
||||
URLString.AssignWithConversion(url);
|
||||
moz->embed_private->navigation->LoadURI(URLString.GetUnicode());
|
||||
}
|
||||
|
||||
// realized function
|
||||
static void mozilla_realized( PtWidget_t *widget )
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
nsCOMPtr<nsIURIContentListener> uriListener;
|
||||
nsCOMPtr<nsIBaseWindow> webBrowserBaseWindow;
|
||||
PRBool visibility;
|
||||
|
||||
PtSuperClassRealized(PtContainer, widget);
|
||||
|
||||
// init our window
|
||||
webBrowserBaseWindow = do_QueryInterface(moz->embed_private->webBrowser);
|
||||
if (!webBrowserBaseWindow)
|
||||
printf("no webBrowserBaseWindow\n");
|
||||
webBrowserBaseWindow->InitWindow(widget, NULL, 0, 0, widget->area.size.w, widget->area.size.h);
|
||||
webBrowserBaseWindow->Create();
|
||||
webBrowserBaseWindow->GetVisibility(&visibility);
|
||||
// set our webBrowser object as the content listener object
|
||||
uriListener = do_QueryInterface(moz->embed_private->embed);
|
||||
if (!uriListener)
|
||||
printf("no uriListener\n");
|
||||
moz->embed_private->webBrowser->SetParentURIContentListener(uriListener);
|
||||
|
||||
// show it
|
||||
webBrowserBaseWindow->SetVisibility(PR_TRUE);
|
||||
|
||||
// If an initial url was stored, load it
|
||||
if (moz->url[0])
|
||||
mozilla_embed_load_url(widget, moz->url);
|
||||
}
|
||||
|
||||
// unrealized function
|
||||
static void mozilla_unrealized( PtWidget_t *widget )
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
}
|
||||
|
||||
static void mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;
|
||||
|
||||
switch( argt->type )
|
||||
{
|
||||
case Pt_ARG_MOZ_GET_URL:
|
||||
{
|
||||
nsString URLString;
|
||||
char *url = (char *)argt->value;
|
||||
URLString.AssignWithConversion(url);
|
||||
moz->embed_private->navigation->LoadURI(URLString.GetUnicode());
|
||||
break;
|
||||
}
|
||||
case Pt_ARG_MOZ_NAVIGATE_PAGE:
|
||||
if (argt->len == WWW_DIRECTION_FWD)
|
||||
moz->embed_private->navigation->GoForward();
|
||||
else
|
||||
moz->embed_private->navigation->GoBack();
|
||||
break;
|
||||
case Pt_ARG_MOZ_STOP:
|
||||
moz->embed_private->navigation->Stop();
|
||||
break;
|
||||
case Pt_ARG_MOZ_RELOAD:
|
||||
moz->embed_private->navigation->Reload(0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// PtMozilla class creation function
|
||||
PtWidgetClass_t *PtCreateMozillaClass( void )
|
||||
{
|
||||
static const PtResourceRec_t resources[] =
|
||||
{
|
||||
{ Pt_ARG_MOZ_GET_URL, mozilla_modify, Pt_QUERY_PREVENT },
|
||||
{ Pt_ARG_MOZ_NAVIGATE_PAGE, mozilla_modify, Pt_QUERY_PREVENT },
|
||||
{ Pt_ARG_MOZ_RELOAD, mozilla_modify, Pt_QUERY_PREVENT },
|
||||
{ Pt_ARG_MOZ_STOP, mozilla_modify, Pt_QUERY_PREVENT },
|
||||
{ Pt_CB_MOZ_STATUS, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, status_cb) },
|
||||
{ Pt_CB_MOZ_PROGRESS, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, progress_cb) },
|
||||
{ Pt_CB_MOZ_TITLE, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, title_cb) },
|
||||
{ Pt_CB_MOZ_START, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, start_cb) },
|
||||
{ Pt_CB_MOZ_COMPLETE, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, complete_cb) },
|
||||
{ Pt_CB_MOZ_URL, NULL, NULL, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t, url_cb) },
|
||||
};
|
||||
|
||||
static const PtArg_t args[] =
|
||||
{
|
||||
{ Pt_SET_VERSION, 200},
|
||||
{ Pt_SET_STATE_LEN, sizeof( PtMozillaWidget_t ) },
|
||||
//{ Pt_SET_CONNECT_F, (long)mozilla_init },
|
||||
{ Pt_SET_DFLTS_F, (long)mozilla_defaults },
|
||||
{ Pt_SET_REALIZED_F, (long)mozilla_realized },
|
||||
{ Pt_SET_UNREALIZE_F, (long)mozilla_unrealized },
|
||||
{ Pt_SET_FLAGS, Pt_RECTANGULAR, Pt_RECTANGULAR },
|
||||
{ Pt_SET_RESOURCES, (long) resources },
|
||||
{ Pt_SET_NUM_RESOURCES, sizeof( resources )/sizeof( resources[0] ) },
|
||||
{ Pt_SET_DESCRIPTION, (long) "PtMozilla" },
|
||||
};
|
||||
|
||||
return( PtMozilla->wclass = PtCreateWidgetClass(
|
||||
PtContainer, 0, sizeof( args )/sizeof( args[0] ), args ) );
|
||||
}
|
122
embedding/browser/photon/src/PtMozilla.h
Normal file
122
embedding/browser/photon/src/PtMozilla.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* PtWebClient.h
|
||||
* Header file for the PtWebClient widget class
|
||||
*
|
||||
* Copyright by QNX Software Systems Limited 1996. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __PT_MOZILLA_H_INCLUDED
|
||||
#define __PT_MOZILLA_H_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "nsString.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "MozEmbedChrome.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PtMozilla public
|
||||
*/
|
||||
|
||||
extern PtWidgetClassRef_t *PtMozilla;
|
||||
|
||||
enum { MOZ_EMBED_FLAG_START = 1,
|
||||
MOZ_EMBED_FLAG_REDIRECTING = 2,
|
||||
MOZ_EMBED_FLAG_TRANSFERRING = 4,
|
||||
MOZ_EMBED_FLAG_NEGOTIATING = 8,
|
||||
MOZ_EMBED_FLAG_STOP = 16,
|
||||
|
||||
MOZ_EMBED_FLAG_IS_REQUEST = 65536,
|
||||
MOZ_EMBED_FLAG_IS_DOCUMENT = 131072,
|
||||
MOZ_EMBED_FLAG_IS_NETWORK = 262144,
|
||||
MOZ_EMBED_FLAG_IS_WINDOW = 524288 };
|
||||
|
||||
/* Resources */
|
||||
|
||||
#define Pt_ARG_MOZ_GET_URL Pt_RESOURCE( Pt_USER(10), 0 )
|
||||
#define Pt_ARG_MOZ_NAVIGATE_PAGE Pt_RESOURCE( Pt_USER(10), 1 )
|
||||
#define Pt_ARG_MOZ_RELOAD Pt_RESOURCE( Pt_USER(10), 2 )
|
||||
#define Pt_ARG_MOZ_STOP Pt_RESOURCE( Pt_USER(10), 3 )
|
||||
#define Pt_CB_MOZ_STATUS Pt_RESOURCE( Pt_USER(10), 4 )
|
||||
#define Pt_CB_MOZ_TITLE Pt_RESOURCE( Pt_USER(10), 5 )
|
||||
#define Pt_CB_MOZ_PROGRESS Pt_RESOURCE( Pt_USER(10), 6 )
|
||||
#define Pt_CB_MOZ_START Pt_RESOURCE( Pt_USER(10), 7 )
|
||||
#define Pt_CB_MOZ_COMPLETE Pt_RESOURCE( Pt_USER(10), 8 )
|
||||
#define Pt_CB_MOZ_URL Pt_RESOURCE( Pt_USER(10), 9 )
|
||||
|
||||
#define MAX_URL_LENGTH 1024
|
||||
|
||||
#define WWW_DIRECTION_FWD 1
|
||||
#define WWW_DIRECTION_BACK 2
|
||||
|
||||
typedef struct mozilla_progress_t
|
||||
{
|
||||
int32 cur;
|
||||
int32 max;
|
||||
} PtMozillaProgressCb_t;
|
||||
|
||||
typedef struct mozilla_title_t
|
||||
{
|
||||
char *title;
|
||||
} PtMozillaTitleCb_t;
|
||||
|
||||
typedef struct mozilla_url_t
|
||||
{
|
||||
char *url;
|
||||
} PtMozillaUrlCb_t;
|
||||
|
||||
typedef struct mozilla_status_t
|
||||
{
|
||||
char *message;
|
||||
} PtMozillaStatusCb_t;
|
||||
|
||||
class MozEmbedPrivate
|
||||
{
|
||||
public:
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
nsCOMPtr<nsIWebNavigation> navigation;
|
||||
nsCOMPtr<nsIPhEmbed> embed;
|
||||
nsCString mInitialURL;
|
||||
};
|
||||
|
||||
typedef struct Pt_mozilla_client_widget
|
||||
{
|
||||
PtContainerWidget_t container;
|
||||
char url[MAX_URL_LENGTH];
|
||||
MozEmbedPrivate *embed_private;
|
||||
MozEmbedChrome *chrome;
|
||||
PtCallbackList_t *title_cb;
|
||||
PtCallbackList_t *status_cb;
|
||||
PtCallbackList_t *progress_cb;
|
||||
PtCallbackList_t *start_cb;
|
||||
PtCallbackList_t *complete_cb;
|
||||
PtCallbackList_t *url_cb;
|
||||
} PtMozillaWidget_t;
|
||||
|
||||
/* Widget union */
|
||||
typedef union Pt_mozilla_union
|
||||
{
|
||||
PtWidget_t core;
|
||||
PtBasicWidget_t basic;
|
||||
PtContainerWidget_t cntnr;
|
||||
PtMozillaWidget_t moz;
|
||||
} PtMozillaUnion_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
72
embedding/browser/photon/src/nsIPhEmbed.h
Normal file
72
embedding/browser/photon/src/nsIPhEmbed.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#ifndef __nsIPhEmbed_h__
|
||||
#define __nsIPhEmbed_h__
|
||||
|
||||
#include <Pt.h>
|
||||
#include "nsIWebBrowser.h"
|
||||
|
||||
#define NS_IGTKEMBED_IID_STR "ebe19ea4-1dd1-11b2-bc20-8e8105516b2f"
|
||||
|
||||
#define NS_IGTKEMBED_IID \
|
||||
{0xebe19ea4, 0x1dd1, 0x11b2, \
|
||||
{ 0xbc, 0x20, 0x8e, 0x81, 0x05, 0x51, 0x6b, 0x2f }}
|
||||
|
||||
typedef nsresult (MozEmbedChromeCB) (PRUint32 chromeMask, nsIWebBrowser **_retval, void *aData);
|
||||
typedef void (MozEmbedDestroyCB) (void *aData);
|
||||
typedef void (MozEmbedVisibilityCB) (PRBool aVisibility, void *aData);
|
||||
typedef void (MozEmbedLinkCB) (void *aData);
|
||||
typedef void (MozEmbedJSStatusCB) (void *aData);
|
||||
typedef void (MozEmbedLocationCB) (void *aData);
|
||||
typedef void (MozEmbedTitleCB) (void *aData);
|
||||
typedef void (MozEmbedProgressCB) (void *aData, PRInt32 aProgressTotal,
|
||||
PRInt32 aProgressCurrent);
|
||||
typedef void (MozEmbedNetCB) (void *aData, PRInt32 aFlags, nsresult aStatus);
|
||||
typedef PRBool (MozEmbedStartOpenCB) (const char *aURI, void *aData);
|
||||
|
||||
class nsIPhEmbed : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGTKEMBED_IID)
|
||||
|
||||
NS_IMETHOD Init (PtWidget_t *aOwningWidget) = 0;
|
||||
NS_IMETHOD SetNewBrowserCallback (MozEmbedChromeCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetDestroyCallback (MozEmbedDestroyCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetVisibilityCallback (MozEmbedVisibilityCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetLinkChangeCallback (MozEmbedLinkCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetJSStatusChangeCallback (MozEmbedJSStatusCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetLocationChangeCallback (MozEmbedLocationCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetTitleChangeCallback (MozEmbedTitleCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetProgressCallback (MozEmbedProgressCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetNetCallback (MozEmbedNetCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD SetStartOpenCallback (MozEmbedStartOpenCB *aCallback, void *aData) = 0;
|
||||
NS_IMETHOD GetLinkMessage (char **retval) = 0;
|
||||
NS_IMETHOD GetJSStatus (char **retval) = 0;
|
||||
NS_IMETHOD GetLocation (char **retval) = 0;
|
||||
NS_IMETHOD GetTitleChar (char **retval) = 0;
|
||||
NS_IMETHOD OpenStream (const char *aBaseURI, const char *aContentType) = 0;
|
||||
NS_IMETHOD AppendToStream (const char *aData, int32 aLen) = 0;
|
||||
NS_IMETHOD CloseStream (void) = 0;
|
||||
};
|
||||
|
||||
#endif /* __nsIPhEmbed_h__ */
|
42
embedding/browser/photon/tests/Makefile.in
Normal file
42
embedding/browser/photon/tests/Makefile.in
Normal file
@ -0,0 +1,42 @@
|
||||
#
|
||||
# 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 Initial Developer of the Original Code is Christopher
|
||||
# Blizzard. Portions created by Christopher Blizzard are
|
||||
# Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Christopher Blizzard <blizzard@mozilla.org>
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
CPPSRCS = \
|
||||
TestPhEmbed.cpp
|
||||
|
||||
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=)
|
||||
|
||||
LIBS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-lphembedmoz \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
|
150
embedding/browser/photon/tests/TestPhEmbed.cpp
Normal file
150
embedding/browser/photon/tests/TestPhEmbed.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "MozEmbedChrome.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "prlog.h"
|
||||
|
||||
#include <Pt.h>
|
||||
#include "PtMozilla.h"
|
||||
#include <string.h>
|
||||
|
||||
PtWidget_t *window, *back, *forward, *stop, *web, *reload;
|
||||
|
||||
int reload_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
||||
{
|
||||
PtArg_t args[1];
|
||||
PtSetArg(&args[0], Pt_ARG_MOZ_RELOAD, 0, 0);
|
||||
PtSetResources(web, 1, args);
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
int stop_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
||||
{
|
||||
PtArg_t args[1];
|
||||
PtSetArg(&args[0], Pt_ARG_MOZ_STOP, 0, 0);
|
||||
PtSetResources(web, 1, args);
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
int back_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
||||
{
|
||||
PtArg_t args[1];
|
||||
PtSetArg(&args[0], Pt_ARG_MOZ_NAVIGATE_PAGE, WWW_DIRECTION_BACK, 0);
|
||||
PtSetResources(web, 1, args);
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
int forward_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
||||
{
|
||||
PtArg_t args[1];
|
||||
PtSetArg(&args[0], Pt_ARG_MOZ_NAVIGATE_PAGE, WWW_DIRECTION_FWD, 0);
|
||||
PtSetResources(web, 1, args);
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
int load_url_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
||||
{
|
||||
PtTextCallback_t *tcb = (PtTextCallback_t *)cbinfo->cbdata;
|
||||
PtArg_t args[1];
|
||||
|
||||
PtSetArg(&args[0], Pt_ARG_MOZ_GET_URL, tcb->text, 0);
|
||||
PtSetResources(web, 1, args);
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
PRLogModuleInfo *PhWidLog;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int n = 0;
|
||||
PtArg_t args[10];
|
||||
PhDim_t win_dim = {700, 700};
|
||||
PhArea_t area = {{0, 0}, {70, 25}};
|
||||
|
||||
if (!PhWidLog)
|
||||
{
|
||||
PhWidLog = PR_NewLogModule("PhWidLog");
|
||||
}
|
||||
|
||||
PtSetArg(&args[n++], Pt_ARG_TITLE, "PtMozilla Test\n", 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_DIM, &win_dim, 0);
|
||||
window = PtAppInit(NULL, NULL, NULL, n, args);
|
||||
|
||||
n = 0;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Back", 0);
|
||||
back = PtCreateWidget(PtButton, window, n, args);
|
||||
PtAddCallback(back, Pt_CB_ACTIVATE, back_cb, NULL);
|
||||
|
||||
n = 0;
|
||||
area.pos.x += 71;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Forward", 0);
|
||||
forward = PtCreateWidget(PtButton, window, n, args);
|
||||
PtAddCallback(forward, Pt_CB_ACTIVATE, forward_cb, NULL);
|
||||
|
||||
n = 0;
|
||||
area.pos.x += 71;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Reload", 0);
|
||||
reload = PtCreateWidget(PtButton, window, n, args);
|
||||
PtAddCallback(reload, Pt_CB_ACTIVATE, reload_cb, NULL);
|
||||
|
||||
n = 0;
|
||||
area.pos.x += 71;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Stop", 0);
|
||||
stop = PtCreateWidget(PtButton, window, n, args);
|
||||
PtAddCallback(stop, Pt_CB_ACTIVATE, stop_cb, NULL);
|
||||
|
||||
n = 0;
|
||||
area.pos.x += 71;
|
||||
area.size.w = win_dim.w - area.pos.x - 2;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
stop = PtCreateWidget(PtText, window, n, args);
|
||||
PtAddCallback(stop, Pt_CB_ACTIVATE, load_url_cb, NULL);
|
||||
|
||||
n = 0;
|
||||
area.pos.y += area.size.h + 2;
|
||||
area.pos.x = 0;
|
||||
area.size.w = win_dim.w;
|
||||
area.size.h = win_dim.h - area.pos.y;
|
||||
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
||||
web = PtCreateWidget(PtMozilla, window, n, args);
|
||||
|
||||
PtRealizeWidget(window);
|
||||
|
||||
PtMainLoop();
|
||||
}
|
Loading…
Reference in New Issue
Block a user