adding tests for qa embedding. not part of the build

This commit is contained in:
amasri%netscape.com 2001-05-30 02:49:08 +00:00
parent 6f138c7969
commit faa25a123b
69 changed files with 12893 additions and 0 deletions

View File

@ -0,0 +1,760 @@
Index: BrowserView.cpp
===================================================================
RCS file: /cvsroot/mozilla/embedding/tests/mfcembed/BrowserView.cpp,v
retrieving revision 1.8
diff -u -6 -r1.8 BrowserView.cpp
--- BrowserView.cpp 2001/04/16 20:34:33 1.8
+++ BrowserView.cpp 2001/05/18 23:49:06
@@ -48,12 +48,15 @@
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserView.h"
#include "BrowserImpl.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
+#include "UrlDialog.h"
+#include "ProfileMgr.h"
+#include "ProfilesDlg.h"
// Print Includes
#include "PrintProgressDialog.h"
#ifdef _DEBUG
@@ -67,18 +70,14 @@
BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
//{{AFX_MSG_MAP(CBrowserView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_SIZE()
-
- // UrlBar command handlers
- ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar)
-
- // Menu/Toolbar command handlers
+ ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
ON_COMMAND(ID_VIEW_SOURCE, OnViewSource)
ON_COMMAND(ID_VIEW_INFO, OnViewInfo)
ON_COMMAND(ID_NAV_BACK, OnNavBack)
ON_COMMAND(ID_NAV_FORWARD, OnNavForward)
@@ -88,29 +87,35 @@
ON_COMMAND(ID_EDIT_CUT, OnCut)
ON_COMMAND(ID_EDIT_COPY, OnCopy)
ON_COMMAND(ID_EDIT_PASTE, OnPaste)
ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp)
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone)
+ ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow)
ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow)
- ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
-
- // Menu/Toolbar UI update handlers
+ ON_COMMAND(ID_TESTS_CHANGEURL, OnTestsChangeUrl)
+ ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
+ ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
+ ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack)
ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward)
ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop)
ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut)
ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy)
ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste)
+ ON_COMMAND(ID_INTERFACES_NSIFILE, OnInterfacesNsifile)
+ ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
+ ON_COMMAND(ID_INTERFACES_NSISHISTORY, OnInterfacesNsishistory)
+ ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CBrowserView::CBrowserView()
{
@@ -126,12 +131,14 @@
m_pFindDlg = NULL;
m_pPrintProgressDlg = NULL;
m_bUrlBarClipOp = FALSE;
m_bCurrentlyPrinting = FALSE;
+
+ char *theUrl = "http://www.aol.com/";
}
CBrowserView::~CBrowserView()
{
}
@@ -166,12 +173,14 @@
//
rv = NS_OK;
mWebNav = do_QueryInterface(mWebBrowser, &rv);
if(NS_FAILED(rv))
return rv;
+// mSessionHistory = do_GetInterface(mWebBrowser, &rv); // de: added 5/11
+
// Create the CBrowserImpl object - this is the object
// which implements the interfaces which are required
// by an app embedding mozilla i.e. these are the interfaces
// thru' which the *embedded* browser communicates with the
// *embedding* app
//
@@ -229,14 +238,24 @@
rv = mBaseWindow->Create();
// Register the BrowserImpl object to receive progress messages
// These callbacks will be used to update the status/progress bars
nsWeakPtr weakling(
dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
- (void)mWebBrowser->AddWebBrowserListener(weakling,
- NS_GET_IID(nsIWebProgressListener));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not added.");
+ WriteToOutputFile("Web Progress Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener added.");
+ WriteToOutputFile("Web Progress Listener added.\r\n");
+ }
// Finally, show the web browser window
mBaseWindow->SetVisibility(PR_TRUE);
return S_OK;
}
@@ -252,12 +271,27 @@
if(mpBrowserImpl)
{
mpBrowserImpl->Release();
mpBrowserImpl = nsnull;
}
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
+ nsresult rv;
+ rv = mWebBrowser->RemoveWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not removed.");
+ WriteToOutputFile("Web Progress Listener not removed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener removed.");
+ WriteToOutputFile("Web Progress Listener removed.\r\n");
+ }
+
return NS_OK;
}
BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
@@ -986,7 +1020,592 @@
case WA_INACTIVE:
focus->Deactivate();
break;
default:
break;
}
+}
+
+// de: Start QA test cases here
+// *********************************************************
+// *********************************************************
+
+void CBrowserView::OnTestsChangeUrl()
+{
+ char *theUrl = "http://www.aol.com/";
+ CUrlDialog myDialog;
+ nsresult rv;
+
+// nsCOMPtr<nsIURI> pURI;
+
+ if (!mWebNav)
+ {
+ AfxMessageBox("Web navigation object not found. Change URL test not performed.");
+ WriteToOutputFile("Web navigation object not found. Change URL test not performed.\r\n");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin Change URL test.");
+ WriteToOutputFile("Begin Change URL test.\r\n");
+ strcpy(theUrl, myDialog.m_urlfield);
+ mWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).GetUnicode(),
+ nsIWebNavigation::LOAD_FLAGS_NONE);
+ WriteToOutputFile("\r\nLoadURI() method is called.");
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+/*
+ char *uriSpec;
+ // GetcurrentURI() declared in nsIP3PUI.idl
+ // used with webNav obj in nsP3PObserverHTML.cpp, line 239
+ // this will be used as an indep routine to verify the URI load
+ rv = mWebNav->GetCurrentURI( getter_AddRefs( pURI ) );
+ if(NS_FAILED(rv) || !pURI)
+ AfxMessageBox("Bad result for GetCurrentURI().");
+
+ rv = pURI->GetSpec(&uriSpec);;
+ if (NS_FAILED(rv))
+ AfxMessageBox("Bad result for GetSpec().");
+
+ AfxMessageBox("Start URL validation test().");
+ if (strcmp(uriSpec, theUrl) == 0)
+ {
+ WriteToOutputFile("Url loaded successfully. Test Passed.");
+ }
+ else
+ {
+ WriteToOutputFile("Url didn't load successfully. Test Failed.");
+ }
+*/
+ AfxMessageBox("End Change URL test.");
+ WriteToOutputFile("End Change URL test.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Change URL test not executed.");
+ WriteToOutputFile("Change URL test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsGlobalHistory()
+{
+ // create instance of myHistory object. Call's XPCOM
+ // service manager to pass the contract ID.
+
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+
+ nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+
+ if (!myHistory)
+ {
+ WriteToOutputFile("Couldn't find history object. No GH tests performed.\r\n");
+ AfxMessageBox("Couldn't find history object. No GH tests performed.");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin IsVisited() and AddPage() tests.");
+ WriteToOutputFile("Begin IsVisited() and AddPage() tests.\r\n");
+
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+ // see if url is already in the GH file (pre-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL has been visited. Won't execute AddPage().\r\n");
+ AfxMessageBox("URL has been visited. Won't execute AddPage().");
+ }
+ else
+ {
+ WriteToOutputFile("URL hasn't been visited. Will execute AddPage().\r\n");
+ AfxMessageBox("URL hasn't been visited. Will execute AddPage().");
+ // adds a url to the global history file
+ rv = myHistory->AddPage(theUrl);
+
+ // prints addPage() results to output file
+ if (NS_FAILED(rv))
+ {
+ WriteToOutputFile("Invalid results for AddPage(). Url not added. Test failed.\r\n");
+ return;
+ }
+ else
+ {
+ WriteToOutputFile("Valid results for AddPage(). Url added. Test passed.\r\n");
+ }
+
+ // checks if url was visited (post-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL is visited; post-AddPage() test. IsVisited() test passed.\r\n");
+ }
+ else
+ {
+ WriteToOutputFile("URL isn't visited; post-AddPage() test. IsVisited() test failed.\r\n");
+ }
+ }
+ AfxMessageBox("End IsVisited() and AddPage() tests.");
+ WriteToOutputFile("End IsVisited() and AddPage() tests.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("IsVisited() and AddPage() tests not executed.");
+ WriteToOutputFile("IsVisited() and AddPage() tests not executed.\r\n");
+ }
+}
+
+
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateFile()
+{
+ nsresult rv;
+ PRBool exists;
+ nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+
+ AfxMessageBox("Start Create File test.");
+ WriteToOutputFile("\r\nStart Create File test.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\theFile.txt");
+ rv = theTestFile->Exists(&exists);
+
+ WriteToOutputFile("File doesn't exist. We'll create it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (theFile.txt).");
+ WriteToOutputFile("Create() test Failed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (theFile.txt).");
+ WriteToOutputFile("Create() test Passed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateprofile()
+{
+ CProfilesDlg myDialog;
+ nsresult rv;
+
+ if (myDialog.DoModal() == IDOK)
+ {
+// NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
+ nsCOMPtr<nsIProfile> theProfServ(do_GetService(NS_PROFILE_CONTRACTID));
+ if (!theProfServ)
+ {
+ WriteToOutputFile("Didn't get profile service. No profile tests performed.\r\n");
+ AfxMessageBox("Didn't get profile service. No profile tests performed.");
+ return;
+ }
+
+ if (theProfServ)
+ {
+ AfxMessageBox("Start Profile switch test.");
+ WriteToOutputFile("Start Profile switch test.\r\n");
+
+ AfxMessageBox("Retrieved profile service.");
+ rv = theProfServ->SetCurrentProfile(myDialog.m_SelectedProfile.GetUnicode());
+ if (NS_SUCCEEDED(rv))
+ AfxMessageBox("SetCurrentProfile() passed. Profile switched.");
+ else
+ AfxMessageBox("SetCurrentProfile() didn't pass.Profile not switched.");
+
+ AfxMessageBox("End Profile switch test.");
+ WriteToOutputFile("End Profile switch test.\r\n");
+ }
+ }
+ else
+ {
+ AfxMessageBox("Profile switch test not executed.");
+ WriteToOutputFile("Profile switch test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+// *********************************************************
+// TOOLS to help us
+
+
+void CBrowserView::OnToolsRemoveGHPage()
+{
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+ nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+ if (!myGHistory)
+ {
+ WriteToOutputFile("Could not get the global history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+ nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
+ if(!NS_SUCCEEDED(rv)) {
+ WriteToOutputFile("Could not get the history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+// nsCOMPtr<nsIBrowserHistory> myHistory(do_GetInterface(myGHistory));
+
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ WriteToOutputFile("Begin URL removal from the GH file.\r\n");
+ AfxMessageBox("Begin URL removal from the GH file.");
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ myGHistory->IsVisited(theUrl, &theRetVal);
+ if (theRetVal)
+ {
+ rv = myHistory->RemovePage(theUrl);
+ if (NS_SUCCEEDED(rv))
+ {
+ WriteToOutputFile("\r\nThe URL was removed from the GH file.\r\n");
+ AfxMessageBox("The URL was removed from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("\r\nThe URL wasn't removed from the GH file.\r\n");
+ AfxMessageBox("The URL wasn't removed from the GH file.");
+ }
+ }
+ else
+ {
+ WriteToOutputFile("The URL wasn't in the GH file.\r\n");
+ }
+ WriteToOutputFile("End URL removal from the GH file.\r\n");
+ AfxMessageBox("End URL removal from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("URL removal from the GH file not executed.\r\n");
+ AfxMessageBox("URL removal from the GH file not executed.");
+ }
+}
+
+// ***********************************************************************
+// ************************** Interface Tests ****************************
+// ***********************************************************************
+
+// nsIFile:
+
+void CBrowserView::OnInterfacesNsifile()
+{
+ nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+ nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+
+ nsresult rv;
+ PRBool exists;
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+ if (!theFileOpDir)
+ {
+ WriteToOutputFile("Dir object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+ AfxMessageBox("Begin nsIFile tests.");
+ WriteToOutputFile("\r\nBegin testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to initialize file path.");
+ WriteToOutputFile("InitWithPath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We initialized file path.");
+ WriteToOutputFile("InitWithPath() test Passed.");
+ }
+
+ rv = theTestFile->AppendRelativePath("myFile.txt");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to append the file.");
+ WriteToOutputFile("AppendRelativePath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We appended the file.");
+ WriteToOutputFile("AppendRelativePath() test Passed.");
+ }
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File doesn't exist. We'll try creating it.");
+ WriteToOutputFile("File doesn't exist. We'll try creating it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (myFile.txt).");
+ WriteToOutputFile("Create() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (myFile.txt).");
+ WriteToOutputFile("Create() test Passed.");
+ }
+ }
+ else
+ {
+ AfxMessageBox("File already exists (myFile.txt). We won't create it.");
+ WriteToOutputFile("File already exists (myFile.txt). We won't create it.");
+ }
+
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File (myFile.txt) doesn't exist.");
+ WriteToOutputFile("Exists() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File (myFile.txt) exists.");
+ WriteToOutputFile("Exists() test Passed.");
+ }
+
+ // FILE COPY test
+
+ AfxMessageBox("Start File Copy test.");
+ WriteToOutputFile("Start File Copy test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+ else
+ {
+ AfxMessageBox("The target dir was found.");
+ WriteToOutputFile("The target dir was found.");
+ }
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+ else
+ AfxMessageBox("The path was found.");
+ rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv CopyTo() test failed.");
+ else
+ AfxMessageBox("rv CopyTo() test succeeded.");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File didn't copy.");
+ WriteToOutputFile("CopyTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File copied.");
+ WriteToOutputFile("CopyTo() test Passed.");
+ }
+
+ // FILE MOVE test
+
+ AfxMessageBox("Start File Move test.");
+ WriteToOutputFile("Start File Move test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\Program Files\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+
+ rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv MoveTo() test failed.");
+ else
+ AfxMessageBox("rv MoveTo() test succeeded.");
+ rv = theTestFile->InitWithPath("c:\\Program Files\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File wasn't moved.");
+ WriteToOutputFile("MoveTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File was moved.");
+ WriteToOutputFile("MoveTo() test Passed.");
+ }
+
+ AfxMessageBox("End nsIFile tests.");
+ WriteToOutputFile("\r\nEnd testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+}
+
+// nsISHistory:
+
+void CBrowserView::OnInterfacesNsishistory()
+{
+ nsresult rv;
+ boolean modifyIndex;
+ long numEntries = 0;
+
+ nsCOMPtr<nsISHistory> theSessionHistory(do_CreateInstance(NS_SHISTORY_CONTRACTID));
+ nsCOMPtr<nsIHistoryEntry> theHistoryEntry(do_CreateInstance(NS_HISTORYENTRY_CONTRACTID));
+ nsCOMPtr<nsISHistoryListener> theSHListener(do_CreateInstance(NS_SHISTORYLISTENER_CONTRACTID));
+ // do_QueryInterface
+ // NS_HISTORYENTRY_CONTRACTID
+ // NS_SHISTORYLISTENER_CONTRACTID
+
+
+ if (!theSessionHistory)
+ {
+ AfxMessageBox("theSessionHistory object wasn't created. No tests performed.");
+ return;
+ }
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ return;
+ }
+
+ // addSHistoryListener test
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ WriteToOutputFile("NSISHistory Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("NSISHistory Listener added.");
+ WriteToOutputFile("NSISHistory Listener added.\r\n");
+ }
+
+/*
+ // getEntryAtIndex() test
+ theHistoryEntry = theSessionHistory->GetEntryAtIndex(index, modifyIndex);
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("We got the History Entry.");
+ }
+ else
+ {
+ AfxMessageBox("We didn't get the History Entry.");
+ }
+
+*/
+
+///*
+ // PurgeHistory() test
+ rv = theSessionHistory->PurgeHistory(numEntries);
+ if (NS_FAILED(rv))
+ AfxMessageBox("Purge History test failed.");
+ else
+ AfxMessageBox("Purge History test succeeded.");
+//*/
+
+ // RemoveSHistoryListener test
+/*
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = theSessionHistory->RemoveSHistoryListener(weakling);
+*/
+}
+
+
+// ***************** Local Methods ******************
+
+void CBrowserView::WriteToOutputFile(char *pLine)
+{
+ CStdioFile myFile;
+ CFileException e;
+ CString strFileName = "c:\\temp\\MFCoutfile";
+
+ if(! myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
+ | CStdioFile::modeNoTruncate, &e ) )
+ {
+ CString failCause = "Unable to open file. Reason : ";
+ failCause += e.m_cause;
+ AfxMessageBox(failCause);
+ }
+ else
+ {
+ myFile.SeekToEnd();
+ CString strLine = pLine;
+ strLine += "\r\n";
+
+ myFile.WriteString(strLine);
+
+ myFile.Close();
+ }
+}
+
+
+// ***************** Bug Verifications ******************
+
+void CBrowserView::OnVerifybugs70228()
+{
+/*
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_GetService(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It's NOT a service!");
+ else
+ AfxMessageBox("Object is created. But should it?! It's NOT a service!");
+
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It should be. It's a component!");
+ else
+ AfxMessageBox("Object is created. It's a component!");
+*/
+/*
+nsCOMPtr<nsIHelperAppLauncher>
+ myHAL(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+
+ rv = myHALD->show(myHal, mySupp);
+*/
}

View File

@ -0,0 +1,97 @@
Index: BrowserView.h
===================================================================
RCS file: /cvsroot/mozilla/embedding/tests/mfcembed/BrowserView.h,v
retrieving revision 1.6
diff -u -6 -r1.6 BrowserView.h
--- BrowserView.h 2001/04/16 20:19:00 1.6
+++ BrowserView.h 2001/05/19 00:09:15
@@ -79,14 +79,16 @@
CBrowserImpl* mpBrowserImpl;
// Mozilla interfaces
//
nsCOMPtr<nsIWebBrowser> mWebBrowser;
nsCOMPtr<nsIBaseWindow> mBaseWindow;
- nsCOMPtr<nsIWebNavigation> mWebNav;
+ nsCOMPtr<nsIWebNavigation> mWebNav;
+ //nsCOMPtr<nsISHistory> mSessionHistory; // de: added in 5/11/01
+
void UpdateBusyState(PRBool aBusy);
PRBool mbDocumentLoading;
void SetCtxMenuLinkUrl(nsAutoString& strLinkUrl);
nsAutoString mCtxMenuLinkUrl;
@@ -108,33 +110,34 @@
void Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
BOOL OpenViewSourceWindow(const char* pUrl);
BOOL IsViewSourceUrl(CString& strUrl);
+ // de: local methods
+ static void WriteToOutputFile(char * strInput);
+ static char *theUrl;
+
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserView)
- protected:
+
+
+protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Generated message map functions
protected:
//{{AFX_MSG(CBrowserView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnSize( UINT, int, int );
- // UrlBar command handlers
- //
afx_msg void OnUrlSelectedInUrlBar();
afx_msg void OnNewUrlEnteredInUrlBar();
-
- // ToolBar/Menu command handlers
- //
afx_msg void OnFileOpen();
afx_msg void OnFileSaveAs();
afx_msg void OnViewSource();
afx_msg void OnViewInfo();
afx_msg void OnNavBack();
afx_msg void OnNavForward();
@@ -153,20 +156,25 @@
afx_msg void OnSaveLinkAs();
afx_msg void OnSaveImageAs();
afx_msg void OnShowFindDlg();
afx_msg void OnFilePrint();
afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam);
-
- // Handlers to keep the toolbar/menu items up to date
- //
+ afx_msg void OnTestsChangeUrl();
+ afx_msg void OnTestsGlobalHistory();
+ afx_msg void OnToolsRemoveGHPage();
+ afx_msg void OnTestsCreateFile();
afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
+ afx_msg void OnInterfacesNsifile();
+ afx_msg void OnTestsCreateprofile();
+ afx_msg void OnInterfacesNsishistory();
+ afx_msg void OnVerifybugs70228();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
-#endif //_BROWSERVIEW_H
\ No newline at end of file
+#endif //_BROWSERVIEW_H

View File

@ -0,0 +1,715 @@
Index: BrowserView.cpp
===================================================================
RCS file: /cvsroot/mozilla/embedding/tests/mfcembed/BrowserView.cpp,v
retrieving revision 1.8
diff -u -r1.8 BrowserView.cpp
--- BrowserView.cpp 2001/04/16 20:34:33 1.8
+++ BrowserView.cpp 2001/05/19 00:15:37
@@ -51,6 +51,9 @@
#include "BrowserImpl.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
+#include "UrlDialog.h"
+#include "ProfileMgr.h"
+#include "ProfilesDlg.h"
// Print Includes
#include "PrintProgressDialog.h"
@@ -70,12 +73,8 @@
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_SIZE()
-
- // UrlBar command handlers
- ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar)
-
- // Menu/Toolbar command handlers
+ ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
ON_COMMAND(ID_VIEW_SOURCE, OnViewSource)
@@ -91,23 +90,29 @@
ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp)
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone)
+ ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow)
ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow)
- ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
-
- // Menu/Toolbar UI update handlers
+ ON_COMMAND(ID_TESTS_CHANGEURL, OnTestsChangeUrl)
+ ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
+ ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
+ ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack)
ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward)
ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop)
ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut)
ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy)
ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste)
+ ON_COMMAND(ID_INTERFACES_NSIFILE, OnInterfacesNsifile)
+ ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
+ ON_COMMAND(ID_INTERFACES_NSISHISTORY, OnInterfacesNsishistory)
+ ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -129,6 +134,8 @@
m_bUrlBarClipOp = FALSE;
m_bCurrentlyPrinting = FALSE;
+
+ char *theUrl = "http://www.aol.com/";
}
CBrowserView::~CBrowserView()
@@ -169,6 +176,8 @@
if(NS_FAILED(rv))
return rv;
+// mSessionHistory = do_GetInterface(mWebBrowser, &rv); // de: added 5/11
+
// Create the CBrowserImpl object - this is the object
// which implements the interfaces which are required
// by an app embedding mozilla i.e. these are the interfaces
@@ -232,8 +241,18 @@
// These callbacks will be used to update the status/progress bars
nsWeakPtr weakling(
dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
- (void)mWebBrowser->AddWebBrowserListener(weakling,
- NS_GET_IID(nsIWebProgressListener));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not added.");
+ WriteToOutputFile("Web Progress Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener added.");
+ WriteToOutputFile("Web Progress Listener added.\r\n");
+ }
// Finally, show the web browser window
mBaseWindow->SetVisibility(PR_TRUE);
@@ -255,6 +274,21 @@
mpBrowserImpl = nsnull;
}
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
+ nsresult rv;
+ rv = mWebBrowser->RemoveWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not removed.");
+ WriteToOutputFile("Web Progress Listener not removed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener removed.");
+ WriteToOutputFile("Web Progress Listener removed.\r\n");
+ }
+
return NS_OK;
}
@@ -989,4 +1023,589 @@
default:
break;
}
+}
+
+// de: Start QA test cases here
+// *********************************************************
+// *********************************************************
+
+void CBrowserView::OnTestsChangeUrl()
+{
+ char *theUrl = "http://www.aol.com/";
+ CUrlDialog myDialog;
+ nsresult rv;
+
+// nsCOMPtr<nsIURI> pURI;
+
+ if (!mWebNav)
+ {
+ AfxMessageBox("Web navigation object not found. Change URL test not performed.");
+ WriteToOutputFile("Web navigation object not found. Change URL test not performed.\r\n");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin Change URL test.");
+ WriteToOutputFile("Begin Change URL test.\r\n");
+ strcpy(theUrl, myDialog.m_urlfield);
+ mWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).GetUnicode(),
+ nsIWebNavigation::LOAD_FLAGS_NONE);
+ WriteToOutputFile("\r\nLoadURI() method is called.");
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+/*
+ char *uriSpec;
+ // GetcurrentURI() declared in nsIP3PUI.idl
+ // used with webNav obj in nsP3PObserverHTML.cpp, line 239
+ // this will be used as an indep routine to verify the URI load
+ rv = mWebNav->GetCurrentURI( getter_AddRefs( pURI ) );
+ if(NS_FAILED(rv) || !pURI)
+ AfxMessageBox("Bad result for GetCurrentURI().");
+
+ rv = pURI->GetSpec(&uriSpec);;
+ if (NS_FAILED(rv))
+ AfxMessageBox("Bad result for GetSpec().");
+
+ AfxMessageBox("Start URL validation test().");
+ if (strcmp(uriSpec, theUrl) == 0)
+ {
+ WriteToOutputFile("Url loaded successfully. Test Passed.");
+ }
+ else
+ {
+ WriteToOutputFile("Url didn't load successfully. Test Failed.");
+ }
+*/
+ AfxMessageBox("End Change URL test.");
+ WriteToOutputFile("End Change URL test.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Change URL test not executed.");
+ WriteToOutputFile("Change URL test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsGlobalHistory()
+{
+ // create instance of myHistory object. Call's XPCOM
+ // service manager to pass the contract ID.
+
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+
+ nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+
+ if (!myHistory)
+ {
+ WriteToOutputFile("Couldn't find history object. No GH tests performed.\r\n");
+ AfxMessageBox("Couldn't find history object. No GH tests performed.");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin IsVisited() and AddPage() tests.");
+ WriteToOutputFile("Begin IsVisited() and AddPage() tests.\r\n");
+
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+ // see if url is already in the GH file (pre-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL has been visited. Won't execute AddPage().\r\n");
+ AfxMessageBox("URL has been visited. Won't execute AddPage().");
+ }
+ else
+ {
+ WriteToOutputFile("URL hasn't been visited. Will execute AddPage().\r\n");
+ AfxMessageBox("URL hasn't been visited. Will execute AddPage().");
+ // adds a url to the global history file
+ rv = myHistory->AddPage(theUrl);
+
+ // prints addPage() results to output file
+ if (NS_FAILED(rv))
+ {
+ WriteToOutputFile("Invalid results for AddPage(). Url not added. Test failed.\r\n");
+ return;
+ }
+ else
+ {
+ WriteToOutputFile("Valid results for AddPage(). Url added. Test passed.\r\n");
+ }
+
+ // checks if url was visited (post-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL is visited; post-AddPage() test. IsVisited() test passed.\r\n");
+ }
+ else
+ {
+ WriteToOutputFile("URL isn't visited; post-AddPage() test. IsVisited() test failed.\r\n");
+ }
+ }
+ AfxMessageBox("End IsVisited() and AddPage() tests.");
+ WriteToOutputFile("End IsVisited() and AddPage() tests.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("IsVisited() and AddPage() tests not executed.");
+ WriteToOutputFile("IsVisited() and AddPage() tests not executed.\r\n");
+ }
+}
+
+
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateFile()
+{
+ nsresult rv;
+ PRBool exists;
+ nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+
+ AfxMessageBox("Start Create File test.");
+ WriteToOutputFile("\r\nStart Create File test.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\theFile.txt");
+ rv = theTestFile->Exists(&exists);
+
+ WriteToOutputFile("File doesn't exist. We'll create it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (theFile.txt).");
+ WriteToOutputFile("Create() test Failed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (theFile.txt).");
+ WriteToOutputFile("Create() test Passed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateprofile()
+{
+ CProfilesDlg myDialog;
+ nsresult rv;
+
+ if (myDialog.DoModal() == IDOK)
+ {
+// NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
+ nsCOMPtr<nsIProfile> theProfServ(do_GetService(NS_PROFILE_CONTRACTID));
+ if (!theProfServ)
+ {
+ WriteToOutputFile("Didn't get profile service. No profile tests performed.\r\n");
+ AfxMessageBox("Didn't get profile service. No profile tests performed.");
+ return;
+ }
+
+ if (theProfServ)
+ {
+ AfxMessageBox("Start Profile switch test.");
+ WriteToOutputFile("Start Profile switch test.\r\n");
+
+ AfxMessageBox("Retrieved profile service.");
+ rv = theProfServ->SetCurrentProfile(myDialog.m_SelectedProfile.GetUnicode());
+ if (NS_SUCCEEDED(rv))
+ AfxMessageBox("SetCurrentProfile() passed. Profile switched.");
+ else
+ AfxMessageBox("SetCurrentProfile() didn't pass.Profile not switched.");
+
+ AfxMessageBox("End Profile switch test.");
+ WriteToOutputFile("End Profile switch test.\r\n");
+ }
+ }
+ else
+ {
+ AfxMessageBox("Profile switch test not executed.");
+ WriteToOutputFile("Profile switch test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+// *********************************************************
+// TOOLS to help us
+
+
+void CBrowserView::OnToolsRemoveGHPage()
+{
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+ nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+ if (!myGHistory)
+ {
+ WriteToOutputFile("Could not get the global history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+ nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
+ if(!NS_SUCCEEDED(rv)) {
+ WriteToOutputFile("Could not get the history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+// nsCOMPtr<nsIBrowserHistory> myHistory(do_GetInterface(myGHistory));
+
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ WriteToOutputFile("Begin URL removal from the GH file.\r\n");
+ AfxMessageBox("Begin URL removal from the GH file.");
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ myGHistory->IsVisited(theUrl, &theRetVal);
+ if (theRetVal)
+ {
+ rv = myHistory->RemovePage(theUrl);
+ if (NS_SUCCEEDED(rv))
+ {
+ WriteToOutputFile("\r\nThe URL was removed from the GH file.\r\n");
+ AfxMessageBox("The URL was removed from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("\r\nThe URL wasn't removed from the GH file.\r\n");
+ AfxMessageBox("The URL wasn't removed from the GH file.");
+ }
+ }
+ else
+ {
+ WriteToOutputFile("The URL wasn't in the GH file.\r\n");
+ }
+ WriteToOutputFile("End URL removal from the GH file.\r\n");
+ AfxMessageBox("End URL removal from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("URL removal from the GH file not executed.\r\n");
+ AfxMessageBox("URL removal from the GH file not executed.");
+ }
+}
+
+// ***********************************************************************
+// ************************** Interface Tests ****************************
+// ***********************************************************************
+
+// nsIFile:
+
+void CBrowserView::OnInterfacesNsifile()
+{
+ nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+ nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+
+ nsresult rv;
+ PRBool exists;
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+ if (!theFileOpDir)
+ {
+ WriteToOutputFile("Dir object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+ AfxMessageBox("Begin nsIFile tests.");
+ WriteToOutputFile("\r\nBegin testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to initialize file path.");
+ WriteToOutputFile("InitWithPath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We initialized file path.");
+ WriteToOutputFile("InitWithPath() test Passed.");
+ }
+
+ rv = theTestFile->AppendRelativePath("myFile.txt");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to append the file.");
+ WriteToOutputFile("AppendRelativePath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We appended the file.");
+ WriteToOutputFile("AppendRelativePath() test Passed.");
+ }
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File doesn't exist. We'll try creating it.");
+ WriteToOutputFile("File doesn't exist. We'll try creating it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (myFile.txt).");
+ WriteToOutputFile("Create() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (myFile.txt).");
+ WriteToOutputFile("Create() test Passed.");
+ }
+ }
+ else
+ {
+ AfxMessageBox("File already exists (myFile.txt). We won't create it.");
+ WriteToOutputFile("File already exists (myFile.txt). We won't create it.");
+ }
+
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File (myFile.txt) doesn't exist.");
+ WriteToOutputFile("Exists() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File (myFile.txt) exists.");
+ WriteToOutputFile("Exists() test Passed.");
+ }
+
+ // FILE COPY test
+
+ AfxMessageBox("Start File Copy test.");
+ WriteToOutputFile("Start File Copy test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+ else
+ {
+ AfxMessageBox("The target dir was found.");
+ WriteToOutputFile("The target dir was found.");
+ }
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+ else
+ AfxMessageBox("The path was found.");
+ rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv CopyTo() test failed.");
+ else
+ AfxMessageBox("rv CopyTo() test succeeded.");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File didn't copy.");
+ WriteToOutputFile("CopyTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File copied.");
+ WriteToOutputFile("CopyTo() test Passed.");
+ }
+
+ // FILE MOVE test
+
+ AfxMessageBox("Start File Move test.");
+ WriteToOutputFile("Start File Move test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\Program Files\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+
+ rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv MoveTo() test failed.");
+ else
+ AfxMessageBox("rv MoveTo() test succeeded.");
+ rv = theTestFile->InitWithPath("c:\\Program Files\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File wasn't moved.");
+ WriteToOutputFile("MoveTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File was moved.");
+ WriteToOutputFile("MoveTo() test Passed.");
+ }
+
+ AfxMessageBox("End nsIFile tests.");
+ WriteToOutputFile("\r\nEnd testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+}
+
+// nsISHistory:
+
+void CBrowserView::OnInterfacesNsishistory()
+{
+ nsresult rv;
+ boolean modifyIndex;
+ long numEntries = 0;
+
+ nsCOMPtr<nsISHistory> theSessionHistory(do_CreateInstance(NS_SHISTORY_CONTRACTID));
+ nsCOMPtr<nsIHistoryEntry> theHistoryEntry(do_CreateInstance(NS_HISTORYENTRY_CONTRACTID));
+ nsCOMPtr<nsISHistoryListener> theSHListener(do_CreateInstance(NS_SHISTORYLISTENER_CONTRACTID));
+ // do_QueryInterface
+ // NS_HISTORYENTRY_CONTRACTID
+ // NS_SHISTORYLISTENER_CONTRACTID
+
+
+ if (!theSessionHistory)
+ {
+ AfxMessageBox("theSessionHistory object wasn't created. No tests performed.");
+ return;
+ }
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ return;
+ }
+
+ // addSHistoryListener test
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ WriteToOutputFile("NSISHistory Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("NSISHistory Listener added.");
+ WriteToOutputFile("NSISHistory Listener added.\r\n");
+ }
+
+/*
+ // getEntryAtIndex() test
+ theHistoryEntry = theSessionHistory->GetEntryAtIndex(index, modifyIndex);
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("We got the History Entry.");
+ }
+ else
+ {
+ AfxMessageBox("We didn't get the History Entry.");
+ }
+
+*/
+
+///*
+ // PurgeHistory() test
+ rv = theSessionHistory->PurgeHistory(numEntries);
+ if (NS_FAILED(rv))
+ AfxMessageBox("Purge History test failed.");
+ else
+ AfxMessageBox("Purge History test succeeded.");
+//*/
+
+ // RemoveSHistoryListener test
+/*
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = theSessionHistory->RemoveSHistoryListener(weakling);
+*/
+}
+
+
+// ***************** Local Methods ******************
+
+void CBrowserView::WriteToOutputFile(char *pLine)
+{
+ CStdioFile myFile;
+ CFileException e;
+ CString strFileName = "c:\\temp\\MFCoutfile";
+
+ if(! myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
+ | CStdioFile::modeNoTruncate, &e ) )
+ {
+ CString failCause = "Unable to open file. Reason : ";
+ failCause += e.m_cause;
+ AfxMessageBox(failCause);
+ }
+ else
+ {
+ myFile.SeekToEnd();
+ CString strLine = pLine;
+ strLine += "\r\n";
+
+ myFile.WriteString(strLine);
+
+ myFile.Close();
+ }
+}
+
+
+// ***************** Bug Verifications ******************
+
+void CBrowserView::OnVerifybugs70228()
+{
+/*
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_GetService(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It's NOT a service!");
+ else
+ AfxMessageBox("Object is created. But should it?! It's NOT a service!");
+
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It should be. It's a component!");
+ else
+ AfxMessageBox("Object is created. It's a component!");
+*/
+/*
+nsCOMPtr<nsIHelperAppLauncher>
+ myHAL(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+
+ rv = myHALD->show(myHal, mySupp);
+*/
}

View File

@ -0,0 +1,393 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// File Overview....
//
// This file has the IBrowserFrameGlueObj implementation
// This frame glue object is nested inside of the BrowserFrame
// object(See BrowserFrm.h for more info)
//
// This is the place where all the platform specific interaction
// with the browser frame window takes place in response to
// callbacks from Gecko interface methods
//
// The main purpose of this interface is to separate the cross
// platform code in BrowserImpl*.cpp from the platform specific
// code(which is in this file)
//
// You'll also notice the use of a macro named "METHOD_PROLOGUE"
// through out this file. This macro essentially makes the pointer
// to a "containing" class available inside of the class which is
// being contained via a var named "pThis". In our case, the
// BrowserFrameGlue object is contained inside of the BrowserFrame
// object so "pThis" will be a pointer to a BrowserFrame object
// Refer to MFC docs for more info on METHOD_PROLOGUE macro
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
/////////////////////////////////////////////////////////////////////////////
// IBrowserFrameGlue implementation
void CBrowserFrame::BrowserFrameGlueObj::UpdateStatusBarText(const PRUnichar *aMessage)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
nsCString strStatus;
if(aMessage)
strStatus.AssignWithConversion(aMessage);
pThis->m_wndStatusBar.SetPaneText(0, strStatus.get());
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndProgressBar.SetRange32(0, aMax);
pThis->m_wndProgressBar.SetPos(aCurrent);
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Just notify the view of the busy state
// There's code in there which will take care of
// updating the STOP toolbar btn. etc
pThis->m_wndBrowserView.UpdateBusyState(aBusy);
}
// Called from the OnLocationChange() method in the nsIWebProgressListener
// interface implementation in CBrowserImpl to update the current URI
// Will get called after a URI is successfully loaded in the browser
// We use this info to update the URL bar's edit box
//
void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aLocation)
{
nsXPIDLCString uriString;
aLocation->GetSpec(getter_Copies(uriString));
pThis->m_wndUrlBar.SetCurrentURL(uriString.get());
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
CString title;
pThis->GetWindowText(title);
if(!title.IsEmpty())
{
nsString nsTitle;
nsTitle.AssignWithConversion(title.GetBuffer(0));
*aTitle = nsTitle.ToNewUnicode();
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameTitle(const PRUnichar *aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
if(W2T(aTitle))
{
pThis->SetWindowText(W2T(aTitle));
}
else
{
// Use the AppName i.e. mfcembed as the title if we
// do not get one from GetBrowserWindowTitle()
//
CString cs;
cs.LoadString(AFX_IDS_APP_TITLE);
pThis->SetWindowText(cs);
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, 0, 0, aCX, aCY,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePosition(PRInt32 aX, PRInt32 aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, aCX, aCY,
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetFocus()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetFocus();
}
void CBrowserFrame::BrowserFrameGlueObj::FocusAvailable(PRBool *aFocusAvail)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
HWND focusWnd = GetFocus()->m_hWnd;
if ((focusWnd == pThis->m_hWnd) || ::IsChild(pThis->m_hWnd, focusWnd))
*aFocusAvail = PR_TRUE;
else
*aFocusAvail = PR_FALSE;
}
void CBrowserFrame::BrowserFrameGlueObj::ShowBrowserFrame(PRBool aShow)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aShow)
{
pThis->ShowWindow(SW_SHOW);
pThis->SetActiveWindow();
pThis->UpdateWindow();
}
else
{
pThis->ShowWindow(SW_HIDE);
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameVisibility(PRBool *aVisible)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Is the current BrowserFrame the active one?
if (GetActiveWindow()->m_hWnd != pThis->m_hWnd)
{
*aVisible = PR_FALSE;
return;
}
// We're the active one
//Return FALSE if we're minimized
WINDOWPLACEMENT wpl;
pThis->GetWindowPlacement(&wpl);
if ((wpl.showCmd == SW_RESTORE) || (wpl.showCmd == SW_MAXIMIZE))
*aVisible = PR_TRUE;
else
*aVisible = PR_FALSE;
}
PRBool CBrowserFrame::BrowserFrameGlueObj::CreateNewBrowserFrame(PRUint32 chromeMask,
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull;
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return PR_FALSE;
// Note that we're calling with the last param set to "false" i.e.
// this instructs not to show the frame window
// This is mainly needed when the window size is specified in the window.open()
// JS call. In those cases Gecko calls us to create the browser with a default
// size (all are -1) and then it calls the SizeBrowserTo() method to set
// the proper window size. If this window were to be visible then you'll see
// the window size changes on the screen causing an unappealing flicker
//
CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_FALSE);
if(!pFrm)
return PR_FALSE;
// At this stage we have a new CBrowserFrame and a new CBrowserView
// objects. The CBrowserView also would have an embedded browser
// object created. Get the mWebBrowser member from the CBrowserView
// and return it. (See CBrowserView's CreateBrowser() on how the
// embedded browser gets created and how it's mWebBrowser member
// gets initialized)
NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser);
return PR_TRUE;
}
void CBrowserFrame::BrowserFrameGlueObj::DestroyBrowserFrame()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->PostMessage(WM_CLOSE);
}
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
UINT nIDResource = IDR_CTXMENU_DOCUMENT;
if(aContextFlags & nsIContextMenuListener::CONTEXT_DOCUMENT)
nIDResource = IDR_CTXMENU_DOCUMENT;
else if(aContextFlags & nsIContextMenuListener::CONTEXT_TEXT)
nIDResource = IDR_CTXMENU_TEXT;
else if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
{
nIDResource = IDR_CTXMENU_LINK;
// Since we handle all the browser menu/toolbar commands
// in the View, we basically setup the Link's URL in the
// BrowserView object. When a menu selection in the context
// menu is made, the appropriate command handler in the
// BrowserView will be invoked and the value of the URL
// will be accesible in the view
// Reset the value from the last invocation
// (A new value will be set after we determine it below)
//
nsAutoString strUrlUcs2;
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
// Get the URL from the link. This is two step process
// 1. We first get the nsIDOMHTMLAnchorElement
// 2. We then get the URL associated with the link
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv))
return;
rv = linkElement->GetHref(strUrlUcs2);
if(NS_FAILED(rv))
return;
// Update the view with the new LinkUrl
// Note that this string is in UCS2 format
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
}
else if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE)
{
nIDResource = IDR_CTXMENU_IMAGE;
nsAutoString strImgSrcUcs2;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Clear it
// Get the IMG SRC
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv))
return;
rv = imgElement->GetSrc(strImgSrcUcs2);
if(NS_FAILED(rv))
return;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
}
CMenu ctxMenu;
if(ctxMenu.LoadMenu(nIDResource))
{
POINT cursorPos;
GetCursorPos(&cursorPos);
(ctxMenu.GetSubMenu(0))->TrackPopupMenu(TPM_LEFTALIGN, cursorPos.x, cursorPos.y, pThis);
}
}
HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
return pThis->m_hWnd;
}

View File

@ -0,0 +1,306 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// File Overview....
//
// The typical MFC View, toolbar, statusbar creation done
// in CBrowserFrame::OnCreate()
//
// Code to update the Status/Tool bars in response to the
// Web page loading progress(called from methods in CBrowserImpl)
//
// SetupFrameChrome() determines what, if any, UI elements this Frame
// will sport based on the current "chromeMask"
//
// Also take a look at OnClose() which gets used when you close a browser
// window. This needs to be overrided mainly to handle supporting multiple
// browser frame windows via the "New Browser Window" menu item
// Without this being overridden the MFC framework handles the OnClose and
// shutsdown the complete application when a frame window is closed.
// In our case, we want the app to shutdown when the File/Exit menu is chosen
//
// Another key functionality this object implements is the IBrowserFrameGlue
// interface - that's the interface the Gecko embedding interfaces call
// upong to update the status bar etc.
// (Take a look at IBrowserFrameGlue.h for the interface definition and
// the BrowserFrm.h to see how we implement this interface - as a nested
// class)
// We pass this Glue object pointer to the CBrowserView object via the
// SetBrowserFrameGlue() method. The CBrowserView passes this on to the
// embedding interface implementaion
//
// Please note the use of the macro METHOD_PROLOGUE in the implementation
// of the nested BrowserFrameGlue object. Essentially what this macro does
// is to get you access to the outer (or the object which is containing the
// nested object) object via the pThis pointer.
// Refer to the AFXDISP.H file in VC++ include dirs
//
// Next suggested file to look at : BrowserView.cpp
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame
IMPLEMENT_DYNAMIC(CBrowserFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd)
//{{AFX_MSG_MAP(CBrowserFrame)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_SIZE()
ON_WM_CLOSE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // For the Status line
ID_SEPARATOR, // For the Progress Bar
};
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame construction/destruction
CBrowserFrame::CBrowserFrame(PRUint32 chromeMask)
{
// Save the chromeMask off. It'll be used
// later to determine whether this browser frame
// will have menubar, toolbar, statusbar etc.
m_chromeMask = chromeMask;
}
CBrowserFrame::~CBrowserFrame()
{
}
void CBrowserFrame::OnClose()
{
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
pApp->RemoveFrameFromList(this);
DestroyWindow();
}
// This is where the UrlBar, ToolBar, StatusBar, ProgressBar
// get created
//
int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Pass "this" to the View for later callbacks
// and/or access to any public data members, if needed
//
m_wndBrowserView.SetBrowserFrame(this);
// Pass on the BrowserFrameGlue also to the View which
// it will use during the Init() process after creation
// of the BrowserImpl obj. Essentially, the View object
// hooks up the Embedded browser's callbacks to the BrowserFrame
// via this BrowserFrameGlue object
m_wndBrowserView.SetBrowserFrameGlue((PBROWSERFRAMEGLUE)&m_xBrowserFrameGlueObj);
// create a view to occupy the client area of the frame
// This will be the view in which the embedded browser will
// be displayed in
//
if (!m_wndBrowserView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
// create the URL bar (essentially a ComboBoxEx object)
if (!m_wndUrlBar.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 150), this, ID_URL_BAR))
{
TRACE0("Failed to create URL Bar\n");
return -1; // fail to create
}
// Load the Most Recently Used(MRU) Urls into the UrlBar
m_wndUrlBar.LoadMRUList();
// Create the toolbar with Back, Fwd, Stop, etc. buttons..
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// Create a ReBar window to which the toolbar and UrlBar
// will be added
if (!m_wndReBar.Create(this))
{
TRACE0("Failed to create ReBar\n");
return -1; // fail to create
}
//Add the ToolBar and UrlBar windows to the rebar
m_wndReBar.AddBar(&m_wndToolBar);
m_wndReBar.AddBar(&m_wndUrlBar, "Enter URL:");
// Create the status bar with two panes - one pane for actual status
// text msgs. and the other for the progress control
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// Create the progress bar as a child of the status bar.
// Note that the ItemRect which we'll get at this stage
// is bogus since the status bar panes are not fully
// positioned yet i.e. we'll be passing in an invalid rect
// to the Create function below
// The actual positioning of the progress bar will be done
// in response to OnSize()
RECT rc;
m_wndStatusBar.GetItemRect (1, &rc);
if (!m_wndProgressBar.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, rc, &m_wndStatusBar, ID_PROG_BAR))
{
TRACE0("Failed to create progress bar\n");
return -1; // fail to create
}
// Based on the "chromeMask" we were supplied during construction
// hide any requested UI elements - statusbar, menubar etc...
// Note that the window styles (WM_RESIZE etc) are set inside
// of PreCreateWindow()
SetupFrameChrome();
return 0;
}
void CBrowserFrame::SetupFrameChrome()
{
if(m_chromeMask == nsIWebBrowserChrome::CHROME_ALL)
return;
if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_MENUBAR) )
SetMenu(NULL); // Hide the MenuBar
if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR) )
m_wndReBar.ShowWindow(SW_HIDE); // Hide the ToolBar
if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) )
m_wndStatusBar.ShowWindow(SW_HIDE); // Hide the StatusBar
}
BOOL CBrowserFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
// Change window style based on the chromeMask
if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR) )
cs.style &= ~WS_CAPTION; // No caption
if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) )
{
// Can't resize this window
cs.style &= ~WS_SIZEBOX;
cs.style &= ~WS_THICKFRAME;
cs.style &= ~WS_MINIMIZEBOX;
cs.style &= ~WS_MAXIMIZEBOX;
}
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame message handlers
void CBrowserFrame::OnSetFocus(CWnd* pOldWnd)
{
// forward focus to the view window
m_wndBrowserView.SetFocus();
}
BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndBrowserView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// otherwise, do default handling
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
// Needed to properly position/resize the progress bar
//
void CBrowserFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// Get the ItemRect of the status bar's Pane 1
// That's where the progress bar will be located
RECT rc;
m_wndStatusBar.GetItemRect(1, &rc);
// Move the progress bar into it's correct location
//
m_wndProgressBar.MoveWindow(&rc);
}
#ifdef _DEBUG
void CBrowserFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CBrowserFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
m_wndBrowserView.Activate(nState, pWndOther, bMinimized);
}

View File

@ -0,0 +1,195 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// BrowserFrm.h : interface of the CBrowserFrame class
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _IBROWSERFRM_H
#define _IBROWSERFRM_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "BrowserView.h"
#include "IBrowserFrameGlue.h"
#include "MostRecentUrls.h"
// A simple UrlBar class...
class CUrlBar : public CComboBoxEx
{
public:
inline void GetEnteredURL(CString& url) {
GetEditCtrl()->GetWindowText(url);
}
inline void GetSelectedURL(CString& url) {
GetLBText(GetCurSel(), url);
}
inline void SetCurrentURL(LPCTSTR pUrl) {
SetWindowText(pUrl);
}
inline void AddURLToList(CString& url, bool bAddToMRUList = true) {
COMBOBOXEXITEM ci;
ci.mask = CBEIF_TEXT; ci.iItem = -1;
ci.pszText = (LPTSTR)(LPCTSTR)url;
InsertItem(&ci);
if(bAddToMRUList)
m_MRUList.AddURL((LPTSTR)(LPCTSTR)url);
}
inline void LoadMRUList() {
for (int i=0;i<m_MRUList.GetNumURLs();i++)
{
CString urlStr(_T(m_MRUList.GetURL(i)));
AddURLToList(urlStr, false);
}
}
inline BOOL EditCtrlHasFocus() {
return (GetEditCtrl()->m_hWnd == CWnd::GetFocus()->m_hWnd);
}
inline BOOL EditCtrlHasSelection() {
int nStartChar = 0, nEndChar = 0;
if(EditCtrlHasFocus())
GetEditCtrl()->GetSel(nStartChar, nEndChar);
return (nEndChar > nStartChar) ? TRUE : FALSE;
}
inline BOOL CanCutToClipboard() {
return EditCtrlHasSelection();
}
inline void CutToClipboard() {
GetEditCtrl()->Cut();
}
inline BOOL CanCopyToClipboard() {
return EditCtrlHasSelection();
}
inline void CopyToClipboard() {
GetEditCtrl()->Copy();
}
inline BOOL CanPasteFromClipboard() {
return EditCtrlHasFocus();
}
inline void PasteFromClipboard() {
GetEditCtrl()->Paste();
}
inline BOOL CanUndoEditOp() {
return EditCtrlHasFocus() ? GetEditCtrl()->CanUndo() : FALSE;
}
inline void UndoEditOp() {
if(EditCtrlHasFocus())
GetEditCtrl()->Undo();
}
protected:
CMostRecentUrls m_MRUList;
};
class CBrowserFrame : public CFrameWnd
{
public:
CBrowserFrame(PRUint32 chromeMask);
protected:
DECLARE_DYNAMIC(CBrowserFrame)
public:
inline CBrowserImpl *GetBrowserImpl() { return m_wndBrowserView.mpBrowserImpl; }
CToolBar m_wndToolBar;
CStatusBar m_wndStatusBar;
CProgressCtrl m_wndProgressBar;
CUrlBar m_wndUrlBar;
CReBar m_wndReBar;
// The view inside which the embedded browser will
// be displayed in
CBrowserView m_wndBrowserView;
// Wrapper functions for UrlBar clipboard operations
inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); }
inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); }
inline BOOL CanCopyUrlBarSelection() { return m_wndUrlBar.CanCopyToClipboard(); }
inline void CopyUrlBarSelToClipboard() { m_wndUrlBar.CopyToClipboard(); }
inline BOOL CanPasteToUrlBar() { return m_wndUrlBar.CanPasteFromClipboard(); }
inline void PasteFromClipboardToUrlBar() { m_wndUrlBar.PasteFromClipboard(); }
inline BOOL CanUndoUrlBarEditOp() { return m_wndUrlBar.CanUndoEditOp(); }
inline void UndoUrlBarEditOp() { m_wndUrlBar.UndoEditOp(); }
// This specifies what UI elements this frame will sport
// w.r.t. toolbar, statusbar, urlbar etc.
PRUint32 m_chromeMask;
protected:
//
// This nested class implements the IBrowserFramGlue interface
// The Gecko embedding interfaces call on this interface
// to update the status bars etc.
//
class BrowserFrameGlueObj : public IBrowserFrameGlue
{
//
// NS_DECL_BROWSERFRAMEGLUE below is a macro which expands
// to the function prototypes of methods in IBrowserFrameGlue
// Take a look at IBrowserFrameGlue.h for this macro define
//
NS_DECL_BROWSERFRAMEGLUE
} m_xBrowserFrameGlueObj;
friend class BrowserFrameGlueObj;
public:
void SetupFrameChrome();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CBrowserFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CBrowserFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnClose();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //_IBROWSERFRM_H

View File

@ -0,0 +1,404 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// File Overview....
// This is the class which implements all the interfaces
// required(and optional) by the mozilla embeddable browser engine
//
// Note that this obj gets passed in the IBrowserFrameGlue* using the
// Init() method. Many of the interface implementations use this
// to get the actual task done. Ex: to update the status bar
//
// Look at the INTERFACE_MAP_ENTRY's below for the list of
// the currently implemented interfaces
//
// This file currently has the implementation for all the interfaces
// which are required of an app embedding Gecko
// Implementation of other optional interfaces are in separate files
// to avoid cluttering this one and to demonstrate other embedding
// principles. For example, nsIPrompt is implemented in a separate DLL.
//
// nsIWebBrowserChrome - This is a required interface to be implemented
// by embeddors
//
// nsIEmbeddingSiteWindow - This is a required interface to be implemented
// by embedders
// - SetTitle() gets called after a document
// load giving us the chance to update our
// titlebar
//
// Some points to note...
//
// nsIWebBrowserChrome interface's SetStatus() gets called when a user
// mouses over the links on a page
//
// nsIWebProgressListener interface's OnStatusChange() gets called
// to indicate progress when a page is being loaded
//
// Next suggested file(s) to look at :
// Any of the BrowserImpl*.cpp files for other interface
// implementation details
//
#ifdef _WINDOWS
#include "stdafx.h"
#endif
#include "nsIDOMWindow.h"
#include "BrowserImpl.h"
CBrowserImpl::CBrowserImpl()
{
NS_INIT_ISUPPORTS();
m_pBrowserFrameGlue = NULL;
mWebBrowser = nsnull;
}
CBrowserImpl::~CBrowserImpl()
{
}
// It's very important that the creator of this CBrowserImpl object
// Call on this Init() method with proper values after creation
//
NS_METHOD CBrowserImpl::Init(PBROWSERFRAMEGLUE pBrowserFrameGlue,
nsIWebBrowser* aWebBrowser)
{
m_pBrowserFrameGlue = pBrowserFrameGlue;
SetWebBrowser(aWebBrowser);
return NS_OK;
}
//*****************************************************************************
// CBrowserImpl::nsISupports
//*****************************************************************************
NS_IMPL_ADDREF(CBrowserImpl)
NS_IMPL_RELEASE(CBrowserImpl)
NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
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(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISHistoryListener) // de: added 5/11
NS_INTERFACE_MAP_END
//*****************************************************************************
// CBrowserImpl::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mWebBrowser)
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
//*****************************************************************************
// CBrowserImpl::nsIWebBrowserChrome
//*****************************************************************************
//Gets called when you mouseover links etc. in a web page
//
NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = mWebBrowser;
NS_IF_ADDREF(*aWebBrowser);
return NS_OK;
}
// Currently called from Init(). I'm not sure who else
// calls this
//
NS_IMETHODIMP CBrowserImpl::SetWebBrowser(nsIWebBrowser* aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
mWebBrowser = aWebBrowser;
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// Gets called in response to create a new browser window.
// Ex: In response to a JavaScript Window.Open() call
//
//
NS_IMETHODIMP CBrowserImpl::CreateBrowserWindow(PRUint32 chromeMask, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aWebBrowser)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
if(m_pBrowserFrameGlue->CreateNewBrowserFrame(chromeMask,
aX, aY, aCX, aCY, aWebBrowser))
return NS_OK;
else
return NS_ERROR_FAILURE;
}
// Will get called in response to JavaScript window.close()
//
NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow()
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->DestroyBrowserFrame();
return NS_OK;
}
// Gets called in response to set the size of a window
// Ex: In response to a JavaScript Window.Open() call of
// the form
//
// window.open("http://www.mozilla.org", "theWin", "width=200, height=400");
//
// First the CreateBrowserWindow() call will be made followed by a
// call to this method to resize the window
//
NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->SetBrowserFrameSize(aCX, aCY);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::ShowAsModal(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval)
{
// We're not modal
*retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus)
{
return NS_OK;
}
//*****************************************************************************
// CBrowserImpl::nsIWebBrowserChromeFocus
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::FocusNextElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::FocusPrevElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// CBrowserImpl::nsIEmbeddingSiteWindow
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
(aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))
{
m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE);
}
else
{
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
{
m_pBrowserFrameGlue->SetBrowserFramePosition(x, y);
}
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
{
m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy);
}
}
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
{
m_pBrowserFrameGlue->GetBrowserFramePosition(x, y);
}
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
{
m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy);
}
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow)
{
if (!aSiteWindow)
return NS_ERROR_NULL_POINTER;
*aSiteWindow = 0;
if (m_pBrowserFrameGlue) {
HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd();
*aSiteWindow = NS_REINTERPRET_CAST(void *, w);
}
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::SetFocus()
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->SetFocus();
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->GetBrowserFrameVisibility(aVisibility);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->ShowBrowserFrame(aVisibility);
return NS_OK;
}
//*****************************************************************************
// CBrowserImpl::nsISHistoryListener methods
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnHistoryNewEntry(nsIURI *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::OnHistoryGoBack(nsIURI *, PRBool *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::OnHistoryGoForward(nsIURI *, PRBool *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::OnHistoryReload(nsIURI *, PRUint32, PRBool *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::OnHistoryGotoIndex(PRInt32, nsIURI *, PRBool *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CBrowserImpl::OnHistoryPurge(PRInt32, PRBool *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifndef _BROWSERIMPL_H
#define _BROWSERIMPL_H
#include "IBrowserFrameGlue.h"
#include "nsIWebBrowserChromeFocus.h"
class CBrowserImpl : public nsIInterfaceRequestor,
public nsIWebBrowserChrome,
public nsIWebBrowserChromeFocus,
public nsIEmbeddingSiteWindow,
public nsIWebProgressListener,
public nsIContextMenuListener,
public nsSupportsWeakReference,
public nsISHistoryListener
// de: added this in 5/11
{
public:
CBrowserImpl();
~CBrowserImpl();
NS_METHOD Init(PBROWSERFRAMEGLUE pBrowserFrameGlue,
nsIWebBrowser* aWebBrowser);
// de: macros that declare methods for the ifaces implemented
// (instead of .h declarations)
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSISHISTORYLISTENER // de: added this in 5/11
protected:
PBROWSERFRAMEGLUE m_pBrowserFrameGlue;
nsCOMPtr<nsIWebBrowser> mWebBrowser;
};
#endif //_BROWSERIMPL_H

View File

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifdef _WINDOWS
#include "stdafx.h"
#endif
#include "BrowserImpl.h"
#include "IBrowserFrameGlue.h"
//*****************************************************************************
// CBrowserImpl::nsIContextMenuListener
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
{
if(m_pBrowserFrameGlue)
m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aNode);
return NS_OK;
}

View File

@ -0,0 +1,149 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// File overview.....
//
// The nsIPrompt interface is mainly used to convey/get information
// from a user via Alerts, Prompts etc.
//
#ifdef _WINDOWS
#include "stdafx.h"
#endif
#include "BrowserImpl.h"
#include "IBrowserFrameGlue.h"
//*****************************************************************************
// CBrowserImpl::nsIPrompt Implementation
//*****************************************************************************
// Needed for JavaScript and other cases where a msg needs to be
// shown to the user. For ex, when a page has some JS such as
// "Alert("Hello")" this method will be invoked
NS_IMETHODIMP
CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Alert(dialogTitle, text);
return NS_OK;
}
// Invoked in the case of a JS confirm() method invocation
NS_IMETHODIMP
CBrowserImpl::Confirm(const PRUnichar *dialogTitle,
const PRUnichar *text, PRBool *retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Confirm(dialogTitle, text, retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **promptText,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password,
checkMsg, checkValue, _retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
username, password,
checkMsg, checkValue,
_retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::AlertCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::ConfirmCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue, PRBool *retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUint32 button0And1Flags, const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::Select(const PRUnichar *dialogTitle,
const PRUnichar *text, PRUint32 count,
const PRUnichar **selectList,
PRInt32 *outSelection, PRBool *retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,266 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifdef _WINDOWS
#include "stdafx.h"
#endif
#include "BrowserImpl.h"
#include "IBrowserFrameGlue.h"
#include "MfcEmbed.h"
#include "BrowserView.h"
#include "BrowserFrm.h"
//*****************************************************************************
// CBrowserImpl::nsIWebProgressListener Implementation
//*****************************************************************************
//
// - Implements browser progress update functionality
// while loading a page into the embedded browser
//
// - Calls methods via the IBrowserFrameGlue interace
// (available thru' the m_pBrowserFrameGlue member var)
// to do the actual statusbar/progress bar updates.
//
class CBrowserView;
NS_IMETHODIMP CBrowserImpl::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
PRInt32 curSelfProgress, PRInt32 maxSelfProgress,
PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
PRInt32 nProgress = curTotalProgress;
PRInt32 nProgressMax = maxTotalProgress;
if (nProgressMax == 0)
nProgressMax = LONG_MAX;
if (curSelfProgress > maxSelfProgress)
CBrowserView::QAOutput("nsIWebProgressListener::OnProgressChange(): Self progress complete!", 1);
if (nProgress > nProgressMax)
{
nProgress = nProgressMax; // Progress complete
CBrowserView::QAOutput("nsIWebProgressListener::OnProgressChange(): Progress Update complete!");
}
m_pBrowserFrameGlue->UpdateProgress(nProgress, nProgressMax);
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
PRInt32 progressStateFlags, PRUint32 status)
{
char theDocType[100];
char theStateType[100];
char theTotalString[100];
int displayMode = 1;
CString strMsg;
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
/*
nsXPIDLString theReqName;
nsresult rv;
const char *CReqName;
rv = request->GetName(getter_Copies(theReqName));
if(NS_SUCCEEDED(rv))
{
CBrowserView::QAOutput("We got the request name.\r\n");
CReqName = NS_ConvertUCS2toUTF8(theReqName).get();
strMsg.Format("The request name = %s", CReqName);
// AfxMessageBox(strMsg);
CBrowserView::WriteToOutputFile((char *)CReqName);
}
else
CBrowserView::QAOutput("We didn't get the request name.\r\n");
*/
CBrowserView::QAOutput("Entering nsIWebProgressListener::OnStateChange().");
if (progressStateFlags & STATE_IS_DOCUMENT) // DOCUMENT
{
strcpy(theDocType, "DOCUMENT");
if (progressStateFlags & STATE_START)
{
// Navigation has begun
strcpy(theStateType, "STATE_START");
displayMode = 2;
if(m_pBrowserFrameGlue)
m_pBrowserFrameGlue->UpdateBusyState(PR_TRUE);
}
else if (progressStateFlags & STATE_REDIRECTING)
strcpy(theStateType, "STATE_REDIRECTING");
else if (progressStateFlags & STATE_TRANSFERRING)
strcpy(theStateType, "STATE_TRANSFERRING");
else if (progressStateFlags & STATE_NEGOTIATING)
strcpy(theStateType, "STATE_NEGOTIATING");
else if (progressStateFlags & STATE_STOP)
{
// We've completed the navigation
strcpy(theStateType, "STATE_STOP");
displayMode = 2;
m_pBrowserFrameGlue->UpdateBusyState(PR_FALSE);
m_pBrowserFrameGlue->UpdateProgress(0, 100); // Clear the prog bar
m_pBrowserFrameGlue->UpdateStatusBarText(nsnull); // Clear the status bar
// CBrowserView::QAOutput("OnStateChange(): STATE_STOP, STATE_IS_DOCUMENT", 2);
/*
char *uriSpec;
nsresult rv;
nsCOMPtr<nsIURI> pURI;
rv = (CBrowserView)mWebNav->GetCurrentURI( getter_AddRefs( pURI ) );
rv = pURI->GetSpec(&uriSpec);
CBrowserView::WriteToOutputFile("The new URL = ");
CBrowserView::WriteToOutputFile(uriSpec);
nsXPIDLCString uriString;
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request), &rv);
channel->getURI(getter_AddRefs(uri));
uri->GetSpec(getter_Copies(uriString));
CBrowserView::QAOutput("Start URL validation test().", 0);
if (strcmp(uriSpec, CBrowserView.theUrl) == 0)
CBrowserView::QAOutput("Url loaded successfully. Test Passed.", 2);
else
CBrowserView::QAOutput("Url didn't load successfully. Test Failed.", 2);
*/
}
} // end STATE_IS_DOCUMENT
else if (progressStateFlags & STATE_IS_REQUEST) // REQUEST
{
strcpy(theDocType, "REQUEST");
if (progressStateFlags & STATE_START)
strcpy(theStateType, "STATE_START");
else if (progressStateFlags & STATE_REDIRECTING)
strcpy(theStateType, "STATE_REDIRECTING");
else if (progressStateFlags & STATE_TRANSFERRING)
strcpy(theStateType, "STATE_TRANSFERRING");
else if (progressStateFlags & STATE_NEGOTIATING)
strcpy(theStateType, "STATE_NEGOTIATING");
else if (progressStateFlags & STATE_STOP)
strcpy(theStateType, "STATE_STOP");
}
else if (progressStateFlags & STATE_IS_NETWORK) // NETWORK
{
strcpy(theDocType, "NETWORK");
if (progressStateFlags & STATE_START)
strcpy(theStateType, "STATE_START");
else if (progressStateFlags & STATE_REDIRECTING)
strcpy(theStateType, "STATE_REDIRECTING");
else if (progressStateFlags & STATE_TRANSFERRING)
strcpy(theStateType, "STATE_TRANSFERRING");
else if (progressStateFlags & STATE_NEGOTIATING)
strcpy(theStateType, "STATE_NEGOTIATING");
else if (progressStateFlags & STATE_STOP)
strcpy(theStateType, "STATE_STOP");
}
else if (progressStateFlags & STATE_IS_WINDOW) // WINDOW
{
strcpy(theDocType, "WINDOW");
if (progressStateFlags & STATE_START)
strcpy(theStateType, "STATE_START");
else if (progressStateFlags & STATE_REDIRECTING)
strcpy(theStateType, "STATE_REDIRECTING");
else if (progressStateFlags & STATE_TRANSFERRING)
strcpy(theStateType, "STATE_TRANSFERRING");
else if (progressStateFlags & STATE_NEGOTIATING)
strcpy(theStateType, "STATE_NEGOTIATING");
else if (progressStateFlags & STATE_STOP)
strcpy(theStateType, "STATE_STOP");
}
// sprintf(theTotalString, "%s %s%c %s%c %s", "OnStateChange():", theStateType, ',',
// theDocType, ',', CReqName);
sprintf(theTotalString, "%s %s%c %s", "OnStateChange():", theStateType, ',',
theDocType);
CBrowserView::QAOutput(theTotalString, displayMode);
CBrowserView::QAOutput("Exiting nsIWebProgressListener::OnStateChange().\r\n");
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->UpdateCurrentURI(location);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const PRUnichar* aMessage)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->UpdateStatusBarText(aMessage);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 state)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,182 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// BrowserView.h : interface of the CBrowserView class
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _BROWSERVIEW_H
#define _BROWSERVIEW_H
#if _MSC_VER > 1000
#pragma once
#endif
#include "IBrowserFrameGlue.h"
/////////////////////////////////////////////////////////////////////////////
// CBrowserView window
class CBrowserFrame;
class CBrowserImpl;
class CFindDialog;
class CPrintProgressDialog;
class CBrowserView : public CWnd
{
public:
CBrowserView();
virtual ~CBrowserView();
// Some helper methods
HRESULT CreateBrowser();
HRESULT DestroyBrowser();
void OpenURL(const char* pUrl);
void OpenURL(const PRUnichar* pUrl);
CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL,
PRInt32 x = -1, PRInt32 y = -1,
PRInt32 cx = -1, PRInt32 cy = -1,
PRBool bShowWindow = PR_TRUE);
void OpenURLInNewWindow(const PRUnichar* pUrl);
void LoadHomePage();
void GetBrowserWindowTitle(nsCString& title);
// Called by the CBrowserFrame after it creates the view
// Essentially a back pointer to the BrowserFrame
void SetBrowserFrame(CBrowserFrame* pBrowserFrame);
CBrowserFrame* mpBrowserFrame;
// Called by the CBrowserFrame after it creates the view
// The view passes this on to the embedded Browser's Impl
// obj
void SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue);
PBROWSERFRAMEGLUE mpBrowserFrameGlue;
// Pointer to the object which implements
// the inerfaces required by Mozilla embedders
//
CBrowserImpl* mpBrowserImpl;
// Mozilla interfaces
//
nsCOMPtr<nsIWebBrowser> mWebBrowser;
nsCOMPtr<nsIBaseWindow> mBaseWindow;
nsCOMPtr<nsIWebNavigation> mWebNav;
//nsCOMPtr<nsISHistory> mSessionHistory; // de: added in 5/11/01
void UpdateBusyState(PRBool aBusy);
PRBool mbDocumentLoading;
void SetCtxMenuLinkUrl(nsAutoString& strLinkUrl);
nsAutoString mCtxMenuLinkUrl;
void SetCtxMenuImageSrc(nsAutoString& strImgSrc);
nsAutoString mCtxMenuImgSrc;
inline void ClearFindDialog() { m_pFindDlg = NULL; }
CFindDialog* m_pFindDlg;
CPrintProgressDialog* m_pPrintProgressDlg;
// When set to TRUE...
// indicates that the clipboard operation needs to be
// performed on the UrlBar rather than on
// the web page content
//
BOOL m_bUrlBarClipOp;
// indicates whether we are currently printing
BOOL m_bCurrentlyPrinting;
void Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
BOOL OpenViewSourceWindow(const char* pUrl);
BOOL IsViewSourceUrl(CString& strUrl);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserView)
// de: qa methods
static void WriteToOutputFile(char * strInput);
static char *theUrl;
static void RvTestResult(nsresult rv, char *pLine, int displayMethod=1);
static void QAOutput(char *pLine, int displayMethod=1);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Generated message map functions
protected:
//{{AFX_MSG(CBrowserView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnSize( UINT, int, int );
afx_msg void OnUrlSelectedInUrlBar();
afx_msg void OnNewUrlEnteredInUrlBar();
afx_msg void OnFileOpen();
afx_msg void OnFileSaveAs();
afx_msg void OnViewSource();
afx_msg void OnViewInfo();
afx_msg void OnNavBack();
afx_msg void OnNavForward();
afx_msg void OnNavHome();
afx_msg void OnNavReload();
afx_msg void OnNavStop();
afx_msg void OnCut();
afx_msg void OnCopy();
afx_msg void OnPaste();
afx_msg void OnUndoUrlBarEditOp();
afx_msg void OnSelectAll();
afx_msg void OnSelectNone();
afx_msg void OnCopyLinkLocation();
afx_msg void OnOpenLinkInNewWindow();
afx_msg void OnViewImageInNewWindow();
afx_msg void OnSaveLinkAs();
afx_msg void OnSaveImageAs();
afx_msg void OnShowFindDlg();
afx_msg void OnFilePrint();
afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam);
afx_msg void OnTestsChangeUrl();
afx_msg void OnTestsGlobalHistory();
afx_msg void OnToolsRemoveGHPage();
afx_msg void OnTestsCreateFile();
afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
afx_msg void OnInterfacesNsifile();
afx_msg void OnTestsCreateprofile();
afx_msg void OnInterfacesNsishistory();
afx_msg void OnVerifybugs70228();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif //_BROWSERVIEW_H

View File

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#include "stdafx.h"
#include "Dialogs.h"
#include "BrowserView.h"
// File overview....
//
// contains Find dialog box code
//
//--------------------------------------------------------------------------//
// CFindDialog Stuff
//--------------------------------------------------------------------------//
CFindDialog::CFindDialog(CString& csSearchStr, PRBool bMatchCase,
PRBool bMatchWholeWord, PRBool bWrapAround,
PRBool bSearchBackwards, CBrowserView* pOwner)
: CFindReplaceDialog()
{
// Save these initial settings off in member vars
// We'll use these to initialize the controls
// in InitDialog()
m_csSearchStr = csSearchStr;
m_bMatchCase = bMatchCase;
m_bMatchWholeWord = bMatchWholeWord;
m_bWrapAround = bWrapAround;
m_bSearchBackwards = bSearchBackwards;
m_pOwner = pOwner;
// Set up to load our customized Find dialog template
// rather than the default one MFC provides
m_fr.Flags |= FR_ENABLETEMPLATE;
m_fr.hInstance = AfxGetInstanceHandle();
m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG);
}
BOOL CFindDialog::OnInitDialog()
{
CFindReplaceDialog::OnInitDialog();
CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT);
if(pEdit)
pEdit->SetWindowText(m_csSearchStr);
CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE);
if(pChk)
pChk->SetCheck(m_bMatchCase);
pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD);
if(pChk)
pChk->SetCheck(m_bMatchWholeWord);
pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);
if(pChk)
pChk->SetCheck(m_bWrapAround);
pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
if(pChk)
pChk->SetCheck(m_bSearchBackwards);
return TRUE;
}
void CFindDialog::PostNcDestroy()
{
// Let the owner know we're gone
if(m_pOwner != NULL)
m_pOwner->ClearFindDialog();
CFindReplaceDialog::PostNcDestroy();
}
BOOL CFindDialog::WrapAround()
{
CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);
return pChk ? pChk->GetCheck() : FALSE;
}
BOOL CFindDialog::SearchBackwards()
{
CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
return pChk ? pChk->GetCheck() : FALSE;
}

