Back to index

lightning-sunbird  0.9+nobinonly
BrowserImpl.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Chak Nanga <chak@netscape.com>
00024  *   David Epstein <depstein@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 // File Overview....
00041 // This is the class which implements all the interfaces
00042 // required(and optional) by the mozilla embeddable browser engine
00043 //
00044 // Note that this obj gets passed in the IBrowserFrameGlue* using the 
00045 // Init() method. Many of the interface implementations use this
00046 // to get the actual task done. Ex: to update the status bar
00047 //
00048 // Look at the INTERFACE_MAP_ENTRY's below for the list of 
00049 // the currently implemented interfaces
00050 //
00051 // This file currently has the implementation for all the interfaces
00052 // which are required of an app embedding Gecko
00053 // Implementation of other optional interfaces are in separate files
00054 // to avoid cluttering this one and to demonstrate other embedding
00055 // principles. For example, nsIPrompt is implemented in a separate DLL.
00056 // 
00057 //     nsIWebBrowserChrome  - This is a required interface to be implemented
00058 //                                          by embeddors
00059 //
00060 //     nsIEmbeddingSiteWindow - This is a required interface to be implemented
00061 //                                         by embedders               
00062 //                                    - SetTitle() gets called after a document
00063 //                                         load giving us the chance to update our
00064 //                                         titlebar
00065 //
00066 // Some points to note...
00067 //
00068 // nsIWebBrowserChrome interface's SetStatus() gets called when a user 
00069 // mouses over the links on a page
00070 //
00071 // nsIWebProgressListener interface's OnStatusChange() gets called
00072 // to indicate progress when a page is being loaded
00073 //
00074 // Next suggested file(s) to look at : 
00075 //                   Any of the BrowserImpl*.cpp files for other interface
00076 //                   implementation details
00077 //
00078 
00079 #ifdef _WINDOWS
00080   #include "stdafx.h"
00081 #endif
00082 
00083 #include "nsIDOMWindow.h"
00084 #include "BrowserImpl.h"
00085 
00086 #include "QaUtils.h"
00087 
00088 #include "nsirequest.h"
00089 #include "Tests.h"
00090 #include "prmem.h"
00091 #include "nsichanneltests.h"
00092 #include "nsihttpchanneltests.h"
00093 
00094 CBrowserImpl::CBrowserImpl()
00095 {
00096   m_pBrowserFrameGlue = NULL;
00097   mWebBrowser = nsnull;
00098 }
00099 
00100 
00101 CBrowserImpl::~CBrowserImpl()
00102 {
00103 }
00104 
00105 extern storage getSupportObj;
00106 
00107 // It's very important that the creator of this CBrowserImpl object
00108 // Call on this Init() method with proper values after creation
00109 //
00110 NS_METHOD CBrowserImpl::Init(PBROWSERFRAMEGLUE pBrowserFrameGlue, 
00111                              nsIWebBrowser* aWebBrowser)
00112 {
00113          m_pBrowserFrameGlue = pBrowserFrameGlue;
00114          
00115          SetWebBrowser(aWebBrowser);
00116 
00117          return NS_OK;
00118 }
00119 
00120 //*****************************************************************************
00121 // CBrowserImpl::nsISupports
00122 //*****************************************************************************   
00123 
00124 NS_IMPL_ADDREF(CBrowserImpl)
00125 NS_IMPL_RELEASE(CBrowserImpl)
00126 
00127 NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
00128    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
00129    NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
00130    NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
00131    NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
00132    NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
00133    NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
00134    NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
00135    NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
00136    NS_INTERFACE_MAP_ENTRY(nsISHistoryListener) // de: added 5/11/01
00137    NS_INTERFACE_MAP_ENTRY(nsIStreamListener) // de: added 6/29/01
00138    NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) // de: added 6/29/01
00139    NS_INTERFACE_MAP_ENTRY(nsITooltipListener) // de: added 7/25/01
00140    NS_INTERFACE_MAP_ENTRY(nsIURIContentListener) // de: added 8/8/02
00141 //   NS_INTERFACE_MAP_ENTRY(nsITooltipTextProvider) // de: added 7/26/01
00142 NS_INTERFACE_MAP_END
00143 
00144 //*****************************************************************************
00145 // CBrowserImpl::nsIInterfaceRequestor
00146 //*****************************************************************************   
00147 
00148 NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
00149 {
00150        if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
00151        {
00152               if (mWebBrowser)
00153                      return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
00154               return NS_ERROR_NOT_INITIALIZED;
00155        }
00156 
00157        return QueryInterface(aIID, aInstancePtr);
00158 }
00159 
00160 //*****************************************************************************
00161 // CBrowserImpl::nsIWebBrowserChrome
00162 //*****************************************************************************   
00163 
00164 //Gets called when you mouseover links etc. in a web page
00165 //
00166 NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
00167 {
00168     QAOutput("\n", 1);
00169     QAOutput("inside nsIWebBrowserChrome::SetStatus().", 1);
00170        FormatAndPrintOutput("SetStatus() type = ", aType, 1);
00171        FormatAndPrintOutput("SetStatus() aStatus = ", *aStatus, 1);
00172 
00173        if(! m_pBrowserFrameGlue)
00174               return NS_ERROR_FAILURE;
00175 
00176        m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);
00177 
00178        return NS_OK;
00179 }
00180 
00181 NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser)
00182 {
00183    QAOutput("inside nsIWebBrowserChrome::GetWebBrowser().", 1);
00184 
00185    NS_ENSURE_ARG_POINTER(aWebBrowser);
00186 
00187    *aWebBrowser = mWebBrowser;
00188    if (!aWebBrowser)
00189       QAOutput("aWebBrowser is null", 1);
00190 
00191    NS_IF_ADDREF(*aWebBrowser);
00192 
00193    return NS_OK;
00194 }
00195 
00196 // Currently called from Init(). I'm not sure who else
00197 // calls this
00198 //
00199 NS_IMETHODIMP CBrowserImpl::SetWebBrowser(nsIWebBrowser* aWebBrowser)
00200 {
00201    QAOutput("inside nsIWebBrowserChrome::SetWebBrowser().", 1);
00202 
00203    NS_ENSURE_ARG_POINTER(aWebBrowser);
00204 
00205    if (!aWebBrowser)
00206       QAOutput("aWebBrowser is null", 1);
00207 
00208    mWebBrowser = aWebBrowser;
00209 
00210    return NS_OK;
00211 }
00212 
00213 NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask)
00214 {
00215     QAOutput("inside nsIWebBrowserChrome::GetChromeFlags().", 1);
00216 
00217        *aChromeMask = nsIWebBrowserChrome::CHROME_ALL;
00218        FormatAndPrintOutput("GetChromeFlags() chromeMask = ", *aChromeMask, 1);
00219 
00220        return NS_OK;
00221 }
00222 
00223 NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask)
00224 {
00225     QAOutput("nsIWebBrowserChrome::SetChromeFlags().", 1);
00226 
00227        FormatAndPrintOutput("SetChromeFlags() chromeMask = ", aChromeMask, 1);
00228 
00229        mChromeMask = aChromeMask;
00230 
00231        return NS_OK;
00232 }
00233 
00234 // Gets called in response to create a new browser window. 
00235 // Ex: In response to a JavaScript Window.Open() call
00236 //
00237 //
00238 /*NS_IMETHODIMP CBrowserImpl::CreateBrowserWindow(PRUint32 chromeMask, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aWebBrowser)
00239 {
00240        if(! m_pBrowserFrameGlue)
00241        {
00242               QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(). Browser Window not created.", 1);
00243               return NS_ERROR_FAILURE;
00244        }
00245 
00246        if(m_pBrowserFrameGlue->CreateNewBrowserFrame(chromeMask, 
00247                                                         aX, aY, aCX, aCY, aWebBrowser))
00248        {
00249               QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(): Browser Window created.", 1);
00250               return NS_OK;
00251        }
00252        else
00253        {
00254               QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(): Browser Window not created.", 1);
00255            return NS_ERROR_FAILURE;
00256        }
00257 }
00258 */
00259 
00260 // Will get called in response to JavaScript window.close()
00261 //
00262 NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow()
00263 {
00264        if(! m_pBrowserFrameGlue)
00265        {
00266               QAOutput("inside nsIWebBrowserChrome::DestroyBrowserWindow(): Browser Window not destroyed.", 1);
00267               return NS_ERROR_FAILURE;
00268        }
00269 
00270        m_pBrowserFrameGlue->DestroyBrowserFrame();
00271        QAOutput("nsIWebBrowserChrome::DestroyBrowserWindow(): Browser Window destroyed.", 1);
00272 
00273        return NS_OK;
00274 }
00275 
00276 // Gets called in response to set the size of a window
00277 // Ex: In response to a JavaScript Window.Open() call of
00278 // the form 
00279 //
00280 //            window.open("http://www.mozilla.org", "theWin", "width=200, height=400");
00281 //
00282 // First the CreateBrowserWindow() call will be made followed by a 
00283 // call to this method to resize the window
00284 //
00285 NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
00286 {
00287     QAOutput("\n", 1);
00288        QAOutput("inside nsIWebBrowserChrome::SizeBrowserTo(): Browser sized.", 1);
00289 
00290        if(! m_pBrowserFrameGlue)
00291               return NS_ERROR_FAILURE;
00292 
00293        FormatAndPrintOutput("SizeBrowserTo() x coordinate = ", aCX, 1);
00294        FormatAndPrintOutput("SizeBrowserTo() y coordinate = ", aCY, 1);
00295 
00296        m_pBrowserFrameGlue->SetBrowserFrameSize(aCX, aCY);
00297 
00298        return NS_OK;
00299 }
00300 
00301 NS_IMETHODIMP CBrowserImpl::ShowAsModal(void)
00302 {
00303        QAOutput("inside nsIWebBrowserChrome::ShowAsModal()", 2);
00304 
00305        return NS_OK;
00306 }
00307 
00308 NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval)
00309 {
00310   QAOutput("inside nsIWebBrowserChrome::IsWindowModal()", 1);
00311 
00312   // We're not modal
00313   *retval = PR_FALSE;
00314 
00315   return NS_OK;
00316 }
00317 
00318 NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus)
00319 {
00320   QAOutput("inside nsIWebBrowserChrome::ExitModalEventLoop()", 1);
00321   RvTestResult(aStatus, "ExitModalEventLoop status test", 1);
00322 
00323   return NS_OK;
00324 }
00325 
00326 //*****************************************************************************
00327 // CBrowserImpl::nsIWebBrowserChromeFocus
00328 //*****************************************************************************
00329 
00330 NS_IMETHODIMP CBrowserImpl::FocusNextElement()
00331 {
00332        QAOutput("inside nsIWebBrowserChromeFocus::FocusNextElement()", 1);
00333 
00334     return NS_OK;
00335 }
00336 
00337 NS_IMETHODIMP CBrowserImpl::FocusPrevElement()
00338 {
00339        QAOutput("inside nsIWebBrowserChromeFocus::FocusPrevElement()", 1);
00340 
00341     return NS_OK;
00342 }
00343 
00344 //*****************************************************************************
00345 // CBrowserImpl::nsIEmbeddingSiteWindow
00346 //*****************************************************************************   
00347 
00348 NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
00349 {
00350     QAOutput("\n", 1);
00351        QAOutput("inside nsIEmbeddingSiteWindow::SetDimensions()", 1);
00352 
00353        FormatAndPrintOutput("SetDimensions() flags = ", aFlags, 1);
00354        FormatAndPrintOutput("SetDimensions() x1 coordinate = ", x, 1);
00355        FormatAndPrintOutput("SetDimensions() y1 coordinate = ", y, 1);
00356        FormatAndPrintOutput("SetDimensions() x2 coordinate = ", cx, 1);
00357        FormatAndPrintOutput("SetDimensions() y2 coordinate = ", cy, 1);
00358 
00359        if(! m_pBrowserFrameGlue)
00360               return NS_ERROR_FAILURE;
00361 
00362     if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
00363         (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || 
00364          aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))
00365     {
00366        m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE);
00367     }
00368     else
00369     {
00370         if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
00371         {
00372            m_pBrowserFrameGlue->SetBrowserFramePosition(x, y);
00373         }
00374         if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || 
00375             aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
00376         {
00377            m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy);
00378         }
00379     }
00380 
00381     return NS_OK;
00382 }
00383 
00384 NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
00385 {
00386     QAOutput("\n", 1);
00387        QAOutput("inside nsIEmbeddingSiteWindow::GetDimensions()", 1);
00388 
00389        FormatAndPrintOutput("GetDimensions() flags = ", aFlags, 1);
00390        FormatAndPrintOutput("GetDimensions() x1 coordinate = ", *x, 1);
00391        FormatAndPrintOutput("GetDimensions() y1 coordinate = ", *y, 1);
00392        FormatAndPrintOutput("GetDimensions() x2 coordinate = ", *cx, 1);
00393        FormatAndPrintOutput("GetDimensions() y2 coordinate = ", *cy, 1);
00394 
00395        if(! m_pBrowserFrameGlue)
00396               return NS_ERROR_FAILURE;
00397     
00398     if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
00399     {
00400        m_pBrowserFrameGlue->GetBrowserFramePosition(x, y);
00401     }
00402     if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || 
00403         aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
00404     {
00405        m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy);
00406     }
00407 
00408     return NS_OK;
00409 }
00410 
00411 NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow)
00412 {
00413   QAOutput("inside nsIEmbeddingSiteWindow::GetSiteWindow()", 1);
00414 
00415   if (!aSiteWindow) {
00416        QAOutput("GetSiteWindow: Didn't get siteWindow.");
00417     return NS_ERROR_NULL_POINTER;
00418   }
00419 
00420   *aSiteWindow = 0;
00421   if (m_pBrowserFrameGlue) {
00422     HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd();
00423     *aSiteWindow = NS_REINTERPRET_CAST(void *, w);
00424   }
00425   return NS_OK;
00426 }
00427 
00428 NS_IMETHODIMP CBrowserImpl::SetFocus()
00429 {
00430     QAOutput("inside nsIEmbeddingSiteWindow::SetFocus()", 1);
00431 
00432        if(! m_pBrowserFrameGlue)
00433               return NS_ERROR_FAILURE;
00434 
00435        m_pBrowserFrameGlue->SetFocus();
00436 
00437        return NS_OK;
00438 }
00439 
00440 NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle)
00441 {
00442     QAOutput("inside nsIEmbeddingSiteWindow::GetTitle()", 1);
00443 
00444        if(! m_pBrowserFrameGlue)
00445               return NS_ERROR_FAILURE;
00446 
00447        m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle);
00448        FormatAndPrintOutput("GetTitle() title = ", **aTitle, 1);
00449        
00450        return NS_OK;
00451 }
00452 
00453 NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle)
00454 {
00455     QAOutput("inside nsIEmbeddingSiteWindow::SetTitle()", 1);
00456        FormatAndPrintOutput("SetTitle() title = ", *aTitle, 1);
00457 
00458        if(! m_pBrowserFrameGlue)
00459               return NS_ERROR_FAILURE;
00460 
00461        m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle);
00462        
00463        return NS_OK;
00464 }
00465 
00466 NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility)
00467 {
00468     QAOutput("inside nsIEmbeddingSiteWindow::GetVisibility()", 1);
00469 
00470        if(! m_pBrowserFrameGlue)
00471               return NS_ERROR_FAILURE;
00472 
00473     m_pBrowserFrameGlue->GetBrowserFrameVisibility(aVisibility);
00474        FormatAndPrintOutput("GetVisibility() boolean = ", *aVisibility, 1);
00475 
00476        return NS_OK;
00477 }
00478 
00479 NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility)
00480 {
00481     QAOutput("inside nsIEmbeddingSiteWindow::SetVisibility()", 1);
00482        FormatAndPrintOutput("SetVisibility() boolean = ", aVisibility, 1);
00483 
00484     if(! m_pBrowserFrameGlue)
00485         return NS_ERROR_FAILURE;
00486 
00487     m_pBrowserFrameGlue->ShowBrowserFrame(aVisibility);
00488 
00489     return NS_OK;
00490 }
00491 
00492 //*****************************************************************************
00493 // CBrowserImpl::nsIStreamListener 
00494 // (used for nsIRequest, nsIChannel, and UriContentListener)
00495 //*****************************************************************************   
00496 
00497 NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request,
00498                             nsISupports *ctxt, nsIInputStream *input,
00499                             PRUint32 offset, PRUint32 count)
00500 {
00501        nsCString stringMsg;
00502        PRUint32 readLen;
00503        QAOutput("\n");
00504        QAOutput("##### inside nsIStreamListener::OnDataAvailable(). #####");
00505 
00506        RequestName(request, stringMsg, 1);
00507        readLen = count;
00508               // from prmem.h: PR_Malloc()
00509        char *buf = (char *)PR_Malloc(count);
00510        if (!input)
00511               QAOutput("We didn't get the nsIInputStream object.", 1);
00512        else {
00513               // consumer of input stream
00514               rv = input->Read(buf, count, &readLen);
00515               RvTestResult(rv, "nsIInputStream->Read() consumer", 1);
00516        }
00517 
00518        FormatAndPrintOutput("OnDataAvailable() offset = ", offset, 1);
00519        FormatAndPrintOutput("OnDataAvailable() count = ", count, 1);
00520 
00521        if (!ctxt)
00522               QAOutput("OnDataAvailable():We didn't get the nsISupports object.", 1);
00523        else
00524               QAOutput("OnDataAvailable():We got the nsISupports object.", 1);
00525 
00526        return NS_OK;
00527 }
00528 
00529 //*****************************************************************************
00530 // CBrowserImpl::nsIRequestObserver 
00531 // (used for nsIRequest, nsIChannel, and UriContentListener)
00532 //*****************************************************************************   
00533 
00534 NS_IMETHODIMP CBrowserImpl::OnStartRequest(nsIRequest *request,
00535                             nsISupports *ctxt)
00536 {
00537        nsCString stringMsg;
00538 
00539        QAOutput("\n");
00540        QAOutput("##### BEGIN: nsIRequestObserver::OnStartRequest() #####");
00541 
00542        if (!ctxt)
00543               QAOutput("We did NOT get the context object.\n");
00544 
00545        if (ctxt == getSupportObj.sup)
00546               QAOutput("Context objects equal each other.\n");
00547        else
00548               QAOutput("Context objects don't equal each other.\n");
00549 
00550        RequestName(request, stringMsg, 1);
00551 
00552        // these are for nsIChannel tests found in nsichanneltests.cpp (post AsyncOpen() tests)
00553        nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
00554        nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
00555        CBrowserImpl *aBrowserImpl = new CBrowserImpl();
00556        CnsIChannelTests  *channelTests = new CnsIChannelTests(mWebBrowser, aBrowserImpl);
00557        CnsIHttpChannelTests *httpChannelTests = new CnsIHttpChannelTests(mWebBrowser, aBrowserImpl);
00558        if (channelTests && channel) {
00559               QAOutput("\n  Start nsIChannel PostAsyncOpenTests tests:");
00560               channelTests->PostAsyncOpenTests(channel, 1);
00561        }
00562        else if (!channelTests)
00563               QAOutput("No object to run PostAsyncOpenTests() for nsIChannel.", 1);
00564 
00565        if (!httpChannelTests)
00566               QAOutput("No object to run CallResponseTests() for nsIHttpChannel.", 1);
00567        else
00568        {
00569               QAOutput("\n  Start nsIHttpChannel response tests:");
00570               httpChannelTests->CallResponseTests(httpChannel, 1);
00571        }
00572 
00573        if (!ctxt)
00574               QAOutput("OnStartRequest():We didn't get the nsISupports object.", 1);
00575        else
00576               QAOutput("OnStartRequest():We got the nsISupports object.", 1);
00577 
00578        return NS_OK;
00579 }
00580 
00581 NS_IMETHODIMP CBrowserImpl::OnStopRequest(nsIRequest *request,
00582                             nsISupports *ctxt, nsresult rv)
00583 {
00584        nsCString stringMsg;
00585        QAOutput("\n");
00586        RvTestResult(rv, "nsIRequestObserver::OnStopRequest rv input", 1);
00587        RequestName(request, stringMsg, 1);
00588 
00589        if (!ctxt)
00590               QAOutput("OnStopRequest():We didn't get the nsISupports object.", 1);
00591        else
00592               QAOutput("OnStopRequest():We got the nsISupports object.", 1);
00593 
00594        RvTestResult(rv, "OnStopRequest() rv test", 1);
00595 
00596        QAOutput("##### END: nsIStreamListener::OnStopRequest() #####");
00597               
00598        return NS_OK;
00599 }
00600 
00601 //*****************************************************************************   
00602 //  CBrowserImpl::Tool Tip Listener
00603 //*****************************************************************************   
00604 
00605 NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
00606                                                                         const PRUnichar *aTipText)
00607 {
00608     if(! m_pBrowserFrameGlue)
00609         return NS_ERROR_FAILURE;
00610 
00611     m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText);
00612 
00613        QAOutput("nsITooltipListener->OnShowTooltip()",1);
00614        FormatAndPrintOutput("OnShowTooltip() aXCoords = ", aXCoords, 1);
00615        FormatAndPrintOutput("OnShowTooltip() aYCoords = ", aYCoords, 1);
00616        FormatAndPrintOutput("OnShowTooltip() aTipText = ", *aTipText, 1);    
00617        return NS_OK;
00618 }
00619 
00620 NS_IMETHODIMP CBrowserImpl::OnHideTooltip() 
00621 {
00622     if(! m_pBrowserFrameGlue)
00623         return NS_ERROR_FAILURE;
00624 
00625     m_pBrowserFrameGlue->HideTooltip();
00626        QAOutput("nsITooltipListener->OnHideTooltip()",1);
00627        return NS_OK;
00628 }
00629 
00630 
00631 //*****************************************************************************   
00632 //  CBrowserImpl::UriContentListener
00633 //*****************************************************************************   
00634 
00635 NS_IMETHODIMP CBrowserImpl::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
00636 {
00637        QAOutput("nsIURIContentListener->OnStartURIOpen()",1);
00638 
00639        GetTheURI(aURI, 1);
00640        // set return boolean to false so uriOpen doesn't abort
00641        *_retval = PR_FALSE;
00642        FormatAndPrintOutput("_retval set to = ", *_retval, 1);
00643 
00644        return NS_OK;
00645 }
00646 
00647 NS_IMETHODIMP CBrowserImpl::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest, nsIStreamListener **aContentHandler, PRBool *_retval)
00648 {
00649        nsCString stringMsg;
00650 
00651        QAOutput("nsIURIContentListener->DoContent()",1);
00652 
00653        FormatAndPrintOutput("DoContent() content type = ", *aContentType, 1);
00654        FormatAndPrintOutput("DoContent() aIsContentPreferred = ", aIsContentPreferred, 1);
00655        RequestName(aRequest, stringMsg);  // nsIRequest::GetName() test
00656 //     *aContentHandler = nsnull;
00657        QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
00658 
00659        *_retval = PR_FALSE;
00660        FormatAndPrintOutput("_retval set to = ", *_retval, 1);
00661 
00662        return NS_OK;
00663 }
00664 
00665 NS_IMETHODIMP CBrowserImpl::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
00666 {
00667        nsCAutoString contentStr;
00668 
00669        QAOutput("nsIURIContentListener->IsPreferred()",1);
00670 
00671        FormatAndPrintOutput("IsPreferred() content type = ", *aContentType, 1);
00672        *aDesiredContentType = nsCRT::strdup("text/html");
00673        FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
00674        *_retval = PR_TRUE;
00675        FormatAndPrintOutput("_retval set to = ", *_retval, 1);
00676 
00677        return NS_OK;
00678 }
00679 
00680 NS_IMETHODIMP CBrowserImpl::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
00681 {
00682        QAOutput("nsIURIContentListener->CanHandleContent()",1);
00683 
00684        FormatAndPrintOutput("CanHandleContent() content type = ", *aContentType, 1);
00685        FormatAndPrintOutput("CanHandleContent() preferred content type = ", aIsContentPreferred, 1);
00686        *aDesiredContentType = nsCRT::strdup("text/html");
00687        FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
00688        *_retval = PR_TRUE;
00689        FormatAndPrintOutput("_retval set to = ", *_retval, 1);
00690        return NS_OK;
00691 }
00692 
00693 NS_IMETHODIMP CBrowserImpl::GetLoadCookie(nsISupports **aLoadCookie)
00694 {
00695        QAOutput("nsIURIContentListener->GetLoadCookie()",1);
00696 
00697        if (!aLoadCookie)
00698               QAOutput("aLoadCookie object is null",1);
00699        *aLoadCookie = mLoadCookie;
00700        NS_IF_ADDREF(*aLoadCookie);
00701 
00702        return NS_OK;
00703 }
00704 
00705 NS_IMETHODIMP CBrowserImpl::SetLoadCookie(nsISupports * aLoadCookie)
00706 {
00707        QAOutput("nsIURIContentListener->SetLoadCookie()",1);
00708 
00709        if (!aLoadCookie)
00710               QAOutput("aLoadCookie object is null",1);
00711        mLoadCookie = aLoadCookie;
00712 
00713        return NS_OK;
00714 }
00715 
00716 NS_IMETHODIMP CBrowserImpl::GetParentContentListener(nsIURIContentListener **aParentContentListener)
00717 {
00718        QAOutput("nsIURIContentListener->GetParentContentListener()",1);
00719 
00720        if (!aParentContentListener)
00721               QAOutput("aParentContentListener object is null",1);
00722        *aParentContentListener = mParentContentListener;
00723        NS_IF_ADDREF(*aParentContentListener);
00724 
00725 //     QueryInterface(NS_GET_IID(nsIURIContentListener), (void **) aParentContentListener);
00726 
00727        return NS_OK;
00728 }
00729 
00730 NS_IMETHODIMP CBrowserImpl::SetParentContentListener(nsIURIContentListener * aParentContentListener)
00731 {
00732        QAOutput("nsIURIContentListener->SetParentContentListener()",1);
00733 
00734        if (!aParentContentListener)
00735               QAOutput("aParentContentListener object is null",1);
00736        mParentContentListener = aParentContentListener;
00737 
00738        return NS_OK; 
00739 }