Back to index

lightning-sunbird  0.9+nobinonly
nsWebBrowserChrome.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Travis Bogard <travis@netscape.com>
00025  *   Brian Ryner <bryner@brianryner.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 // Local Includes
00042 #include "nsWebBrowserChrome.h"
00043 #include "nsBrowserWindow.h"
00044 #include "nsWebCrawler.h"
00045 #include "nsViewerApp.h"
00046 
00047 // Helper Classes
00048 #include "nsIGenericFactory.h"
00049 #include "nsString.h"
00050 #include "nsXPIDLString.h"
00051 
00052 // Interfaces needed to be included
00053 #include "nsIDocShellTreeItem.h"
00054 #include "nsIWebProgress.h"
00055 #include "nsIURI.h"
00056 #include "nsIDOMWindow.h"
00057 
00058 struct JSContext;
00059 #include "nsIJSContextStack.h"
00060 
00061 // CIDs
00062 #include "nsWidgetsCID.h"
00063 static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
00064 
00065 //*****************************************************************************
00066 //***    nsWebBrowserChrome: Object Management
00067 //*****************************************************************************
00068 
00069 nsWebBrowserChrome::nsWebBrowserChrome() : mBrowserWindow(nsnull), mTimerSet(PR_FALSE)
00070 
00071 {
00072    mActiveDocuments = 0;
00073    mChromeFlags = 0;
00074    mSizeSet = PR_FALSE;
00075    mContinueModalLoop = PR_FALSE;
00076    mModalStatus = NS_OK;
00077    mChromeLoaded = PR_FALSE;
00078 }
00079 
00080 nsWebBrowserChrome::~nsWebBrowserChrome()
00081 {
00082 }
00083 
00084 //*****************************************************************************
00085 // nsWebBrowserChrome::nsISupports
00086 //*****************************************************************************   
00087 
00088 NS_IMPL_ADDREF(nsWebBrowserChrome)
00089 NS_IMPL_RELEASE(nsWebBrowserChrome)
00090 
00091 NS_INTERFACE_MAP_BEGIN(nsWebBrowserChrome)
00092   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
00093   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
00094   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
00095   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
00096   NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
00097   NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
00098   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
00099 NS_INTERFACE_MAP_END
00100 
00101 //*****************************************************************************
00102 // nsWebBrowserChrome::nsIInterfaceRequestor
00103 //*****************************************************************************   
00104 
00105 NS_IMETHODIMP nsWebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
00106 {
00107   NS_ENSURE_ARG_POINTER(aInstancePtr);
00108   *aInstancePtr = 0;
00109 
00110   /* WindowCreator wants the main content shell when it asks a chrome window
00111      for this interface. */
00112   if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
00113     if (mBrowserWindow && mBrowserWindow->mWebBrowser) {
00114       nsIDOMWindow *contentWin;
00115       mBrowserWindow->mWebBrowser->GetContentDOMWindow(&contentWin);
00116       *aInstancePtr = contentWin;
00117     }
00118     return NS_OK;
00119   }
00120   return QueryInterface(aIID, aInstancePtr);
00121 }
00122 
00123 //*****************************************************************************
00124 // nsWebBrowserChrome::nsIWebBrowserChrome
00125 //*****************************************************************************   
00126 NS_IMETHODIMP nsWebBrowserChrome::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
00127 {
00128    NS_ENSURE_STATE(mBrowserWindow->mStatus);
00129 
00130    switch (aStatusType)
00131      {
00132      case STATUS_SCRIPT:
00133      case STATUS_LINK:
00134        {
00135          NS_ENSURE_STATE(mBrowserWindow->mStatus);
00136          PRUint32 size;
00137          mBrowserWindow->mStatus->SetText(nsAutoString(aStatus), size);
00138        }
00139        break;
00140      }
00141    return NS_OK;
00142 }
00143 
00144 NS_IMETHODIMP nsWebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
00145 {
00146    NS_ERROR("Haven't Implemented this yet");
00147    return NS_ERROR_FAILURE;
00148 }
00149 
00150 NS_IMETHODIMP nsWebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
00151 {
00152   // Unimplemented, and probably will remain so; xpfe windows have docshells,
00153   // not webbrowsers.
00154   NS_ENSURE_ARG_POINTER(aWebBrowser);
00155   *aWebBrowser = 0;
00156   return NS_ERROR_FAILURE;
00157 }
00158 
00159 NS_IMETHODIMP nsWebBrowserChrome::SetChromeFlags(PRUint32 aChromeFlags)
00160 {
00161    mChromeFlags = aChromeFlags;
00162    return NS_OK;
00163 }
00164 
00165 NS_IMETHODIMP nsWebBrowserChrome::GetChromeFlags(PRUint32* aChromeFlags)
00166 {
00167    *aChromeFlags = mChromeFlags;
00168    return NS_OK;
00169 }
00170 
00171 NS_IMETHODIMP nsWebBrowserChrome::DestroyBrowserWindow()
00172 {
00173    ExitModalEventLoop(NS_OK);
00174    return mBrowserWindow->Destroy();
00175 }
00176 
00177 NS_IMETHODIMP nsWebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
00178 {
00179    mSizeSet = PR_TRUE;
00180    mBrowserWindow->mWindow->Resize(aCX, aCY, PR_FALSE);
00181    mBrowserWindow->Layout(aCX, aCY);
00182 
00183    return NS_OK;
00184 }
00185 
00186 NS_IMETHODIMP nsWebBrowserChrome::ShowAsModal()
00187 {
00188   /* Copied from nsXULWindow */
00189   nsCOMPtr<nsIAppShell> appShell(do_CreateInstance(kAppShellCID));
00190   if (!appShell)
00191     return NS_ERROR_FAILURE;
00192 
00193   appShell->Create(0, nsnull);
00194   appShell->Spinup();
00195   // Store locally so it doesn't die on us
00196   nsCOMPtr<nsIWidget> window = mBrowserWindow->mWindow;
00197 
00198   window->SetModal(PR_TRUE);
00199   mContinueModalLoop = PR_TRUE;
00200   EnableParent(PR_FALSE);
00201 
00202   nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
00203   nsresult rv = NS_OK;
00204   if (stack && NS_SUCCEEDED(stack->Push(nsnull))) {
00205     while (NS_SUCCEEDED(rv) && mContinueModalLoop) {
00206       void* data;
00207       PRBool isRealEvent;
00208       PRBool processEvent;
00209 
00210       rv = appShell->GetNativeEvent(isRealEvent, data);
00211       if (NS_SUCCEEDED(rv)) {
00212         window->ModalEventFilter(isRealEvent, data, &processEvent);
00213         if (processEvent)
00214           appShell->DispatchNativeEvent(isRealEvent, data);
00215       }
00216     }
00217 
00218     JSContext* cx;
00219     stack->Pop(&cx);
00220     NS_ASSERTION(!cx, "JSContextStack mismatch");
00221   } else
00222     rv = NS_ERROR_FAILURE;
00223 
00224   mContinueModalLoop = PR_FALSE;
00225   window->SetModal(PR_FALSE);
00226   appShell->Spindown();
00227 
00228   return mModalStatus;
00229 }
00230 
00231 NS_IMETHODIMP nsWebBrowserChrome::IsWindowModal(PRBool *_retval)
00232 {
00233   *_retval = mContinueModalLoop;
00234   return NS_OK;
00235 }
00236 
00237 NS_IMETHODIMP nsWebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
00238 {
00239   if (mContinueModalLoop)
00240     EnableParent(PR_TRUE);
00241   mContinueModalLoop = PR_FALSE;
00242   mModalStatus = aStatus;
00243   return NS_OK;
00244 }
00245 
00246 //*****************************************************************************
00247 // nsIWebBrowserChromeFocus
00248 //*****************************************************************************
00249 
00250 NS_IMETHODIMP
00251 nsWebBrowserChrome::FocusNextElement()
00252 {
00253   return NS_ERROR_NOT_IMPLEMENTED;
00254 }
00255 
00256 NS_IMETHODIMP
00257 nsWebBrowserChrome::FocusPrevElement()
00258 {
00259   return NS_ERROR_NOT_IMPLEMENTED;
00260 }
00261 
00262 //*****************************************************************************
00263 // nsWebBrowserChrome::nsIEmbeddingSiteWindow
00264 //*****************************************************************************   
00265 
00266 NS_IMETHODIMP nsWebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY)
00267 {
00268   PRInt32 x, y, cx, cy;
00269   mBrowserWindow->GetPositionAndSize(&x, &y, &cx, &cy);
00270   if (aFlags & DIM_FLAGS_POSITION)
00271   {
00272     x = aX;
00273     y = aY;
00274   }
00275   if (aFlags & DIM_FLAGS_SIZE_INNER || aFlags & DIM_FLAGS_SIZE_OUTER)
00276   {
00277     cx = aCX;
00278     cy = aCY;
00279   }
00280   return mBrowserWindow->SetPositionAndSize(aX, aY, aCX, aCY, PR_TRUE);
00281 }
00282 
00283 NS_IMETHODIMP nsWebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
00284 {
00285   PRInt32 x, y, cx, cy;
00286   mBrowserWindow->GetPositionAndSize(&x, &y, &cx, &cy);
00287   if (aFlags & DIM_FLAGS_POSITION)
00288   {
00289     if(aX)
00290       *aX = x;
00291     if(aY)
00292       *aY = y;
00293   }
00294   if (aFlags & DIM_FLAGS_SIZE_INNER || aFlags & DIM_FLAGS_SIZE_OUTER)
00295   {
00296     if(aCX)
00297       *aCX = cx;
00298     if(aCY)
00299       *aCY = cy;
00300   }
00301   return NS_OK;
00302 }
00303 
00304 NS_IMETHODIMP nsWebBrowserChrome::GetSiteWindow(void ** aParentNativeWindow)
00305 {
00306    NS_ENSURE_ARG_POINTER(aParentNativeWindow);
00307 
00308    if (mBrowserWindow) {
00309      nsCOMPtr<nsIWidget> window;
00310      mBrowserWindow->GetWindow(getter_AddRefs(window));
00311      if (window) {
00312        *aParentNativeWindow = window->GetNativeData(NS_NATIVE_WINDOW);
00313      }
00314    }
00315    return NS_OK;
00316 }
00317 
00318 NS_IMETHODIMP nsWebBrowserChrome::GetVisibility(PRBool *aVisibility)
00319 {
00320   return mBrowserWindow->GetVisibility(aVisibility);
00321 }
00322 
00323 NS_IMETHODIMP nsWebBrowserChrome::SetVisibility(PRBool aVisibility)
00324 {
00325   if ((mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) && !mChromeLoaded) {
00326     // suppress showing the window until the chrome has completely loaded
00327     return NS_OK;
00328   } else
00329     return mBrowserWindow->SetVisibility(aVisibility);
00330 }
00331 
00332 NS_IMETHODIMP nsWebBrowserChrome::SetFocus()
00333 {  
00334    return mBrowserWindow->SetFocus();
00335 }
00336 
00337 NS_IMETHODIMP nsWebBrowserChrome::GetTitle(PRUnichar** aTitle)
00338 {
00339    return mBrowserWindow->GetTitle(aTitle);
00340 }
00341 
00342 NS_IMETHODIMP nsWebBrowserChrome::SetTitle(const PRUnichar* aTitle)
00343 {
00344    mBrowserWindow->mTitle = aTitle;
00345 
00346    nsAutoString newTitle(aTitle);
00347 
00348    newTitle.AppendLiteral(" - Raptor");
00349    
00350    mBrowserWindow->SetTitle(newTitle.get());
00351    return NS_OK;
00352 }
00353 
00354 //*****************************************************************************
00355 // nsWebBrowserChrome::nsIWebProgressListener
00356 //*****************************************************************************   
00357 
00358 NS_IMETHODIMP
00359 nsWebBrowserChrome::OnProgressChange(nsIWebProgress* aProgress,
00360                                       nsIRequest* aRequest,
00361                                       PRInt32 aCurSelfProgress,
00362                                       PRInt32 aMaxSelfProgress, 
00363                                       PRInt32 aCurTotalProgress,
00364                                       PRInt32 aMaxTotalProgress)
00365 {
00366   mProgress = aCurTotalProgress;
00367   mMaxProgress = aMaxTotalProgress;
00368   if(mBrowserWindow->mStatus) {
00369     nsAutoString buf;
00370     PRUint32 size;
00371 
00372     buf.AppendLiteral("Loaded ");
00373     buf.AppendInt(mCurrent);
00374     buf.AppendLiteral(" of ");
00375     buf.AppendInt(mTotal);
00376     buf.AppendLiteral(" items.  (");
00377     buf.AppendInt(mProgress);
00378     buf.AppendLiteral(" bytes of ");
00379     buf.AppendInt(mMaxProgress);
00380     buf.Append(NS_LITERAL_STRING(" bytes)"));
00381 
00382     mBrowserWindow->mStatus->SetText(buf,size);
00383   }
00384    return NS_OK;
00385 }
00386 
00387 NS_IMETHODIMP
00388 nsWebBrowserChrome::OnStateChange(nsIWebProgress* aProgress,
00389                                   nsIRequest* aRequest,
00390                                   PRUint32 aProgressStateFlags,
00391                                   nsresult aStatus)
00392 {
00393   if (aProgressStateFlags & STATE_START) {
00394     if (aProgressStateFlags & STATE_IS_NETWORK) {
00395       OnWindowActivityStart();
00396       OnLoadStart(aRequest);
00397     }
00398     if (aProgressStateFlags & STATE_IS_REQUEST) {
00399       mTotal += 1;
00400     }
00401   }
00402 
00403   if (aProgressStateFlags & STATE_STOP) {
00404     if (aProgressStateFlags & STATE_IS_REQUEST) {
00405       mCurrent += 1;
00406 
00407       if(mBrowserWindow->mStatus) {
00408         nsAutoString buf;
00409         PRUint32 size;
00410 
00411         buf.AppendLiteral("Loaded ");
00412         buf.AppendInt(mCurrent);
00413         buf.AppendLiteral(" of ");
00414         buf.AppendInt(mTotal);
00415         buf.AppendLiteral(" items.  (");
00416         buf.AppendInt(mProgress);
00417         buf.AppendLiteral(" bytes of ");
00418         buf.AppendInt(mMaxProgress);
00419         buf.Append(NS_LITERAL_STRING(" bytes)"));
00420 
00421         mBrowserWindow->mStatus->SetText(buf,size);
00422       }
00423     }
00424 
00425     if (aProgressStateFlags & STATE_IS_NETWORK) {
00426       OnLoadFinished(aRequest, aProgressStateFlags);
00427       OnWindowActivityFinished();
00428     }
00429   }
00430 
00431   if (aProgressStateFlags & STATE_TRANSFERRING) {
00432     OnStatusTransferring(aRequest);
00433   }
00434 
00435   return NS_OK;
00436 }
00437 
00438 NS_IMETHODIMP nsWebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress,
00439                                                    nsIRequest* aRequest,
00440                                                    nsIURI* aURI)
00441 {
00442    nsCAutoString spec;
00443 
00444    if(aURI)
00445       aURI->GetSpec(spec);
00446 
00447    PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load
00448    if (aWebProgress) {
00449      nsCOMPtr<nsIDOMWindow>  domWindow;
00450      nsCOMPtr<nsIDOMWindow>  topDomWindow;
00451      aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
00452      if (domWindow) { // Get root domWindow
00453        domWindow->GetTop(getter_AddRefs(topDomWindow));
00454      }
00455      if (domWindow != topDomWindow)
00456        isSubFrameLoad = PR_TRUE;
00457    }
00458 
00459    if(mBrowserWindow->mLocation && !isSubFrameLoad)
00460       {
00461       PRUint32 size;
00462       NS_ConvertUTF8toUCS2 tmp(spec);
00463       mBrowserWindow->mLocation->SetText(tmp,size);
00464       }
00465 
00466    return NS_OK;
00467 }
00468 
00469 NS_IMETHODIMP 
00470 nsWebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress,
00471                                    nsIRequest* aRequest,
00472                                    nsresult aStatus,
00473                                    const PRUnichar* aMessage)
00474 {
00475     if (mBrowserWindow && mBrowserWindow->mStatus) {
00476         PRUint32 size;
00477         mBrowserWindow->mStatus->SetText(nsAutoString(aMessage), size);
00478     }
00479     return NS_OK;
00480 }
00481 
00482 NS_IMETHODIMP 
00483 nsWebBrowserChrome::OnSecurityChange(nsIWebProgress *aWebProgress, 
00484                                      nsIRequest *aRequest, 
00485                                      PRUint32 state)
00486 {
00487     return NS_OK;
00488 }
00489 
00490 //*****************************************************************************
00491 // nsWebBrowserChrome: Helpers
00492 //*****************************************************************************   
00493 
00494 //*****************************************************************************
00495 // nsWebBrowserChrome: Accessors
00496 //*****************************************************************************   
00497 
00498 void nsWebBrowserChrome::BrowserWindow(nsBrowserWindow* aBrowserWindow)
00499 {
00500    mBrowserWindow = aBrowserWindow;
00501 }
00502 
00503 nsBrowserWindow* nsWebBrowserChrome::BrowserWindow()
00504 {
00505    return mBrowserWindow;
00506 }
00507 
00508 //*****************************************************************************
00509 // nsWebBrowserChrome: Status Change Handling
00510 //*****************************************************************************   
00511 
00512 void nsWebBrowserChrome::OnLoadStart(nsIRequest* aRequest)
00513 {
00514 mCurrent=mTotal=mProgress=mMaxProgress=0;
00515 
00516   mBrowserWindow->mLoadStartTime = PR_Now();
00517 
00518   if (aRequest) {
00519     nsresult rv;
00520     nsCOMPtr<nsIChannel> channel;
00521     nsCOMPtr<nsIURI> uri;
00522 
00523     channel = do_QueryInterface(aRequest, &rv);
00524     if (NS_SUCCEEDED(rv)) {
00525       channel->GetURI(getter_AddRefs(uri));
00526      
00527 #ifdef MOZ_PERF_METRICS
00528       if (PR_FALSE == mTimerSet) {
00529         nsCAutoString url;
00530         nsresult rv = NS_OK;
00531         rv = uri->GetSpec(url);
00532         if (NS_SUCCEEDED(rv))
00533           MOZ_TIMER_LOG(("*** Timing layout processes on url: '%s', WebBrowserChrome: %p\n", url.get(), this));
00534         MOZ_TIMER_DEBUGLOG(("Reset and start: nsWebBrowserChrome::OnLoadStart(), this=%p\n", this));
00535         MOZ_TIMER_RESET(mTotalTime);
00536         MOZ_TIMER_START(mTotalTime);
00537         mTimerSet = PR_TRUE;
00538       }
00539 #endif
00540 
00541       if(mBrowserWindow->mStatus) {
00542         nsCAutoString uriString;
00543 
00544         uri->GetSpec(uriString);
00545 
00546         NS_ConvertUTF8toUCS2 url(uriString);
00547         url.AppendLiteral(": start");
00548         PRUint32 size;
00549         mBrowserWindow->mStatus->SetText(url,size);
00550       }
00551     }
00552   } // if (aChannel)
00553 }
00554 
00555 void nsWebBrowserChrome::OnLoadFinished(nsIRequest* aRequest,
00556                                         PRInt32 aProgressStatusFlags)
00557 {
00558 #ifdef MOZ_PERF_METRICS
00559   if ( /*(aProgressStatusFlags & nsIWebProgress::flag_win_stop) && */mTimerSet ) {
00560     MOZ_TIMER_DEBUGLOG(("Stop: nsWebShell::OnEndDocumentLoad(), this=%p\n", this));
00561     MOZ_TIMER_STOP(mTotalTime);
00562     MOZ_TIMER_LOG(("Total (Layout + Page Load) Time (webBrowserChrome=%p): ", this));
00563     MOZ_TIMER_PRINT(mTotalTime);
00564     mTimerSet = PR_FALSE;
00565   }
00566 #endif
00567 
00568   nsCAutoString uriString;
00569   if(aRequest) {
00570     nsresult rv;
00571     nsCOMPtr<nsIChannel> channel;
00572     nsCOMPtr<nsIURI> uri;
00573 
00574     channel = do_QueryInterface(channel, &rv);
00575     if (NS_SUCCEEDED(rv)) {
00576       channel->GetURI(getter_AddRefs(uri));
00577 
00578       uri->GetSpec(uriString);
00579     }
00580   }  
00581   NS_ConvertUTF8toUCS2 msg(uriString);
00582 
00583   PRTime endLoadTime = PR_Now();
00584   if(mBrowserWindow->mShowLoadTimes)
00585      {
00586      printf("Loading ");
00587      fputs(NS_LossyConvertUCS2toASCII(msg).get(), stdout);
00588      PRTime delta;
00589      LL_SUB(delta, endLoadTime, mBrowserWindow->mLoadStartTime);
00590      double usecs;
00591      LL_L2D(usecs, delta);
00592      printf(" took %g milliseconds\n", usecs / 1000.0);
00593      }
00594 
00595   if(mBrowserWindow->mStatus)
00596      {
00597 //     PRUint32 size;
00598 
00599      msg.AppendLiteral(" done.");
00600 
00602       }
00603 }
00604 
00605 void nsWebBrowserChrome::OnStatusDNS(nsIChannel* aChannel)
00606 {
00607 }
00608 
00609 void nsWebBrowserChrome::OnStatusConnecting(nsIChannel* aChannel)
00610 {
00611    nsCAutoString uriString;
00612    if(aChannel)
00613       {
00614       nsCOMPtr<nsIURI> uri;
00615       aChannel->GetURI(getter_AddRefs(uri));
00616 
00617       uri->GetSpec(uriString);
00618       }
00619    
00620    NS_ConvertUTF8toUCS2 msg(NS_LITERAL_CSTRING("Connecting to ") + uriString);
00621       
00622    PRUint32 size;
00623    mBrowserWindow->mStatus->SetText(msg,size);
00624 }
00625 
00626 void nsWebBrowserChrome::OnStatusRedirecting(nsIChannel* aChannel)
00627 {
00628 }
00629 
00630 void nsWebBrowserChrome::OnStatusNegotiating(nsIChannel* aChannel)
00631 {
00632 }
00633 
00634 void nsWebBrowserChrome::OnStatusTransferring(nsIRequest* aRequest)
00635 {
00636 }
00637 
00638 void nsWebBrowserChrome::OnWindowActivityStart()
00639 {
00640    if(mBrowserWindow->mThrobber)
00641       mBrowserWindow->mThrobber->Start();
00642 
00643 }
00644 
00645 void nsWebBrowserChrome::OnWindowActivityFinished()
00646 {
00647    if(mBrowserWindow->mThrobber)
00648       mBrowserWindow->mThrobber->Stop();
00649 
00650    if (!mSizeSet && (mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
00651      nsCOMPtr<nsIDOMWindow> contentWin;
00652      mBrowserWindow->mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin));
00653      if (contentWin)
00654        contentWin->SizeToContent();
00655      mBrowserWindow->SetVisibility(PR_TRUE);
00656      mChromeLoaded = PR_TRUE;
00657    }
00658 }
00659 
00660 void nsWebBrowserChrome::EnableParent(PRBool aEnable)
00661 {
00662 }