View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifndef _DIALOGS_H_
#define _DIALOGS_H_
#include "resource.h"
class CBrowserView;
class CFindDialog : public CFindReplaceDialog
{
public:
CFindDialog(CString& csSearchStr, PRBool bMatchCase,
PRBool bMatchWholeWord, PRBool bWrapAround,
PRBool bSearchBackwards, CBrowserView* pOwner);
BOOL WrapAround();
BOOL SearchBackwards();
private:
CString m_csSearchStr;
PRBool m_bMatchCase;
PRBool m_bMatchWholeWord;
PRBool m_bWrapAround;
PRBool m_bSearchBackwards;
CBrowserView* m_pOwner;
protected:
virtual BOOL OnInitDialog();
virtual void PostNcDestroy();
};
#endif //_DIALOG_H_

View File

@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// This interface acts as a glue between the required/optional
// Gecko embedding interfaces and the actual platform specific
// way of doing things - such as updating a statusbar etc.
//
// For ex, in the mfcembed sample the required interfaces such as
// IWebBrowserChrome etc. are implemented in a XP way in the
// BrowserImp*.cpp files. However, when they get called to update the
// statusbar etc. they call on this interface to get the actual job
// done. During the BrowserFrame creation some object must implement
// this interface and pass the pointer to it via the Init() member of
// the CBrowserImpl class
#ifndef _IBROWSERFRAMEGLUE_H
#define _IBROWSERFRAMEGLUE_H
struct IBrowserFrameGlue {
// Progress Related Methods
virtual void UpdateStatusBarText(const PRUnichar *aMessage) = 0;
virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) = 0;
virtual void UpdateBusyState(PRBool aBusy) = 0;
virtual void UpdateCurrentURI(nsIURI *aLocation) = 0;
// BrowserFrame Related Methods
virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask,
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
nsIWebBrowser ** aWebBrowser) = 0;
virtual void DestroyBrowserFrame() = 0;
virtual void GetBrowserFrameTitle(PRUnichar **aTitle) = 0;
virtual void SetBrowserFrameTitle(const PRUnichar *aTitle) = 0;
virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY) = 0;
virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY) = 0;
virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY) = 0;
virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY) = 0;
virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) = 0;
virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint) = 0;
virtual void ShowBrowserFrame(PRBool aShow) = 0;
virtual void SetFocus() = 0;
virtual void FocusAvailable(PRBool *aFocusAvail) = 0;
virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0;
// ContextMenu Related Methods
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode) = 0;
virtual HWND GetBrowserFrameNativeWnd() = 0;
};
#define NS_DECL_BROWSERFRAMEGLUE \
public: \
virtual void UpdateStatusBarText(const PRUnichar *aMessage); \
virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); \
virtual void UpdateBusyState(PRBool aBusy); \
virtual void UpdateCurrentURI(nsIURI *aLocation); \
virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, nsIWebBrowser** aWebBrowser); \
virtual void DestroyBrowserFrame(); \
virtual void GetBrowserFrameTitle(PRUnichar **aTitle); \
virtual void SetBrowserFrameTitle(const PRUnichar *aTitle); \
virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY); \
virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY); \
virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY); \
virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY); \
virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY); \
virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint); \
virtual void ShowBrowserFrame(PRBool aShow); \
virtual void SetFocus(); \
virtual void FocusAvailable(PRBool *aFocusAvail); \
virtual void GetBrowserFrameVisibility(PRBool *aVisible); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual HWND GetBrowserFrameNativeWnd();
typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE;
#endif //_IBROWSERFRAMEGLUE_H

View File

@ -0,0 +1,653 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
* Conrad Carlen <ccarlen@netscape.com>
*/
// File Overview....
//
// The typical MFC app, frame creation code + AboutDlg handling
//
// NS_InitEmbedding() is called in InitInstance()
//
// NS_TermEmbedding() is called in ExitInstance()
// ExitInstance() also takes care of cleaning up of
// multiple browser frame windows on app exit
//
// NS_DoIdleEmbeddingStuff(); is called in the overridden
// OnIdle() method
//
// Code to handle the creation of a new browser window
// Next suggested file to look at : BrowserFrm.cpp
// Local Includes
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserFrm.h"
#include "winEmbedFileLocProvider.h"
#include "ProfileMgr.h"
#include "BrowserImpl.h"
#include "BrowserView.h"
#include "nsIWindowWatcher.h"
#include "plstr.h"
#include "Preferences.h"
#include <io.h>
#include <fcntl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// this is for overriding the Mozilla default PromptService component
#include "PromptService.h"
#define kComponentsLibname "mfcEmbedComponents.dll"
#define NS_PROMPTSERVICE_CID \
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
BEGIN_MESSAGE_MAP(CMfcEmbedApp, CWinApp)
//{{AFX_MSG_MAP(CMfcEmbedApp)
ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser)
ON_COMMAND(ID_MANAGE_PROFILES, OnManageProfiles)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_EDIT_PREFERENCES, OnEditPreferences)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CMfcEmbedApp::CMfcEmbedApp() :
m_ProfileMgr(NULL)
{
mRefCnt = 1; // Start at one - nothing is going to addref this object
m_strHomePage = "";
m_iStartupPage = 0;
}
CMfcEmbedApp theApp;
BOOL CMfcEmbedApp::IsCmdLineSwitch(const char *pSwitch, BOOL bRemove)
{
// Search for the switch in the command line.
// Don't take it out of m_lpCmdLine by default
char *pFound = PL_strcasestr(m_lpCmdLine, pSwitch);
if(pFound == NULL ||
// Switch must be at beginning of command line
// or have a space in front of it to avoid
// mangling filenames
( (pFound != m_lpCmdLine) &&
*(pFound-1) != ' ' ) )
{
return(FALSE);
}
if (bRemove)
{
// remove the flag from the command line
char *pTravEnd = pFound + strlen(pSwitch);
char *pTraverse = pFound;
*pTraverse = *pTravEnd;
while(*pTraverse != '\0')
{
pTraverse++;
pTravEnd++;
*pTraverse = *pTravEnd;
}
}
return(TRUE);
}
void CMfcEmbedApp::ParseCmdLine()
{
// Show Debug Console?
if(IsCmdLineSwitch("-console"))
ShowDebugConsole();
}
/* Some Gecko interfaces are implemented as components, automatically
registered at application initialization. nsIPrompt is an example:
the default implementation uses XUL, not native windows. Embedding
apps can override the default implementation by implementing the
nsIPromptService interface and registering a factory for it with
the same CID and Contract ID as the default's.
Note that this example implements the service in a separate DLL,
replacing the default if the override DLL is present. This could
also have been done in the same module, without a separate DLL.
See the PowerPlant example for, well, an example.
*/
nsresult CMfcEmbedApp::OverrideComponents()
{
nsresult rv = NS_OK;
// replace Mozilla's default PromptService with our own, if the
// expected override DLL is present
HMODULE overlib = ::LoadLibrary(kComponentsLibname);
if (overlib) {
InitPromptServiceType InitLib;
MakeFactoryType MakeFactory;
InitLib = reinterpret_cast<InitPromptServiceType>(::GetProcAddress(overlib, kPromptServiceInitFuncName));
MakeFactory = reinterpret_cast<MakeFactoryType>(::GetProcAddress(overlib, kPromptServiceFactoryFuncName));
if (InitLib && MakeFactory) {
InitLib(overlib);
nsCOMPtr<nsIFactory> promptFactory;
rv = MakeFactory(getter_AddRefs(promptFactory));
if (NS_SUCCEEDED(rv))
nsComponentManager::RegisterFactory(kPromptServiceCID,
"Prompt Service",
"@mozilla.org/embedcomp/prompt-service;1",
promptFactory,
PR_TRUE); // replace existing
} else
::FreeLibrary(overlib);
}
return rv;
}
void CMfcEmbedApp::ShowDebugConsole()
{
#ifdef _DEBUG
// Show console only in debug mode
if(! AllocConsole())
return;
// Redirect stdout to the console
int hCrtOut = _open_osfhandle(
(long) GetStdHandle(STD_OUTPUT_HANDLE),
_O_TEXT);
if(hCrtOut == -1)
return;
FILE *hfOut = _fdopen(hCrtOut, "w");
if(hfOut != NULL)
{
// Setup for unbuffered I/O so the console
// output shows up right away
*stdout = *hfOut;
setvbuf(stdout, NULL, _IONBF, 0);
}
// Redirect stderr to the console
int hCrtErr = _open_osfhandle(
(long) GetStdHandle(STD_ERROR_HANDLE),
_O_TEXT);
if(hCrtErr == -1)
return;
FILE *hfErr = _fdopen(hCrtErr, "w");
if(hfErr != NULL)
{
// Setup for unbuffered I/O so the console
// output shows up right away
*stderr = *hfErr;
setvbuf(stderr, NULL, _IONBF, 0);
}
#endif
}
// Initialize our MFC application and also init
// the Gecko embedding APIs
// Note that we're also init'ng the profile switching
// code here
// Then, create a new BrowserFrame and load our
// default homepage
//
BOOL CMfcEmbedApp::InitInstance()
{
ParseCmdLine();
Enable3dControls();
// Take a look at
// http://www.mozilla.org/projects/xpcom/file_locations.html
// for more info on File Locations
winEmbedFileLocProvider *provider = new winEmbedFileLocProvider("MfcEmbed");
if(!provider)
{
ASSERT(FALSE);
return FALSE;
}
nsresult rv;
rv = NS_InitEmbedding(nsnull, provider);
if(NS_FAILED(rv))
{
CBrowserView::WriteToOutputFile("MFCEmbed didn't start up.");
ASSERT(FALSE);
return FALSE;
}
else
CBrowserView::WriteToOutputFile("MFCEmbed started up.");
rv = OverrideComponents();
if(NS_FAILED(rv))
{
ASSERT(FALSE);
return FALSE;
}
rv = InitializeWindowCreator();
if (NS_FAILED(rv))
{
ASSERT(FALSE);
return FALSE;
}
if(!InitializeProfiles())
{
ASSERT(FALSE);
NS_TermEmbedding();
return FALSE;
}
if(!CreateHiddenWindow())
{
ASSERT(FALSE);
NS_TermEmbedding();
return FALSE;
}
// Create the first browser frame window
OnNewBrowser();
return TRUE;
}
CBrowserFrame* CMfcEmbedApp::CreateNewBrowserFrame(PRUint32 chromeMask,
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
PRBool bShowWindow)
{
// Setup a CRect with the requested window dimensions
CRect winSize(x, y, cx, cy);
// Use the Windows default if all are specified as -1
if(x == -1 && y == -1 && cx == -1 && cy == -1)
winSize = CFrameWnd::rectDefault;
// Load the window title from the string resource table
CString strTitle;
strTitle.LoadString(IDR_MAINFRAME);
// Now, create the browser frame
CBrowserFrame* pFrame = new CBrowserFrame(chromeMask);
if (!pFrame->Create(NULL, strTitle, WS_OVERLAPPEDWINDOW,
winSize, NULL, MAKEINTRESOURCE(IDR_MAINFRAME), 0L, NULL))
{
return NULL;
}
// load accelerator resource
pFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MAINFRAME));
// Show the window...
if(bShowWindow)
{
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
}
// Add to the list of BrowserFrame windows
m_FrameWndLst.AddHead(pFrame);
return pFrame;
}
void CMfcEmbedApp::OnNewBrowser()
{
CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame();
//Load the HomePage into the browser view
if(pBrowserFrame && (GetStartupPageMode() == 1))
pBrowserFrame->m_wndBrowserView.LoadHomePage();
}
// This gets called anytime a BrowserFrameWindow is
// closed i.e. by choosing the "close" menu item from
// a window's system menu or by dbl clicking on the
// system menu box
//
// Sends a WM_QUIT to the hidden window which results
// in ExitInstance() being called and the app is
// properly cleaned up and shutdown
//
void CMfcEmbedApp::RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame/*= TRUE*/)
{
POSITION pos = m_FrameWndLst.Find(pFrm);
m_FrameWndLst.RemoveAt(pos);
// Send a WM_QUIT msg. to the hidden window if we've
// just closed the last browserframe window and
// if the bCloseAppOnLastFrame is TRUE. This be FALSE
// only in the case we're switching profiles
// Without this the hidden window will stick around
// i.e. the app will never die even after all the
// visible windows are gone.
if(m_FrameWndLst.GetCount() == 0 && bCloseAppOnLastFrame)
m_pMainWnd->PostMessage(WM_QUIT);
}
int CMfcEmbedApp::ExitInstance()
{
// When File/Exit is chosen and if the user
// has opened multiple browser windows shut all
// of them down properly before exiting the app
CBrowserFrame* pBrowserFrame = NULL;
nsresult rv;
POSITION pos = m_FrameWndLst.GetHeadPosition();
while( pos != NULL )
{
pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos);
if(pBrowserFrame)
{
pBrowserFrame->ShowWindow(false);
pBrowserFrame->DestroyWindow();
}
}
m_FrameWndLst.RemoveAll();
if (m_pMainWnd)
m_pMainWnd->DestroyWindow();
delete m_ProfileMgr;
rv = NS_TermEmbedding();
if (NS_FAILED(rv))
CBrowserView::WriteToOutputFile("MFCEmbed didn't shut down.");
else
CBrowserView::WriteToOutputFile("MFCEmbed shut down.");
return 1;
}
BOOL CMfcEmbedApp::OnIdle(LONG lCount)
{
CWinApp::OnIdle(lCount);
NS_DoIdleEmbeddingStuff();
return FALSE;
}
void CMfcEmbedApp::OnManageProfiles()
{
m_ProfileMgr->DoManageProfilesDialog(PR_FALSE);
}
void CMfcEmbedApp::OnEditPreferences()
{
CPreferences prefs(_T("Preferences"));
prefs.m_startupPage.m_iStartupPage = m_iStartupPage;
prefs.m_startupPage.m_strHomePage = m_strHomePage;
if(prefs.DoModal() == IDOK)
{
// Update our member vars with these new pref values
m_iStartupPage = prefs.m_startupPage.m_iStartupPage;
m_strHomePage = prefs.m_startupPage.m_strHomePage;
// Save these changes to disk now
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
prefs->SetIntPref("browser.startup.page", m_iStartupPage);
rv = prefs->SetCharPref("browser.startup.homepage", m_strHomePage);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile(nsnull);
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");
}
}
BOOL CMfcEmbedApp::InitializeProfiles()
{
m_ProfileMgr = new CProfileMgr;
if (!m_ProfileMgr)
return FALSE;
nsresult rv;
NS_WITH_SERVICE(nsIObserverService, observerService, NS_OBSERVERSERVICE_CONTRACTID, &rv);
observerService->AddObserver(this, NS_LITERAL_STRING("profile-approve-change").get());
observerService->AddObserver(this, NS_LITERAL_STRING("profile-change-teardown").get());
observerService->AddObserver(this, NS_LITERAL_STRING("profile-after-change").get());
m_ProfileMgr->StartUp();
return TRUE;
}
// When the profile switch happens, all open browser windows need to be
// closed.
// In order for that not to kill off the app, we just make the MFC app's
// mainframe be an invisible window which doesn't get closed on profile
// switches
BOOL CMfcEmbedApp::CreateHiddenWindow()
{
CFrameWnd *hiddenWnd = new CFrameWnd;
if(!hiddenWnd)
return FALSE;
RECT bounds = { -10010, -10010, -10000, -10000 };
hiddenWnd->Create(NULL, "main", WS_DISABLED, bounds, NULL, NULL, 0, NULL);
m_pMainWnd = hiddenWnd;
return TRUE;
}
nsresult CMfcEmbedApp::InitializePrefs()
{
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
// We are using the default prefs from mozilla. If you were
// disributing your own, this would be done simply by editing
// the default pref files.
PRBool inited;
rv = prefs->GetBoolPref("mfcbrowser.prefs_inited", &inited);
if (NS_FAILED(rv) || !inited)
{
m_iStartupPage = 1;
m_strHomePage = "http://www.mozilla.org/projects/embedding";
prefs->SetIntPref("browser.startup.page", m_iStartupPage);
prefs->SetCharPref("browser.startup.homepage", m_strHomePage);
prefs->SetIntPref("font.size.variable.x-western", 16);
prefs->SetIntPref("font.size.fixed.x-western", 13);
rv = prefs->SetBoolPref("mfcbrowser.prefs_inited", PR_TRUE);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile(nsnull);
}
else
{
// The prefs are present, read them in
prefs->GetIntPref("browser.startup.page", &m_iStartupPage);
CString strBuf;
char *pBuf = strBuf.GetBuffer(_MAX_PATH);
prefs->CopyCharPref("browser.startup.homepage", &pBuf);
strBuf.ReleaseBuffer(-1);
if(pBuf)
m_strHomePage = pBuf;
}
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");
return rv;
}
/* InitializeWindowCreator creates and hands off an object with a callback
to a window creation function. This will be used by Gecko C++ code
(never JS) to create new windows when no previous window is handy
to begin with. This is done in a few exceptional cases, like PSM code.
Failure to set this callback will only disable the ability to create
new windows under these circumstances. */
nsresult CMfcEmbedApp::InitializeWindowCreator()
{
// give an nsIWindowCreator to the WindowWatcher service
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, this));
if (windowCreator) {
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
wwatch->SetWindowCreator(windowCreator);
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
// ---------------------------------------------------------------------------
// CMfcEmbedApp : nsISupports
// ---------------------------------------------------------------------------
NS_IMPL_THREADSAFE_ISUPPORTS3(CMfcEmbedApp, nsIObserver, nsIWindowCreator, nsISupportsWeakReference);
// ---------------------------------------------------------------------------
// CMfcEmbedApp : nsIObserver
// ---------------------------------------------------------------------------
// Mainly needed to support "on the fly" profile switching
NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData)
{
nsresult rv = NS_OK;
if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-approve-change").get()) == 0)
{
// Ask the user if they want to
int result = MessageBox(NULL, "Do you want to close all windows in order to switch the profile?", "Confirm", MB_YESNO | MB_ICONQUESTION);
if (result != IDYES)
{
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
NS_ENSURE_TRUE(status, NS_ERROR_FAILURE);
status->VetoChange();
}
}
else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-change-teardown").get()) == 0)
{
// Close all open windows. Alternatively, we could just call CBrowserWindow::Stop()
// on each. Either way, we have to stop all network activity on this phase.
POSITION pos = m_FrameWndLst.GetHeadPosition();
while( pos != NULL )
{
CBrowserFrame *pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos);
if(pBrowserFrame)
{
pBrowserFrame->ShowWindow(false);
// Passing in FALSE below so that we do not
// kill the main app during a profile switch
RemoveFrameFromList(pBrowserFrame, FALSE);
pBrowserFrame->DestroyWindow();
}
}
}
else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-after-change").get()) == 0)
{
InitializePrefs(); // In case we have just switched to a newly created profile.
// Only make a new browser window on a switch. This also gets
// called at start up and we already make a window then.
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("switch").get()))
OnNewBrowser();
}
return rv;
}
// ---------------------------------------------------------------------------
// CMfcEmbedApp : nsIWindowCreator
// ---------------------------------------------------------------------------
NS_IMETHODIMP CMfcEmbedApp::CreateChromeWindow(nsIWebBrowserChrome *parent,
PRUint32 chromeFlags,
nsIWebBrowserChrome **_retval)
{
// XXX we're ignoring the "parent" parameter
NS_ENSURE_ARG_POINTER(_retval);
*_retval = 0;
CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(chromeFlags);
if(pBrowserFrame) {
*_retval = NS_STATIC_CAST(nsIWebBrowserChrome *, pBrowserFrame->GetBrowserImpl());
NS_ADDREF(*_retval);
}
return NS_OK;
}
// AboutDlg Stuff
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// Show the AboutDlg
void CMfcEmbedApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}

View File

