diff --git a/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp b/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp new file mode 100644 index 00000000000..c402c60a677 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp @@ -0,0 +1,152 @@ +#include "global.h" + +#include "BrowserFrame.h" + +#include "nsIURI.h" + +BEGIN_EVENT_TABLE(BrowserFrame, wxFrame) + EVT_MENU(XRCID("browse_back"), BrowserFrame::OnBrowserBack) + EVT_MENU(XRCID("browse_fwd"), BrowserFrame::OnBrowserForward) + EVT_MENU(XRCID("browse_reload"), BrowserFrame::OnBrowserReload) + EVT_MENU(XRCID("browse_stop"), BrowserFrame::OnBrowserStop) + EVT_MENU(XRCID("browse_home"), BrowserFrame::OnBrowserHome) + EVT_BUTTON(XRCID("browser_go"), BrowserFrame::OnBrowserGo) + EVT_TEXT_ENTER(XRCID("url"), BrowserFrame::OnBrowserUrl) +END_EVENT_TABLE() + +BrowserFrame::BrowserFrame(wxWindow* aParent) : + mGeckoWnd(NULL) +{ + wxXmlResource::Get()->LoadFrame(this, aParent, wxT("browser_frame")); + + SetIcon(wxICON(appicon)); + + mGeckoWnd = (GeckoWindow *) FindWindowById(XRCID("gecko"), this); + if (mGeckoWnd) + { + GeckoContainer *geckoContainer = new GeckoContainer(this); + if (geckoContainer) + { + mGeckoWnd->SetGeckoContainer(geckoContainer); + + PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL; + geckoContainer->SetChromeFlags(aChromeFlags); + geckoContainer->SetParent(nsnull); + + wxSize size = mGeckoWnd->GetClientSize(); + + // Insert the browser + geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(), + (nativeWindow) mGeckoWnd->GetHWND(), getter_AddRefs(mWebbrowser)); + + GeckoContainerUI::ShowWindow(PR_TRUE); + + } + } + + CreateStatusBar(); +} + + +/////////////////////////////////////////////////////////////////////////////// +// Browser specific handlers + + +void BrowserFrame::OnBrowserGo(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this); + wxString url = txtCtrl->GetValue(); + if (!url.IsEmpty()) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->LoadURI(NS_ConvertASCIItoUCS2(url.c_str()).get(), + nsIWebNavigation::LOAD_FLAGS_NONE, + nsnull, + nsnull, + nsnull); + } + } +} + +void BrowserFrame::OnBrowserUrl(wxCommandEvent & event) +{ + OnBrowserGo(event); +} + +void BrowserFrame::OnBrowserBack(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->GoBack(); + } +} + +void BrowserFrame::OnBrowserForward(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->GoForward(); + } +} + +void BrowserFrame::OnBrowserReload(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); + } +} + +void BrowserFrame::OnBrowserStop(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->Stop(nsIWebNavigation::STOP_ALL); + } +} + +void BrowserFrame::OnBrowserHome(wxCommandEvent & WXUNUSED(event)) +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->LoadURI(NS_ConvertASCIItoUCS2("www.cnn.com").get(), + nsIWebNavigation::LOAD_FLAGS_NONE, + nsnull, + nsnull, + nsnull); + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// GeckoContainerUI overrides + +void BrowserFrame::UpdateStatusBarText(const PRUnichar* aStatusText) +{ + SetStatusText(aStatusText); +} + +void BrowserFrame::UpdateCurrentURI() +{ + if (mWebbrowser) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr currentURI; + webNav->GetCurrentURI(getter_AddRefs(currentURI)); + nsCAutoString spec; + currentURI->GetSpec(spec); + + wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this); + if (txtCtrl) + { + txtCtrl->SetValue(spec.get()); + } + } +} diff --git a/mozilla/embedding/tests/wxEmbed/BrowserFrame.h b/mozilla/embedding/tests/wxEmbed/BrowserFrame.h new file mode 100644 index 00000000000..1843ac81b9f --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/BrowserFrame.h @@ -0,0 +1,32 @@ +#ifndef BROWSERFRAME_H +#define BROWSERFRAME_H + +#include "GeckoContainer.h" +#include "GeckoWindow.h" + +class BrowserFrame : + public wxFrame, + public GeckoContainerUI +{ +public : + BrowserFrame(wxWindow* aParent); + + DECLARE_EVENT_TABLE() + + void OnBrowserUrl(wxCommandEvent &event); + void OnBrowserGo(wxCommandEvent &event); + void OnBrowserBack(wxCommandEvent &event); + void OnBrowserForward(wxCommandEvent &event); + void OnBrowserReload(wxCommandEvent &event); + void OnBrowserStop(wxCommandEvent &event); + void OnBrowserHome(wxCommandEvent &event); + + GeckoWindow *mGeckoWnd; + nsCOMPtr mWebbrowser; + + // GeckoContainerUI overrides + void UpdateStatusBarText(const PRUnichar* aStatusText); + void UpdateCurrentURI(); +}; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp b/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp new file mode 100644 index 00000000000..243950b36cd --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp @@ -0,0 +1,121 @@ +#include "global.h" + +#include "nsIProfile.h" +#include "nsMemory.h" + +#include "BrowserFrame.h" +#include "MailFrame.h" +#include "GeckoProtocolHandler.h" + +class FooCallback : public GeckoChannelCallback +{ +public: + virtual nsresult GetData( + nsIURI *aURI, + nsIChannel *aChannel, + nsACString &aContentType, + void **aData, + PRUint32 *aSize) + { + nsCAutoString spec; + nsCAutoString txt("Hello, your URL was \'"); + aURI->GetSpec(spec); + txt.Append(spec); + txt.Append("\'"); + aContentType.Assign("text/html"); + + size_t size = txt.Length(); + *aData = (void *) nsMemory::Alloc(size); + if (!*aData) + return NS_ERROR_OUT_OF_MEMORY; + memset(*aData, 0, size); + memcpy((char *) *aData, txt.get(), size); + *aSize = size; + return NS_OK; + } +}; + +class EmbedApp : public wxApp +{ + virtual bool OnInit(); + virtual int OnExit(); + + DECLARE_EVENT_TABLE() + void OnQuit(wxCommandEvent &event); + void OnAbout(wxCommandEvent &event); + void OnMail(wxCommandEvent &event); +}; + +BEGIN_EVENT_TABLE(EmbedApp, wxApp) + EVT_MENU(XRCID("menu_quit"), EmbedApp::OnQuit) + EVT_MENU(XRCID("menu_about"), EmbedApp::OnAbout) + EVT_MENU(XRCID("menu_mail"), EmbedApp::OnMail) +END_EVENT_TABLE() + +/////////////////////////////////////////////////////////////////////////////// + +IMPLEMENT_APP(EmbedApp) + +bool EmbedApp::OnInit() +{ + wxImage::AddHandler(new wxGIFHandler); + wxXmlResource::Get()->InitAllHandlers(); + InitXmlResource(); + + if (NS_FAILED(NS_InitEmbedding(nsnull, nsnull))) + { + return FALSE; + } + + + nsresult rv; + nsCOMPtr profileService = + do_GetService(NS_PROFILE_CONTRACTID, &rv); + rv = profileService->CreateNewProfile(L"wxEmbed", nsnull, nsnull, PR_FALSE); + if (NS_FAILED(rv)) return FALSE; + rv = profileService->SetCurrentProfile(L"wxEmbed"); + if (NS_FAILED(rv)) return FALSE; + + + // Create the main frame window + BrowserFrame* frame = new BrowserFrame(NULL); + frame->Show(TRUE); + + GeckoProtocolHandler::RegisterHandler("foo", "Test handler", new FooCallback); + + SetTopWindow(frame); + + return TRUE; +} + +int EmbedApp::OnExit() +{ + // Shutdown the profile + nsresult rv; + nsCOMPtr profileService = + do_GetService(NS_PROFILE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv)) + { + profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST); + } + NS_TermEmbedding(); + return 0; +} + +void EmbedApp::OnQuit(wxCommandEvent & WXUNUSED(event)) +{ + GetTopWindow()->Close(TRUE); +} + +void EmbedApp::OnAbout(wxCommandEvent & WXUNUSED(event)) +{ + (void)wxMessageBox(_T("wxEmbed"), _T("About wxEmbed")); +} + +void EmbedApp::OnMail(wxCommandEvent & WXUNUSED(event)) +{ + // Create the mail frame window + MailFrame * frame = new MailFrame(NULL); + frame->Show(TRUE); +} + diff --git a/mozilla/embedding/tests/wxEmbed/GeckoContainer.cpp b/mozilla/embedding/tests/wxEmbed/GeckoContainer.cpp new file mode 100644 index 00000000000..0fbacfa98fd --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoContainer.cpp @@ -0,0 +1,468 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +// Mozilla Includes +//#include "nsIGenericFactory.h" +#include "nsIComponentManager.h" +#include "nsString.h" +#include "nsXPIDLString.h" +#include "nsIURI.h" +#include "nsIWebProgress.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDOMWindow.h" +#include "nsIDOMWindowInternal.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsCWebBrowser.h" +#include "nsCRT.h" + +#include "GeckoContainer.h" + + +GeckoContainer::GeckoContainer(GeckoContainerUI *pUI, const char *aRole) : + mUI(pUI), + mNativeWindow(nsnull), + mSizeSet(PR_FALSE) +{ + NS_ASSERTION(mUI, "No GeckoContainerUI! How do you expect this to work???"); + if (aRole) + mRole = aRole; +} + +GeckoContainer::~GeckoContainer() +{ + mUI->Destroyed(); +} + +nsresult GeckoContainer::CreateBrowser(PRInt32 aX, PRInt32 aY, + PRInt32 aCX, PRInt32 aCY, nativeWindow aParent, + nsIWebBrowser **aBrowser) +{ + NS_ENSURE_ARG_POINTER(aBrowser); + *aBrowser = nsnull; + + nsresult rv; + mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); + if (!mWebBrowser || NS_FAILED(rv)) + return NS_ERROR_FAILURE; + + (void)mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); + + nsCOMPtr dsti = do_QueryInterface(mWebBrowser); + dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper); + + nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); + + mNativeWindow = aParent; + + if (!mNativeWindow) + return NS_ERROR_FAILURE; + + browserBaseWindow->InitWindow( mNativeWindow, + nsnull, + aX, aY, aCX, aCY); + browserBaseWindow->Create(); + + nsCOMPtr listener(NS_STATIC_CAST(nsIWebProgressListener*, this)); + nsCOMPtr thisListener(dont_AddRef(NS_GetWeakReference(listener))); + (void)mWebBrowser->AddWebBrowserListener(thisListener, + NS_GET_IID(nsIWebProgressListener)); + + // The window has been created. Now register for history notifications +// mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsISHistoryListener)); + + if (mWebBrowser) + { + *aBrowser = mWebBrowser; + NS_ADDREF(*aBrowser); + return NS_OK; + } + return NS_ERROR_FAILURE; +} + + +void GeckoContainer::ContentFinishedLoading() +{ + // if it was a chrome window and no one has already specified a size, + // size to content + if (mWebBrowser && !mSizeSet && + (mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) { + nsCOMPtr contentWin; + mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin)); + if (contentWin) + contentWin->SizeToContent(); + mUI->ShowWindow(PR_TRUE); + } +} + +//***************************************************************************** +// GeckoContainer::nsISupports +//***************************************************************************** + +NS_IMPL_ADDREF(GeckoContainer) +NS_IMPL_RELEASE(GeckoContainer) + +NS_INTERFACE_MAP_BEGIN(GeckoContainer) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome) + NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) + NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) + NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus) + NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow) + NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow2) + NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) // optional + NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) + NS_INTERFACE_MAP_ENTRY(nsIObserver) + NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener) + NS_INTERFACE_MAP_ENTRY(nsITooltipListener) + NS_INTERFACE_MAP_ENTRY(nsIGeckoContainer) +NS_INTERFACE_MAP_END + + +//***************************************************************************** +// GeckoContainer::nsIGeckoContainer +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::GetRole(nsACString &aRole) +{ + aRole = mRole; + return NS_OK; +} + + +//***************************************************************************** +// GeckoContainer::nsIInterfaceRequestor +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::GetInterface(const nsIID &aIID, void** aInstancePtr) +{ + NS_ENSURE_ARG_POINTER(aInstancePtr); + + *aInstancePtr = 0; + if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) + { + if (mWebBrowser) + { + return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr); + } + return NS_ERROR_NOT_INITIALIZED; + } + return QueryInterface(aIID, aInstancePtr); +} + +//***************************************************************************** +// GeckoContainer::nsIWebBrowserChrome +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::SetStatus(PRUint32 aType, const PRUnichar* aStatus) +{ + mUI->UpdateStatusBarText(aStatus); + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::GetWebBrowser(nsIWebBrowser** aWebBrowser) +{ + NS_ENSURE_ARG_POINTER(aWebBrowser); + *aWebBrowser = mWebBrowser; + NS_IF_ADDREF(*aWebBrowser); + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::SetWebBrowser(nsIWebBrowser* aWebBrowser) +{ + mWebBrowser = aWebBrowser; + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::GetChromeFlags(PRUint32* aChromeMask) +{ + *aChromeMask = mChromeFlags; + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::SetChromeFlags(PRUint32 aChromeMask) +{ + mChromeFlags = aChromeMask; + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::DestroyBrowserWindow(void) +{ + mUI->Destroy(); + return NS_OK; +} + + +// IN: The desired browser client area dimensions. +NS_IMETHODIMP GeckoContainer::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight) +{ + /* This isn't exactly correct: we're setting the whole window to + the size requested for the browser. At time of writing, though, + it's fine and useful for winEmbed's purposes. */ + mUI->SizeTo(aWidth, aHeight); + mSizeSet = PR_TRUE; + return NS_OK; +} + + +NS_IMETHODIMP GeckoContainer::ShowAsModal(void) +{ +/* if (mDependentParent) + mUI->EnableChromeWindow(mDependentParent, PR_FALSE); + + mContinueModalLoop = PR_TRUE; + mUI->RunEventLoop(mContinueModalLoop); + + if (mDependentParent) + mUI->EnableChromeWindow(mDependentParent, PR_TRUE); +*/ + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::IsWindowModal(PRBool *_retval) +{ + *_retval = PR_FALSE; + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP GeckoContainer::ExitModalEventLoop(nsresult aStatus) +{ + mContinueModalLoop = PR_FALSE; + return NS_OK; +} + +//***************************************************************************** +// GeckoContainer::nsIWebBrowserChromeFocus +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::FocusNextElement() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP GeckoContainer::FocusPrevElement() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +//***************************************************************************** +// GeckoContainer::nsIWebProgressListener +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::OnProgressChange(nsIWebProgress *progress, nsIRequest *request, + PRInt32 curSelfProgress, PRInt32 maxSelfProgress, + PRInt32 curTotalProgress, PRInt32 maxTotalProgress) +{ + mUI->UpdateProgress(curTotalProgress, maxTotalProgress); + return NS_OK; +} + +NS_IMETHODIMP GeckoContainer::OnStateChange(nsIWebProgress *progress, nsIRequest *request, + PRUint32 progressStateFlags, nsresult status) +{ + if ((progressStateFlags & STATE_START) && (progressStateFlags & STATE_IS_DOCUMENT)) + { + mUI->UpdateBusyState(PR_TRUE); + } + + if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_DOCUMENT)) + { + mUI->UpdateBusyState(PR_FALSE); + mUI->UpdateProgress(0, 100); + mUI->UpdateStatusBarText(nsnull); + ContentFinishedLoading(); + } + + return NS_OK; +} + + +NS_IMETHODIMP GeckoContainer::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) +{ + PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load + if (aWebProgress) + { + nsCOMPtr domWindow; + nsCOMPtr topDomWindow; + aWebProgress->GetDOMWindow(getter_AddRefs(domWindow)); + if (domWindow) + { + // Get root domWindow + domWindow->GetTop(getter_AddRefs(topDomWindow)); + } + if (domWindow != topDomWindow) + isSubFrameLoad = PR_TRUE; + } + if (!isSubFrameLoad) + mUI->UpdateCurrentURI(); + return NS_OK; +} + +NS_IMETHODIMP +GeckoContainer::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + mUI->UpdateStatusBarText(aMessage); + return NS_OK; +} + + + +NS_IMETHODIMP +GeckoContainer::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRUint32 state) +{ + return NS_OK; +} + + +//***************************************************************************** +// GeckoContainer::nsIEmbeddingSiteWindow +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP GeckoContainer::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) +{ + if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) + { + *x = 0; + *y = 0; + } + if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || + aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) + { + *cx = 0; + *cy = 0; + } + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void setFocus (); */ +NS_IMETHODIMP GeckoContainer::SetFocus() +{ + mUI->SetFocus(); + return NS_OK; +} + +/* attribute wstring title; */ +NS_IMETHODIMP GeckoContainer::GetTitle(PRUnichar * *aTitle) +{ + NS_ENSURE_ARG_POINTER(aTitle); + + *aTitle = nsnull; + + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP GeckoContainer::SetTitle(const PRUnichar * aTitle) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute boolean visibility; */ +NS_IMETHODIMP GeckoContainer::GetVisibility(PRBool * aVisibility) +{ + NS_ENSURE_ARG_POINTER(aVisibility); + *aVisibility = PR_TRUE; + return NS_OK; +} +NS_IMETHODIMP GeckoContainer::SetVisibility(PRBool aVisibility) +{ + return NS_OK; +} + +/* attribute nativeSiteWindow siteWindow */ +NS_IMETHODIMP GeckoContainer::GetSiteWindow(void * *aSiteWindow) +{ + NS_ENSURE_ARG_POINTER(aSiteWindow); + + *aSiteWindow = mNativeWindow; + return NS_OK; +} + +//***************************************************************************** +// GeckoContainer::nsIEmbeddingSiteWindow2 +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::Blur() +{ + mUI->KillFocus(); + return NS_OK; +} + +//***************************************************************************** +// GeckoContainer::nsIObserver +//***************************************************************************** + +NS_IMETHODIMP GeckoContainer::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) +{ + nsresult rv = NS_OK; + if (nsCRT::strcmp(aTopic, "profile-change-teardown") == 0) + { + // A profile change means death for this window + mUI->Destroy(); + } + return rv; +} + +//***************************************************************************** +// GeckoContainer::nsIContextMenuListener +//***************************************************************************** + +/* void OnShowContextMenu (in unsigned long aContextFlags, in nsIDOMEvent aEvent, in nsIDOMNode aNode); */ +NS_IMETHODIMP GeckoContainer::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode) +{ + mUI->ShowContextMenu(aContextFlags, aEvent, aNode); + return NS_OK; +} + +//***************************************************************************** +// GeckoContainer::nsITooltipListener +//***************************************************************************** + +/* void OnShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */ +NS_IMETHODIMP GeckoContainer::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) +{ + mUI->ShowTooltip(aXCoords, aYCoords, aTipText); + return NS_OK; +} + +/* void OnHideTooltip (); */ +NS_IMETHODIMP GeckoContainer::OnHideTooltip() +{ + mUI->HideTooltip(); + return NS_OK; +} diff --git a/mozilla/embedding/tests/wxEmbed/GeckoContainer.h b/mozilla/embedding/tests/wxEmbed/GeckoContainer.h new file mode 100644 index 00000000000..c3ee8936696 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoContainer.h @@ -0,0 +1,166 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __WebBrowserChrome__ +#define __WebBrowserChrome__ + +#include "nsCOMPtr.h" +#include "nsIGenericFactory.h" +#include "nsIWebBrowserChrome.h" +#include "nsIWebBrowserChromeFocus.h" + +#include "nsIContentViewer.h" +#include "nsIContentViewerFile.h" +#include "nsIBaseWindow.h" +#include "nsIEmbeddingSiteWindow2.h" +#include "nsIWebNavigation.h" +#include "nsIWebProgressListener.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsIWebBrowser.h" +#include "nsIObserver.h" +#include "nsWeakReference.h" +#include "nsIContextMenuListener.h" +#include "nsITooltipListener.h" + +class GeckoContainerUI; + +// Define a custom nsIGeckoContainer interface. It means that if we are passed +// some random nsIWebBrowserChrome object we can tell if its one of ours by +// QIing to see if it implements nsIGeckoContainer + +#define NS_IGECKOCONTAINER_IID \ + { 0xbf47a2ec, 0x9be0, 0x4f18, { 0x9a, 0xf0, 0x8e, 0x1c, 0x89, 0x2a, 0xa3, 0x1d } } + +class NS_NO_VTABLE nsIGeckoContainer : public nsISupports +{ +public: + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGECKOCONTAINER_IID) + + NS_IMETHOD GetRole(nsACString &aRole) = 0; +}; + +#define NS_DECL_NSIGECKOCONTAINER + +class GeckoContainer : + public nsIWebBrowserChrome, + public nsIWebBrowserChromeFocus, + public nsIWebProgressListener, + public nsIEmbeddingSiteWindow2, + public nsIInterfaceRequestor, + public nsIObserver, + public nsIContextMenuListener, + public nsITooltipListener, + public nsIGeckoContainer, + public nsSupportsWeakReference +{ +public: + // Supply a container UI callback and optionally a role, e.g. "browser" + // which can be used to modify the behaviour depending on the value + // it contains. + GeckoContainer(GeckoContainerUI *pUI, const char *aRole = NULL); + virtual ~GeckoContainer(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBBROWSERCHROME + NS_DECL_NSIWEBBROWSERCHROMEFOCUS + NS_DECL_NSIWEBPROGRESSLISTENER + NS_DECL_NSIEMBEDDINGSITEWINDOW + NS_DECL_NSIEMBEDDINGSITEWINDOW2 + NS_DECL_NSIINTERFACEREQUESTOR + NS_DECL_NSIOBSERVER + NS_DECL_NSICONTEXTMENULISTENER + NS_DECL_NSITOOLTIPLISTENER + NS_DECL_NSIGECKOCONTAINER + + // nsIGeckoContainer + NS_IMETHOD GetRole(nsACString &aRole); + + + nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nativeWindow aParent, + nsIWebBrowser **aBrowser); + + void SetParent(nsIWebBrowserChrome *aParent) + { mDependentParent = aParent; } + +protected: + nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0); + + void ContentFinishedLoading(); + + GeckoContainerUI *mUI; + nativeWindow mNativeWindow; + PRUint32 mChromeFlags; + PRBool mContinueModalLoop; + PRBool mSizeSet; + nsCString mRole; + nsCOMPtr mWebBrowser; + nsCOMPtr mDependentParent; // opener (for dependent windows only) +}; + + +class GeckoContainerUI +{ +public: + static nsresult CreateBrowserWindow(PRUint32 aChromeFlags, + GeckoContainer *aParent, + GeckoContainer **aNewWindow); + + // Called when the content wants to be destroyed (e.g. a window.close() happened) + virtual void Destroy(); + // Called when the Gecko has been torn down, allowing dangling references to be released + virtual void Destroyed(); + // Called when the content wants focus + virtual void SetFocus(); + // Called when the content wants focus (e.g. onblur handler) + virtual void KillFocus(); + // Called when the status bar text needs to be updated (e.g. progress notifications) + virtual void UpdateStatusBarText(const PRUnichar* aStatusText); + // Called when the current URI has changed. Allows UI to update address bar + virtual void UpdateCurrentURI(); + // Called when the browser busy state changes. Allows UI to display an hourglass + virtual void UpdateBusyState(PRBool aBusy); + // Called when total progress changes + virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); + virtual void GetResourceStringById(PRInt32 aID, char ** aReturn); + // Called when a context menu event has been detected on the page + virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode); + // Called when a tooltip should be shown + virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText); + // Called when a tooltip should be hidden + virtual void HideTooltip(); + // Called when the window should be hidden or shown + virtual void ShowWindow(PRBool aShow); + // Called when the browser area should be resized + virtual void SizeTo(PRInt32 aWidth, PRInt32 aHeight); + virtual void EnableChromeWindow(PRBool aEnabled); + virtual PRUint32 RunEventLoop(PRBool &aRunCondition); +}; + +#endif /* __WebBrowserChrome__ */ diff --git a/mozilla/embedding/tests/wxEmbed/GeckoContainerUI.cpp b/mozilla/embedding/tests/wxEmbed/GeckoContainerUI.cpp new file mode 100644 index 00000000000..901967b8a0b --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoContainerUI.cpp @@ -0,0 +1,77 @@ + +#include "global.h" + +#include "GeckoContainer.h" + + +nsresult GeckoContainerUI::CreateBrowserWindow(PRUint32 aChromeFlags, + GeckoContainer *aParent, + GeckoContainer **aNewWindow) +{ + return NS_ERROR_FAILURE; +} + +void GeckoContainerUI::Destroy() +{ +} + +void GeckoContainerUI::Destroyed() +{ +} + +void GeckoContainerUI::SetFocus() +{ +} + +void GeckoContainerUI::KillFocus() +{ +} + +void GeckoContainerUI::UpdateStatusBarText(const PRUnichar* aStatusText) +{ +} + +void GeckoContainerUI::UpdateCurrentURI() +{ +} + +void GeckoContainerUI::UpdateBusyState(PRBool aBusy) +{ +} + +void GeckoContainerUI::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) +{ +} + +void GeckoContainerUI::GetResourceStringById(PRInt32 aID, char ** aReturn) +{ +} + +void GeckoContainerUI::ShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode) +{ +} + +void GeckoContainerUI::ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) +{ +} + +void GeckoContainerUI::HideTooltip() +{ +} + +void GeckoContainerUI::ShowWindow(PRBool aShow) +{ +} + +void GeckoContainerUI::SizeTo(PRInt32 aWidth, PRInt32 aHeight) +{ +} + +void GeckoContainerUI::EnableChromeWindow(PRBool aEnabled) +{ +} + +PRUint32 GeckoContainerUI::RunEventLoop(PRBool &aRunCondition) +{ + return 0; +} diff --git a/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp b/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp new file mode 100644 index 00000000000..37086abd74f --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp @@ -0,0 +1,514 @@ +#include "GeckoProtocolHandler.h" + +#include "nsString.h" +#include "nsNetCID.h" +#include "nsNetUtil.h" +#include "nsIGenericFactory.h" +#include "nsIComponentManager.h" +#include "nsIProgressEventSink.h" +#include "nsILoadGroup.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsIStringStream.h" +#include "nsIStreamListener.h" +#include "nsIInputStreamPump.h" + +// Everytime register handler is called, it picks the next available CID in the +// list. +// TODO - is there a cross-platform way to generate UUIDs and obviate this? +static const nsCID kProtocolCIDs[] = +{ + { 0xfc8b2366, 0x0d07, 0x45ef, { 0x9f, 0xab, 0x22, 0x31, 0x9d, 0xbc, 0xfa, 0x77 } }, + { 0x6b5db250, 0xcf4b, 0x4ab1, { 0xb3, 0xaa, 0x1a, 0x9a, 0xd6, 0xdf, 0x7f, 0x95 } }, + { 0x677c6eaf, 0x3c3d, 0x4e0d, { 0xad, 0x30, 0x5a, 0xb8, 0x69, 0x1d, 0x1f, 0xfc } }, + { 0xbe383b01, 0x58d3, 0x4e65, { 0x9d, 0x50, 0x05, 0xb4, 0xc3, 0x92, 0x43, 0x2e } }, + { 0x81290231, 0xedf0, 0x4876, { 0x94, 0xa2, 0xdb, 0x96, 0xca, 0xa3, 0xc1, 0xfc } }, + { 0xf9c466b0, 0x0da8, 0x48a7, { 0xbb, 0xe4, 0x2f, 0x63, 0xb0, 0x71, 0x41, 0x6f } }, + { 0x9cbaef5e, 0xdf94, 0x4cb0, { 0xb4, 0xc3, 0x89, 0x66, 0x89, 0xd0, 0x2d, 0x56 } }, + { 0xce79440d, 0xdafc, 0x4908, { 0xb8, 0x94, 0xb2, 0x74, 0xa3, 0x51, 0x2f, 0x45 } } +}; +static const int kProtocolCIDsSize = sizeof(kProtocolCIDs) / sizeof(kProtocolCIDs[0]); +static PRUint32 gUsedCIDs = 0; +struct GeckoChannelCallbacks +{ + nsCString mScheme; + GeckoChannelCallback *mCallback; + // SUCKS, component registry should properly copy this variable or take ownership of + // it so it doesn't have to be made a static or global like this. + // I also wonder if having component info memory dotted all over the place doesn't + // impact component registry performance in some way. + nsModuleComponentInfo mComponentInfo; +}; +static GeckoChannelCallbacks gCallbacks[kProtocolCIDsSize]; + +class GeckoProtocolHandlerImpl : + public nsIProtocolHandler +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROTOCOLHANDLER + static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); +}; + +nsresult GeckoProtocolHandler::RegisterHandler(const char *aScheme, const char *aDescription, GeckoChannelCallback *aCallback) +{ + if (!aScheme || !aCallback) + { + return NS_ERROR_INVALID_ARG; + } + + if (gUsedCIDs >= kProtocolCIDsSize) + { + // We've run out of CIDs. Perhaps this code should be generating them + // on the fly somehow instead? + return NS_ERROR_FAILURE; + } + for (PRUint32 i = 0; i < gUsedCIDs; i++) + { + if (gCallbacks[i].mScheme.EqualsIgnoreCase(aScheme)) + return NS_ERROR_FAILURE; + } + + nsCAutoString contractID(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX); + contractID.Append(aScheme); + nsCID cid = kProtocolCIDs[gUsedCIDs]; + gCallbacks[gUsedCIDs].mScheme = aScheme; + gCallbacks[gUsedCIDs].mCallback = aCallback; + gUsedCIDs++; + + nsModuleComponentInfo &ci = gCallbacks[gUsedCIDs].mComponentInfo; + memset(&ci, 0, sizeof(ci)); + ci.mDescription = strdup(aDescription); + ci.mCID = cid; + ci.mContractID = strdup(contractID.get()); + ci.mConstructor = GeckoProtocolHandlerImpl::Create; + + // Create a factory object which will create the protocol handler on demand + nsCOMPtr factory; + NS_NewGenericFactory(getter_AddRefs(factory), &ci); + nsComponentManager::RegisterFactory( + cid, aDescription, contractID.get(), factory, PR_FALSE); + + return NS_OK; +} + + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + + +class GeckoProtocolChannel : + public nsIChannel, + public nsIStreamListener +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIREQUEST + NS_DECL_NSICHANNEL + NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSISTREAMLISTENER + + GeckoProtocolChannel(); + nsresult Init(nsIURI *aURI); + +protected: + nsCOMPtr mURI; + nsCOMPtr mOriginalURI; + nsCOMPtr mCallbacks; + nsCOMPtr mProgressSink; + nsCOMPtr mOwner; + nsCOMPtr mLoadGroup; + nsCOMPtr mListener; + nsCOMPtr mListenerContext; + nsCOMPtr mContentStream; + nsCString mContentType; + nsCString mContentCharset; + PRUint32 mLoadFlags; + nsresult mStatus; + PRUint32 mContentLength; + void * mData; + nsCOMPtr mPump; + + virtual ~GeckoProtocolChannel(); +}; + +GeckoProtocolChannel::GeckoProtocolChannel() : + mContentLength(0), + mData(nsnull), + mStatus(NS_OK), + mLoadFlags(LOAD_NORMAL) +{ +} + +GeckoProtocolChannel::~GeckoProtocolChannel() +{ + if (mData) + nsMemory::Free(mData); +} + +static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); + +NS_METHOD GeckoProtocolHandlerImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + GeckoProtocolHandlerImpl *impl = new GeckoProtocolHandlerImpl(); + if (!impl) + { + return NS_ERROR_OUT_OF_MEMORY; + } + *aResult = nsnull; + nsresult rv = impl->QueryInterface(aIID, aResult); + if (NS_FAILED(rv)) + { + impl->Release(); + } + return rv; +} + +NS_IMPL_ISUPPORTS1(GeckoProtocolHandlerImpl, nsIProtocolHandler) + +/* readonly attribute ACString scheme; */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::GetScheme(nsACString & aScheme) +{ + // Since we have no clue what scheme we're an implementation of, + // just return the first one that was registered. + aScheme = gCallbacks[0].mScheme; + return NS_OK; +} + +/* readonly attribute long defaultPort; */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::GetDefaultPort(PRInt32 *aDefaultPort) +{ + *aDefaultPort = -1; + return NS_OK; +} + +/* readonly attribute unsigned long protocolFlags; */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::GetProtocolFlags(PRUint32 *aProtocolFlags) +{ + *aProtocolFlags = URI_NORELATIVE | URI_NOAUTH; + return NS_OK; +} + +/* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) +{ + nsresult rv; + nsIURI* url = nsnull; + rv = nsComponentManager::CreateInstance( + kSimpleURICID, nsnull, NS_GET_IID(nsIURI), (void**) &url); + if (NS_FAILED(rv)) + return rv; + rv = url->SetSpec(aSpec); + if (NS_FAILED(rv)) + { + NS_RELEASE(url); + return rv; + } + *_retval = url; + return rv; +} + +/* nsIChannel newChannel (in nsIURI aURI); */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::NewChannel(nsIURI *aURI, nsIChannel **_retval) +{ + GeckoProtocolChannel *channel = new GeckoProtocolChannel; + if (!channel) + { + return NS_ERROR_OUT_OF_MEMORY; + } + channel->Init(aURI); + channel->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval); + return NS_OK; +} + +/* boolean allowPort (in long port, in string scheme); */ +NS_IMETHODIMP GeckoProtocolHandlerImpl::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +NS_IMPL_ISUPPORTS4(GeckoProtocolChannel, nsIRequest, nsIChannel, nsIRequestObserver, nsIStreamListener) + +nsresult GeckoProtocolChannel::Init(nsIURI *aURI) +{ + mURI = aURI; + return NS_OK; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods + + +NS_IMETHODIMP +GeckoProtocolChannel::GetName(nsACString &result) +{ + return mURI->GetSpec(result); +} + +NS_IMETHODIMP +GeckoProtocolChannel::IsPending(PRBool *result) +{ + *result = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetStatus(nsresult *status) +{ + *status = mStatus; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::Cancel(nsresult status) +{ + NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); + + mStatus = status; + return NS_ERROR_UNEXPECTED; +} + +NS_IMETHODIMP +GeckoProtocolChannel::Suspend() +{ + return NS_ERROR_UNEXPECTED; +} + +NS_IMETHODIMP +GeckoProtocolChannel::Resume() +{ + return NS_ERROR_UNEXPECTED; +} + + +//////////////////////////////////////////////////////////////////////////////// +// nsIChannel methods: + +NS_IMETHODIMP +GeckoProtocolChannel::GetOriginalURI(nsIURI* *aURI) +{ + *aURI = mOriginalURI ? mOriginalURI : mURI; + NS_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetOriginalURI(nsIURI* aURI) +{ + mOriginalURI = aURI; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetURI(nsIURI* *aURI) +{ + *aURI = mURI; + NS_IF_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::Open(nsIInputStream **_retval) +{ + NS_NOTREACHED("GeckoProtocolChannel::Open"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +GeckoProtocolChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) +{ + nsresult rv = NS_OK; + + nsCAutoString scheme; + mURI->GetScheme(scheme); + for (PRUint32 i = 0; i < gUsedCIDs; i++) + { + if (scheme.EqualsIgnoreCase(gCallbacks[i].mScheme.get())) + { + rv = gCallbacks[i].mCallback->GetData( + mURI, NS_STATIC_CAST(nsIChannel *,this), mContentType, &mData, &mContentLength); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr stream; + rv = NS_NewByteInputStream(getter_AddRefs(stream), (const char *) mData, mContentLength); + if (NS_FAILED(rv)) return rv; + nsCOMPtr contentStream = do_QueryInterface(stream); + + nsresult rv = NS_NewInputStreamPump(getter_AddRefs(mPump), contentStream, + -1, mContentLength, 0, 0, PR_TRUE); + if (NS_FAILED(rv)) return rv; + + mListenerContext = aContext; + mListener = aListener; + if (mLoadGroup) + { + mLoadGroup->AddRequest(this, nsnull); + } + + rv = mPump->AsyncRead(this, nsnull); + if (NS_FAILED(rv)) return rv; + + return rv; + } + } + + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetLoadFlags(PRUint32 *aLoadFlags) +{ + *aLoadFlags = mLoadFlags; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetLoadFlags(PRUint32 aLoadFlags) +{ + mLoadFlags = aLoadFlags; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetContentType(nsACString &aContentType) +{ + aContentType = mContentType; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetContentType(const nsACString &aContentType) +{ + mContentType = aContentType; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetContentCharset(nsACString &aContentCharset) +{ + aContentCharset = mContentCharset; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetContentCharset(const nsACString &aContentCharset) +{ + mContentCharset = aContentCharset; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetContentLength(PRInt32 *aContentLength) +{ + *aContentLength = mContentLength; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetContentLength(PRInt32 aContentLength) +{ + // silently ignore this... + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) +{ + *aLoadGroup = mLoadGroup; + NS_IF_ADDREF(*aLoadGroup); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + mLoadGroup = aLoadGroup; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetOwner(nsISupports* *aOwner) +{ + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetOwner(nsISupports* aOwner) +{ + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + *aNotificationCallbacks = mCallbacks.get(); + NS_IF_ADDREF(*aNotificationCallbacks); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + mCallbacks = aNotificationCallbacks; + mProgressSink = do_GetInterface(mCallbacks); + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::GetSecurityInfo(nsISupports **aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIStreamListener methods + + +NS_IMETHODIMP +GeckoProtocolChannel::OnStartRequest(nsIRequest *req, nsISupports *ctx) +{ + return mListener->OnStartRequest(this, mListenerContext); +} + +NS_IMETHODIMP +GeckoProtocolChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status) +{ + if (NS_SUCCEEDED(mStatus)) + mStatus = status; + + mListener->OnStopRequest(this, mListenerContext, mStatus); + mListener = 0; + mListenerContext = 0; + + if (mLoadGroup) + mLoadGroup->RemoveRequest(this, nsnull, mStatus); + + mPump = 0; + mContentStream = 0; + return NS_OK; +} + +NS_IMETHODIMP +GeckoProtocolChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx, + nsIInputStream *stream, + PRUint32 offset, PRUint32 count) +{ + nsresult rv; + + rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count); + + if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND)) + mProgressSink->OnProgress(this, nsnull, offset + count, mContentLength); + + return rv; // let the pump cancel on failure +} diff --git a/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.h b/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.h new file mode 100644 index 00000000000..72519c0fb66 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoProtocolHandler.h @@ -0,0 +1,27 @@ +#ifndef GECKOPROTOCOLHANDLER_H +#define GECKOPROTOCOLHANDLER_H + +#include "nsIProtocolHandler.h" +#include "nsIChannel.h" +#include "nsIURI.h" + +class GeckoChannelCallback +{ +public: + // Return an nsMemory allocated memory block containing the data requested + // Ownership transfers to the caller so it will be freed automatically + virtual nsresult GetData( + nsIURI *aURI, + nsIChannel *aChannel, + nsACString &aContentType, + void **aData, + PRUint32 *aSize) = 0; +}; + +class GeckoProtocolHandler +{ +public: + static nsresult RegisterHandler(const char *aScheme, const char *aDescription, GeckoChannelCallback *aCallback); +}; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/GeckoWindow.cpp b/mozilla/embedding/tests/wxEmbed/GeckoWindow.cpp new file mode 100644 index 00000000000..1ca3d19ae1c --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoWindow.cpp @@ -0,0 +1,48 @@ +#include "global.h" + +#include "GeckoWindow.h" + +IMPLEMENT_DYNAMIC_CLASS(GeckoWindow, wxPanel) + +GeckoWindow::GeckoWindow(void) : + mGeckoContainer(NULL) +{ +} + +GeckoWindow::~GeckoWindow() +{ + SetGeckoContainer(NULL); +} + +void GeckoWindow::SetGeckoContainer(GeckoContainer *aGeckoContainer) +{ + if (aGeckoContainer != mGeckoContainer) + { + NS_IF_RELEASE(mGeckoContainer); + mGeckoContainer = aGeckoContainer; + NS_IF_ADDREF(mGeckoContainer); + } +} + +BEGIN_EVENT_TABLE(GeckoWindow, wxPanel) + EVT_SIZE(GeckoWindow::OnSize) +END_EVENT_TABLE() + +void GeckoWindow::OnSize(wxSizeEvent &event) +{ + if (!mGeckoContainer) + { + return; + } + // Make sure the browser is visible and sized + nsCOMPtr webBrowser; + mGeckoContainer->GetWebBrowser(getter_AddRefs(webBrowser)); + nsCOMPtr webBrowserAsWin = do_QueryInterface(webBrowser); + if (webBrowserAsWin) + { + wxSize size = GetClientSize(); + webBrowserAsWin->SetPositionAndSize( + 0, 0, size.GetWidth(), size.GetHeight(), PR_TRUE); + webBrowserAsWin->SetVisibility(PR_TRUE); + } +} diff --git a/mozilla/embedding/tests/wxEmbed/GeckoWindow.h b/mozilla/embedding/tests/wxEmbed/GeckoWindow.h new file mode 100644 index 00000000000..2fc72722b4c --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoWindow.h @@ -0,0 +1,22 @@ +#ifndef GECKOWND_H_270B94BB_E0EE_44bd_8983_CC43BFA39996 +#define GECKOWND_H_270B94BB_E0EE_44bd_8983_CC43BFA39996 + +#include "GeckoContainer.h" + +class GeckoWindow : public wxPanel +{ + DECLARE_DYNAMIC_CLASS(GeckoWindow); + +protected: + DECLARE_EVENT_TABLE() + void OnSize(wxSizeEvent &event); + + GeckoContainer *mGeckoContainer; + +public: + GeckoWindow(); + virtual ~GeckoWindow(); + void SetGeckoContainer(GeckoContainer *aGeckoContainer); +}; + +#endif /* GECKOWND_H_270B94BB_E0EE_44bd_8983_CC43BFA39996 */ \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.cpp b/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.cpp new file mode 100644 index 00000000000..c170df76f77 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.cpp @@ -0,0 +1,26 @@ +#include "GeckoWindowCreator.h" +#include "GeckoContainer.h" + +#include "nsIWebBrowserChrome.h" + +GeckoWindowCreator::GeckoWindowCreator() +{ +} + +GeckoWindowCreator::~GeckoWindowCreator() +{ +} + +NS_IMPL_ISUPPORTS1(GeckoWindowCreator, nsIWindowCreator) + +NS_IMETHODIMP +GeckoWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *parent, + PRUint32 chromeFlags, + nsIWebBrowserChrome **_retval) +{ + NS_ENSURE_ARG_POINTER(_retval); +// AppCallbacks::CreateBrowserWindow(PRInt32(chromeFlags), parent, _retval); + // TODO QI nsIGeckoContainer + *_retval = nsnull; + return *_retval ? NS_OK : NS_ERROR_FAILURE; +} \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.h b/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.h new file mode 100644 index 00000000000..71e87ae3322 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoWindowCreator.h @@ -0,0 +1,17 @@ +#ifndef GECKOWINDOWCREATOR_H +#define GECKOWINDOWCREATOR_H + +#include "nsIWindowCreator.h" + +class GeckoWindowCreator : + public nsIWindowCreator +{ +public: + GeckoWindowCreator(); + virtual ~GeckoWindowCreator(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWINDOWCREATOR +}; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/MailFrame.cpp b/mozilla/embedding/tests/wxEmbed/MailFrame.cpp new file mode 100644 index 00000000000..850e27bfac2 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/MailFrame.cpp @@ -0,0 +1,128 @@ +#include "global.h" + +#include "MailFrame.h" +#include "GeckoProtocolHandler.h" + +#include "nsIURI.h" + +const char msg1[] = +"Attention: Sir, \n" +"Good day. I am ALEXANDER NENE, Solicitor and Notary Public, The Personal Attorney to MR HENRI CARLTON, The president of DIAMOND SAFARIESCO.LTD.ACCRA-GHANA who is a National of your country. On the 21st of April 2000, my client, his wife and their only son were Involved in a car accident along ACCRA/KUMASI Express Road. \n" +"Unfortunately, they all lost their lives in the event of the accident, since then I have made several enquiries to locate any of my clients extended relatives and this has also proved unsuccessful.After these several unsuccessful attempts, I decided to trace his Relatives over the Internet, to locate any member of his family but of no avail, hence I contacted youI contacted you to assist in repatriating the money and property left Behind before they get confiscated or declare unserviceable by the bank where my client lodged this huge deposits. Particularly, the Bank where the deceased had an account valued at about 28.3 million dollars.Conseqently, the bank issued me a notice to provide the next of kin or Have the account confiscated within a short time. Since I have been Unsuccessful in locating the relatives for over some years now, I seek your consent to present you as the next of kin of the deceased since you share the same surname so that the proceeds of this account va!\n" +"lued at 48.3 million dollars can be paid to you for both of us to share the money; 70% to me and 25% to you, while 5% should be for expenses or tax as your government may require. I have all necessary legal documents that can be used to backup the claim.All I require is your honest cooperation to enable us see this deal \n" +"Through. I guarantee that this will be executed under a legitimate arrangement that will protect you from any breach of the law. Please get in touch with me through my email to enable us discuss further. \n" +"Thanks for you kind co-operation \n" +"ALEXANDER NENE \n" +"\n" +"\n" +"___________________________________________________\n" +"GO.com Mail \n" +"Get Your Free, Private E-mail at http://mail.go.com\n"; + + +static bool gMailChannelCallbackRegistered = FALSE; + +class MailChannelCallback : public GeckoChannelCallback +{ +public: + virtual nsresult GetData( + nsIURI *aURI, + nsIChannel *aChannel, + nsACString &aContentType, + void **aData, + PRUint32 *aSize) + { + nsCAutoString txt(msg1); + aContentType.Assign("text/plain"); + + size_t size = txt.Length(); + *aData = (void *) nsMemory::Alloc(size); + if (!*aData) + return NS_ERROR_OUT_OF_MEMORY; + memset(*aData, 0, size); + memcpy((char *) *aData, txt.get(), size); + *aSize = size; + return NS_OK; + } +}; + +BEGIN_EVENT_TABLE(MailFrame, wxFrame) + EVT_LIST_ITEM_SELECTED(XRCID("articles"), MailFrame::OnArticleClick) +END_EVENT_TABLE() + +MailFrame::MailFrame(wxWindow* aParent) : + mGeckoWnd(NULL) +{ + wxXmlResource::Get()->LoadFrame(this, aParent, wxT("mail_frame")); + + SetIcon(wxICON(appicon)); + + if (!gMailChannelCallbackRegistered) + { + GeckoProtocolHandler::RegisterHandler("wxmail", "wxMail handler", new MailChannelCallback); + gMailChannelCallbackRegistered = TRUE; + } + + + // Set up the article pane + wxListCtrl *articleListCtrl = (wxListCtrl *) FindWindowById(XRCID("articles"), this); + if (articleListCtrl) + { + articleListCtrl->InsertColumn(0, "Subject", wxLIST_FORMAT_LEFT, 200); + articleListCtrl->InsertColumn(1, "Sender", wxLIST_FORMAT_LEFT, 100); + articleListCtrl->InsertColumn(2, "Date", wxLIST_FORMAT_LEFT, 100); + long idx; + idx = articleListCtrl->InsertItem(0, "URGENT ASSITANCE PLS"); + articleListCtrl->SetItem(idx, 1, "alexander nene"); + articleListCtrl->SetItem(idx, 2, "09/06/2003 14:38"); + idx = articleListCtrl->InsertItem(1, "Reminder: Network Outage Tonight"); + articleListCtrl->SetItem(idx, 1, "IT Dept"); + articleListCtrl->SetItem(idx, 2, "09/06/2003 15:22"); + idx = articleListCtrl->InsertItem(2, "Expense Reports Due"); + articleListCtrl->SetItem(idx, 1, "Finance Dept"); + articleListCtrl->SetItem(idx, 2, "09/06/2003 15:40"); + } + + mGeckoWnd = (GeckoWindow *) FindWindowById(XRCID("gecko"), this); + if (mGeckoWnd) + { + GeckoContainer *geckoContainer = new GeckoContainer(this); + if (geckoContainer) + { + mGeckoWnd->SetGeckoContainer(geckoContainer); + + PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL; + geckoContainer->SetChromeFlags(aChromeFlags); + geckoContainer->SetParent(nsnull); + + wxSize size = mGeckoWnd->GetClientSize(); + + // Insert the browser + geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(), + (nativeWindow) mGeckoWnd->GetHWND(), getter_AddRefs(mWebbrowser)); + + GeckoContainerUI::ShowWindow(PR_TRUE); + + } + } + + CreateStatusBar(); +} + +void MailFrame::OnArticleClick(wxListEvent &event) +{ + if (mWebbrowser) + { + wxString url = "wxmail:" + event.GetIndex(); + if (!url.IsEmpty()) + { + nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + webNav->LoadURI(NS_ConvertASCIItoUCS2(url.c_str()).get(), + nsIWebNavigation::LOAD_FLAGS_NONE, + nsnull, + nsnull, + nsnull); + } + } +} + diff --git a/mozilla/embedding/tests/wxEmbed/MailFrame.h b/mozilla/embedding/tests/wxEmbed/MailFrame.h new file mode 100644 index 00000000000..e203393fa95 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/MailFrame.h @@ -0,0 +1,22 @@ +#ifndef MAILFRAME_H +#define MAILFRAME_H + +#include "GeckoContainer.h" +#include "GeckoWindow.h" + +class MailFrame : + public wxFrame, + public GeckoContainerUI +{ +public : + MailFrame(wxWindow* aParent); + + DECLARE_EVENT_TABLE() + + void OnArticleClick(wxListEvent &event); + + GeckoWindow *mGeckoWnd; + nsCOMPtr mWebbrowser; + }; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/README.txt b/mozilla/embedding/tests/wxEmbed/README.txt new file mode 100644 index 00000000000..0cb11f3b16f --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/README.txt @@ -0,0 +1,18 @@ +wxEmbed is a sample application developed with wxWindows to demonstrate +various ways of embedding Gecko. It contains a sample browser and several +other demonstrations of embedded Gecko. + +wxEmbed is deliberately not based upon wxMozilla - a 3rd party wrapper +for wxWindows. Go with wxMozilla if you are more interested in something more +robust and cross-platform. wxEmbed is intended more as a harness to test the +embedding functionality of Gecko not an end solution. + +To build wxEmbed you must: + +1. Get the latest 2.4 release from wxwindows.org +2. Build the debug/release static lib versions +3. cd into wxWindows/control and build src/xrc and utils/wxrc +4. Set your WXWIN environment variable to point to the wxWindows dir +5. Build Mozilla +6. Set MOZ_SRC environment variable to point to it. + diff --git a/mozilla/embedding/tests/wxEmbed/global.h b/mozilla/embedding/tests/wxEmbed/global.h new file mode 100644 index 00000000000..4312f0935bd --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/global.h @@ -0,0 +1,17 @@ +#ifndef GLOBAL_H_D5809FA6_E3E6_4726_9CD4_DE7330D9C2A1 +#define GLOBAL_H_D5809FA6_E3E6_4726_9CD4_DE7330D9C2A1 + +#include +#include +#include +#include +#include +#include + +#include "nsEmbedAPI.h" +#include "nsIWeakReference.h" +#include "nsIWeakReferenceUtils.h" + +extern void InitXmlResource(); // Generated by wxrc in C++ source + +#endif /* GLOBAL_H_D5809FA6_E3E6_4726_9CD4_DE7330D9C2A1 */ \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/makefile.vc b/mozilla/embedding/tests/wxEmbed/makefile.vc new file mode 100644 index 00000000000..e411e505e47 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/makefile.vc @@ -0,0 +1,67 @@ +MOZ_SRC = c:\m\source_1.4 + +WXDIR = $(WXWIN) +MOZDIR = $(MOZ_SRC)\mozilla +MOZSDK = $(MOZDIR)\dist + +PROGRAM = wxEmbed +OBJECTS = \ + EmbedApp.obj \ + BrowserFrame.obj \ + MailFrame.obj \ + GeckoContainer.obj \ + GeckoContainerUI.obj \ + GeckoWindow.obj \ + GeckoWindowCreator.obj \ + GeckoProtocolHandler.obj \ + resource.obj \ + $(NULL) + +XRC = \ + rc\mail.xrc \ + rc\browser.xrc \ + $(NULL) + +# Needing to include this big long list of includes STINKS!!! +MOZINC = \ + -I$(MOZSDK)\include \ + -I$(MOZSDK)\include\nspr \ + -I$(MOZSDK)\include\xpcom \ + -I$(MOZSDK)\include\string \ + -I$(MOZSDK)\include\necko \ + -I$(MOZSDK)\include\docshell \ + -I$(MOZSDK)\include\dom \ + -I$(MOZSDK)\include\widget \ + -I$(MOZSDK)\include\gfx \ + -I$(MOZSDK)\include\uriloader \ + -I$(MOZSDK)\include\shistory \ + -I$(MOZSDK)\include\profile \ + -I$(MOZSDK)\include\webbrwsr \ + -I$(MOZSDK)\include\embed_base \ + $(NULL) + +# This isn't much better either! +MOZLIBS = \ + $(MOZSDK)\lib\xpcom.lib \ + $(MOZSDK)\lib\embed_base_s.lib \ + $(NULL) +# $(MOZSDK)\lib\xpcomglue_s.lib \ + +MOZDEFS = \ + -DXPCOM_GLUE \ + $(NULL) + +EXTRALIBS = $(WXDIR)\lib\wxxrc$(LIBEXT).lib $(MOZLIBS) +EXTRAINC = -I$(WXDIR)\contrib\include $(MOZINC) + +!include $(WXDIR)\src\makeprog.vc + +# CPPFLAGS = $(CPPFLAGS) $(MOZDEFS) + +all: + -copy $(PROGRAM).exe $(MOZDIR)\dist\bin + +resource.cpp: $(XRC) + $(WXDIR)\contrib\utils\wxrc\wxrc.exe -v -c -o $@ $(XRC) + + diff --git a/mozilla/embedding/tests/wxEmbed/rc/back.gif b/mozilla/embedding/tests/wxEmbed/rc/back.gif new file mode 100644 index 00000000000..f1febf3c9ab Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/back.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/rc/browser.xrc b/mozilla/embedding/tests/wxEmbed/rc/browser.xrc new file mode 100644 index 00000000000..6b2d781c4db --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/rc/browser.xrc @@ -0,0 +1,124 @@ + + + + + + wxEmbed Browser + 300,300 + + -1,-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2,2 + 20,18 + + + back.gif + Back + + + forward.gif + Forward + + + + reload.gif + Reload + + + stop.gif + Stop + + + + home.gif + Home + + + + + + 1 + 2 + 0 + 0 + 0 + 1 + + + + + wxALIGN_LEFT|wxGROW|wxALL + + + + 3 + 1 + 0 + 0 + 1 + 0 + + wxHORIZONTAL + + wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + + + + + + wxGROW|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + + + + + + wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + + + + + + + + + + + + wxGROW|wxALL + + + 500,280 + + + + + + + diff --git a/mozilla/embedding/tests/wxEmbed/rc/forward.gif b/mozilla/embedding/tests/wxEmbed/rc/forward.gif new file mode 100644 index 00000000000..c98f4369dac Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/forward.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/rc/help.gif b/mozilla/embedding/tests/wxEmbed/rc/help.gif new file mode 100644 index 00000000000..be454087af5 Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/help.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/rc/home.gif b/mozilla/embedding/tests/wxEmbed/rc/home.gif new file mode 100644 index 00000000000..e2b1080d2b0 Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/home.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/rc/mail.xrc b/mozilla/embedding/tests/wxEmbed/rc/mail.xrc new file mode 100644 index 00000000000..db54aaede90 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/rc/mail.xrc @@ -0,0 +1,49 @@ + + + + + + wxEmbed Mail + 300,300 + + -1,-1 + + + + + + + + + + 1 + 2 + 0 + 0 + 0 + 1 + + + wxALL|wxGROW + + + 500,150 + + + + + + + + wxGROW|wxALL + + + 500,280 + + + + + + + + \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/rc/reload.gif b/mozilla/embedding/tests/wxEmbed/rc/reload.gif new file mode 100644 index 00000000000..74d3080cfba Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/reload.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/rc/stop.gif b/mozilla/embedding/tests/wxEmbed/rc/stop.gif new file mode 100644 index 00000000000..a22f14ebbc2 Binary files /dev/null and b/mozilla/embedding/tests/wxEmbed/rc/stop.gif differ diff --git a/mozilla/embedding/tests/wxEmbed/wxEmbed.def b/mozilla/embedding/tests/wxEmbed/wxEmbed.def new file mode 100644 index 00000000000..b2eb77d98dd --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/wxEmbed.def @@ -0,0 +1,8 @@ +NAME wxEmbed +DESCRIPTION 'wxEmbed' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 1024 +STACKSIZE 8192 diff --git a/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp b/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp new file mode 100644 index 00000000000..0d7b962feef --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp @@ -0,0 +1,217 @@ +# Microsoft Developer Studio Project File - Name="wxEmbed" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=wxEmbed - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "wxEmbed.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "wxEmbed.mak" CFG="wxEmbed - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "wxEmbed - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "wxEmbed - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "wxEmbed - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f wxEmbed.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "wxEmbed.exe" +# PROP BASE Bsc_Name "wxEmbed.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f makefile.vc" +# PROP Rebuild_Opt "/a" +# PROP Target_File "c:\m\source_1.4\mozilla\dist\bin" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "wxEmbed - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "wxEmbed___Win32_Debug" +# PROP BASE Intermediate_Dir "wxEmbed___Win32_Debug" +# PROP BASE Cmd_Line "NMAKE /f wxEmbed.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "wxEmbed.exe" +# PROP BASE Bsc_Name "wxEmbed.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "wxEmbed___Win32_Debug" +# PROP Intermediate_Dir "wxEmbed___Win32_Debug" +# PROP Cmd_Line "nmake /f makefile.vc" +# PROP Rebuild_Opt "/a" +# PROP Target_File "c:\m\source_1.4\mozilla\dist\bin\wxEmbed.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "wxEmbed - Win32 Release" +# Name "wxEmbed - Win32 Debug" + +!IF "$(CFG)" == "wxEmbed - Win32 Release" + +!ELSEIF "$(CFG)" == "wxEmbed - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\BrowserFrame.cpp +# End Source File +# Begin Source File + +SOURCE=.\EmbedApp.cpp +# End Source File +# Begin Source File + +SOURCE=.\GeckoContainer.cpp +# End Source File +# Begin Source File + +SOURCE=.\GeckoContainerUI.cpp +# End Source File +# Begin Source File + +SOURCE=.\GeckoProtocolHandler.cpp +# End Source File +# Begin Source File + +SOURCE=.\GeckoWindow.cpp +# End Source File +# Begin Source File + +SOURCE=.\GeckoWindowCreator.cpp +# End Source File +# Begin Source File + +SOURCE=.\MailFrame.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\BrowserFrame.h +# End Source File +# Begin Source File + +SOURCE=.\GeckoContainer.h +# End Source File +# Begin Source File + +SOURCE=.\GeckoProtocolHandler.h +# End Source File +# Begin Source File + +SOURCE=.\GeckoWindow.h +# End Source File +# Begin Source File + +SOURCE=.\GeckoWindowCreator.h +# End Source File +# Begin Source File + +SOURCE=.\global.h +# End Source File +# Begin Source File + +SOURCE=.\MailFrame.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\rc\back.gif +# End Source File +# Begin Source File + +SOURCE=.\rc\browser.xrc +# End Source File +# Begin Source File + +SOURCE=.\rc\forward.gif +# End Source File +# Begin Source File + +SOURCE=.\rc\help.gif +# End Source File +# Begin Source File + +SOURCE=.\rc\home.gif +# End Source File +# Begin Source File + +SOURCE=.\rc\mail.xrc +# End Source File +# Begin Source File + +SOURCE=.\rc\reload.gif +# End Source File +# Begin Source File + +SOURCE=.\rc\stop.gif +# End Source File +# Begin Source File + +SOURCE=.\wxEmbed.rc +# End Source File +# End Group +# Begin Group "Generated Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\resource.cpp +# End Source File +# End Group +# Begin Group "External Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE="..\wxWindows-2.4.0\docs\tech\tn0014.txt" +# End Source File +# End Group +# Begin Source File + +SOURCE=.\makefile.vc +# End Source File +# Begin Source File + +SOURCE=.\README.txt +# End Source File +# End Target +# End Project diff --git a/mozilla/embedding/tests/wxEmbed/wxEmbed.rc b/mozilla/embedding/tests/wxEmbed/wxEmbed.rc new file mode 100644 index 00000000000..b86c4e2265c --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/wxEmbed.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc"