Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / embedding / qa / testembed / BrowserImpl.cpp
blob2b1954775ba9e8c3d801006f0e463d1404ac53d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Chak Nanga <chak@netscape.com>
24 * David Epstein <depstein@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 // File Overview....
41 // This is the class which implements all the interfaces
42 // required(and optional) by the mozilla embeddable browser engine
44 // Note that this obj gets passed in the IBrowserFrameGlue* using the
45 // Init() method. Many of the interface implementations use this
46 // to get the actual task done. Ex: to update the status bar
48 // Look at the INTERFACE_MAP_ENTRY's below for the list of
49 // the currently implemented interfaces
51 // This file currently has the implementation for all the interfaces
52 // which are required of an app embedding Gecko
53 // Implementation of other optional interfaces are in separate files
54 // to avoid cluttering this one and to demonstrate other embedding
55 // principles. For example, nsIPrompt is implemented in a separate DLL.
56 //
57 // nsIWebBrowserChrome - This is a required interface to be implemented
58 // by embeddors
60 // nsIEmbeddingSiteWindow - This is a required interface to be implemented
61 // by embedders
62 // - SetTitle() gets called after a document
63 // load giving us the chance to update our
64 // titlebar
66 // Some points to note...
68 // nsIWebBrowserChrome interface's SetStatus() gets called when a user
69 // mouses over the links on a page
71 // nsIWebProgressListener interface's OnStatusChange() gets called
72 // to indicate progress when a page is being loaded
74 // Next suggested file(s) to look at :
75 // Any of the BrowserImpl*.cpp files for other interface
76 // implementation details
79 #ifdef _WINDOWS
80 #include "stdafx.h"
81 #endif
83 #include "nsIDOMWindow.h"
84 #include "BrowserImpl.h"
86 #include "QaUtils.h"
88 #include "nsirequest.h"
89 #include "Tests.h"
90 #include "prmem.h"
91 #include "nsichanneltests.h"
92 #include "nsihttpchanneltests.h"
94 CBrowserImpl::CBrowserImpl()
96 m_pBrowserFrameGlue = NULL;
97 mWebBrowser = nsnull;
101 CBrowserImpl::~CBrowserImpl()
105 extern storage getSupportObj;
107 // It's very important that the creator of this CBrowserImpl object
108 // Call on this Init() method with proper values after creation
110 NS_METHOD CBrowserImpl::Init(PBROWSERFRAMEGLUE pBrowserFrameGlue,
111 nsIWebBrowser* aWebBrowser)
113 m_pBrowserFrameGlue = pBrowserFrameGlue;
115 SetWebBrowser(aWebBrowser);
117 return NS_OK;
120 //*****************************************************************************
121 // CBrowserImpl::nsISupports
122 //*****************************************************************************
124 NS_IMPL_ADDREF(CBrowserImpl)
125 NS_IMPL_RELEASE(CBrowserImpl)
127 NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
128 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
129 NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
130 NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
131 NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
132 NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
133 NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
134 NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
135 NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
136 NS_INTERFACE_MAP_ENTRY(nsISHistoryListener) // de: added 5/11/01
137 NS_INTERFACE_MAP_ENTRY(nsIStreamListener) // de: added 6/29/01
138 NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) // de: added 6/29/01
139 NS_INTERFACE_MAP_ENTRY(nsITooltipListener) // de: added 7/25/01
140 NS_INTERFACE_MAP_ENTRY(nsIURIContentListener) // de: added 8/8/02
141 // NS_INTERFACE_MAP_ENTRY(nsITooltipTextProvider) // de: added 7/26/01
142 NS_INTERFACE_MAP_END
144 //*****************************************************************************
145 // CBrowserImpl::nsIInterfaceRequestor
146 //*****************************************************************************
148 NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
150 if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
152 if (mWebBrowser)
153 return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
154 return NS_ERROR_NOT_INITIALIZED;
157 return QueryInterface(aIID, aInstancePtr);
160 //*****************************************************************************
161 // CBrowserImpl::nsIWebBrowserChrome
162 //*****************************************************************************
164 //Gets called when you mouseover links etc. in a web page
166 NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
168 QAOutput("\n", 1);
169 QAOutput("inside nsIWebBrowserChrome::SetStatus().", 1);
170 FormatAndPrintOutput("SetStatus() type = ", aType, 1);
171 FormatAndPrintOutput("SetStatus() aStatus = ", *aStatus, 1);
173 if(! m_pBrowserFrameGlue)
174 return NS_ERROR_FAILURE;
176 m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);
178 return NS_OK;
181 NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser)
183 QAOutput("inside nsIWebBrowserChrome::GetWebBrowser().", 1);
185 NS_ENSURE_ARG_POINTER(aWebBrowser);
187 *aWebBrowser = mWebBrowser;
188 if (!aWebBrowser)
189 QAOutput("aWebBrowser is null", 1);
191 NS_IF_ADDREF(*aWebBrowser);
193 return NS_OK;
196 // Currently called from Init(). I'm not sure who else
197 // calls this
199 NS_IMETHODIMP CBrowserImpl::SetWebBrowser(nsIWebBrowser* aWebBrowser)
201 QAOutput("inside nsIWebBrowserChrome::SetWebBrowser().", 1);
203 NS_ENSURE_ARG_POINTER(aWebBrowser);
205 if (!aWebBrowser)
206 QAOutput("aWebBrowser is null", 1);
208 mWebBrowser = aWebBrowser;
210 return NS_OK;
213 NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask)
215 QAOutput("inside nsIWebBrowserChrome::GetChromeFlags().", 1);
217 *aChromeMask = nsIWebBrowserChrome::CHROME_ALL;
218 FormatAndPrintOutput("GetChromeFlags() chromeMask = ", *aChromeMask, 1);
220 return NS_OK;
223 NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask)
225 QAOutput("nsIWebBrowserChrome::SetChromeFlags().", 1);
227 FormatAndPrintOutput("SetChromeFlags() chromeMask = ", aChromeMask, 1);
229 mChromeMask = aChromeMask;
231 return NS_OK;
234 // Gets called in response to create a new browser window.
235 // Ex: In response to a JavaScript Window.Open() call
238 /*NS_IMETHODIMP CBrowserImpl::CreateBrowserWindow(PRUint32 chromeMask, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aWebBrowser)
240 if(! m_pBrowserFrameGlue)
242 QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(). Browser Window not created.", 1);
243 return NS_ERROR_FAILURE;
246 if(m_pBrowserFrameGlue->CreateNewBrowserFrame(chromeMask,
247 aX, aY, aCX, aCY, aWebBrowser))
249 QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(): Browser Window created.", 1);
250 return NS_OK;
252 else
254 QAOutput("nsIWebBrowserChrome::CreateBrowserWindow(): Browser Window not created.", 1);
255 return NS_ERROR_FAILURE;
260 // Will get called in response to JavaScript window.close()
262 NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow()
264 if(! m_pBrowserFrameGlue)
266 QAOutput("inside nsIWebBrowserChrome::DestroyBrowserWindow(): Browser Window not destroyed.", 1);
267 return NS_ERROR_FAILURE;
270 m_pBrowserFrameGlue->DestroyBrowserFrame();
271 QAOutput("nsIWebBrowserChrome::DestroyBrowserWindow(): Browser Window destroyed.", 1);
273 return NS_OK;
276 // Gets called in response to set the size of a window
277 // Ex: In response to a JavaScript Window.Open() call of
278 // the form
280 // window.open("http://www.mozilla.org", "theWin", "width=200, height=400");
282 // First the CreateBrowserWindow() call will be made followed by a
283 // call to this method to resize the window
285 NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
287 QAOutput("\n", 1);
288 QAOutput("inside nsIWebBrowserChrome::SizeBrowserTo(): Browser sized.", 1);
290 if(! m_pBrowserFrameGlue)
291 return NS_ERROR_FAILURE;
293 FormatAndPrintOutput("SizeBrowserTo() x coordinate = ", aCX, 1);
294 FormatAndPrintOutput("SizeBrowserTo() y coordinate = ", aCY, 1);
296 m_pBrowserFrameGlue->SetBrowserFrameSize(aCX, aCY);
298 return NS_OK;
301 NS_IMETHODIMP CBrowserImpl::ShowAsModal(void)
303 QAOutput("inside nsIWebBrowserChrome::ShowAsModal()", 2);
305 return NS_OK;
308 NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval)
310 QAOutput("inside nsIWebBrowserChrome::IsWindowModal()", 1);
312 // We're not modal
313 *retval = PR_FALSE;
315 return NS_OK;
318 NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus)
320 QAOutput("inside nsIWebBrowserChrome::ExitModalEventLoop()", 1);
321 RvTestResult(aStatus, "ExitModalEventLoop status test", 1);
323 return NS_OK;
326 //*****************************************************************************
327 // CBrowserImpl::nsIWebBrowserChromeFocus
328 //*****************************************************************************
330 NS_IMETHODIMP CBrowserImpl::FocusNextElement()
332 QAOutput("inside nsIWebBrowserChromeFocus::FocusNextElement()", 1);
334 return NS_OK;
337 NS_IMETHODIMP CBrowserImpl::FocusPrevElement()
339 QAOutput("inside nsIWebBrowserChromeFocus::FocusPrevElement()", 1);
341 return NS_OK;
344 //*****************************************************************************
345 // CBrowserImpl::nsIEmbeddingSiteWindow
346 //*****************************************************************************
348 NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
350 QAOutput("\n", 1);
351 QAOutput("inside nsIEmbeddingSiteWindow::SetDimensions()", 1);
353 FormatAndPrintOutput("SetDimensions() flags = ", aFlags, 1);
354 FormatAndPrintOutput("SetDimensions() x1 coordinate = ", x, 1);
355 FormatAndPrintOutput("SetDimensions() y1 coordinate = ", y, 1);
356 FormatAndPrintOutput("SetDimensions() x2 coordinate = ", cx, 1);
357 FormatAndPrintOutput("SetDimensions() y2 coordinate = ", cy, 1);
359 if(! m_pBrowserFrameGlue)
360 return NS_ERROR_FAILURE;
362 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
363 (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
364 aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))
366 m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE);
368 else
370 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
372 m_pBrowserFrameGlue->SetBrowserFramePosition(x, y);
374 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
375 aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
377 m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy);
381 return NS_OK;
384 NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
386 QAOutput("\n", 1);
387 QAOutput("inside nsIEmbeddingSiteWindow::GetDimensions()", 1);
389 FormatAndPrintOutput("GetDimensions() flags = ", aFlags, 1);
390 FormatAndPrintOutput("GetDimensions() x1 coordinate = ", *x, 1);
391 FormatAndPrintOutput("GetDimensions() y1 coordinate = ", *y, 1);
392 FormatAndPrintOutput("GetDimensions() x2 coordinate = ", *cx, 1);
393 FormatAndPrintOutput("GetDimensions() y2 coordinate = ", *cy, 1);
395 if(! m_pBrowserFrameGlue)
396 return NS_ERROR_FAILURE;
398 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
400 m_pBrowserFrameGlue->GetBrowserFramePosition(x, y);
402 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
403 aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
405 m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy);
408 return NS_OK;
411 NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow)
413 QAOutput("inside nsIEmbeddingSiteWindow::GetSiteWindow()", 1);
415 if (!aSiteWindow) {
416 QAOutput("GetSiteWindow: Didn't get siteWindow.");
417 return NS_ERROR_NULL_POINTER;
420 *aSiteWindow = 0;
421 if (m_pBrowserFrameGlue) {
422 HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd();
423 *aSiteWindow = reinterpret_cast<void *>(w);
425 return NS_OK;
428 NS_IMETHODIMP CBrowserImpl::SetFocus()
430 QAOutput("inside nsIEmbeddingSiteWindow::SetFocus()", 1);
432 if(! m_pBrowserFrameGlue)
433 return NS_ERROR_FAILURE;
435 m_pBrowserFrameGlue->SetFocus();
437 return NS_OK;
440 NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle)
442 QAOutput("inside nsIEmbeddingSiteWindow::GetTitle()", 1);
444 if(! m_pBrowserFrameGlue)
445 return NS_ERROR_FAILURE;
447 m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle);
448 FormatAndPrintOutput("GetTitle() title = ", **aTitle, 1);
450 return NS_OK;
453 NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle)
455 QAOutput("inside nsIEmbeddingSiteWindow::SetTitle()", 1);
456 FormatAndPrintOutput("SetTitle() title = ", *aTitle, 1);
458 if(! m_pBrowserFrameGlue)
459 return NS_ERROR_FAILURE;
461 m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle);
463 return NS_OK;
466 NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility)
468 QAOutput("inside nsIEmbeddingSiteWindow::GetVisibility()", 1);
470 if(! m_pBrowserFrameGlue)
471 return NS_ERROR_FAILURE;
473 m_pBrowserFrameGlue->GetBrowserFrameVisibility(aVisibility);
474 FormatAndPrintOutput("GetVisibility() boolean = ", *aVisibility, 1);
476 return NS_OK;
479 NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility)
481 QAOutput("inside nsIEmbeddingSiteWindow::SetVisibility()", 1);
482 FormatAndPrintOutput("SetVisibility() boolean = ", aVisibility, 1);
484 if(! m_pBrowserFrameGlue)
485 return NS_ERROR_FAILURE;
487 m_pBrowserFrameGlue->ShowBrowserFrame(aVisibility);
489 return NS_OK;
492 //*****************************************************************************
493 // CBrowserImpl::nsIStreamListener
494 // (used for nsIRequest, nsIChannel, and UriContentListener)
495 //*****************************************************************************
497 NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request,
498 nsISupports *ctxt, nsIInputStream *input,
499 PRUint32 offset, PRUint32 count)
501 nsCString stringMsg;
502 PRUint32 readLen;
503 QAOutput("\n");
504 QAOutput("##### inside nsIStreamListener::OnDataAvailable(). #####");
506 RequestName(request, stringMsg, 1);
507 readLen = count;
508 // from prmem.h: PR_Malloc()
509 char *buf = (char *)PR_Malloc(count);
510 if (!input)
511 QAOutput("We didn't get the nsIInputStream object.", 1);
512 else {
513 // consumer of input stream
514 rv = input->Read(buf, count, &readLen);
515 RvTestResult(rv, "nsIInputStream->Read() consumer", 1);
518 FormatAndPrintOutput("OnDataAvailable() offset = ", offset, 1);
519 FormatAndPrintOutput("OnDataAvailable() count = ", count, 1);
521 if (!ctxt)
522 QAOutput("OnDataAvailable():We didn't get the nsISupports object.", 1);
523 else
524 QAOutput("OnDataAvailable():We got the nsISupports object.", 1);
526 return NS_OK;
529 //*****************************************************************************
530 // CBrowserImpl::nsIRequestObserver
531 // (used for nsIRequest, nsIChannel, and UriContentListener)
532 //*****************************************************************************
534 NS_IMETHODIMP CBrowserImpl::OnStartRequest(nsIRequest *request,
535 nsISupports *ctxt)
537 nsCString stringMsg;
539 QAOutput("\n");
540 QAOutput("##### BEGIN: nsIRequestObserver::OnStartRequest() #####");
542 if (!ctxt)
543 QAOutput("We did NOT get the context object.\n");
545 if (ctxt == getSupportObj.sup)
546 QAOutput("Context objects equal each other.\n");
547 else
548 QAOutput("Context objects don't equal each other.\n");
550 RequestName(request, stringMsg, 1);
552 // these are for nsIChannel tests found in nsichanneltests.cpp (post AsyncOpen() tests)
553 nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
554 nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
555 CBrowserImpl *aBrowserImpl = new CBrowserImpl();
556 CnsIChannelTests *channelTests = new CnsIChannelTests(mWebBrowser, aBrowserImpl);
557 CnsIHttpChannelTests *httpChannelTests = new CnsIHttpChannelTests(mWebBrowser, aBrowserImpl);
558 if (channelTests && channel) {
559 QAOutput("\n Start nsIChannel PostAsyncOpenTests tests:");
560 channelTests->PostAsyncOpenTests(channel, 1);
562 else if (!channelTests)
563 QAOutput("No object to run PostAsyncOpenTests() for nsIChannel.", 1);
565 if (!httpChannelTests)
566 QAOutput("No object to run CallResponseTests() for nsIHttpChannel.", 1);
567 else
569 QAOutput("\n Start nsIHttpChannel response tests:");
570 httpChannelTests->CallResponseTests(httpChannel, 1);
573 if (!ctxt)
574 QAOutput("OnStartRequest():We didn't get the nsISupports object.", 1);
575 else
576 QAOutput("OnStartRequest():We got the nsISupports object.", 1);
578 return NS_OK;
581 NS_IMETHODIMP CBrowserImpl::OnStopRequest(nsIRequest *request,
582 nsISupports *ctxt, nsresult rv)
584 nsCString stringMsg;
585 QAOutput("\n");
586 RvTestResult(rv, "nsIRequestObserver::OnStopRequest rv input", 1);
587 RequestName(request, stringMsg, 1);
589 if (!ctxt)
590 QAOutput("OnStopRequest():We didn't get the nsISupports object.", 1);
591 else
592 QAOutput("OnStopRequest():We got the nsISupports object.", 1);
594 RvTestResult(rv, "OnStopRequest() rv test", 1);
596 QAOutput("##### END: nsIStreamListener::OnStopRequest() #####");
598 return NS_OK;
601 //*****************************************************************************
602 // CBrowserImpl::Tool Tip Listener
603 //*****************************************************************************
605 NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
606 const PRUnichar *aTipText)
608 if(! m_pBrowserFrameGlue)
609 return NS_ERROR_FAILURE;
611 m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText);
613 QAOutput("nsITooltipListener->OnShowTooltip()",1);
614 FormatAndPrintOutput("OnShowTooltip() aXCoords = ", aXCoords, 1);
615 FormatAndPrintOutput("OnShowTooltip() aYCoords = ", aYCoords, 1);
616 FormatAndPrintOutput("OnShowTooltip() aTipText = ", *aTipText, 1);
617 return NS_OK;
620 NS_IMETHODIMP CBrowserImpl::OnHideTooltip()
622 if(! m_pBrowserFrameGlue)
623 return NS_ERROR_FAILURE;
625 m_pBrowserFrameGlue->HideTooltip();
626 QAOutput("nsITooltipListener->OnHideTooltip()",1);
627 return NS_OK;
631 //*****************************************************************************
632 // CBrowserImpl::UriContentListener
633 //*****************************************************************************
635 NS_IMETHODIMP CBrowserImpl::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
637 QAOutput("nsIURIContentListener->OnStartURIOpen()",1);
639 GetTheURI(aURI, 1);
640 // set return boolean to false so uriOpen doesn't abort
641 *_retval = PR_FALSE;
642 FormatAndPrintOutput("_retval set to = ", *_retval, 1);
644 return NS_OK;
647 NS_IMETHODIMP CBrowserImpl::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest, nsIStreamListener **aContentHandler, PRBool *_retval)
649 nsCString stringMsg;
651 QAOutput("nsIURIContentListener->DoContent()",1);
653 FormatAndPrintOutput("DoContent() content type = ", *aContentType, 1);
654 FormatAndPrintOutput("DoContent() aIsContentPreferred = ", aIsContentPreferred, 1);
655 RequestName(aRequest, stringMsg); // nsIRequest::GetName() test
656 // *aContentHandler = nsnull;
657 QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
659 *_retval = PR_FALSE;
660 FormatAndPrintOutput("_retval set to = ", *_retval, 1);
662 return NS_OK;
665 NS_IMETHODIMP CBrowserImpl::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
667 nsCAutoString contentStr;
669 QAOutput("nsIURIContentListener->IsPreferred()",1);
671 FormatAndPrintOutput("IsPreferred() content type = ", *aContentType, 1);
672 *aDesiredContentType = nsCRT::strdup("text/html");
673 FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
674 *_retval = PR_TRUE;
675 FormatAndPrintOutput("_retval set to = ", *_retval, 1);
677 return NS_OK;
680 NS_IMETHODIMP CBrowserImpl::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
682 QAOutput("nsIURIContentListener->CanHandleContent()",1);
684 FormatAndPrintOutput("CanHandleContent() content type = ", *aContentType, 1);
685 FormatAndPrintOutput("CanHandleContent() preferred content type = ", aIsContentPreferred, 1);
686 *aDesiredContentType = nsCRT::strdup("text/html");
687 FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
688 *_retval = PR_TRUE;
689 FormatAndPrintOutput("_retval set to = ", *_retval, 1);
690 return NS_OK;
693 NS_IMETHODIMP CBrowserImpl::GetLoadCookie(nsISupports **aLoadCookie)
695 QAOutput("nsIURIContentListener->GetLoadCookie()",1);
697 if (!aLoadCookie)
698 QAOutput("aLoadCookie object is null",1);
699 *aLoadCookie = mLoadCookie;
700 NS_IF_ADDREF(*aLoadCookie);
702 return NS_OK;
705 NS_IMETHODIMP CBrowserImpl::SetLoadCookie(nsISupports * aLoadCookie)
707 QAOutput("nsIURIContentListener->SetLoadCookie()",1);
709 if (!aLoadCookie)
710 QAOutput("aLoadCookie object is null",1);
711 mLoadCookie = aLoadCookie;
713 return NS_OK;
716 NS_IMETHODIMP CBrowserImpl::GetParentContentListener(nsIURIContentListener **aParentContentListener)
718 QAOutput("nsIURIContentListener->GetParentContentListener()",1);
720 if (!aParentContentListener)
721 QAOutput("aParentContentListener object is null",1);
722 *aParentContentListener = mParentContentListener;
723 NS_IF_ADDREF(*aParentContentListener);
725 // QueryInterface(NS_GET_IID(nsIURIContentListener), (void **) aParentContentListener);
727 return NS_OK;
730 NS_IMETHODIMP CBrowserImpl::SetParentContentListener(nsIURIContentListener * aParentContentListener)
732 QAOutput("nsIURIContentListener->SetParentContentListener()",1);
734 if (!aParentContentListener)
735 QAOutput("aParentContentListener object is null",1);
736 mParentContentListener = aParentContentListener;
738 return NS_OK;