@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// mozembed.h : main header file for the MOZEMBED application
//
#ifndef _MFCEMBED_H
#define _MFCEMBED_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CMfcEmbedApp:
// See mozembed.cpp for the implementation of this class
//
class CBrowserFrame;
class CProfileMgr;
class CMfcEmbedApp : public CWinApp,
public nsIObserver,
public nsIWindowCreator,
public nsSupportsWeakReference
{
public:
CMfcEmbedApp();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIWINDOWCREATOR
CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL,
PRInt32 x = -1, PRInt32 y = -1,
PRInt32 cx = -1, PRInt32 cy = -1,
PRBool bShowWindow = PR_TRUE);
void RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame = TRUE);
void ShowDebugConsole();
BOOL IsCmdLineSwitch(const char *pSwitch, BOOL bRemove = TRUE);
void ParseCmdLine();
nsresult OverrideComponents();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMfcEmbedApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual BOOL OnIdle(LONG lCount);
//}}AFX_VIRTUAL
CObList m_FrameWndLst;
CString m_strHomePage;
inline BOOL GetHomePage(CString& strHomePage) {
strHomePage = m_strHomePage;
return TRUE;
}
int m_iStartupPage; //0 = BlankPage, 1 = HomePage
inline int GetStartupPageMode() {
return m_iStartupPage;
}
// Implementation
public:
//{{AFX_MSG(CMfcEmbedApp)
afx_msg void OnAppAbout();
afx_msg void OnNewBrowser();
afx_msg void OnManageProfiles();
afx_msg void OnEditPreferences();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
BOOL InitializeProfiles();
BOOL CreateHiddenWindow();
nsresult InitializePrefs();
nsresult InitializeWindowCreator();
private:
CProfileMgr *m_ProfileMgr;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // _MFCEMBED_H

View File

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Rod Spears <rods@netscape.com>
*/
//
// CMostRecentUrls object is responsible for keeping track of the
// 16 most recently used URLs. It stores this list in a file named
// "urls.txt" on a per profile basis in the user's profile directory
//
// The constructor loads the URL list
// The destructor saves the URL list
//
#include "StdAfx.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsAppDirectoryServiceDefs.h"
#include "MostRecentUrls.h"
//--------------------------------------------------------
//-- CMostRecentUrls
//--------------------------------------------------------
CMostRecentUrls::CMostRecentUrls() :
mNumURLs(0)
{
for (int i=0;i<MAX_URLS;i++) {
mURLs[i] = NULL;
}
FILE * fd = GetFD("r");
if (fd) {
char line[512];
while (fgets(line, 512, fd)) {
if (strlen(line) > 1) {
line[strlen(line)-1] = 0;
mURLs[mNumURLs++] = _strdup(line);
}
}
fclose(fd);
}
}
FILE * CMostRecentUrls::GetFD(const char * aMode)
{
FILE * fd = nsnull;
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> local_file(do_QueryInterface(file));
local_file->Append("urls.txt");
local_file->OpenANSIFileDesc(aMode, &fd);
}
return fd;
}
CMostRecentUrls::~CMostRecentUrls()
{
FILE * fd = GetFD("w");
if (fd) {
for (int i=0;i<MAX_URLS;i++) {
if(mURLs[i])
fprintf(fd, "%s\n", mURLs[i]);
}
fclose(fd);
}
for (int i=0;i<MAX_URLS;i++) {
if(mURLs[i])
free(mURLs[i]);
}
}
char * CMostRecentUrls::GetURL(int aInx)
{
if (aInx < mNumURLs) {
return mURLs[aInx];
}
return NULL;
}
void CMostRecentUrls::AddURL(const char * aURL)
{
TCHAR szTemp[512];
strcpy(szTemp, aURL);
// check to see if an existing url matches the one passed in
for (int i=0; i<MAX_URLS-1; i++)
{
if(mURLs[i])
{
if(strcmpi(mURLs[i], szTemp) == 0)
break;
}
}
// if there was a match "i" will point to matching url entry
// if not i will be MAX_URLS-1
// move all url entries before this one down
for (; i>0; i--)
{
if(mURLs[i])
free(mURLs[i]);
if(mURLs[i-1])
mURLs[i] = _strdup(mURLs[i-1]);
}
// place this url at the top
if(mURLs[0])
free(mURLs[0]);
mURLs[0] = _strdup(szTemp);
}

View File

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Rod Spears <rods@netscape.com>
*/
class CMostRecentUrls {
public:
enum _maxUrls {
MAX_URLS = 16
};
CMostRecentUrls();
virtual ~CMostRecentUrls();
char * GetURL(int aInx);
void AddURL(const char * aURL);
inline int GetNumURLs() { return mNumURLs; }
FILE * CMostRecentUrls::GetFD(const char * aMode);
protected:
char * mURLs[MAX_URLS];
int mNumURLs;
};

View File

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#include "stdafx.h"
#include "Preferences.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////
// CPreferences
IMPLEMENT_DYNAMIC(CPreferences, CPropertySheet)
CPreferences::CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
AddPage(&m_startupPage);
}
CPreferences::~CPreferences()
{
}
BEGIN_MESSAGE_MAP(CPreferences, CPropertySheet)
//{{AFX_MSG_MAP(CPreferences)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CPreferences::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
// Hide the Apply button
CWnd* pApplyButton = GetDlgItem(ID_APPLY_NOW);
ASSERT(pApplyButton);
pApplyButton->ShowWindow(SW_HIDE);
return bResult;
}
/////////////////////////////////////////////////////////////////
// CStartupPrefsPage property page
IMPLEMENT_DYNCREATE(CStartupPrefsPage, CPropertyPage)
CStartupPrefsPage::CStartupPrefsPage() : CPropertyPage(CStartupPrefsPage::IDD)
{
//{{AFX_DATA_INIT(CStartupPrefsPage)
m_strHomePage = _T("");
m_iStartupPage = -1;
//}}AFX_DATA_INIT
}
CStartupPrefsPage::~CStartupPrefsPage()
{
}
void CStartupPrefsPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStartupPrefsPage)
DDX_Control(pDX, IDC_EDIT_HOMEPAGE, m_HomePage);
DDX_Text(pDX, IDC_EDIT_HOMEPAGE, m_strHomePage);
DDX_Radio(pDX, IDC_RADIO_BLANK_PAGE, m_iStartupPage);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStartupPrefsPage, CPropertyPage)
//{{AFX_MSG_MAP(CStartupPrefsPage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

View File

@ -0,0 +1,110 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifndef _PREFERENCES_H_
#define _PREFERENCES_H_
#include "resource.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CStartupPrefsPage dialog
class CStartupPrefsPage : public CPropertyPage
{
DECLARE_DYNCREATE(CStartupPrefsPage)
// Construction
public:
CStartupPrefsPage();
~CStartupPrefsPage();
// Dialog Data
//{{AFX_DATA(CStartupPrefsPage)
enum { IDD = IDD_PREFS_START_PAGE };
CEdit m_HomePage;
CString m_strHomePage;
int m_iStartupPage;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CStartupPrefsPage)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CStartupPrefsPage)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CPreferences
class CPreferences : public CPropertySheet
{
DECLARE_DYNAMIC(CPreferences)
// Construction
public:
CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
// Attributes
public:
CStartupPrefsPage m_startupPage;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPreferences)
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPreferences();
// Generated message map functions
protected:
//{{AFX_MSG(CPreferences)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // _PREFERENCES_H_

View File

@ -0,0 +1,246 @@
// PrintProgressDialog.cpp : implementation file
//
#include "stdafx.h"
#include "mfcembed.h"
#include "PrintProgressDialog.h"
#include "BrowserView.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserPrint.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog dialog
class CDlgPrintListener : public nsIPrintListener
{
// Construction
public:
CDlgPrintListener(CPrintProgressDialog* aDlg);
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTLISTENER
void ClearDlg() { m_PrintDlg = NULL; } // weak reference
// Implementation
protected:
CPrintProgressDialog* m_PrintDlg;
};
NS_IMPL_ADDREF(CDlgPrintListener)
NS_IMPL_RELEASE(CDlgPrintListener)
NS_INTERFACE_MAP_BEGIN(CDlgPrintListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrintListener)
NS_INTERFACE_MAP_ENTRY(nsIPrintListener)
NS_INTERFACE_MAP_END
CDlgPrintListener::CDlgPrintListener(CPrintProgressDialog* aDlg) :
m_PrintDlg(aDlg)
{
NS_INIT_ISUPPORTS();
//NS_ADDREF_THIS();
}
/* void OnStartPrinting (); */
NS_IMETHODIMP
CDlgPrintListener::OnStartPrinting()
{
if (m_PrintDlg) {
return m_PrintDlg->OnStartPrinting();
}
return NS_OK;
}
/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); */
NS_IMETHODIMP
CDlgPrintListener::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax)
{
if (m_PrintDlg) {
return m_PrintDlg->OnProgressPrinting(aProgress, aProgressMax);
}
return NS_OK;
}
/* void OnEndPrinting (in PRUint32 aStatus); */
NS_IMETHODIMP
CDlgPrintListener::OnEndPrinting(PRUint32 aStatus)
{
if (m_PrintDlg) {
return m_PrintDlg->OnEndPrinting(aStatus);
}
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog dialog
CPrintProgressDialog::CPrintProgressDialog(nsIWebBrowser* aWebBrowser,
nsIDOMWindow* aDOMWin,
CWnd* pParent /*=NULL*/)
: CDialog(CPrintProgressDialog::IDD, pParent),
m_WebBrowser(aWebBrowser),
m_DOMWin(aDOMWin),
m_PrintListener(nsnull),
m_InModalMode(PR_FALSE)
{
//{{AFX_DATA_INIT(CPrintProgressDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CPrintProgressDialog::~CPrintProgressDialog()
{
CDlgPrintListener * pl = (CDlgPrintListener*)m_PrintListener.get();
if (pl) {
pl->ClearDlg();
}
}
void CPrintProgressDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrintProgressDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrintProgressDialog, CDialog)
//{{AFX_MSG_MAP(CPrintProgressDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog message handlers
static void GetLocalRect(CWnd * aWnd, CRect& aRect, CWnd * aParent)
{
CRect wr;
aParent->GetWindowRect(wr);
CRect cr;
aParent->GetClientRect(cr);
aWnd->GetWindowRect(aRect);
int borderH = wr.Height() - cr.Height();
int borderW = (wr.Width() - cr.Width())/2;
aRect.top -= wr.top+borderH-borderW;
aRect.left -= wr.left+borderW;
aRect.right -= wr.left+borderW;
aRect.bottom -= wr.top+borderH-borderW;
}
BOOL CPrintProgressDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CRect clientRect;
GetClientRect(&clientRect);
CRect titleRect;
GetLocalRect(GetDlgItem(IDC_PPD_DOC_TITLE_STATIC), titleRect, this);
CRect itemRect;
GetLocalRect(GetDlgItem(IDC_PPD_DOC_TXT), itemRect, this);
CRect progRect;
progRect.left = titleRect.left;
progRect.top = itemRect.top+itemRect.Height()+5;
progRect.right = clientRect.Width()-(2*titleRect.left);
progRect.bottom = progRect.top+titleRect.Height();
m_wndProgress.Create (WS_CHILD | WS_VISIBLE, progRect, this, -1);
m_wndProgress.SetPos (0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
int CPrintProgressDialog::DoModal( )
{
PRBool doModal = PR_FALSE;
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
if(print)
{
m_PrintListener = new CDlgPrintListener(this); // constructor addrefs
if (m_PrintListener) {
// doModal will be set to false if the print job was cancelled
doModal = NS_SUCCEEDED(print->Print(m_DOMWin, nsnull, m_PrintListener)) == PR_TRUE;
}
}
if (doModal) {
m_InModalMode = PR_TRUE;
return CDialog::DoModal();
}
return 0;
}
/* void OnStartPrinting (); */
NS_IMETHODIMP
CPrintProgressDialog::OnStartPrinting()
{
return NS_OK;
}
/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); */
NS_IMETHODIMP
CPrintProgressDialog::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax)
{
// Initialize the progress meter we we get the "zero" progress
// which also tells us the max progress
if (aProgress == 0) {
CWnd *pWnd = GetDlgItem(IDC_PPD_DOC_TXT);
if(pWnd)
pWnd->SetWindowText(m_URL);
m_wndProgress.SetRange(0, aProgressMax);
m_wndProgress.SetPos(0);
}
m_wndProgress.SetPos(aProgress);
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return NS_OK;
}
/* void OnEndPrinting (in PRUint32 aStatus); */
NS_IMETHODIMP
CPrintProgressDialog::OnEndPrinting(PRUint32 aStatus)
{
// Here we need to know whether we have gone "modal"
// because we could get notified here if the user cancels
// before we ever get a chance to go into the modal loop
if (m_InModalMode) {
EndDialog(1);
}
return NS_OK;
}
void CPrintProgressDialog::OnCancel()
{
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
if (print) {
print->Cancel();
}
CDialog::OnCancel();
}
void CPrintProgressDialog::SetURI(const char* aTitle)
{
m_URL = _T(aTitle);
}

View File

@ -0,0 +1,70 @@
#if !defined(AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_)
#define AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PrintProgressDialog.h : header file
//
#include "nsIPrintListener.h"
class nsIWebBrowser;
class nsIDOMWindow;
class nsIPrintListener;
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog dialog
class CPrintProgressDialog : public CDialog
{
// Construction
public:
CPrintProgressDialog(nsIWebBrowser* aWebBrowser,
nsIDOMWindow* aDOMWin,
CWnd* pParent = NULL);
virtual ~CPrintProgressDialog();
virtual int DoModal( );
// Helper
void SetURI(const char* aTitle);
// same as nsIPrintListener
NS_IMETHOD OnStartPrinting(void);
NS_IMETHOD OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax);
NS_IMETHOD OnEndPrinting(PRUint32 aStatus);
// Dialog Data
//{{AFX_DATA(CPrintProgressDialog)
enum { IDD = IDD_PRINT_PROGRESS_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrintProgressDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CProgressCtrl m_wndProgress;
CString m_URL;
nsIWebBrowser* m_WebBrowser;
nsIDOMWindow* m_DOMWin;
nsCOMPtr<nsIPrintListener> m_PrintListener;
BOOL m_InModalMode;
// Generated message map functions
//{{AFX_MSG(CPrintProgressDialog)
virtual BOOL OnInitDialog();
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_)

View File

@ -0,0 +1,189 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*/
// Local Includes
#include "stdafx.h"
#include "mfcembed.h"
#include "ProfileMgr.h"
#include "ProfilesDlg.h"
// Mozilla Includes
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIRegistry.h"
#include "nsIProfile.h"
// Constants
#define kRegistryGlobalPrefsSubtreeString (NS_LITERAL_STRING("global-prefs"))
#define kRegistryShowProfilesAtStartup "start-show-dialog"
//*****************************************************************************
//*** CProfileMgr: Object Management
//*****************************************************************************
CProfileMgr::CProfileMgr()
{
}
CProfileMgr::~CProfileMgr()
{
}
//*****************************************************************************
//*** CProfileMgr: Public Methods
//*****************************************************************************
nsresult CProfileMgr::StartUp()
{
nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
PRInt32 profileCount;
rv = profileService->GetProfileCount(&profileCount);
if (NS_FAILED(rv)) return rv;
if (profileCount == 0)
{
// Make a new default profile
NS_NAMED_LITERAL_STRING(newProfileName, "default");
rv = profileService->CreateNewProfile(newProfileName.get(), nsnull, nsnull, PR_FALSE);
if (NS_FAILED(rv)) return rv;
rv = profileService->SetCurrentProfile(newProfileName.get());
if (NS_FAILED(rv)) return rv;
}
else
{
// Use our flag here to check for whether to show profile mgr UI. If the flag
// says don't show it, just start with the last used profile.
PRBool showIt;
rv = GetShowDialogOnStart(&showIt);
if (NS_FAILED(rv) || (profileCount > 1 && showIt))
{
DoManageProfilesDialog(TRUE);
}
else
{
// GetCurrentProfile returns the profile which was last used but is not nescesarily
// active. Call SetCurrentProfile to make it installed and active.
nsXPIDLString currProfileName;
rv = profileService->GetCurrentProfile(getter_Copies(currProfileName));
if (NS_FAILED(rv)) return rv;
rv = profileService->SetCurrentProfile(currProfileName);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
}
nsresult CProfileMgr::DoManageProfilesDialog(PRBool bAtStartUp)
{
CProfilesDlg dialog;
nsresult rv;
PRBool showIt;
rv = GetShowDialogOnStart(&showIt);
dialog.m_bAtStartUp = bAtStartUp;
dialog.m_bAskAtStartUp = NS_SUCCEEDED(rv) ? showIt : TRUE;
if (dialog.DoModal() == IDOK)
{
SetShowDialogOnStart(dialog.m_bAskAtStartUp);
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
rv = profileService->SetCurrentProfile(dialog.m_SelectedProfile.GetUnicode());
}
return NS_OK;
}
//*****************************************************************************
//*** CProfileMgr: Protected Methods
//*****************************************************************************
nsresult CProfileMgr::GetShowDialogOnStart(PRBool* showIt)
{
nsresult rv = NS_OK;
*showIt = PR_TRUE;
nsCOMPtr<nsIRegistry> registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv));
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry);
if (NS_FAILED(rv)) return rv;
nsRegistryKey profilesTreeKey;
rv = registry->GetKey(nsIRegistry::Common,
kRegistryGlobalPrefsSubtreeString.get(),
&profilesTreeKey);
if (NS_SUCCEEDED(rv))
{
PRInt32 flagValue;
rv = registry->GetInt(profilesTreeKey,
kRegistryShowProfilesAtStartup,
&flagValue);
if (NS_SUCCEEDED(rv))
*showIt = (flagValue != 0);
}
return rv;
}
nsresult CProfileMgr::SetShowDialogOnStart(PRBool showIt)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIRegistry> registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv));
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry);
if (NS_FAILED(rv)) return rv;
nsRegistryKey profilesTreeKey;
rv = registry->GetKey(nsIRegistry::Common,
kRegistryGlobalPrefsSubtreeString.get(),
&profilesTreeKey);
if (NS_FAILED(rv))
{
rv = registry->AddKey(nsIRegistry::Common,
kRegistryGlobalPrefsSubtreeString.get(),
&profilesTreeKey);
}
if (NS_SUCCEEDED(rv))
{
rv = registry->SetInt(profilesTreeKey,
kRegistryShowProfilesAtStartup,
showIt);
}
return rv;
}

View File

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*/
#ifndef __ProfileMgr__
#define __ProfileMgr__
// Mozilla Includes
#include "nsError.h"
// Forward Declarations
class nsIRegistry;
//*****************************************************************************
//*** CProfileMgr
//*****************************************************************************
class CProfileMgr
{
public:
CProfileMgr();
virtual ~CProfileMgr();
virtual nsresult StartUp();
virtual nsresult DoManageProfilesDialog(PRBool bAtStartUp);
// If bAtStartUp is TRUE, a profile must be selected.
protected:
nsresult GetShowDialogOnStart(PRBool* showIt);
nsresult SetShowDialogOnStart(PRBool showIt);
};
#endif

View File

@ -0,0 +1,292 @@
// ProfilesDlg.cpp : implementation file
//
#include "stdafx.h"
#include <afxpriv.h>
#include "mfcembed.h"
#include "ProfilesDlg.h"
// Mozilla
#include "nsIProfile.h"
#include "nsIServiceManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Static Routines
static void ValidateProfileName(const CString& profileName, CDataExchange* pDX)
{
USES_CONVERSION;
nsresult rv;
PRBool exists = FALSE;
{
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
rv = profileService->ProfileExists(T2W(profileName), &exists);
}
if (NS_SUCCEEDED(rv) && exists)
{
CString errMsg;
errMsg.Format(_T("Error: A profile named \"%s\" already exists."), (const char *)profileName);
AfxMessageBox( errMsg, MB_ICONEXCLAMATION );
errMsg.Empty();
pDX->Fail();
}
if (profileName.FindOneOf("\\/") != -1)
{
AfxMessageBox( _T("Error: A profile name cannot contain the characters \"\\\" or \"/\"."), MB_ICONEXCLAMATION );
pDX->Fail();
}
}
/////////////////////////////////////////////////////////////////////////////
// CNewProfileDlg dialog
CNewProfileDlg::CNewProfileDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNewProfileDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewProfileDlg)
m_LocaleIndex = -1;
m_Name = _T("");
//}}AFX_DATA_INIT
}
void CNewProfileDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewProfileDlg)
DDX_CBIndex(pDX, IDC_LOCALE_COMBO, m_LocaleIndex);
DDX_Text(pDX, IDC_NEW_PROF_NAME, m_Name);
//}}AFX_DATA_MAP
pDX->PrepareEditCtrl(IDC_NEW_PROF_NAME);
if (pDX->m_bSaveAndValidate)
{
ValidateProfileName(m_Name, pDX);
}
}
BEGIN_MESSAGE_MAP(CNewProfileDlg, CDialog)
//{{AFX_MSG_MAP(CNewProfileDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewProfileDlg message handlers
/////////////////////////////////////////////////////////////////////////////
// CRenameProfileDlg dialog
CRenameProfileDlg::CRenameProfileDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRenameProfileDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRenameProfileDlg)
m_NewName = _T("");
//}}AFX_DATA_INIT
}
void CRenameProfileDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRenameProfileDlg)
DDX_Text(pDX, IDC_NEW_NAME, m_NewName);
//}}AFX_DATA_MAP
pDX->PrepareEditCtrl(IDC_NEW_NAME);
if (pDX->m_bSaveAndValidate)
{
ValidateProfileName(m_NewName, pDX);
}
}
BEGIN_MESSAGE_MAP(CRenameProfileDlg, CDialog)
//{{AFX_MSG_MAP(CRenameProfileDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRenameProfileDlg message handlers
/////////////////////////////////////////////////////////////////////////////
// CProfilesDlg dialog
CProfilesDlg::CProfilesDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProfilesDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProfilesDlg)
m_bAtStartUp = FALSE;
m_bAskAtStartUp = FALSE;
//}}AFX_DATA_INIT
}
void CProfilesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProfilesDlg)
DDX_Control(pDX, IDC_LIST1, m_ProfileList);
DDX_Check(pDX, IDC_CHECK_ASK_AT_START, m_bAskAtStartUp);
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate)
{
USES_CONVERSION;
int itemIndex = m_ProfileList.GetCurSel();
if (itemIndex != LB_ERR)
{
CString itemText;
m_ProfileList.GetText(itemIndex, itemText);
m_SelectedProfile.Assign(T2W(itemText));
}
}
}
BEGIN_MESSAGE_MAP(CProfilesDlg, CDialog)
//{{AFX_MSG_MAP(CProfilesDlg)
ON_BN_CLICKED(IDC_PROF_NEW, OnNewProfile)
ON_BN_CLICKED(IDC_PROF_RENAME, OnRenameProfile)
ON_BN_CLICKED(IDC_PROF_DELETE, OnDeleteProfile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProfilesDlg message handlers
BOOL CProfilesDlg::OnInitDialog()
{
USES_CONVERSION;
CDialog::OnInitDialog();
nsCAutoString cStr;
nsXPIDLString curProfileName;
// Fill the list of profiles
nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
profileService->GetCurrentProfile(getter_Copies(curProfileName));
PRInt32 selectedRow = 0;
PRUint32 listLen;
PRUnichar **profileList;
rv = profileService->GetProfileList(&listLen, &profileList);
for (PRUint32 index = 0; index < listLen; index++)
{
CString tmpStr(W2T(profileList[index]));
m_ProfileList.AddString(tmpStr);
if (nsCRT::strcmp(profileList[index], curProfileName.get()) == 0)
selectedRow = index;
}
m_ProfileList.SetCurSel(selectedRow);
if (m_bAtStartUp)
{
GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CProfilesDlg::OnNewProfile()
{
CNewProfileDlg dialog;
if (dialog.DoModal() == IDOK)
{
nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv))
{
USES_CONVERSION;
rv = profileService->CreateNewProfile(T2W(dialog.m_Name), nsnull, nsnull, PR_FALSE);
ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv))
{
int item = m_ProfileList.AddString(dialog.m_Name);
m_ProfileList.SetCurSel(item);
GetDlgItem(IDOK)->EnableWindow(TRUE);
}
}
}
}
void CProfilesDlg::OnRenameProfile()
{
CRenameProfileDlg dialog;
int itemIndex = m_ProfileList.GetCurSel();
ASSERT(itemIndex != LB_ERR);
if (itemIndex == LB_ERR)
return;
m_ProfileList.GetText(itemIndex, dialog.m_CurrentName);
if (dialog.DoModal() == IDOK)
{
USES_CONVERSION;
nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv))
{
rv = profileService->RenameProfile(T2W(dialog.m_CurrentName), T2W(dialog.m_NewName));
ASSERT(NS_SUCCEEDED(rv));
}
}
}
void CProfilesDlg::OnDeleteProfile()
{
int itemIndex = m_ProfileList.GetCurSel();
ASSERT(itemIndex != LB_ERR);
if (itemIndex == LB_ERR)
return;
CString selectedProfile;
m_ProfileList.GetText(itemIndex, selectedProfile);
nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv))
{
USES_CONVERSION;
rv = profileService->DeleteProfile(T2W(selectedProfile), PR_TRUE);
ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv))
{
int itemCount = m_ProfileList.DeleteString(itemIndex);
if (itemCount == 0)
GetDlgItem(IDOK)->EnableWindow(FALSE);
}
}
}

