windowEnumerator->HasMoreElements(&more); while (more) { nsCOMPtr<nsISupports> protoWindow; rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow)); if (NS_SUCCEEDED(rv) && protoWindow) { nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(protoWindow)); if (window) window->Close();
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsISimpleEnumerator> windowEnumerator; rv = windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator));  if (NS_SUCCEEDED(rv)) { PRBool more;  while (1) { rv = windowEnumerator->HasMoreElements(&more); if (NS_FAILED(rv) || !more) break;  nsCOMPtr<nsISupports> isupports; rv = windowEnumerator->GetNext(getter_AddRefs(isupports)); if (NS_FAILED(rv)) break;  nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(isupports); NS_ASSERTION(window != nsnull, "not an nsIDOMWindow"); if (! window) continue;  window->Close();
NS_IMETHODIMP nsAppShellService::Quit(){	if ( mQuiting )		return NS_OK; nsresult rv; mQuiting = PR_TRUE;	// now step through all opened registered windows and close them.  NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);  if (NS_SUCCEEDED(rv)) {    nsCOMPtr<nsISimpleEnumerator> windowEnumerator;    if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {      PRBool more;      // get the (main) webshell for each window in the enumerator      windowEnumerator->HasMoreElements(&more);      while (more) {        nsCOMPtr<nsISupports> protoWindow;        rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));        if (NS_SUCCEEDED(rv) && protoWindow) {          nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(protoWindow));          if (window)            window->Close();        }        windowEnumerator->HasMoreElements(&more);      }    }   }  mQuiting = PR_FALSE;   return mAppShell->Exit();}