diff --git a/embedding/browser/photon/src/EmbedContentListener.cpp b/embedding/browser/photon/src/EmbedContentListener.cpp index 771eb4febab0..fbe2382ccad8 100644 --- a/embedding/browser/photon/src/EmbedContentListener.cpp +++ b/embedding/browser/photon/src/EmbedContentListener.cpp @@ -58,6 +58,7 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI, PtCallbackList_t *cb = NULL; PtCallbackInfo_t cbinfo; PtMozillaUrlCb_t url; + nsCAutoString specString; if (!moz->open_cb) return NS_OK; @@ -66,7 +67,9 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI, cbinfo.cbdata = &url; cbinfo.reason = Pt_CB_MOZ_OPEN; cb = moz->open_cb; - aURI->GetSpec(&(url.url)); + + aURI->GetSpec(specString); + url.url = (char *) specString.get(); if (PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo) == Pt_END) { diff --git a/embedding/browser/photon/src/EmbedPrivate.cpp b/embedding/browser/photon/src/EmbedPrivate.cpp index 5a3bfd36d611..92acdde207ff 100644 --- a/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/embedding/browser/photon/src/EmbedPrivate.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "nsIWebBrowserPrint.h" #include "nsIClipboardCommands.h" #include "docshell/nsCDefaultURIFixup.h" @@ -64,6 +65,7 @@ // for profiles #include +#include "nsIWebBrowserPrint.h" #include "nsIPrintOptions.h" // all of our local includes @@ -208,6 +210,11 @@ EmbedPrivate::Setup() nsCOMPtr webBrowser; mWindow->GetWebBrowser(getter_AddRefs(webBrowser)); + // Configure what the web browser can and cannot do + PRBool aAllowPlugins = PR_TRUE; + nsCOMPtr webBrowserAsSetup(do_QueryInterface(webBrowser)); + webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, aAllowPlugins); + // get a handle on the navigation object mNavigation = do_QueryInterface(webBrowser); @@ -234,9 +241,9 @@ EmbedPrivate::Setup() uriListener = do_QueryInterface(mContentListenerGuard); webBrowser->SetParentURIContentListener(uriListener); - nsCOMPtr print(do_GetInterface(webBrowser)); + nsCOMPtr print(do_GetInterface(webBrowser)); if (print) - print->GetPrintSettings(getter_AddRefs(m_PrintSettings)); + print->GetNewPrintSettings(getter_AddRefs(m_PrintSettings)); return NS_OK; } @@ -521,11 +528,12 @@ EmbedPrivate::Clear() void EmbedPrivate::Print(PpPrintContext_t *pc) { - nsCOMPtr print = do_GetInterface(mWindow->mWebBrowser); - if (print) { - m_PrintSettings->SetEndPageRange((PRInt32) pc); - print->Print(m_PrintSettings, mPrint); - } + nsCOMPtr window; + mWindow->mWebBrowser->GetContentDOMWindow(getter_AddRefs(window)); + nsCOMPtr print( do_GetInterface( mWindow->mWebBrowser ) ); + + m_PrintSettings->SetEndPageRange((PRInt32) pc); + print->Print(m_PrintSettings, mPrint); } nsresult diff --git a/embedding/browser/photon/src/EmbedProgress.cpp b/embedding/browser/photon/src/EmbedProgress.cpp index cf9d224e73ba..5c9a80c5a779 100644 --- a/embedding/browser/photon/src/EmbedProgress.cpp +++ b/embedding/browser/photon/src/EmbedProgress.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "nsGfxCIID.h" #include "EmbedWindow.h" @@ -75,11 +76,13 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress, PtMozillaWidget_t *moz = (PtMozillaWidget_t *) mOwner->mOwningWidget; PtCallbackList_t *cb = NULL; PtCallbackInfo_t cbinfo; - PRUnichar *url; PtMozillaNetStateCb_t state; - aRequest->GetName( &url ); - nsString surl( url ); + // get the uri for this request + nsXPIDLCString uriString; + RequestToURIString(aRequest, getter_Copies(uriString)); + nsString tmpString; + tmpString.AssignWithConversion(uriString); if( ( aStateFlags & STATE_IS_NETWORK ) && NS_FAILED( aStatus ) ) { @@ -92,10 +95,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress, cbinfo.cbdata = &cbw; memset( &cbw, 0, sizeof( PtWebErrorCallback_t ) ); - char *s = ToNewCString(surl); - strcpy( cbw.url, s ); - free( s ); - + strcpy(cbw.url, (const char *)uriString); cbw.type = WWW_ERROR_TOPVIEW; switch( aStatus ) @@ -183,9 +183,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress, cbinfo.reason = Pt_CB_MOZ_COMPLETE; cbinfo.cbdata = &cbcomplete; memset( &cbcomplete, 0, sizeof( PtWebCompleteCallback_t ) ); - char *s = ToNewCString(surl); - strcpy( cbcomplete.url, s ); - free( s ); + strcpy(cbcomplete.url, (const char *)uriString); if( ( cb = moz->complete_cb ) ) PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo); @@ -197,7 +195,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress, cbinfo.cbdata = &state; state.flags = aStateFlags; state.status = aStatus; - state.url = (char *)ToNewCString(surl); + state.url = (const char *)uriString; char *statusMessage = ""; PRInt32 flags = aStateFlags; @@ -270,10 +268,10 @@ EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress, PtCallbackList_t *cb = NULL; PtCallbackInfo_t cbinfo; PtMozillaUrlCb_t url; - char *uri; + nsCAutoString newURI; - aLocation->GetSpec(&uri); - mOwner->SetURI(uri); + aLocation->GetSpec(newURI); + mOwner->SetURI(newURI.get()); if (!moz->url_cb) return NS_OK; @@ -281,7 +279,8 @@ EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress, memset(&cbinfo, 0, sizeof(cbinfo)); cbinfo.cbdata = &url; cbinfo.reason = Pt_CB_MOZ_URL; - aLocation->GetSpec(&(url.url)); + url.url = (char *) newURI.get(); +// aLocation->GetSpec(&(url.url)); cb = moz->url_cb; PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo); @@ -330,21 +329,19 @@ EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress, void EmbedProgress::RequestToURIString(nsIRequest *aRequest, char **aString) { - // is it a channel - nsCOMPtr channel; - channel = do_QueryInterface(aRequest); - if (!channel) - return; - - nsCOMPtr uri; - channel->GetURI(getter_AddRefs(uri)); - if (!uri) - return; - - nsXPIDLCString uriString; - uri->GetSpec(getter_Copies(uriString)); - if (!uriString) - return; + // is it a channel + nsCOMPtr channel; + channel = do_QueryInterface(aRequest); + if (!channel) + return; - *aString = nsCRT::strdup((const char *)uriString); + nsCOMPtr uri; + channel->GetURI(getter_AddRefs(uri)); + if (!uri) + return; + + nsCAutoString uriString; + uri->GetSpec(uriString); + + *aString = strdup(uriString.get()); } diff --git a/embedding/browser/photon/src/EmbedStream.cpp b/embedding/browser/photon/src/EmbedStream.cpp index 0307470706c1..38a46b6a4b4a 100644 --- a/embedding/browser/photon/src/EmbedStream.cpp +++ b/embedding/browser/photon/src/EmbedStream.cpp @@ -17,7 +17,6 @@ * * Contributor(s): * Christopher Blizzard - * Brian Edmond */ #include @@ -69,12 +68,9 @@ EmbedStream::Init(void) if (NS_FAILED(rv)) return rv; - mInputStream = do_QueryInterface(bufInStream, &rv); - if (NS_FAILED(rv)) - return rv; - - mOutputStream = do_QueryInterface(bufOutStream, &rv); - return rv; + mInputStream = bufInStream; + mOutputStream = bufOutStream; + return NS_OK; } NS_METHOD @@ -121,7 +117,8 @@ EmbedStream::OpenStream(const char *aBaseURI, const char *aContentType) // create a new input stream channel rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri, NS_STATIC_CAST(nsIInputStream *, this), - aContentType, + nsDependentCString(aContentType), + NS_LITERAL_CSTRING(""), 1024); /* len */ if (NS_FAILED(rv)) return rv; @@ -175,7 +172,7 @@ EmbedStream::OpenStream(const char *aBaseURI, const char *aContentType) } NS_METHOD -EmbedStream::AppendToStream(const char *aData, PRInt32 aLen) +EmbedStream::AppendToStream(const char *aData, int aLen) { nsresult rv; diff --git a/embedding/browser/photon/src/EmbedStream.h b/embedding/browser/photon/src/EmbedStream.h index 7401ab60ba92..796b645bdff6 100644 --- a/embedding/browser/photon/src/EmbedStream.h +++ b/embedding/browser/photon/src/EmbedStream.h @@ -17,7 +17,6 @@ * * Contributor(s): * Christopher Blizzard - * Brian Edmond */ #include diff --git a/embedding/browser/photon/src/PtMozilla.cpp b/embedding/browser/photon/src/PtMozilla.cpp index 070e1b1135bb..50c9de098f35 100644 --- a/embedding/browser/photon/src/PtMozilla.cpp +++ b/embedding/browser/photon/src/PtMozilla.cpp @@ -35,6 +35,7 @@ #include "nsILoadGroup.h" #include "nsIHistoryEntry.h" +#include "nsIWebBrowserPrint.h" #include "nsIPrintOptions.h" #include "nsIDOMEventReceiver.h" @@ -307,21 +308,20 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt ) moz->EmbedRef->Back(); else { - PhDim_t dim; + PhDim_t dim; - PtWidgetDim(widget, &dim); - dim.w = (argt->value * dim.w)/100; - dim.h = (argt->value * dim.h)/100; - printf("Scroll: V: %d P: (%d, %d) \n", argt->value, dim.w, dim.h); + PtWidgetDim(widget, &dim); + dim.w = (argt->value * dim.w)/100; + dim.h = (argt->value * dim.h)/100; - if (argt->value == WWW_DIRECTION_UP) - moz->EmbedRef->ScrollUp(dim.h); - else if (argt->value == WWW_DIRECTION_DOWN) - moz->EmbedRef->ScrollDown(dim.h); - else if (argt->value == WWW_DIRECTION_LEFT) - moz->EmbedRef->ScrollLeft(dim.w); - else if (argt->value == WWW_DIRECTION_RIGHT) - moz->EmbedRef->ScrollRight(dim.w); + if (argt->value == WWW_DIRECTION_UP) + moz->EmbedRef->ScrollUp(dim.h); + else if (argt->value == WWW_DIRECTION_DOWN) + moz->EmbedRef->ScrollDown(dim.h); + else if (argt->value == WWW_DIRECTION_LEFT) + moz->EmbedRef->ScrollLeft(dim.w); + else if (argt->value == WWW_DIRECTION_RIGHT) + moz->EmbedRef->ScrollRight(dim.w); } } break; @@ -500,7 +500,6 @@ mozilla_get_info(PtWidget_t *widget, PtArg_t *argt) { PtMozillaWidget_t *moz = (PtMozillaWidget_t *) widget; nsIPref *pref = moz->EmbedRef->GetPrefs(); - int retval; switch (argt->type) { @@ -555,9 +554,9 @@ mozilla_get_info(PtWidget_t *widget, PtArg_t *argt) strncpy( HistoryReplyBuf[j].title, ToNewCString(stitle), 127 ); HistoryReplyBuf[j].title[127] = '\0'; - char *urlspec; - url->GetSpec( &urlspec ); - strcpy( HistoryReplyBuf[j].url, urlspec ); + nsCAutoString specString; + url->GetSpec(specString); + strcpy( HistoryReplyBuf[j].url, (char *) specString.get() ); } } break; @@ -1015,7 +1014,8 @@ StartupEmbedding() profile_dir = (char *)alloca(strlen(getenv("HOME")) + strlen("/.ph") + 1); sprintf(profile_dir, "%s/.ph", getenv("HOME")); - rv = StartupProfile(profile_dir, "mozilla"); + //rv = StartupProfile(profile_dir, "mozilla"); + rv = StartupProfile("/home/briane", ".mozilla"); if (NS_FAILED(rv)) NS_WARNING("Warning: Failed to start up profiles.\n"); @@ -1097,7 +1097,7 @@ PtWidgetClass_t *PtCreateMozillaClass( void ) if (StartupEmbedding() == -1) return (NULL); - Init_nsUnknownContentTypeHandler_Factory( ); +// Init_nsUnknownContentTypeHandler_Factory( ); nsCOMPtr promptFactory; NS_NewPromptServiceFactory(getter_AddRefs(promptFactory)); diff --git a/embedding/browser/photon/src/PtMozilla.h b/embedding/browser/photon/src/PtMozilla.h index 91039909dfea..39a292806488 100644 --- a/embedding/browser/photon/src/PtMozilla.h +++ b/embedding/browser/photon/src/PtMozilla.h @@ -174,7 +174,7 @@ typedef struct mozilla_net_state_t { int flags; unsigned int status; - char *url; + const char *url; char *message; } PtMozillaNetStateCb_t; diff --git a/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp b/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp index ab52e62db3dd..cb246f849915 100644 --- a/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp +++ b/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp @@ -100,8 +100,11 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher PRInt64 dummy; nsCOMPtr aFile; aLauncher->GetDownloadInfo( getter_AddRefs(aSourceUrl), &dummy, getter_AddRefs(aFile) ); + char *url; - aSourceUrl->GetSpec( &url ); + nsCAutoString specString; + aSourceUrl->GetSpec(specString); + url = (char *) specString.get(); PtCallbackInfo_t cbinfo; PtWebUnknownCallback_t cb; @@ -226,7 +229,7 @@ NS_IMETHODIMP className::QueryInterface( REFNSIID anIID, void **anInstancePtr ) NS_GENERIC_FACTORY_CONSTRUCTOR( nsUnknownContentTypeHandler ) // The list of components we register -static const nsModuleComponentInfo info[] = { +static nsModuleComponentInfo info[] = { "nsUnknownContentTypeHandler", NS_IHELPERAPPLAUNCHERDIALOG_IID, NS_IHELPERAPPLAUNCHERDLG_CONTRACTID,