View File

@ -0,0 +1,120 @@
#if !defined(AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_)
#define AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ProfilesDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CNewProfileDlg dialog
class CNewProfileDlg : public CDialog
{
// Construction
public:
CNewProfileDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CNewProfileDlg)
enum { IDD = IDD_PROFILE_NEW };
int m_LocaleIndex;
CString m_Name;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewProfileDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CNewProfileDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CRenameProfileDlg dialog
class CRenameProfileDlg : public CDialog
{
// Construction
public:
CRenameProfileDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CRenameProfileDlg)
enum { IDD = IDD_PROFILE_RENAME };
CString m_NewName;
//}}AFX_DATA
CString m_CurrentName;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRenameProfileDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CRenameProfileDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CProfilesDlg dialog
class CProfilesDlg : public CDialog
{
// Construction
public:
CProfilesDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CProfilesDlg)
enum { IDD = IDD_PROFILES };
CListBox m_ProfileList;
BOOL m_bAtStartUp;
BOOL m_bAskAtStartUp;
//}}AFX_DATA
nsAutoString m_SelectedProfile;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CProfilesDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CProfilesDlg)
virtual BOOL OnInitDialog();
afx_msg void OnNewProfile();
afx_msg void OnRenameProfile();
afx_msg void OnDeleteProfile();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_)

View File

@ -0,0 +1,137 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
This sample shows how to embed Mozilla from within
an MFC Windows application
Mainly demonstrates the use of the following interfaces:
nsIWebBrowserChrome
nsIEmbeddingSiteWindow
nsIWebProgressListener
nsIContextMenuListener
nsIPrompt
nsIWebBrowserFind
General Overview:
-----------------
1. The MfcEmbedApp creates BrowserFrames
2. BrowserFrame creates the toolbar, statusbar, URLbar
BrowserView etc.
BrowserFrames implement the IBrowserFrameGlue interface
using which new BrowserFrames can be created, statusbar
updated etc.
3. BrowserView creates the embeddable browser instance and
manages user interaction such as URL navigation etc.
BrowserView connects the BrowserImpl with the BrowserFrame
via the IBrowserFrameGlue interface
4. BrowserImpl implements the set of required/optional Gecko
embedding interfaces
Start by first looking at MfcEmbed.cpp
Files:
StdAfx.h
- Includes the required Mozilla header files
MfcEmbed.cpp
- CWinApp derived class
- Creates the browser's main frame window etc
using the CreateNewBrowserFrame() and loads
the HomePage
- Makes the required NS_InitEmbedding() and the
NS_TermEmbedding() calls in the app's InitInstance()
and ExitInstance() functions
- Keeps track of the list of new BrowserFrames created
which it cleans up properly in ExitInstance()
BrowserFrm.cpp
- This is the browser's Frame window i.e. the one with the
"chrome" - with the toolbar, urlbar etc.
- Creates the toolbar, URLbar, statusbar, progressbar
also the browser's view window.
BrowserFrameGlue.cpp
- Implements the IBrowserFrameGlue interface. This interface
contains platform specific implementations of functions to
update the statusbar, creating new browser frames etc. Embedded
browser's callbacks use this interface when needed
BrowserView.cpp
- Creates the embedded browser object and handles most aspects
of the embedded browser interactions - like URL navigation,
clipboard interactions etc
- Also has code to keep the menu/toolbar/statusbar UI items up
to date
- It's the view which conntects the BrowserFrame to the BrowserImpl
(see below) by passing it the pointer to IBrowserFrameGlue
BrowserImpl*.cpp
- Implements the required and/or optional embedded browser
interfaces
(BrowserImpl.cpp implements the set of interfaces which
are required by Gecko of all embedding apps. The other
interfaces implemented in the BrowserImpl*.cpp files are
optional)
- Calls on the statusbar/progressbar update functions exposed
via the IBrowserFrameGlue in response to the nsIProgressListener
interface callbacks
Dialogs.cpp
- Contains dialog box code for displaying Prompts, getting
passwords, getting username/passwords etc
- Contains the CFindDialog class - used for searching text
in a web page
winEmbedFileLocProvider.cpp, ProfilesDlg.cpp, ProfileMgr.cpp
- Profile management related code (by Conrad Carlen)
MfcEmbed.htm
- This is a simple test harness for excercising some of the
implemented interfaces . For ex, the nsIWebBrowserChrome.
- Open the file in mfcemed by typing the following in it's
location bar. For ex:
file:///c:/tmp/mfcembed.htm
- Read/Click on the links on that page more info
- This test page is just a start and will add more test
case to it over time
makefile.win
- We define "_AFXDLL" and for the compiler and specify
"-SUBSYSTEM:windows" for the linker using LCFLAGS and
LLFLAGS, respectively
- We also define "USE_SINGLE_SIGN_ON" to enable the
single sign-on support
mfcembed.dsp and mfcembed.dsw
- These VisualStudio workspace/project files can be used
to open/build this sample inside of the VC++ IDE

View File

@ -0,0 +1,31 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// stdafx.cpp : source file that includes just the standard includes
// mozembed.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -0,0 +1,103 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#ifndef _STDAFX_H
#define _STDAFX_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#include <afxpriv.h> // Needed for MFC MBCS/Unicode Conversion Macros
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include "nsCOMPtr.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsCWebBrowser.h"
#include "nsXPIDLString.h"
#include "nsWidgetsCID.h"
#include "nsIDocShell.h"
#include "nsIWebBrowser.h"
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebProgressListener.h"
#include "nsIWindowCreator.h"
#include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
#include "nsIClipboardCommands.h"
#include "nsIWebBrowserPersist.h"
#include "nsIContextMenuListener.h"
#include "nsIDOMNode.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsReadableUtils.h"
#include "nsIPrompt.h"
#include "nsEmbedAPI.h"
#include "nsISHistory.h"
#include "nsISHEntry.h"
#include "nsIPref.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIProfileChangeStatus.h"
#include "nsIObserverService.h"
#ifdef MOZ_OLD_CACHE
#include "nsINetDataCacheManager.h"
#endif
#include "nsError.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserFocus.h"
// Printer Includes
#include "nsIPrintOptions.h"
#include "nsIWebBrowserPrint.h"
#include "nsIDOMWindow.h"
// qa additions
#include "nsIGlobalHistory.h"
#include "nsIBrowserHistory.h"
#include "nsILocalFile.h"
#include "nsIProfile.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //_STDAFX_H

View File

@ -0,0 +1,54 @@
// UrlDialog.cpp : implementation file
//
#include "stdafx.h"
#include "mfcembed.h"
#include "UrlDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUrlDialog dialog
CUrlDialog::CUrlDialog(CWnd* pParent /*=NULL*/)
: CDialog(CUrlDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CUrlDialog)
m_urlfield = _T("");
//}}AFX_DATA_INIT
}
void CUrlDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUrlDialog)
DDX_Text(pDX, IDC_URLFIELD, m_urlfield);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUrlDialog, CDialog)
//{{AFX_MSG_MAP(CUrlDialog)
ON_EN_CHANGE(IDC_URLFIELD, OnChangeUrlfield)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUrlDialog message handlers
void CUrlDialog::OnChangeUrlfield()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}

View File

@ -0,0 +1,46 @@
#if !defined(AFX_URLDIALOG_H__260C4EE1_2F8E_11D5_99F0_00C04FA02BE6__INCLUDED_)
#define AFX_URLDIALOG_H__260C4EE1_2F8E_11D5_99F0_00C04FA02BE6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// UrlDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CUrlDialog dialog
class CUrlDialog : public CDialog
{
// Construction
public:
CUrlDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CUrlDialog)
enum { IDD = IDD_URLDIALOG };
CString m_urlfield;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUrlDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CUrlDialog)
afx_msg void OnChangeUrlfield();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_URLDIALOG_H__260C4EE1_2F8E_11D5_99F0_00C04FA02BE6__INCLUDED_)

View File

@ -0,0 +1,256 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#include "stdafx.h"
#include "Dialogs.h"
// File overview....
//
// Contains dialog box code to support Alerts, Prompts such as
// password prompt and username/password prompts
//
//--------------------------------------------------------------------------//
// CPromptDialog Stuff
//--------------------------------------------------------------------------//
CPromptDialog::CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPromptText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitPromptText)
m_csPromptAnswer = pInitPromptText;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptDialog)
DDX_Text(pDX, IDC_PROMPT_ANSWER, m_csPromptAnswer);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptDialog, CDialog)
//{{AFX_MSG_MAP(CPromptDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if (m_bHasCheckBox)
{
if(!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
// Hide the check box control if there's no label text
// This will be the case when we're not using single sign-on
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PROMPT_ANSWER);
if(pEdit)
{
pEdit->SetWindowText(m_csPromptAnswer);
pEdit->SetFocus();
pEdit->SetSel(0, -1);
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}
//--------------------------------------------------------------------------//
// CPromptPasswordDialog Stuff
//--------------------------------------------------------------------------//
CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPasswordText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptPasswordDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitPasswordText)
m_csPassword = pInitPasswordText;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptPasswordDialog)
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptPasswordDialog, CDialog)
//{{AFX_MSG_MAP(CPromptPasswordDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptPasswordDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if (m_bHasCheckBox)
{
if(!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
// Hide the check box control if there's no label text
// This will be the case when we're not using single sign-on
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
if(pEdit)
{
pEdit->SetFocus();
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}
//--------------------------------------------------------------------------//
// CPromptUsernamePasswordDialog Stuff
//--------------------------------------------------------------------------//
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitUsername, const char* pInitPassword,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitUsername)
m_csUserName = pInitUsername;
if(pInitPassword)
m_csPassword = pInitPassword;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptUsernamePasswordDialog)
DDX_Text(pDX, IDC_USERNAME, m_csUserName);
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptUsernamePasswordDialog, CDialog)
//{{AFX_MSG_MAP(CPromptUsernamePasswordDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptUsernamePasswordDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if(m_bHasCheckBox)
{
if (!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
if(pEdit)
{
pEdit->SetWindowText(m_csPassword);
}
pEdit = (CEdit *)GetDlgItem(IDC_USERNAME);
if(pEdit)
{
pEdit->SetWindowText(m_csUserName);
pEdit->SetSel(0, -1);
pEdit->SetFocus();
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}

View File

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifndef _DIALOGS_H_
#define _DIALOGS_H_
#include "resource.h"
class CPromptDialog : public CDialog
{
public:
CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPromptText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptDialog)
enum { IDD = IDD_PROMPT_DIALOG };
CString m_csPromptAnswer;
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CPromptPasswordDialog : public CDialog
{
public:
CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPasswordText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptPasswordDialog)
enum { IDD = IDD_PROMPT_PASSWORD_DIALOG };
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
CString m_csPassword;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptPasswordDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptPasswordDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CPromptUsernamePasswordDialog : public CDialog
{
public:
CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitUsername, const char* pInitPassword,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptUsernamePasswordDialog)
enum { IDD = IDD_PROMPT_USERPASS_DIALOG };
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
CString m_csUserNameLabel;
CString m_csPasswordLabel;
CString m_csPassword;
CString m_csUserName;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptUsernamePasswordDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptUsernamePasswordDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif //_DIALOG_H_

View File

@ -0,0 +1,136 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\mfcembed.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Prompt Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,130,69,50,14
PUSHBUTTON "Cancel",IDCANCEL,189,69,50,14
LTEXT "Please enter something....",IDC_PROMPT_TEXT,10,7,229,29
EDITTEXT IDC_PROMPT_ANSWER,7,39,232,13,ES_AUTOHSCROLL
CONTROL "Save Answer",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
END
IDD_PROMPT_PASSWORD_DIALOG DIALOG DISCARDABLE 0, 0, 248, 93
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Password Entry Dialog"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Please enter your password:",IDC_PROMPT_TEXT,5,7,232,20
DEFPUSHBUTTON "OK",IDOK,129,75,50,14
PUSHBUTTON "Cancel",IDCANCEL,188,75,50,14
EDITTEXT IDC_PASSWORD,5,37,233,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Save Password",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
END
IDD_PROMPT_USERPASS_DIALOG DIALOG DISCARDABLE 0, 0, 214, 123
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Username and Password Required"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "This operation requires authentication. Please enter your user name and password:",
IDC_PROMPT_TEXT,6,9,171,25
LTEXT "User Name:",IDC_USERNAME_LABEL,6,39,39,9
EDITTEXT IDC_USERNAME,49,39,153,12,ES_AUTOHSCROLL
LTEXT "Password:",IDC_PASSWORD_LABEL,6,58,36,8
EDITTEXT IDC_PASSWORD,49,56,153,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Save User Name and Password",IDC_CHECK_SAVE_PASSWORD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10
DEFPUSHBUTTON "OK",IDOK,40,101,50,14
PUSHBUTTON "Cancel",IDCANCEL,95,101,50,14
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,383 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* PromptService is intended to override the default Mozilla PromptService,
giving nsIPrompt implementations of our own design, rather than using
Mozilla's. Do this by building this into a component and registering the
factory with the same CID/ContractID as Mozilla's (see MfcEmbed.cpp).
*/
#include "stdafx.h"
#include "Dialogs.h"
#include "PromptService.h"
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsIDOMWindow.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIFactory.h"
#include "nsIPromptService.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWindowWatcher.h"
static HINSTANCE gInstance;
//*****************************************************************************
// ResourceState
//*****************************************************************************
class ResourceState {
public:
ResourceState() {
mPreviousInstance = ::AfxGetResourceHandle();
::AfxSetResourceHandle(gInstance);
}
~ResourceState() {
::AfxSetResourceHandle(mPreviousInstance);
}
private:
HINSTANCE mPreviousInstance;
};
//*****************************************************************************
// CPromptService
//*****************************************************************************
class CPromptService: public nsIPromptService {
public:
CPromptService();
virtual ~CPromptService();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROMPTSERVICE
private:
nsCOMPtr<nsIWindowWatcher> mWWatch;
CWnd *CWndForDOMWindow(nsIDOMWindow *aWindow);
};
//*****************************************************************************
NS_IMPL_ISUPPORTS1(CPromptService, nsIPromptService)
CPromptService::CPromptService() :
mWWatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"))
{
NS_INIT_REFCNT();
}
CPromptService::~CPromptService() {
}
CWnd *
CPromptService::CWndForDOMWindow(nsIDOMWindow *aWindow)
{
nsCOMPtr<nsIWebBrowserChrome> chrome;
CWnd *val = 0;
if (mWWatch) {
nsCOMPtr<nsIDOMWindow> fosterParent;
if (!aWindow) { // it will be a dependent window. try to find a foster parent.
mWWatch->GetActiveWindow(getter_AddRefs(fosterParent));
aWindow = fosterParent;
}
mWWatch->GetChromeForWindow(aWindow, getter_AddRefs(chrome));
}
if (chrome) {
nsCOMPtr<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome));
if (site) {
HWND w;
site->GetSiteWindow(reinterpret_cast<void **>(&w));
val = CWnd::FromHandle(w);
}
}
return val;
}
NS_IMETHODIMP CPromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text)
{
USES_CONVERSION;
CWnd *wnd = CWndForDOMWindow(parent);
if (wnd)
wnd->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
else
::MessageBox(0, W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
return NS_OK;
}
NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkboxMsg,
PRBool *checkValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CPromptService::Confirm(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRBool *_retval)
{
USES_CONVERSION;
CWnd *wnd = CWndForDOMWindow(parent);
int choice;
if (wnd)
choice = wnd->MessageBox(W2T(text), W2T(dialogTitle),
MB_YESNO | MB_ICONEXCLAMATION);
else
choice = ::MessageBox(0, W2T(text), W2T(dialogTitle),
MB_YESNO | MB_ICONEXCLAMATION);
*_retval = choice == IDYES ? PR_TRUE : PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkboxMsg,
PRBool *checkValue,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **value,
const PRUnichar *checkboxMsg,
PRBool *checkValue,
PRBool *_retval)
{
ResourceState setState;
USES_CONVERSION;
CWnd *wnd = CWndForDOMWindow(parent);
CPromptDialog dlg(wnd, W2T(dialogTitle), W2T(text),
text && *text ? W2T(text) : 0,
checkValue != nsnull, W2T(checkboxMsg),
checkValue ? *checkValue : 0);
if(dlg.DoModal() == IDOK) {
// Get the value entered in the editbox of the PromptDlg
if (value && *value) {
nsMemory::Free(*value);
*value = nsnull;
}
nsString csPromptEditValue;
csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0));
*value = csPromptEditValue.ToNewUnicode();
*_retval = PR_TRUE;
} else
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username,
PRUnichar **password,
const PRUnichar *checkboxMsg,
PRBool *checkValue,
PRBool *_retval)
{
ResourceState setState;
USES_CONVERSION;
CWnd *wnd = CWndForDOMWindow(parent);
CPromptUsernamePasswordDialog dlg(wnd, W2T(dialogTitle), W2T(text),
username && *username ? W2T(*username) : 0,
password && *password ? W2T(*password) : 0,
checkValue != nsnull, W2T(checkboxMsg),
checkValue ? *checkValue : 0);
if (dlg.DoModal() == IDOK) {
// Get the username entered
if (username && *username) {
nsMemory::Free(*username);
*username = nsnull;
}
nsString csUserName;
csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0));
*username = csUserName.ToNewUnicode();
// Get the password entered
if (password && *password) {
nsMemory::Free(*password);
*password = nsnull;
}
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
if(checkValue)
*checkValue = dlg.m_bCheckBoxValue;
*_retval = PR_TRUE;
} else
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkboxMsg,
PRBool *checkValue,
PRBool *_retval)
{
ResourceState setState;
USES_CONVERSION;
CWnd *wnd = CWndForDOMWindow(parent);
CPromptPasswordDialog dlg(wnd, W2T(dialogTitle), W2T(text),
password && *password ? W2T(*password) : 0,
checkValue != nsnull, W2T(checkboxMsg),
checkValue ? *checkValue : 0);
if(dlg.DoModal() == IDOK) {
// Get the password entered
if (password && *password) {
nsMemory::Free(*password);
*password = nsnull;
}
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
if(checkValue)
*checkValue = dlg.m_bCheckBoxValue;
*_retval = PR_TRUE;
} else
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP CPromptService::Select(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text, PRUint32 count,
const PRUnichar **selectList,
PRInt32 *outSelection,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// CPromptServiceFactory
//*****************************************************************************
class CPromptServiceFactory : public nsIFactory {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
CPromptServiceFactory();
virtual ~CPromptServiceFactory();
};
//*****************************************************************************
NS_IMPL_ISUPPORTS1(CPromptServiceFactory, nsIFactory)
CPromptServiceFactory::CPromptServiceFactory() {
NS_INIT_ISUPPORTS();
}
CPromptServiceFactory::~CPromptServiceFactory() {
}
NS_IMETHODIMP CPromptServiceFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = NULL;
CPromptService *inst = new CPromptService;
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = inst->QueryInterface(aIID, aResult);
if (rv != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
return rv;
}
NS_IMETHODIMP CPromptServiceFactory::LockFactory(PRBool lock)
{
return NS_OK;
}
//*****************************************************************************
void InitPromptService(HINSTANCE instance) {
gInstance = instance;
}
nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory)
{
NS_ENSURE_ARG_POINTER(aFactory);
*aFactory = nsnull;
CPromptServiceFactory *result = new CPromptServiceFactory;
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*aFactory = result;
return NS_OK;
}

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __PromptService_h
#define __PromptService_h
#include "nsError.h"
// this component is for an MFC app; it's Windows. make sure this is defined.
#ifndef XP_WIN
#define XP_WIN
#endif
class nsIFactory;
// factory creator, in hard and soft link formats
extern "C" NS_EXPORT nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory);
typedef nsresult (__cdecl *MakeFactoryType)(nsIFactory **);
#define kPromptServiceFactoryFuncName "NS_NewPromptServiceFactory"
// initialization function, in hard and soft link formats
extern "C" NS_EXPORT void InitPromptService(HINSTANCE instance);
typedef nsresult (__cdecl *InitPromptServiceType)(HINSTANCE instance);
#define kPromptServiceInitFuncName "InitPromptService"
#endif

View File

@ -0,0 +1,6 @@
/NOLOGO /DLL /OUT:.\WIN32_D.OBJ\mfcEmbedComponents.dll
/PDB:.\WIN32_D.OBJ\mfcEmbedComponents.pdb
/SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:.\WIN32_D.OBJ\mfcEmbedComponents.pdb -SUBSYSTEM:windows
.\WIN32_D.OBJ\Dialogs.obj .\WIN32_D.OBJ\PromptService.obj
.\WIN32_D.OBJ\Dialogs.res
..\..\..\..\dist\WIN32_D.OBJ\lib\nspr4.lib ..\..\..\..\dist\WIN32_D.OBJ\lib\plds4.lib ..\..\..\..\dist\WIN32_D.OBJ\lib\plc4.lib ..\..\..\..\dist\WIN32_D.OBJ\lib\xpcom.lib kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib

View File

@ -0,0 +1,12 @@
DIALOGS.CPP: \
D:\MOZILLA_SRC\MOZILLA\EMBEDDING\TESTS\MFCEMBED\COMPONENTS\STDAFX.H \
D:\MOZILLA_SRC\MOZILLA\EMBEDDING\TESTS\MFCEMBED\COMPONENTS\DIALOGS.H
PROMPTSERVICE.CPP: \
D:\MOZILLA_SRC\MOZILLA\EMBEDDING\TESTS\MFCEMBED\COMPONENTS\STDAFX.H \
D:\MOZILLA_SRC\MOZILLA\EMBEDDING\TESTS\MFCEMBED\COMPONENTS\DIALOGS.H \
D:\MOZILLA_SRC\MOZILLA\EMBEDDING\TESTS\MFCEMBED\COMPONENTS\PROMPTSERVICE.H

View File

