1 /* ***** BEGIN LICENSE BLOCK
*****
2 * Version
: MPL
1.1/GPL
2.0/LGPL
2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the
"License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http
://www.mozilla.org
/MPL
/
9 * Software distributed under the License is distributed on an
"AS IS" basis
,
10 * WITHOUT WARRANTY
OF ANY KIND
, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation
18 * Portions created by the Initial Developer are
Copyright (C
) 1998
19 * the Initial Developer. All Rights Reserved.
22 * Chak Nanga
<chak@netscape.com
>
24 * Alternatively
, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version
2 or
later (the
"GPL"), or
26 * the GNU Lesser General Public License Version
2.1 or
later (the
"LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL
, and not to allow others to
30 * use your version of this file under the terms of the MPL
, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above
, a recipient may use your version of this file under
34 * the terms of any one of the MPL
, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK
***** */
37 // -*- Mode
: C
++; tab
-width
: 4; indent
-tabs
-mode
: nil
; c
-basic
-offset
: 4 -*-
40 // When the CBrowserFrm creates this View
:
41 // - CreateBrowser() is called in
OnCreate() to create the
42 // mozilla embeddable browser
44 // OnSize() method handles the window resizes and calls the approriate
45 // interface method to resize the embedded browser properly
47 // Command handlers to handle browser navigation
- OnNavBack(),
50 // DestroyBrowser() called for cleaning up during object destruction
52 // Some important coding notes....
54 // 1. Make sure we do not have the CS_HREDRAW|CS_VREDRAW in the call
55 // to
AfxRegisterWndClass() inside of
PreCreateWindow() below
56 // If these flags are present then you
'll see screen flicker when
57 // you resize the frame window
59 // Next suggested file to look at : BrowserImpl.cpp
64 #include "BrowserView.h"
65 #include "BrowserImpl.h"
66 #include "BrowserFrm.h"
68 #include "UrlDialog.h"
69 #include "ProfileMgr.h"
70 #include "ProfilesDlg.h"
73 #include "PrintProgressDialog.h"
79 static char THIS_FILE[] = __FILE__;
82 // Register message for FindDialog communication
83 static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING);
85 BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
86 //{{AFX_MSG_MAP(CBrowserView)
90 ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar)
91 ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar)
92 ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
93 ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
94 ON_COMMAND(ID_VIEW_SOURCE, OnViewSource)
95 ON_COMMAND(ID_VIEW_INFO, OnViewInfo)
96 ON_COMMAND(ID_NAV_BACK, OnNavBack)
97 ON_COMMAND(ID_NAV_FORWARD, OnNavForward)
98 ON_COMMAND(ID_NAV_HOME, OnNavHome)
99 ON_COMMAND(ID_NAV_RELOAD, OnNavReload)
100 ON_COMMAND(ID_NAV_STOP, OnNavStop)
101 ON_COMMAND(ID_EDIT_CUT, OnCut)
102 ON_COMMAND(ID_EDIT_COPY, OnCopy)
103 ON_COMMAND(ID_EDIT_PASTE, OnPaste)
104 ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp)
105 ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
106 ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone)
107 ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
108 ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow)
109 ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow)
110 ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
111 ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
112 ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
113 ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
114 ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
115 ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
116 ON_COMMAND(ID_TESTS_CHANGEURL, OnTestsChangeUrl)
117 ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
118 ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
119 ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
120 ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack)
121 ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward)
122 ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop)
123 ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut)
124 ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy)
125 ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste)
126 ON_COMMAND(ID_INTERFACES_NSIFILE, OnInterfacesNsifile)
127 ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
128 ON_COMMAND(ID_INTERFACES_NSISHISTORY, OnInterfacesNsishistory)
129 ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
134 CBrowserView::CBrowserView()
136 mWebBrowser = nsnull;
137 mBaseWindow = nsnull;
140 mpBrowserImpl = nsnull;
141 mpBrowserFrame = nsnull;
142 mpBrowserFrameGlue = nsnull;
144 mbDocumentLoading = PR_FALSE;
147 m_pPrintProgressDlg = NULL;
149 m_bUrlBarClipOp = FALSE;
150 m_bCurrentlyPrinting = FALSE;
152 char *theUrl = "http://www.aol.com/";
155 CBrowserView::~CBrowserView()
159 // This is a good place to create the embeddable browser
162 int CBrowserView::OnCreate(LPCREATESTRUCT lpCreateStruct)
169 void CBrowserView::OnDestroy()
174 // Create an instance of the Mozilla embeddable browser
176 HRESULT CBrowserView::CreateBrowser()
180 mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
184 // Save off the nsIWebNavigation interface pointer
185 // in the mWebNav member variable which we'll use
186 // later for web page navigation
189 mWebNav
= do_QueryInterface(mWebBrowser
, &rv
);
193 // mSessionHistory
= do_GetInterface(mWebBrowser
, &rv
); // de
: added
5/11
195 // Create the CBrowserImpl object
- this is the object
196 // which implements the interfaces which are required
197 // by an app embedding mozilla i.e. these are the interfaces
198 // thru
' which the *embedded* browser communicates with the
201 // The CBrowserImpl object will be passed in to the
202 // SetContainerWindow() call below
204 // Also note that we're passing the BrowserFrameGlue pointer
205 // and also the mWebBrowser interface pointer via CBrowserImpl
::Init()
206 // of CBrowserImpl object.
207 // These pointers will be saved by the CBrowserImpl object.
208 // The CBrowserImpl object uses the BrowserFrameGlue pointer to
209 // call the methods on that interface to update the status
/progress bars
211 mpBrowserImpl
= new
CBrowserImpl();
212 if(mpBrowserImpl
== nsnull
)
213 return NS_ERROR_OUT_OF_MEMORY
;
215 // Pass along the mpBrowserFrameGlue pointer to the BrowserImpl object
216 // This is the interface thru
' which the XP BrowserImpl code communicates
217 // with the platform specific code to update status bars etc.
218 mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser);
219 mpBrowserImpl->AddRef();
221 mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(mpBrowserImpl));
224 nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser, &rv);
227 dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
229 // Create the real webbrowser window
231 // Note that we're passing the m_hWnd in the call below to
InitWindow()
232 // (CBrowserView inherits the m_hWnd from CWnd
)
233 // This m_hWnd will be used as the parent window by the embeddable browser
236 mBaseWindow
= do_QueryInterface(mWebBrowser
, &rv
);
240 // Get the view
's ClientRect which to be passed in to the InitWindow()
243 GetClientRect(&rcLocation);
244 if(IsRectEmpty(&rcLocation))
250 rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd), nsnull,
251 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top);
252 rv = mBaseWindow->Create();
254 // Register the BrowserImpl object to receive progress messages
255 // These callbacks will be used to update the status/progress bars
257 do_GetWeakReference(static_cast<nsIWebProgressListener*>(mpBrowserImpl)));
258 rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
262 AfxMessageBox("Web Progress Listener not added.");
263 WriteToOutputFile("Web Progress Listener not added.\r\n");
267 AfxMessageBox("Web Progress Listener added.");
268 WriteToOutputFile("Web Progress Listener added.\r\n");
271 // Finally, show the web browser window
272 mBaseWindow->SetVisibility(PR_TRUE);
277 HRESULT CBrowserView::DestroyBrowser()
281 mBaseWindow->Destroy();
282 mBaseWindow = nsnull;
287 mpBrowserImpl->Release();
288 mpBrowserImpl = nsnull;
292 do_GetWeakReference(static_cast<nsIWebProgressListener*>(mpBrowserImpl)));
294 rv = mWebBrowser->RemoveWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
297 AfxMessageBox("Web Progress Listener not removed.");
298 WriteToOutputFile("Web Progress Listener not removed.\r\n");
302 AfxMessageBox("Web Progress Listener removed.");
303 WriteToOutputFile("Web Progress Listener removed.\r\n");
309 BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs)
311 if (!CWnd::PreCreateWindow(cs))
314 cs.dwExStyle |= WS_EX_CLIENTEDGE;
315 cs.style &= ~WS_BORDER;
316 cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS,
317 ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
322 // Adjust the size of the embedded browser
323 // in response to any container size changes
325 void CBrowserView::OnSize( UINT nType, int cx, int cy)
327 mBaseWindow->SetPositionAndSize(0, 0, cx, cy, PR_TRUE);
330 // Called by this object's creator i.e. the CBrowserFrame object
331 // to pass it
's pointer to us
333 void CBrowserView::SetBrowserFrame(CBrowserFrame* pBrowserFrame)
335 mpBrowserFrame = pBrowserFrame;
338 void CBrowserView::SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue)
340 mpBrowserFrameGlue = pBrowserFrameGlue;
343 // A new URL was entered in the URL bar
344 // Get the URL's text from the Urlbar
's (ComboBox's
) EditControl
345 // and navigate to that URL
347 void CBrowserView
::OnNewUrlEnteredInUrlBar()
349 // Get the currently entered URL
351 mpBrowserFrame
->m_wndUrlBar.
GetEnteredURL(strUrl
);
353 if(IsViewSourceUrl(strUrl
))
354 OpenViewSourceWindow(strUrl.
GetBuffer(0));
356 // Navigate to that URL
357 OpenURL(strUrl.
GetBuffer(0));
359 // Add what was just entered into the UrlBar
360 mpBrowserFrame
->m_wndUrlBar.
AddURLToList(strUrl
);
363 // A URL has been selected from the UrlBar
's dropdown list
365 void CBrowserView::OnUrlSelectedInUrlBar()
369 mpBrowserFrame->m_wndUrlBar.GetSelectedURL(strUrl);
371 if(IsViewSourceUrl(strUrl))
372 OpenViewSourceWindow(strUrl.GetBuffer(0));
374 OpenURL(strUrl.GetBuffer(0));
377 BOOL CBrowserView::IsViewSourceUrl(CString& strUrl)
379 return (strUrl.Find("view-source:", 0) != -1) ? TRUE : FALSE;
382 BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl)
384 // Create a new browser frame in which we'll show the document source
385 // Note that we
're getting rid of the toolbars etc. by specifying
386 // the appropriate chromeFlags
387 PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS |
388 nsIWebBrowserChrome::CHROME_TITLEBAR |
389 nsIWebBrowserChrome::CHROME_WINDOW_RESIZE;
390 CBrowserFrame* pFrm = CreateNewBrowserFrame(chromeFlags);
394 // Finally, load this URI into the newly created frame
395 pFrm->m_wndBrowserView.OpenURL(pUrl);
397 pFrm->BringWindowToTop();
402 void CBrowserView::OnViewSource()
407 // Get the URI object whose source we want to view.
409 nsCOMPtr<nsIURI> currentURI;
410 rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI));
411 if(NS_FAILED(rv) || !currentURI)
414 // Get the uri string associated with the nsIURI object
415 nsXPIDLCString uriString;
416 rv = currentURI->GetSpec(getter_Copies(uriString));
420 // Build the view-source: url
421 nsCAutoString viewSrcUrl;
422 viewSrcUrl.Append("view-source:");
423 viewSrcUrl.Append(uriString);
425 OpenViewSourceWindow(viewSrcUrl.get());
428 void CBrowserView::OnViewInfo()
430 AfxMessageBox("To Be Done...");
433 void CBrowserView::OnNavBack()
439 void CBrowserView::OnUpdateNavBack(CCmdUI* pCmdUI)
441 PRBool canGoBack = PR_FALSE;
444 mWebNav->GetCanGoBack(&canGoBack);
446 pCmdUI->Enable(canGoBack);
449 void CBrowserView::OnNavForward()
452 mWebNav->GoForward();
455 void CBrowserView::OnUpdateNavForward(CCmdUI* pCmdUI)
457 PRBool canGoFwd = PR_FALSE;
460 mWebNav->GetCanGoForward(&canGoFwd);
462 pCmdUI->Enable(canGoFwd);
465 void CBrowserView::OnNavHome()
467 // Get the currently configured HomePage URL
469 CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
471 pApp->GetHomePage(strHomeURL);
473 if(strHomeURL.GetLength() > 0)
477 void CBrowserView::OnNavReload()
480 mWebNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
483 void CBrowserView::OnNavStop()
489 void CBrowserView::OnUpdateNavStop(CCmdUI* pCmdUI)
491 pCmdUI->Enable(mbDocumentLoading);
494 void CBrowserView::OnCut()
498 // We need to operate on the URLBar selection
499 mpBrowserFrame->CutUrlBarSelToClipboard();
500 m_bUrlBarClipOp = FALSE;
504 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
507 clipCmds->CutSelection();
511 void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI)
513 PRBool canCutSelection = PR_FALSE;
515 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
517 clipCmds->CanCutSelection(&canCutSelection);
521 // Check to see if the Cut cmd is to cut the URL
522 // selection in the UrlBar
523 if(mpBrowserFrame->CanCutUrlBarSelection())
525 canCutSelection = TRUE;
526 m_bUrlBarClipOp = TRUE;
530 pCmdUI->Enable(canCutSelection);
533 void CBrowserView::OnCopy()
537 // We need to operate on the URLBar selection
538 mpBrowserFrame->CopyUrlBarSelToClipboard();
539 m_bUrlBarClipOp = FALSE;
543 // We need to operate on the web page content
544 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
547 clipCmds->CopySelection();
551 void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI)
553 PRBool canCopySelection = PR_FALSE;
555 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
557 clipCmds->CanCopySelection(&canCopySelection);
559 if(!canCopySelection)
561 // Check to see if the Copy cmd is to copy the URL
562 // selection in the UrlBar
563 if(mpBrowserFrame->CanCopyUrlBarSelection())
565 canCopySelection = TRUE;
566 m_bUrlBarClipOp = TRUE;
570 pCmdUI->Enable(canCopySelection);
573 void CBrowserView::OnPaste()
577 mpBrowserFrame->PasteFromClipboardToUrlBar();
578 m_bUrlBarClipOp = FALSE;
582 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
589 void CBrowserView::OnUndoUrlBarEditOp()
591 if(mpBrowserFrame->CanUndoUrlBarEditOp())
592 mpBrowserFrame->UndoUrlBarEditOp();
595 void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI)
597 PRBool canPaste = PR_FALSE;
599 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
601 clipCmds->CanPaste(&canPaste);
605 if(mpBrowserFrame->CanPasteToUrlBar())
608 m_bUrlBarClipOp = TRUE;
612 pCmdUI->Enable(canPaste);
615 void CBrowserView::OnSelectAll()
617 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
620 clipCmds->SelectAll();
623 void CBrowserView::OnSelectNone()
625 nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
628 clipCmds->SelectNone();
631 void CBrowserView::OnFileOpen()
634 "HTML Files Only (*.htm;*.html)|*.htm;*.html|"
635 "All Files (*.*)|*.*||";
637 CFileDialog cf(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
639 if(cf.DoModal() == IDOK)
641 CString strFullPath = cf.GetPathName(); // Will be like: c:\tmp\junk.htm
642 OpenURL(strFullPath);
646 void CBrowserView::GetBrowserWindowTitle(nsCString& title)
648 nsXPIDLString idlStrTitle;
650 mBaseWindow->GetTitle(getter_Copies(idlStrTitle));
652 title.AssignWithConversion(idlStrTitle);
654 // Sanitize the title of all illegal characters
655 title.CompressWhitespace(); // Remove whitespace from the ends
656 title.StripChars("\\*|:\"><?"); // Strip illegal characters
657 title.ReplaceChar('.
', L'_
'); // Dots become underscores
658 title.ReplaceChar('/', L'-'); // Forward slashes become hyphens
661 void CBrowserView::OnFileSaveAs()
665 GetBrowserWindowTitle(fileName); // Suggest the window title as the filename
668 "Web Page, HTML Only (*.htm;*.html)|*.htm;*.html|"
669 "Web Page, Complete (*.htm;*.html)|*.htm;*.html|"
670 "Text File (*.txt)|*.txt||";
672 CFileDialog cf(FALSE, "htm", (const char *)fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
675 if(cf.DoModal() == IDOK)
677 CString strFullPath = cf.GetPathName(); // Will be like: c:\tmp\junk.htm
678 char *pStrFullPath = strFullPath.GetBuffer(0); // Get char * for later use
681 char *pStrDataPath = NULL;
682 if(cf.m_ofn.nFilterIndex == 2)
684 // cf.m_ofn.nFilterIndex == 2 indicates
685 // user want to save the complete document including
686 // all frames, images, scripts, stylesheets etc.
688 int idxPeriod = strFullPath.ReverseFind('.
');
689 strDataPath = strFullPath.Mid(0, idxPeriod);
690 strDataPath += "_files";
692 // At this stage strDataPath will be of the form
693 // c:\tmp\junk_files - assuming we're saving to a file
695 // Any images etc in the doc will be saved to a dir
696 // with the name c
:\tmp\junk_files
698 pStrDataPath
= strDataPath.
GetBuffer(0); //Get char
* for later use
702 nsCOMPtr
<nsIWebBrowserPersist
> persist(do_QueryInterface(mWebBrowser
));
704 persist
->SaveDocument(nsnull
, pStrFullPath
, pStrDataPath
);
708 void CBrowserView
::OpenURL(const char
* pUrl
)
711 mWebNav
->LoadURI(NS_ConvertASCIItoUTF16(pUrl
).
get(), nsIWebNavigation
::LOAD_FLAGS_NONE
);
714 void CBrowserView
::OpenURL(const PRUnichar
* pUrl
)
717 mWebNav
->LoadURI(pUrl
, nsIWebNavigation
::LOAD_FLAGS_NONE
);
720 CBrowserFrame
* CBrowserView
::CreateNewBrowserFrame(PRUint32 chromeMask
,
721 PRInt32 x
, PRInt32 y
,
722 PRInt32 cx
, PRInt32 cy
,
725 CMfcEmbedApp
*pApp
= (CMfcEmbedApp *)
AfxGetApp();
729 return pApp
->CreateNewBrowserFrame(chromeMask
, x
, y
, cx
, cy
, bShowWindow
);
732 void CBrowserView
::OpenURLInNewWindow(const PRUnichar
* pUrl
)
737 CBrowserFrame
* pFrm
= CreateNewBrowserFrame();
741 // Load the URL into it...
743 // Note that
OpenURL() is overloaded
- one takes a
"char *"
744 // and the other a
"PRUniChar *". We
're using the "PRUnichar *"
747 pFrm->m_wndBrowserView.OpenURL(pUrl);
750 void CBrowserView::LoadHomePage()
755 void CBrowserView::OnCopyLinkLocation()
757 if(! mCtxMenuLinkUrl.Length())
760 if (! OpenClipboard())
763 HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, mCtxMenuLinkUrl.Length() + 1);
767 char *pszClipData = (char*)::GlobalLock(hClipData);
771 nsFixedCString clipDataStr(pszClipData, mCtxMenuLinkUrl.Length() + 1);
772 LossyCopyUTF16toASCII(mCtxMenuLinkUrl, clipDataStr);
773 NS_ASSERTION(clipDataStr.get() == pszClipData, "buffer too small");
775 GlobalUnlock(hClipData);
778 SetClipboardData(CF_TEXT, hClipData);
782 void CBrowserView::OnOpenLinkInNewWindow()
784 if(mCtxMenuLinkUrl.Length())
785 OpenURLInNewWindow(mCtxMenuLinkUrl.get());
788 void CBrowserView::OnViewImageInNewWindow()
790 if(mCtxMenuImgSrc.Length())
791 OpenURLInNewWindow(mCtxMenuImgSrc.get());
794 void CBrowserView::OnSaveLinkAs()
796 if(! mCtxMenuLinkUrl.Length())
799 // Try to get the file name part from the URL
800 // To do that we first construct an obj which supports
801 // nsIRUI interface. Makes it easy to extract portions
802 // of a URL like the filename, scheme etc. + We'll also
803 // use it while saving this link to a file
805 nsCOMPtr
<nsIURI
> linkURI
;
806 rv
= NS_NewURI(getter_AddRefs(linkURI
), mCtxMenuLinkUrl
);
810 // Get the
"path" portion (see nsIURI.h for more info
811 // on various parts of a URI
)
813 linkURI
->GetPath(getter_Copies(path
));
815 // The path may have the
"/" char in it
- strip those
816 nsCAutoString
fileName(path
);
817 fileName.
StripChars("\\/");
819 // Now
, use this file name in a File Save As dlg...
822 "HTML Files (*.htm;*.html)|*.htm;*.html|"
823 "Text Files (*.txt)|*.txt|"
824 "All Files (*.*)|*.*||";
826 const char
*pFileName
= fileName.
Length() ? fileName.
get() : NULL
;
828 CFileDialog
cf(FALSE, "htm", pFileName
, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT
,
830 if(cf.
DoModal() == IDOK
)
832 CString strFullPath
= cf.
GetPathName();
834 nsCOMPtr
<nsIWebBrowserPersist
> persist(do_QueryInterface(mWebBrowser
));
836 persist
->SaveURI(linkURI
, nsnull
, strFullPath.
GetBuffer(0));
840 void CBrowserView
::OnSaveImageAs()
842 if(! mCtxMenuImgSrc.
Length())
845 // Try to get the file name part from the URL
846 // To do that we first construct an obj which supports
847 // nsIRUI interface. Makes it easy to extract portions
848 // of a URL like the filename
, scheme etc.
+ We
'll also
849 // use it while saving this link to a file
851 nsCOMPtr<nsIURI> linkURI;
852 rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc);
856 // Get the "path" portion (see nsIURI.h for more info
857 // on various parts of a URI)
859 linkURI->GetPath(getter_Copies(path));
861 // The path may have the "/" char in it - strip those
862 nsCAutoString fileName(path);
863 fileName.StripChars("\\/");
865 // Now, use this file name in a File Save As dlg...
867 char *lpszFilter = "All Files (*.*)|*.*||";
868 const char *pFileName = fileName.Length() ? fileName.get() : NULL;
870 CFileDialog cf(FALSE, NULL, pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
872 if(cf.DoModal() == IDOK)
874 CString strFullPath = cf.GetPathName();
876 nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(mWebBrowser));
878 persist->SaveURI(linkURI, nsnull, strFullPath.GetBuffer(0));
882 void CBrowserView::OnShowFindDlg()
884 // When the the user chooses the Find menu item
885 // and if a Find dlg. is already being shown
886 // just set focus to the existing dlg instead of
887 // creating a new one
890 m_pFindDlg->SetFocus();
895 PRBool bMatchCase = PR_FALSE;
896 PRBool bMatchWholeWord = PR_FALSE;
897 PRBool bWrapAround = PR_FALSE;
898 PRBool bSearchBackwards = PR_FALSE;
900 // See if we can get and initialize the dlg box with
901 // the values/settings the user specified in the previous search
902 nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser));
905 nsXPIDLString stringBuf;
906 finder->GetSearchString(getter_Copies(stringBuf));
907 csSearchStr = stringBuf.get();
909 finder->GetMatchCase(&bMatchCase);
910 finder->GetEntireWord(&bMatchWholeWord);
911 finder->GetWrapFind(&bWrapAround);
912 finder->GetFindBackwards(&bSearchBackwards);
915 m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord,
916 bWrapAround, bSearchBackwards, this);
917 m_pFindDlg->Create(TRUE, NULL, NULL, 0, this);
920 // This will be called whenever the user pushes the Find
921 // button in the Find dialog box
922 // This method gets bound to the WM_FINDMSG windows msg via the
924 // ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
926 // message map entry.
928 // WM_FINDMSG (which is registered towards the beginning of this file)
929 // is the message via which the FindDialog communicates with this view
931 LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam)
933 nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser));
937 // Get the pointer to the current Find dialog box
938 CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam);
942 // Has the user decided to terminate the dialog box?
943 if(dlg->IsTerminating())
948 nsString searchString;
949 searchString.AssignWithConversion(dlg->GetFindString().GetBuffer(0));
950 finder->SetSearchString(searchString.get());
952 finder->SetMatchCase(dlg->MatchCase() ? PR_TRUE : PR_FALSE);
953 finder->SetEntireWord(dlg->MatchWholeWord() ? PR_TRUE : PR_FALSE);
954 finder->SetWrapFind(dlg->WrapAround() ? PR_TRUE : PR_FALSE);
955 finder->SetFindBackwards(dlg->SearchBackwards() ? PR_TRUE : PR_FALSE);
958 nsresult rv = finder->FindNext(&didFind);
960 return (NS_SUCCEEDED(rv) && didFind);
966 void CBrowserView::OnFilePrint()
968 nsCOMPtr<nsIDOMWindow> domWindow;
969 mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
971 nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
974 CPrintProgressDialog dlg(mWebBrowser, domWindow);
976 nsCOMPtr<nsIURI> currentURI;
977 nsresult rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI));
978 if(NS_SUCCEEDED(rv) || currentURI)
981 currentURI->GetPath(getter_Copies(path));
982 dlg.SetURI(path.get());
984 m_bCurrentlyPrinting = TRUE;
986 m_bCurrentlyPrinting = FALSE;
991 /////////////////////////////////////////////////////////////////////////////
992 void CBrowserView::OnUpdateFilePrint(CCmdUI* pCmdUI)
994 pCmdUI->Enable(!m_bCurrentlyPrinting);
999 // Called from the busy state related methods in the
1000 // BrowserFrameGlue object
1002 // When aBusy is TRUE it means that browser is busy loading a URL
1003 // When aBusy is FALSE, it's done loading
1004 // We use this to update our STOP tool bar button
1006 // We basically note this state into a member variable
1007 // The actual toolbar state will be updated in response to the
1008 // ON_UPDATE_COMMAND_UI method
- OnUpdateNavStop() being called
1010 void CBrowserView
::UpdateBusyState(PRBool aBusy
)
1012 mbDocumentLoading
= aBusy
;
1015 void CBrowserView
::SetCtxMenuLinkUrl(nsAutoString
& strLinkUrl
)
1017 mCtxMenuLinkUrl
= strLinkUrl
;
1020 void CBrowserView
::SetCtxMenuImageSrc(nsAutoString
& strImgSrc
)
1022 mCtxMenuImgSrc
= strImgSrc
;
1025 void CBrowserView
::Activate(UINT nState
, CWnd
* pWndOther
, BOOL bMinimized
)
1027 nsCOMPtr
<nsIWebBrowserFocus
> focus(do_GetInterface(mWebBrowser
));
1033 case WA_CLICKACTIVE
:
1037 focus
->Deactivate();
1044 // de
: Start QA test cases here
1045 // *********************************************************
1046 // *********************************************************
1048 void CBrowserView
::OnTestsChangeUrl()
1050 char
*theUrl
= "http://www.aol.com/";
1051 CUrlDialog myDialog
;
1054 // nsCOMPtr
<nsIURI
> pURI
;
1058 AfxMessageBox("Web navigation object not found. Change URL test not performed.");
1059 WriteToOutputFile("Web navigation object not found. Change URL test not performed.\r\n");
1063 if (myDialog.
DoModal() == IDOK
)
1065 AfxMessageBox("Begin Change URL test.");
1066 WriteToOutputFile("Begin Change URL test.\r\n");
1067 strcpy(theUrl
, myDialog.m_urlfield
);
1068 mWebNav
->LoadURI(NS_ConvertASCIItoUTF16(theUrl
).
get(),
1069 nsIWebNavigation
::LOAD_FLAGS_NONE
);
1070 WriteToOutputFile("\r\nLoadURI() method is called.");
1071 WriteToOutputFile("theUrl = ");
1072 WriteToOutputFile(theUrl
);
1076 // GetcurrentURI() declared in nsIP3PUI.idl
1077 // used with webNav obj in nsP3PObserverHTML.cpp
, line
239
1078 // this will be used as an indep routine to verify the URI load
1079 rv
= mWebNav
->GetCurrentURI( getter_AddRefs( pURI
) );
1080 if(NS_FAILED(rv
) ||
!pURI
)
1081 AfxMessageBox("Bad result for GetCurrentURI().");
1083 rv
= pURI
->GetSpec(&uriSpec
);;
1085 AfxMessageBox("Bad result for GetSpec().");
1087 AfxMessageBox("Start URL validation test().");
1088 if (strcmp(uriSpec
, theUrl
) == 0)
1090 WriteToOutputFile("Url loaded successfully. Test Passed.");
1094 WriteToOutputFile("Url didn't load successfully. Test Failed.");
1097 AfxMessageBox("End Change URL test.");
1098 WriteToOutputFile("End Change URL test.\r\n");
1102 AfxMessageBox("Change URL test not executed.");
1103 WriteToOutputFile("Change URL test not executed.\r\n");
1107 // *********************************************************
1109 void CBrowserView
::OnTestsGlobalHistory()
1111 // create instance of myHistory object. Call
's XPCOM
1112 // service manager to pass the contract ID.
1114 char *theUrl = "http://www.bogussite.com/";
1115 CUrlDialog myDialog;
1117 PRBool theRetVal = PR_FALSE;
1120 nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
1124 WriteToOutputFile("Couldn't find history object. No GH tests performed.
\r\n");
1125 AfxMessageBox("Couldn
't find history object. No GH tests performed.");
1129 if (myDialog.DoModal() == IDOK)
1131 AfxMessageBox("Begin IsVisited() and AddPage() tests.");
1132 WriteToOutputFile("Begin IsVisited() and AddPage() tests.\r\n");
1134 strcpy(theUrl, myDialog.m_urlfield);
1136 WriteToOutputFile("theUrl = ");
1137 WriteToOutputFile(theUrl);
1139 // see if url is already in the GH file (pre-AddPage() test)
1140 myHistory->IsVisited(theUrl, &theRetVal);
1144 WriteToOutputFile("URL has been visited. Won't execute
AddPage().
\r\n");
1145 AfxMessageBox("URL has been visited. Won
't execute AddPage().");
1149 WriteToOutputFile("URL hasn't been visited. Will execute
AddPage().
\r\n");
1150 AfxMessageBox("URL hasn
't been visited. Will execute AddPage().");
1151 // adds a url to the global history file
1152 rv = myHistory->AddPage(theUrl);
1154 // prints addPage() results to output file
1157 WriteToOutputFile("Invalid results for AddPage(). Url not added. Test failed.\r\n");
1162 WriteToOutputFile("Valid results for AddPage(). Url added. Test passed.\r\n");
1165 // checks if url was visited (post-AddPage() test)
1166 myHistory->IsVisited(theUrl, &theRetVal);
1170 WriteToOutputFile("URL is visited; post-AddPage() test. IsVisited() test passed.\r\n");
1174 WriteToOutputFile("URL isn't visited
; post
-AddPage() test.
IsVisited() test failed.
\r\n");
1177 AfxMessageBox("End
IsVisited() and
AddPage() tests.
");
1178 WriteToOutputFile("End
IsVisited() and
AddPage() tests.
\r\n");
1182 AfxMessageBox("IsVisited() and
AddPage() tests not executed.
");
1183 WriteToOutputFile("IsVisited() and
AddPage() tests not executed.
\r\n");
1189 // *********************************************************
1191 void CBrowserView::OnTestsCreateFile()
1195 nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));
1199 WriteToOutputFile("File object doesn
't exist. No File tests performed.\r\n");
1200 AfxMessageBox("File object doesn't exist. No File tests performed.
");
1205 AfxMessageBox("Start Create File test.
");
1206 WriteToOutputFile("\r\nStart Create File test.
\r\n");
1208 rv = theTestFile->InitWithPath("c
:\\temp
\\theFile.txt
");
1209 rv = theTestFile->Exists(&exists);
1211 WriteToOutputFile("File doesn
't exist. We'll create it.
\r\n");
1212 rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
1215 AfxMessageBox("We failed to create the
file (theFile.txt
).
");
1216 WriteToOutputFile("Create() test Failed.
\r\n");
1220 AfxMessageBox("We created the
file (theFile.txt
).
");
1221 WriteToOutputFile("Create() test Passed.
\r\n");
1225 // *********************************************************
1227 void CBrowserView::OnTestsCreateprofile()
1229 CProfilesDlg myDialog;
1232 if (myDialog.DoModal() == IDOK)
1234 // NS_WITH_SERVICE(nsIProfile, profileService, NS_PROFILE_CONTRACTID, &rv);
1235 nsCOMPtr<nsIProfile> theProfServ(do_GetService(NS_PROFILE_CONTRACTID));
1238 WriteToOutputFile("Didn
't get profile service. No profile tests performed.\r\n");
1239 AfxMessageBox("Didn't get profile service. No profile tests performed.
");
1245 AfxMessageBox("Start Profile switch test.
");
1246 WriteToOutputFile("Start Profile switch test.
\r\n");
1248 AfxMessageBox("Retrieved profile service.
");
1249 rv = theProfServ->SetCurrentProfile(myDialog.m_SelectedProfile.get());
1250 if (NS_SUCCEEDED(rv))
1251 AfxMessageBox("SetCurrentProfile() passed. Profile switched.
");
1253 AfxMessageBox("SetCurrentProfile() didn
't pass.Profile not switched.");
1255 AfxMessageBox("End Profile switch test.");
1256 WriteToOutputFile("End Profile switch test.\r\n");
1261 AfxMessageBox("Profile switch test not executed.");
1262 WriteToOutputFile("Profile switch test not executed.\r\n");
1266 // *********************************************************
1267 // *********************************************************
1271 void CBrowserView::OnToolsRemoveGHPage()
1273 char *theUrl = "http://www.bogussite.com/";
1274 CUrlDialog myDialog;
1275 PRBool theRetVal = PR_FALSE;
1277 nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
1280 WriteToOutputFile("Could not get the global history object.\r\n");
1281 AfxMessageBox("Could not get the global history object.");
1284 nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
1286 WriteToOutputFile("Could not get the history object.\r\n");
1287 AfxMessageBox("Could not get the global history object.");
1290 // nsCOMPtr<nsIBrowserHistory> myHistory(do_GetInterface(myGHistory));
1293 if (myDialog.DoModal() == IDOK)
1295 WriteToOutputFile("Begin URL removal from the GH file.\r\n");
1296 AfxMessageBox("Begin URL removal from the GH file.");
1297 strcpy(theUrl, myDialog.m_urlfield);
1299 myGHistory->IsVisited(theUrl, &theRetVal);
1302 rv = myHistory->RemovePage(theUrl);
1303 if (NS_SUCCEEDED(rv))
1305 WriteToOutputFile("\r\nThe URL was removed from the GH file.\r\n");
1306 AfxMessageBox("The URL was removed from the GH file.");
1310 WriteToOutputFile("\r\nThe URL wasn't removed from the GH file.
\r\n");
1311 AfxMessageBox("The URL wasn
't removed from the GH file.");
1316 WriteToOutputFile("The URL wasn't in the GH file.
\r\n");
1318 WriteToOutputFile("End URL removal from the GH file.
\r\n");
1319 AfxMessageBox("End URL removal from the GH file.
");
1323 WriteToOutputFile("URL removal from the GH file not executed.
\r\n");
1324 AfxMessageBox("URL removal from the GH file not executed.
");
1328 // ***********************************************************************
1329 // ************************** Interface Tests ****************************
1330 // ***********************************************************************
1334 void CBrowserView::OnInterfacesNsifile()
1336 nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
1337 nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
1344 WriteToOutputFile("File object doesn
't exist. No File tests performed.\r\n");
1345 AfxMessageBox("File object doesn't exist. No File tests performed.
");
1350 WriteToOutputFile("Dir object doesn
't exist. No File tests performed.\r\n");
1351 AfxMessageBox("File object doesn't exist. No File tests performed.
");
1355 AfxMessageBox("Begin nsIFile tests.
");
1356 WriteToOutputFile("\r\nBegin testing nsIFile
InitWithPath(), AppendRelativePath(), \
1357 Create(), and
Exists() methods.
\r\n");
1359 rv = theTestFile->InitWithPath("c
:\\temp
\\");
1362 AfxMessageBox("We failed to initialize file path.
");
1363 WriteToOutputFile("InitWithPath() test Failed.
");
1367 AfxMessageBox("We initialized file path.
");
1368 WriteToOutputFile("InitWithPath() test Passed.
");
1371 rv = theTestFile->AppendRelativePath("myFile.txt
");
1374 AfxMessageBox("We failed to append the file.
");
1375 WriteToOutputFile("AppendRelativePath() test Failed.
");
1379 AfxMessageBox("We appended the file.
");
1380 WriteToOutputFile("AppendRelativePath() test Passed.
");
1383 rv = theTestFile->Exists(&exists);
1386 AfxMessageBox("File doesn
't exist. We'll try creating it.
");
1387 WriteToOutputFile("File doesn
't exist. We'll try creating it.
\r\n");
1388 rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
1391 AfxMessageBox("We failed to create the
file (myFile.txt
).
");
1392 WriteToOutputFile("Create() test Failed.
");
1396 AfxMessageBox("We created the
file (myFile.txt
).
");
1397 WriteToOutputFile("Create() test Passed.
");
1402 AfxMessageBox("File already
exists (myFile.txt
). We won
't create it.");
1403 WriteToOutputFile("File already exists (myFile.txt). We won't create it.
");
1407 rv = theTestFile->Exists(&exists);
1410 AfxMessageBox("File (myFile.txt
) doesn
't exist.");
1411 WriteToOutputFile("Exists() test Failed.");
1415 AfxMessageBox("File (myFile.txt) exists.");
1416 WriteToOutputFile("Exists() test Passed.");
1421 AfxMessageBox("Start File Copy test.");
1422 WriteToOutputFile("Start File Copy test.");
1424 rv = theFileOpDir->InitWithPath("c:\\temp\\");
1427 AfxMessageBox("The target dir wasn't found.
");
1428 WriteToOutputFile("The target dir wasn
't found.");
1432 AfxMessageBox("The target dir was found.");
1433 WriteToOutputFile("The target dir was found.");
1435 rv = theTestFile->InitWithPath("c:\\temp\\myFile.txt");
1437 AfxMessageBox("The path wasn't found.
");
1439 AfxMessageBox("The path was found.
");
1440 rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt
");
1442 AfxMessageBox("rv
CopyTo() test failed.
");
1444 AfxMessageBox("rv
CopyTo() test succeeded.
");
1446 rv = theTestFile->InitWithPath("c
:\\temp
\\myFile2.txt
");
1447 rv = theTestFile->Exists(&exists);
1450 AfxMessageBox("File didn
't copy.");
1451 WriteToOutputFile("CopyTo() test Failed.");
1455 AfxMessageBox("File copied.");
1456 WriteToOutputFile("CopyTo() test Passed.");
1461 AfxMessageBox("Start File Move test.");
1462 WriteToOutputFile("Start File Move test.");
1464 rv = theFileOpDir->InitWithPath("c:\\Program Files\\");
1467 AfxMessageBox("The target dir wasn't found.
");
1468 WriteToOutputFile("The target dir wasn
't found.");
1471 rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
1473 AfxMessageBox("The path wasn't found.
");
1475 rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt
");
1477 AfxMessageBox("rv
MoveTo() test failed.
");
1479 AfxMessageBox("rv
MoveTo() test succeeded.
");
1480 rv = theTestFile->InitWithPath("c
:\\Program Files
\\myFile2.txt
");
1481 rv = theTestFile->Exists(&exists);
1484 AfxMessageBox("File wasn
't moved.");
1485 WriteToOutputFile("MoveTo() test Failed.");
1489 AfxMessageBox("File was moved.");
1490 WriteToOutputFile("MoveTo() test Passed.");
1493 AfxMessageBox("End nsIFile tests.");
1494 WriteToOutputFile("\r\nEnd testing nsIFile InitWithPath(), AppendRelativePath(), \
1495 Create(), and Exists() methods.\r\n");
1501 void CBrowserView::OnInterfacesNsishistory()
1504 boolean modifyIndex;
1505 long numEntries = 0;
1507 nsCOMPtr<nsISHistory> theSessionHistory(do_CreateInstance(NS_SHISTORY_CONTRACTID));
1508 nsCOMPtr<nsIHistoryEntry> theHistoryEntry(do_CreateInstance(NS_HISTORYENTRY_CONTRACTID));
1509 // do_QueryInterface
1510 // NS_HISTORYENTRY_CONTRACTID
1513 if (!theSessionHistory)
1515 AfxMessageBox("theSessionHistory object wasn't created. No tests performed.
");
1518 if (!theHistoryEntry)
1520 AfxMessageBox("NSISHistory Listener not added.
");
1524 // addSHistoryListener test
1526 do_GetWeakReference(static_cast<nsISHistoryListener*>(mpBrowserImpl)));
1527 rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
1531 AfxMessageBox("NSISHistory Listener not added.
");
1532 WriteToOutputFile("NSISHistory Listener not added.
\r\n");
1536 AfxMessageBox("NSISHistory Listener added.
");
1537 WriteToOutputFile("NSISHistory Listener added.
\r\n");
1541 // getEntryAtIndex() test
1542 theHistoryEntry = theSessionHistory->GetEntryAtIndex(index, modifyIndex);
1543 if (!theHistoryEntry)
1545 AfxMessageBox("We got the History Entry.
");
1549 AfxMessageBox("We didn
't get the History Entry.");
1555 // PurgeHistory() test
1556 rv = theSessionHistory->PurgeHistory(numEntries);
1558 AfxMessageBox("Purge History test failed.");
1560 AfxMessageBox("Purge History test succeeded.");
1563 // RemoveSHistoryListener test
1566 do_GetWeakReference(static_cast<nsISHistoryListener*>(mpBrowserImpl)));
1567 rv = theSessionHistory->RemoveSHistoryListener(weakling);
1572 // ***************** Local Methods ******************
1574 void CBrowserView::WriteToOutputFile(char *pLine)
1578 CString strFileName = "c:\\temp\\MFCoutfile";
1580 if(! myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
1581 | CStdioFile::modeNoTruncate, &e ) )
1583 CString failCause = "Unable to open file. Reason : ";
1584 failCause += e.m_cause;
1585 AfxMessageBox(failCause);
1590 CString strLine = pLine;
1593 myFile.WriteString(strLine);
1600 // ***************** Bug Verifications ******************
1602 void CBrowserView::OnVerifybugs70228()
1605 nsCOMPtr<nsIHelperAppLauncherDialog>
1606 myHALD(do_GetService(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
1608 AfxMessageBox("Object not created. It's
NOT a service
!");
1610 AfxMessageBox("Object is created. But should it?
! It
's NOT a service!");
1612 nsCOMPtr<nsIHelperAppLauncherDialog>
1613 myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
1615 AfxMessageBox("Object not created. It should be. It's a component
!");
1617 AfxMessageBox("Object is created. It
's a component!");
1620 nsCOMPtr<nsIHelperAppLauncher>
1621 myHAL(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
1623 rv = myHALD->show(myHal, mySupp);