@ -0,0 +1,53 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications, Inc. Portions created by Netscape are
# Copyright (C) 2001, Mozilla. All Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
MAKE_OBJ_TYPE=DLL
DLLNAME=mfcEmbedComponents
DLL=.\$(OBJDIR)\$(DLLNAME).dll
RESFILE=Dialogs.res
LCFLAGS=/D "WIN32_LEAN_AND_MEAN" /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON" \
/D "_USRDLL" /D "_WINDLL"
LLFLAGS=-SUBSYSTEM:windows
CPP_OBJS= \
.\$(OBJDIR)\Dialogs.obj \
.\$(OBJDIR)\PromptService.obj \
$(NULL)
LLIBS= \
$(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(NULL)
include <$(DEPTH)\config\rules.mak>
Dialogs.res: Dialogs.rc resource.h
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
$(RM) $(DIST)\bin\$(DLL_NAME).dll
$(RM) $(DIST)\lib\$(DLL_NAME).lib

View File

@ -0,0 +1,26 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Dialogs.rc
//
#define IDD_PROMPT_DIALOG 128
#define IDD_PROMPT_PASSWORD_DIALOG 129
#define IDD_PROMPT_USERPASS_DIALOG 130
#define IDC_PROMPT_ANSWER 1001
#define IDC_PROMPT_TEXT 1002
#define IDC_USERNAME 1003
#define IDC_PASSWORD 1004
#define IDC_CHECK_SAVE_PASSWORD 1005
#define IDC_USERNAME_LABEL 1006
#define IDC_PASSWORD_LABEL 1007
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 143
#define _APS_NEXT_COMMAND_VALUE 32789
#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#ifndef _STDAFX_H
#define _STDAFX_H
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#include <afxpriv.h> // Needed for MFC MBCS/Unicode Conversion Macros
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //_STDAFX_H

View File

@ -0,0 +1,760 @@
Index: BrowserView.cpp
===================================================================
RCS file: /cvsroot/mozilla/embedding/tests/mfcembed/BrowserView.cpp,v
retrieving revision 1.8
diff -u -6 -r1.8 BrowserView.cpp
--- BrowserView.cpp 2001/04/16 20:34:33 1.8
+++ BrowserView.cpp 2001/05/18 23:49:06
@@ -48,12 +48,15 @@
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserView.h"
#include "BrowserImpl.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
+#include "UrlDialog.h"
+#include "ProfileMgr.h"
+#include "ProfilesDlg.h"
// Print Includes
#include "PrintProgressDialog.h"
#ifdef _DEBUG
@@ -67,18 +70,14 @@
BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
//{{AFX_MSG_MAP(CBrowserView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_SIZE()
-
- // UrlBar command handlers
- ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar)
-
- // Menu/Toolbar command handlers
+ ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
ON_COMMAND(ID_VIEW_SOURCE, OnViewSource)
ON_COMMAND(ID_VIEW_INFO, OnViewInfo)
ON_COMMAND(ID_NAV_BACK, OnNavBack)
ON_COMMAND(ID_NAV_FORWARD, OnNavForward)
@@ -88,29 +87,35 @@
ON_COMMAND(ID_EDIT_CUT, OnCut)
ON_COMMAND(ID_EDIT_COPY, OnCopy)
ON_COMMAND(ID_EDIT_PASTE, OnPaste)
ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp)
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone)
+ ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow)
ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow)
- ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
-
- // Menu/Toolbar UI update handlers
+ ON_COMMAND(ID_TESTS_CHANGEURL, OnTestsChangeUrl)
+ ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
+ ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
+ ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack)
ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward)
ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop)
ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut)
ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy)
ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste)
+ ON_COMMAND(ID_INTERFACES_NSIFILE, OnInterfacesNsifile)
+ ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
+ ON_COMMAND(ID_INTERFACES_NSISHISTORY, OnInterfacesNsishistory)
+ ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CBrowserView::CBrowserView()
{
@@ -126,12 +131,14 @@
m_pFindDlg = NULL;
m_pPrintProgressDlg = NULL;
m_bUrlBarClipOp = FALSE;
m_bCurrentlyPrinting = FALSE;
+
+ char *theUrl = "http://www.aol.com/";
}
CBrowserView::~CBrowserView()
{
}
@@ -166,12 +173,14 @@
//
rv = NS_OK;
mWebNav = do_QueryInterface(mWebBrowser, &rv);
if(NS_FAILED(rv))
return rv;
+// mSessionHistory = do_GetInterface(mWebBrowser, &rv); // de: added 5/11
+
// Create the CBrowserImpl object - this is the object
// which implements the interfaces which are required
// by an app embedding mozilla i.e. these are the interfaces
// thru' which the *embedded* browser communicates with the
// *embedding* app
//
@@ -229,14 +238,24 @@
rv = mBaseWindow->Create();
// Register the BrowserImpl object to receive progress messages
// These callbacks will be used to update the status/progress bars
nsWeakPtr weakling(
dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
- (void)mWebBrowser->AddWebBrowserListener(weakling,
- NS_GET_IID(nsIWebProgressListener));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not added.");
+ WriteToOutputFile("Web Progress Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener added.");
+ WriteToOutputFile("Web Progress Listener added.\r\n");
+ }
// Finally, show the web browser window
mBaseWindow->SetVisibility(PR_TRUE);
return S_OK;
}
@@ -252,12 +271,27 @@
if(mpBrowserImpl)
{
mpBrowserImpl->Release();
mpBrowserImpl = nsnull;
}
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))));
+ nsresult rv;
+ rv = mWebBrowser->RemoveWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("Web Progress Listener not removed.");
+ WriteToOutputFile("Web Progress Listener not removed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Web Progress Listener removed.");
+ WriteToOutputFile("Web Progress Listener removed.\r\n");
+ }
+
return NS_OK;
}
BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
@@ -986,7 +1020,592 @@
case WA_INACTIVE:
focus->Deactivate();
break;
default:
break;
}
+}
+
+// de: Start QA test cases here
+// *********************************************************
+// *********************************************************
+
+void CBrowserView::OnTestsChangeUrl()
+{
+ char *theUrl = "http://www.aol.com/";
+ CUrlDialog myDialog;
+ nsresult rv;
+
+// nsCOMPtr<nsIURI> pURI;
+
+ if (!mWebNav)
+ {
+ AfxMessageBox("Web navigation object not found. Change URL test not performed.");
+ WriteToOutputFile("Web navigation object not found. Change URL test not performed.\r\n");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin Change URL test.");
+ WriteToOutputFile("Begin Change URL test.\r\n");
+ strcpy(theUrl, myDialog.m_urlfield);
+ mWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).GetUnicode(),
+ nsIWebNavigation::LOAD_FLAGS_NONE);
+ WriteToOutputFile("\r\nLoadURI() method is called.");
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+/*
+ char *uriSpec;
+ // GetcurrentURI() declared in nsIP3PUI.idl
+ // used with webNav obj in nsP3PObserverHTML.cpp, line 239
+ // this will be used as an indep routine to verify the URI load
+ rv = mWebNav->GetCurrentURI( getter_AddRefs( pURI ) );
+ if(NS_FAILED(rv) || !pURI)
+ AfxMessageBox("Bad result for GetCurrentURI().");
+
+ rv = pURI->GetSpec(&uriSpec);;
+ if (NS_FAILED(rv))
+ AfxMessageBox("Bad result for GetSpec().");
+
+ AfxMessageBox("Start URL validation test().");
+ if (strcmp(uriSpec, theUrl) == 0)
+ {
+ WriteToOutputFile("Url loaded successfully. Test Passed.");
+ }
+ else
+ {
+ WriteToOutputFile("Url didn't load successfully. Test Failed.");
+ }
+*/
+ AfxMessageBox("End Change URL test.");
+ WriteToOutputFile("End Change URL test.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("Change URL test not executed.");
+ WriteToOutputFile("Change URL test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsGlobalHistory()
+{
+ // create instance of myHistory object. Call's XPCOM
+ // service manager to pass the contract ID.
+
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+
+ nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+
+ if (!myHistory)
+ {
+ WriteToOutputFile("Couldn't find history object. No GH tests performed.\r\n");
+ AfxMessageBox("Couldn't find history object. No GH tests performed.");
+ return;
+ }
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ AfxMessageBox("Begin IsVisited() and AddPage() tests.");
+ WriteToOutputFile("Begin IsVisited() and AddPage() tests.\r\n");
+
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ WriteToOutputFile("theUrl = ");
+ WriteToOutputFile(theUrl);
+
+ // see if url is already in the GH file (pre-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL has been visited. Won't execute AddPage().\r\n");
+ AfxMessageBox("URL has been visited. Won't execute AddPage().");
+ }
+ else
+ {
+ WriteToOutputFile("URL hasn't been visited. Will execute AddPage().\r\n");
+ AfxMessageBox("URL hasn't been visited. Will execute AddPage().");
+ // adds a url to the global history file
+ rv = myHistory->AddPage(theUrl);
+
+ // prints addPage() results to output file
+ if (NS_FAILED(rv))
+ {
+ WriteToOutputFile("Invalid results for AddPage(). Url not added. Test failed.\r\n");
+ return;
+ }
+ else
+ {
+ WriteToOutputFile("Valid results for AddPage(). Url added. Test passed.\r\n");
+ }
+
+ // checks if url was visited (post-AddPage() test)
+ myHistory->IsVisited(theUrl, &theRetVal);
+
+ if (theRetVal)
+ {
+ WriteToOutputFile("URL is visited; post-AddPage() test. IsVisited() test passed.\r\n");
+ }
+ else
+ {
+ WriteToOutputFile("URL isn't visited; post-AddPage() test. IsVisited() test failed.\r\n");
+ }
+ }
+ AfxMessageBox("End IsVisited() and AddPage() tests.");
+ WriteToOutputFile("End IsVisited() and AddPage() tests.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("IsVisited() and AddPage() tests not executed.");
+ WriteToOutputFile("IsVisited() and AddPage() tests not executed.\r\n");
+ }
+}
+
+
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateFile()
+{
+ nsresult rv;
+ PRBool exists;
+ nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+
+ AfxMessageBox("Start Create File test.");
+ WriteToOutputFile("\r\nStart Create File test.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\theFile.txt");
+ rv = theTestFile->Exists(&exists);
+
+ WriteToOutputFile("File doesn't exist. We'll create it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (theFile.txt).");
+ WriteToOutputFile("Create() test Failed.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (theFile.txt).");
+ WriteToOutputFile("Create() test Passed.\r\n");
+ }
+}
+
+// *********************************************************
+
+void CBrowserView::OnTestsCreateprofile()
+{
+ CProfilesDlg myDialog;
+ nsresult rv;
+
+ if (myDialog.DoModal() == IDOK)
+ {
+// NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
+ nsCOMPtr<nsIProfile> theProfServ(do_GetService(NS_PROFILE_CONTRACTID));
+ if (!theProfServ)
+ {
+ WriteToOutputFile("Didn't get profile service. No profile tests performed.\r\n");
+ AfxMessageBox("Didn't get profile service. No profile tests performed.");
+ return;
+ }
+
+ if (theProfServ)
+ {
+ AfxMessageBox("Start Profile switch test.");
+ WriteToOutputFile("Start Profile switch test.\r\n");
+
+ AfxMessageBox("Retrieved profile service.");
+ rv = theProfServ->SetCurrentProfile(myDialog.m_SelectedProfile.GetUnicode());
+ if (NS_SUCCEEDED(rv))
+ AfxMessageBox("SetCurrentProfile() passed. Profile switched.");
+ else
+ AfxMessageBox("SetCurrentProfile() didn't pass.Profile not switched.");
+
+ AfxMessageBox("End Profile switch test.");
+ WriteToOutputFile("End Profile switch test.\r\n");
+ }
+ }
+ else
+ {
+ AfxMessageBox("Profile switch test not executed.");
+ WriteToOutputFile("Profile switch test not executed.\r\n");
+ }
+}
+
+// *********************************************************
+// *********************************************************
+// TOOLS to help us
+
+
+void CBrowserView::OnToolsRemoveGHPage()
+{
+ char *theUrl = "http://www.bogussite.com/";
+ CUrlDialog myDialog;
+ PRBool theRetVal = PR_FALSE;
+ nsresult rv;
+ nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
+ if (!myGHistory)
+ {
+ WriteToOutputFile("Could not get the global history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+ nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
+ if(!NS_SUCCEEDED(rv)) {
+ WriteToOutputFile("Could not get the history object.\r\n");
+ AfxMessageBox("Could not get the global history object.");
+ return;
+ }
+// nsCOMPtr<nsIBrowserHistory> myHistory(do_GetInterface(myGHistory));
+
+
+ if (myDialog.DoModal() == IDOK)
+ {
+ WriteToOutputFile("Begin URL removal from the GH file.\r\n");
+ AfxMessageBox("Begin URL removal from the GH file.");
+ strcpy(theUrl, myDialog.m_urlfield);
+
+ myGHistory->IsVisited(theUrl, &theRetVal);
+ if (theRetVal)
+ {
+ rv = myHistory->RemovePage(theUrl);
+ if (NS_SUCCEEDED(rv))
+ {
+ WriteToOutputFile("\r\nThe URL was removed from the GH file.\r\n");
+ AfxMessageBox("The URL was removed from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("\r\nThe URL wasn't removed from the GH file.\r\n");
+ AfxMessageBox("The URL wasn't removed from the GH file.");
+ }
+ }
+ else
+ {
+ WriteToOutputFile("The URL wasn't in the GH file.\r\n");
+ }
+ WriteToOutputFile("End URL removal from the GH file.\r\n");
+ AfxMessageBox("End URL removal from the GH file.");
+ }
+ else
+ {
+ WriteToOutputFile("URL removal from the GH file not executed.\r\n");
+ AfxMessageBox("URL removal from the GH file not executed.");
+ }
+}
+
+// ***********************************************************************
+// ************************** Interface Tests ****************************
+// ***********************************************************************
+
+// nsIFile:
+
+void CBrowserView::OnInterfacesNsifile()
+{
+ nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+ nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+
+ nsresult rv;
+ PRBool exists;
+
+ if (!theTestFile)
+ {
+ WriteToOutputFile("File object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+ if (!theFileOpDir)
+ {
+ WriteToOutputFile("Dir object doesn't exist. No File tests performed.\r\n");
+ AfxMessageBox("File object doesn't exist. No File tests performed.");
+ return;
+ }
+
+ AfxMessageBox("Begin nsIFile tests.");
+ WriteToOutputFile("\r\nBegin testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to initialize file path.");
+ WriteToOutputFile("InitWithPath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We initialized file path.");
+ WriteToOutputFile("InitWithPath() test Passed.");
+ }
+
+ rv = theTestFile->AppendRelativePath("myFile.txt");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to append the file.");
+ WriteToOutputFile("AppendRelativePath() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We appended the file.");
+ WriteToOutputFile("AppendRelativePath() test Passed.");
+ }
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File doesn't exist. We'll try creating it.");
+ WriteToOutputFile("File doesn't exist. We'll try creating it.\r\n");
+ rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("We failed to create the file (myFile.txt).");
+ WriteToOutputFile("Create() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("We created the file (myFile.txt).");
+ WriteToOutputFile("Create() test Passed.");
+ }
+ }
+ else
+ {
+ AfxMessageBox("File already exists (myFile.txt). We won't create it.");
+ WriteToOutputFile("File already exists (myFile.txt). We won't create it.");
+ }
+
+
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File (myFile.txt) doesn't exist.");
+ WriteToOutputFile("Exists() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File (myFile.txt) exists.");
+ WriteToOutputFile("Exists() test Passed.");
+ }
+
+ // FILE COPY test
+
+ AfxMessageBox("Start File Copy test.");
+ WriteToOutputFile("Start File Copy test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\temp\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+ else
+ {
+ AfxMessageBox("The target dir was found.");
+ WriteToOutputFile("The target dir was found.");
+ }
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+ else
+ AfxMessageBox("The path was found.");
+ rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv CopyTo() test failed.");
+ else
+ AfxMessageBox("rv CopyTo() test succeeded.");
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File didn't copy.");
+ WriteToOutputFile("CopyTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File copied.");
+ WriteToOutputFile("CopyTo() test Passed.");
+ }
+
+ // FILE MOVE test
+
+ AfxMessageBox("Start File Move test.");
+ WriteToOutputFile("Start File Move test.");
+
+ rv = theFileOpDir->InitWithPath("c:\\Program Files\\");
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("The target dir wasn't found.");
+ WriteToOutputFile("The target dir wasn't found.");
+ }
+
+ rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("The path wasn't found.");
+
+ rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
+ if (NS_FAILED(rv))
+ AfxMessageBox("rv MoveTo() test failed.");
+ else
+ AfxMessageBox("rv MoveTo() test succeeded.");
+ rv = theTestFile->InitWithPath("c:\\Program Files\\myFile2.txt");
+ rv = theTestFile->Exists(&exists);
+ if (!exists)
+ {
+ AfxMessageBox("File wasn't moved.");
+ WriteToOutputFile("MoveTo() test Failed.");
+ }
+ else
+ {
+ AfxMessageBox("File was moved.");
+ WriteToOutputFile("MoveTo() test Passed.");
+ }
+
+ AfxMessageBox("End nsIFile tests.");
+ WriteToOutputFile("\r\nEnd testing nsIFile InitWithPath(), AppendRelativePath(), \
+ Create(), and Exists() methods.\r\n");
+
+}
+
+// nsISHistory:
+
+void CBrowserView::OnInterfacesNsishistory()
+{
+ nsresult rv;
+ boolean modifyIndex;
+ long numEntries = 0;
+
+ nsCOMPtr<nsISHistory> theSessionHistory(do_CreateInstance(NS_SHISTORY_CONTRACTID));
+ nsCOMPtr<nsIHistoryEntry> theHistoryEntry(do_CreateInstance(NS_HISTORYENTRY_CONTRACTID));
+ nsCOMPtr<nsISHistoryListener> theSHListener(do_CreateInstance(NS_SHISTORYLISTENER_CONTRACTID));
+ // do_QueryInterface
+ // NS_HISTORYENTRY_CONTRACTID
+ // NS_SHISTORYLISTENER_CONTRACTID
+
+
+ if (!theSessionHistory)
+ {
+ AfxMessageBox("theSessionHistory object wasn't created. No tests performed.");
+ return;
+ }
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ return;
+ }
+
+ // addSHistoryListener test
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
+
+ if (NS_FAILED(rv))
+ {
+ AfxMessageBox("NSISHistory Listener not added.");
+ WriteToOutputFile("NSISHistory Listener not added.\r\n");
+ }
+ else
+ {
+ AfxMessageBox("NSISHistory Listener added.");
+ WriteToOutputFile("NSISHistory Listener added.\r\n");
+ }
+
+/*
+ // getEntryAtIndex() test
+ theHistoryEntry = theSessionHistory->GetEntryAtIndex(index, modifyIndex);
+ if (!theHistoryEntry)
+ {
+ AfxMessageBox("We got the History Entry.");
+ }
+ else
+ {
+ AfxMessageBox("We didn't get the History Entry.");
+ }
+
+*/
+
+///*
+ // PurgeHistory() test
+ rv = theSessionHistory->PurgeHistory(numEntries);
+ if (NS_FAILED(rv))
+ AfxMessageBox("Purge History test failed.");
+ else
+ AfxMessageBox("Purge History test succeeded.");
+//*/
+
+ // RemoveSHistoryListener test
+/*
+ nsWeakPtr weakling(
+ dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, mpBrowserImpl))));
+ rv = theSessionHistory->RemoveSHistoryListener(weakling);
+*/
+}
+
+
+// ***************** Local Methods ******************
+
+void CBrowserView::WriteToOutputFile(char *pLine)
+{
+ CStdioFile myFile;
+ CFileException e;
+ CString strFileName = "c:\\temp\\MFCoutfile";
+
+ if(! myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
+ | CStdioFile::modeNoTruncate, &e ) )
+ {
+ CString failCause = "Unable to open file. Reason : ";
+ failCause += e.m_cause;
+ AfxMessageBox(failCause);
+ }
+ else
+ {
+ myFile.SeekToEnd();
+ CString strLine = pLine;
+ strLine += "\r\n";
+
+ myFile.WriteString(strLine);
+
+ myFile.Close();
+ }
+}
+
+
+// ***************** Bug Verifications ******************
+
+void CBrowserView::OnVerifybugs70228()
+{
+/*
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_GetService(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It's NOT a service!");
+ else
+ AfxMessageBox("Object is created. But should it?! It's NOT a service!");
+
+ nsCOMPtr<nsIHelperAppLauncherDialog>
+ myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+ if (!myHALD)
+ AfxMessageBox("Object not created. It should be. It's a component!");
+ else
+ AfxMessageBox("Object is created. It's a component!");
+*/
+/*
+nsCOMPtr<nsIHelperAppLauncher>
+ myHAL(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
+
+ rv = myHALD->show(myHal, mySupp);
+*/
}

View File

@ -0,0 +1,75 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
DIRS=components \
$(NULL)
MAKE_OBJ_TYPE = EXE
MODULE = mfcembed
PROGRAM = .\$(OBJDIR)\$(MODULE).exe
RESFILE = $(MODULE).res
LINCS = -Icomponents \
$(NULL)
OBJS = \
.\$(OBJDIR)\MfcEmbed.obj \
.\$(OBJDIR)\BrowserFrm.obj \
.\$(OBJDIR)\BrowserFrameGlue.obj \
.\$(OBJDIR)\BrowserView.obj \
.\$(OBJDIR)\BrowserImpl.obj \
.\$(OBJDIR)\BrowserImplWebPrgrsLstnr.obj \
.\$(OBJDIR)\BrowserImplCtxMenuLstnr.obj \
.\$(OBJDIR)\Dialogs.obj \
.\$(OBJDIR)\ProfileMgr.obj \
.\$(OBJDIR)\ProfilesDlg.obj \
.\$(OBJDIR)\winEmbedFileLocProvider.obj \
.\$(OBJDIR)\MostRecentUrls.obj \
.\$(OBJDIR)\PrintProgressDialog.obj \
.\$(OBJDIR)\Preferences.obj \
.\$(OBJDIR)\StdAfx.obj \
.\$(OBJDIR)\UrlDialog.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\baseembed_s.lib \
$(DIST)\lib\gkgfxwin.lib \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\mfcEmbedComponents.lib \
$(LIBNSPR) \
$(NULL)
LCFLAGS = /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON"
LLFLAGS = -SUBSYSTEM:windows
include <$(DEPTH)\config\rules.mak>
install:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
$(MAKE_INSTALL) mfcembed.htm $(DIST)\bin
clobber_all::
$(RM) $(DIST)\bin\$(MODULE).exe
$(RM) $(DIST)\bin\mfcembed.htm

Binary file not shown.

View File

@ -0,0 +1,237 @@
# Microsoft Developer Studio Project File - Name="mfcembed" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) External Target" 0x0106
CFG=mfcembed - 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 "mfcembed.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 "mfcembed.mak" CFG="mfcembed - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "mfcembed - Win32 Release" (based on "Win32 (x86) External Target")
!MESSAGE "mfcembed - Win32 Debug" (based on "Win32 (x86) External Target")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "mfcembed - 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 mfcembed.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "mfcembed.exe"
# PROP BASE Bsc_Name "mfcembed.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 "makfile.win""
# PROP Rebuild_Opt "/a"
# PROP Target_File "WIN32_O.OBJ\mfcembed.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "mfcembed - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Cmd_Line "NMAKE /f mfcembed.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "mfcembed.exe"
# PROP BASE Bsc_Name "mfcembed.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Cmd_Line "nmake /f "makefile.win""
# PROP Rebuild_Opt "/a"
# PROP Target_File "WIN32_D.OBJ\mfcembed.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ENDIF
# Begin Target
# Name "mfcembed - Win32 Release"
# Name "mfcembed - Win32 Debug"
!IF "$(CFG)" == "mfcembed - Win32 Release"
!ELSEIF "$(CFG)" == "mfcembed - Win32 Debug"
!ENDIF
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BrowserFrameGlue.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImpl.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImplCtxMenuLstnr.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImplPrompt.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImplWebPrgrsLstnr.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserView.cpp
# End Source File
# Begin Source File
SOURCE=.\Dialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\MfcEmbed.cpp
# End Source File
# Begin Source File
SOURCE=.\MfcEmbed.rc
# End Source File
# Begin Source File
SOURCE=.\MostRecentUrls.cpp
# End Source File
# Begin Source File
SOURCE=.\Preferences.cpp
# End Source File
# Begin Source File
SOURCE=.\PrintProgressDialog.cpp
# End Source File
# Begin Source File
SOURCE=.\ProfileMgr.cpp
# End Source File
# Begin Source File
SOURCE=.\ProfilesDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# Begin Source File
SOURCE=.\UrlDialog.cpp
# End Source File
# Begin Source File
SOURCE=.\winEmbedFileLocProvider.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BrowserFrm.h
# End Source File
# Begin Source File
SOURCE=.\BrowserImpl.h
# End Source File
# Begin Source File
SOURCE=.\BrowserView.h
# End Source File
# Begin Source File
SOURCE=.\Dialogs.h
# End Source File
# Begin Source File
SOURCE=.\IBrowserFrameGlue.h
# End Source File
# Begin Source File
SOURCE=.\MfcEmbed.h
# End Source File
# Begin Source File
SOURCE=.\MostRecentUrls.h
# End Source File
# Begin Source File
SOURCE=.\Preferences.h
# End Source File
# Begin Source File
SOURCE=.\PrintProgressDialog.h
# End Source File
# Begin Source File
SOURCE=.\ProfileMgr.h
# End Source File
# Begin Source File
SOURCE=.\ProfilesDlg.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\UrlDialog.h
# End Source File
# Begin Source File
SOURCE=.\winEmbedFileLocProvider.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=.\res\mfcembed.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group
# End Target
# End Project

View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "mfcembed"=.\mfcembed.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -0,0 +1,58 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=x-user-defined">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]">
<title> MfcEmbed JavaScript Tests </title>
<script language="JavaScript">
// Open a window with default size/style
function ShowWin()
{
window.open("http://www.mozilla.org", "theWin1");
}
// Open a window with specific size
function ShowWinSpecificSize()
{
window.open("http://www.mozilla.org", "theWin2", "width=400, height=600");
}
// Open a window with chrome + specific size
function ShowWinSpecificSizeWithChrome()
{
window.open("http://www.mozilla.org", "theWin3", "menubar=yes, toolbar=yes, status=yes, resizable=yes, width=400, height=600");
}
</script>
</head>
<body>
<h1>
Excercising MfcEmbed's Interfaces</h1>
This test page serves as a testbed to execercise some of the interfaces
MfcEmbed implements - such as nsIWebBrowserChrome, nsIPrompt etc.
<p>You can test these by loading mfcembed in the debugger and setting breakpoints
in the interface methods discussed below. Then clicking on these links
will break in the debugger at the specified locations for you to explore
these interface implementations further.
<p><a href="javascript:ShowWin()">Open a simple JavaScript window with
defaults for size etc:</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window</font></blockquote>
<a href="javascript:ShowWinSpecificSize()">Open a JavaScript window with
only its size specified (Not Resizable)</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window and also invokes <i>nsIWebBrowserChrome::SizeBrowserTo()</i>
to set the window size. This also shows how we handle the chromeMask to
make the window non-resizeable</font></blockquote>
<a href="javascript:ShowWinSpecificSizeWithChrome()">Open a window with
chrome and its size specified (Resizable)</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window and also invokes <i>nsIWebBrowserChrome::SizeBrowserTo()</i>
to set the window size</font>
<br><font size=-1>All of the above tests also invoke<i> nsIWebBrowserChrome::FindNamedBrowserItem()</i>
to find the named target window in the JavaScript code.</font></blockquote>
</body>
</html>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,22 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: mfcembed - Win32 Debug--------------------
</h3>
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
+++ make: export in D:\mozilla_src\mozilla\embedding\tests\mfcembed\components
+++ make: install in D:\mozilla_src\mozilla\embedding\tests\mfcembed\components
<h3>Results</h3>
mfcembed.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -0,0 +1,646 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\mfcembed.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\mfcembed.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_MAINFRAME TOOLBAR DISCARDABLE 20, 18
BEGIN
BUTTON ID_NAV_BACK
BUTTON ID_NAV_FORWARD
SEPARATOR
BUTTON ID_NAV_RELOAD
BUTTON ID_NAV_STOP
SEPARATOR
BUTTON ID_NAV_HOME
SEPARATOR
BUTTON ID_APP_ABOUT
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New Browser Window\tCtrl+N", ID_NEW_BROWSER
MENUITEM SEPARATOR
MENUITEM "&Open File...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Save Page As...\tCtrl+S", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Print...\tCtrl-P", ID_FILE_PRINT
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
MENUITEM SEPARATOR
MENUITEM "Select &All", ID_EDIT_SELECT_ALL
MENUITEM "Select &None", ID_EDIT_SELECT_NONE
MENUITEM SEPARATOR
MENUITEM "&Find in This Page...\tCtrl+F", ID_EDIT_FIND
MENUITEM SEPARATOR
MENUITEM "Profiles...", ID_MANAGE_PROFILES
MENUITEM SEPARATOR
MENUITEM "Preferences...", ID_EDIT_PREFERENCES
END
POPUP "&View"
BEGIN
MENUITEM "Page S&ource", ID_VIEW_SOURCE
MENUITEM "Page &Info", ID_VIEW_INFO
MENUITEM SEPARATOR
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
END
POPUP "&Go"
BEGIN
MENUITEM "&Back", ID_NAV_BACK
MENUITEM "&Forward", ID_NAV_FORWARD
MENUITEM "&Home", ID_NAV_HOME
END
POPUP "&Help"
BEGIN
MENUITEM "&About MfcEmbed...", ID_APP_ABOUT
END
POPUP "Tests"
BEGIN
MENUITEM "Change URL", ID_TESTS_CHANGEURL
MENUITEM "Global History", ID_TESTS_GLOBALHISTORY
MENUITEM "Create File", ID_TESTS_CREATEFILE
MENUITEM "Create/Switch Profile", ID_TESTS_CREATEPROFILE
END
POPUP "Interfaces"
BEGIN
MENUITEM "nsIFile", ID_INTERFACES_NSIFILE
MENUITEM "nsISHistory", ID_INTERFACES_NSISHISTORY
END
POPUP "Tools"
BEGIN
MENUITEM "Remove GH Page", ID_TOOLS_REMOVEGHPAGE
END
POPUP "Verify Bugs"
BEGIN
MENUITEM "70228", ID_VERIFYBUGS_70228
END
END
IDR_CTXMENU_DOCUMENT MENU DISCARDABLE
BEGIN
POPUP "Document Context Menu"
BEGIN
MENUITEM "&Back", ID_NAV_BACK
MENUITEM "&Forward", ID_NAV_FORWARD
MENUITEM "&Reload", ID_NAV_RELOAD
MENUITEM "&Stop", ID_NAV_STOP
MENUITEM SEPARATOR
MENUITEM "&View Page Source", ID_VIEW_SOURCE
MENUITEM "View Page &Info", ID_VIEW_INFO
MENUITEM SEPARATOR
MENUITEM "Save &Page As...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "Select &All", ID_EDIT_SELECT_ALL
MENUITEM "Select &None", ID_EDIT_SELECT_NONE
MENUITEM "&Copy", ID_EDIT_COPY
END
END
IDR_CTXMENU_IMAGE MENU DISCARDABLE
BEGIN
POPUP "Image Context Menu"
BEGIN
MENUITEM "&Back", ID_NAV_BACK
MENUITEM "&Forward", ID_NAV_FORWARD
MENUITEM "&Reload", ID_NAV_RELOAD
MENUITEM "&Stop", ID_NAV_STOP
MENUITEM SEPARATOR
MENUITEM "&View Page Source", ID_VIEW_SOURCE
MENUITEM "View &Image", ID_VIEW_IMAGE
MENUITEM SEPARATOR
MENUITEM "Save Image As...", ID_SAVE_IMAGE_AS
MENUITEM "Save &Page As...", ID_FILE_SAVE_AS
END
END
IDR_CTXMENU_LINK MENU DISCARDABLE
BEGIN
POPUP "Link Context Menu"
BEGIN
MENUITEM "Open Link In New Window", ID_OPEN_LINK_IN_NEW_WINDOW
MENUITEM SEPARATOR
MENUITEM "&Back", ID_NAV_BACK
MENUITEM "&Forward", ID_NAV_FORWARD
MENUITEM "&Reload", ID_NAV_RELOAD
MENUITEM "&Stop", ID_NAV_STOP
MENUITEM SEPARATOR
MENUITEM "&View Page Source", ID_VIEW_SOURCE
MENUITEM SEPARATOR
MENUITEM "Save &Page As...", ID_FILE_SAVE_AS
MENUITEM "Save &Link As...", ID_SAVE_LINK_AS
MENUITEM "&Copy Link Location", ID_COPY_LINK_LOCATION
END
END
IDR_CTXMENU_TEXT MENU DISCARDABLE
BEGIN
POPUP "Selection Context Menu"
BEGIN
MENUITEM "Cu&t", ID_EDIT_CUT
MENUITEM "&Copy", ID_EDIT_COPY
MENUITEM "&Paste", ID_EDIT_PASTE
MENUITEM "Select &All", ID_EDIT_SELECT_ALL
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
"F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
"N", ID_NEW_BROWSER, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE_AS, VIRTKEY, CONTROL, NOINVERT
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
VK_ESCAPE, ID_NAV_STOP, VIRTKEY
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About MfcEmbed"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "Mozilla MfcEmbed Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2001",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
END
IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Prompt Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,130,69,50,14
PUSHBUTTON "Cancel",IDCANCEL,189,69,50,14
LTEXT "Please enter something....",IDC_PROMPT_TEXT,10,7,229,29
EDITTEXT IDC_PROMPT_ANSWER,7,39,232,13,ES_AUTOHSCROLL
CONTROL "Save Answer",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
END
IDD_PROMPT_PASSWORD_DIALOG DIALOG DISCARDABLE 0, 0, 248, 93
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Password Entry Dialog"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Please enter your password:",IDC_PROMPT_TEXT,5,7,232,20
DEFPUSHBUTTON "OK",IDOK,129,75,50,14
PUSHBUTTON "Cancel",IDCANCEL,188,75,50,14
EDITTEXT IDC_PASSWORD,5,37,233,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Save Password",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
END
IDD_PROMPT_USERPASS_DIALOG DIALOG DISCARDABLE 0, 0, 214, 123
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Username and Password Required"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "This operation requires authentication. Please enter your user name and password:",
IDC_PROMPT_TEXT,6,9,171,25
LTEXT "User Name:",IDC_USERNAME_LABEL,6,39,39,9
EDITTEXT IDC_USERNAME,49,39,153,12,ES_AUTOHSCROLL
LTEXT "Password:",IDC_PASSWORD_LABEL,6,58,36,8
EDITTEXT IDC_PASSWORD,49,56,153,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Save User Name and Password",IDC_CHECK_SAVE_PASSWORD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10
DEFPUSHBUTTON "OK",IDOK,40,101,50,14
PUSHBUTTON "Cancel",IDCANCEL,95,101,50,14
END
IDD_PROFILES DIALOG DISCARDABLE 0, 0, 196, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Manage Profiles"
FONT 8, "MS Sans Serif"
BEGIN
LISTBOX IDC_LIST1,79,17,110,44,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
PUSHBUTTON "Rename...",IDC_PROF_RENAME,7,7,50,14
PUSHBUTTON "Delete",IDC_PROF_DELETE,7,27,50,14
PUSHBUTTON "New...",IDC_PROF_NEW,7,48,50,14
DEFPUSHBUTTON "OK",IDOK,139,74,50,14
PUSHBUTTON "Cancel",IDCANCEL,80,74,50,14
CONTROL "Ask At Startup",IDC_CHECK_ASK_AT_START,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,75,61,10
END
IDD_PROFILE_NEW DIALOG DISCARDABLE 0, 0, 177, 79
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "New Profile"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_NEW_PROF_NAME,39,16,122,14,ES_AUTOHSCROLL
COMBOBOX IDC_LOCALE_COMBO,39,35,67,30,CBS_DROPDOWNLIST | CBS_SORT |
WS_DISABLED | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,120,58,50,14
PUSHBUTTON "Cancel",IDCANCEL,63,58,50,14
RTEXT "Name:",IDC_STATIC,13,18,22,8
RTEXT "Locale:",IDC_STATIC,11,37,24,8
END
IDD_PROFILE_RENAME DIALOG DISCARDABLE 0, 0, 177, 76
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rename Profile"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_NEW_NAME,50,16,113,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,120,55,50,14
PUSHBUTTON "Cancel",IDCANCEL,63,55,50,14
RTEXT "New Name:",IDC_STATIC,7,18,38,8
END
IDD_FINDDLG DIALOG DISCARDABLE 30, 73, 236, 62
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Find"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fi&nd what:",-1,4,8,42,8
EDITTEXT IDC_FIND_EDIT,47,7,128,12,ES_AUTOHSCROLL | WS_GROUP
CONTROL "Match &whole word only",IDC_MATCH_WHOLE_WORD,"Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,4,26,90,12
CONTROL "Wra&p around",IDC_WRAP_AROUND,"Button",BS_AUTOCHECKBOX |
WS_GROUP | WS_TABSTOP,101,26,65,12
CONTROL "Match &case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,4,42,64,12
CONTROL "Search &backwards",IDC_SEARCH_BACKWARDS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,101,42,67,12
DEFPUSHBUTTON "&Find Next",IDOK,182,5,50,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,182,23,50,14
END
IDD_PRINT_PROGRESS_DIALOG DIALOG DISCARDABLE 0, 0, 294, 55
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION
CAPTION "Printing..."
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Cancel",IDCANCEL,122,34,50,14
LTEXT "Document:",IDC_PPD_DOC_TITLE_STATIC,7,7,36,8
LTEXT "",IDC_PPD_DOC_TXT,43,7,244,8
END
IDD_PREFS_START_PAGE DIALOG DISCARDABLE 0, 0, 284, 150
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Startup"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "MfcEmbed starts with",IDC_STATIC,6,10,271,49
CONTROL "Bla&nk Page",IDC_RADIO_BLANK_PAGE,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,16,24,53,10
CONTROL "&Home Page",IDC_RADIO_HOME_PAGE,"Button",
BS_AUTORADIOBUTTON,16,40,53,10
GROUPBOX "Home Page",IDC_STATIC,6,67,271,51
LTEXT "Clicking the Home button will take you to this page",
IDC_STATIC,17,80,234,8
LTEXT "Loc&ation:",IDC_STATIC,17,98,31,8
EDITTEXT IDC_EDIT_HOMEPAGE,53,95,211,14,ES_AUTOHSCROLL
END
IDD_URLDIALOG DIALOG DISCARDABLE 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "URL Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Enter URL here:",IDC_ENTER_URLTEXT,65,48,69,8
EDITTEXT IDC_URLFIELD,30,66,132,14,ES_AUTOHSCROLL
END
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "MfcEmbed MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "MfcEmbed\0"
VALUE "LegalCopyright", "Copyright (C) 2001\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "MfcEmbed.EXE\0"
VALUE "ProductName", "MfcEmbed Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_PROFILES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 189
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_PROFILE_NEW, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 170
TOPMARGIN, 7
BOTTOMMARGIN, 72
END
IDD_PROFILE_RENAME, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 170
TOPMARGIN, 7
BOTTOMMARGIN, 69
END
IDD_PRINT_PROGRESS_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 287
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_URLDIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_DIALOG1, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "mfcembed"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "mfcembed"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
ID_EDIT_FIND "Find the specified text\nFind"
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
ID_EDIT_UNDO "Undo the last action\nUndo"
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_SELECT_NONE "Select nothing in the document\nSelect None"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\mfcembed.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,13 @@
//
// MFCEMBED.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@ -0,0 +1,88 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by mfcembed.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_MOZEMBTYPE 129
#define IDR_CTXMENU_DOCUMENT 130
#define IDR_CTXMENU_LINK 131
#define IDR_CTXMENU_TEXT 132
#define IDR_CTXMENU_IMAGE 133
#define IDD_PROMPT_DIALOG 134
#define IDD_PROMPT_PASSWORD_DIALOG 135
#define IDD_PROMPT_USERPASS_DIALOG 136
#define IDD_PROFILES 137
#define IDD_PROFILE_NEW 138
#define IDD_PROFILE_RENAME 139
#define IDD_FINDDLG 140
#define IDD_PRINT_PROGRESS_DIALOG 141
#define IDD_PREFS_START_PAGE 142
#define IDD_URLDIALOG 144
#define IDD_DIALOG1 145
#define ID_URL_BAR 1001
#define ID_PROG_BAR 1002
#define IDC_PROMPT_ANSWER 1003
#define IDC_PROMPT_QUESTION 1004
#define IDC_PROMPT_TEXT 1005
#define IDC_USERNAME 1006
#define IDC_PASSWORD 1007
#define IDC_CHECK_SAVE_PASSWORD 1008
#define IDC_USERNAME_LABEL 1009
#define IDC_PASSWORD_LABEL 1010
#define IDC_LIST1 1011
#define IDC_PROF_RENAME 1012
#define IDC_PROF_DELETE 1013
#define IDC_PROF_NEW 1014
#define IDC_CHECK_ASK_AT_START 1015
#define IDC_NEW_PROF_NAME 1016
#define IDC_LOCALE_COMBO 1017
#define IDC_NEW_NAME 1018
#define IDC_PPD_DOC_TXT 1020
#define IDC_PPD_DOC_TITLE_STATIC 1021
#define IDC_ENTER_URLTEXT 1022
#define IDC_URLFIELD 1023
#define IDC_MATCH_WHOLE_WORD 1040
#define IDC_MATCH_CASE 1041
#define IDC_WRAP_AROUND 1042
#define IDC_SEARCH_BACKWARDS 1043
#define IDC_FIND_EDIT 1152
#define IDC_RADIO_BLANK_PAGE 1153
#define IDC_RADIO_HOME_PAGE 1154
#define IDC_EDIT_HOMEPAGE 1155
#define ID_NAV_BACK 32773
#define ID_NAV_FORWARD 32774
#define ID_NAV_HOME 32775
#define ID_NAV_STOP 32776
#define ID_NAV_RELOAD 32777
#define ID_EDIT_SELECT_NONE 32778
#define ID_NEW_BROWSER 32779
#define ID_VIEW_SOURCE 32780
#define ID_VIEW_INFO 32781
#define ID_VIEW_IMAGE 32782
#define ID_OPEN_LINK_IN_NEW_WINDOW 32783
#define ID_SAVE_LINK_AS 32784
#define ID_SAVE_IMAGE_AS 32785
#define ID_COPY_LINK_LOCATION 32786
#define ID_MANAGE_PROFILES 32787
#define ID_EDIT_PREFERENCES 32788
#define ID_TESTS_CHANGEURL 32789
#define ID_TESTS_GLOBALHISTORY 32790
#define ID_TOOLS_REMOVEGHPAGE 32791
#define ID_TESTS_CREATEFILE 32792
#define ID_INTERFACES_NSIFILE 32793
#define ID_TESTS_CREATEPROFILE 32794
#define ID_INTERFACES_NSISHISTORY 32795
#define ID_VERIFYBUGS_70228 32796
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 146
#define _APS_NEXT_COMMAND_VALUE 32797
#define _APS_NEXT_CONTROL_VALUE 1024
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -0,0 +1,265 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <conrad@ingress.com>
*/
#include "winEmbedFileLocProvider.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "nsILocalFile.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include <windows.h>
#include <shlobj.h>
// WARNING: These hard coded names need to go away. They need to
// come from localizable resources
#define APP_REGISTRY_NAME "registry.dat"
#define PROFILE_ROOT_DIR_NAME "Profiles"
#define DEFAULTS_DIR_NAME "defaults"
#define DEFAULTS_PREF_DIR_NAME "pref"
#define DEFAULTS_PROFILE_DIR_NAME "profile"
#define RES_DIR_NAME "res"
#define CHROME_DIR_NAME "chrome"
#define PLUGINS_DIR_NAME "plugins"
#define SEARCH_DIR_NAME "searchplugins"
//*****************************************************************************
// winEmbedFileLocProvider::Constructor/Destructor
//*****************************************************************************
winEmbedFileLocProvider::winEmbedFileLocProvider(const char* productDirName)
{
NS_INIT_ISUPPORTS();
strncpy(mProductDirName, productDirName, sizeof(mProductDirName) - 1);
mProductDirName[sizeof(mProductDirName) - 1] = '\0';
}
winEmbedFileLocProvider::~winEmbedFileLocProvider()
{
}
//*****************************************************************************
// winEmbedFileLocProvider::nsISupports
//*****************************************************************************
NS_IMPL_ISUPPORTS1(winEmbedFileLocProvider, nsIDirectoryServiceProvider)
//*****************************************************************************
// winEmbedFileLocProvider::nsIDirectoryServiceProvider
//*****************************************************************************
NS_IMETHODIMP
winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
nsCOMPtr<nsILocalFile> localFile;
nsresult rv = NS_ERROR_FAILURE;
*_retval = nsnull;
*persistant = PR_TRUE;
if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
{
rv = GetProductDirectory(getter_AddRefs(localFile));
}
else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0)
{
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(APP_REGISTRY_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PREF_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 ||
nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
{
rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
}
else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(RES_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(CHROME_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
}
if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
return rv;
}
NS_METHOD winEmbedFileLocProvider::CloneMozBinDirectory(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
if (!mMozBinDirectory)
{
// Get the mozilla bin directory
// 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
// This will be set if a directory was passed to NS_InitXPCOM
// 2. If that doesn't work, set it to be the current process directory
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
if (NS_FAILED(rv)) {
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
if (NS_FAILED(rv))
return rv;
}
}
nsCOMPtr<nsIFile> aFile;
rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface (aFile);
if (!lfile)
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aLocalFile = lfile);
return NS_OK;
}
//----------------------------------------------------------------------------------------
// GetProductDirectory - Gets the directory which contains the application data folder
//
// WIN : <Application Data folder on user's machine>\Mozilla
//----------------------------------------------------------------------------------------
NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
PRBool exists;
nsCOMPtr<nsILocalFile> localDir;
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_SUCCEEDED(rv))
rv = localDir->Exists(&exists);
if (NS_FAILED(rv) || !exists)
{
// On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
localDir = nsnull;
rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
}
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath(mProductDirName);
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
if (NS_FAILED(rv)) return rv;
*aLocalFile = localDir;
NS_ADDREF(*aLocalFile);
return rv;
}
//----------------------------------------------------------------------------------------
// GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
//
// WIN : <Application Data folder on user's machine>\Mozilla\Users50
//----------------------------------------------------------------------------------------
NS_METHOD winEmbedFileLocProvider::GetDefaultUserProfileRoot(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
PRBool exists;
nsCOMPtr<nsILocalFile> localDir;
rv = GetProductDirectory(getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
// These 3 platforms share this part of the path - do them as one
rv = localDir->AppendRelativePath(PROFILE_ROOT_DIR_NAME);
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
if (NS_FAILED(rv)) return rv;
*aLocalFile = localDir;
NS_ADDREF(*aLocalFile);
return rv;
}

View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <conrad@ingress.com>
*/
#include "nsIDirectoryService.h"
#include "nsILocalFile.h"
class nsIFile;
//*****************************************************************************
// class winEmbedFileLocProvider
//*****************************************************************************
class winEmbedFileLocProvider : public nsIDirectoryServiceProvider
{
public:
// productDirName is the name (not path) of the dir
// in which the application registry and profiles live.
winEmbedFileLocProvider(const char* productDirName);
NS_DECL_ISUPPORTS
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
protected:
virtual ~winEmbedFileLocProvider();
NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile);
NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile);
NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile);
char mProductDirName[256];
nsCOMPtr<nsILocalFile> mMozBinDirectory;
};