nsCOMPtr<nsIDOMWindow>         content; nsCOMPtr<nsIDOMWindowInternal> internalContent; nsCOMPtr<nsIDOMLocation>       location;
GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) );
nsNativeAppSupportWin::OpenBrowserWindow( const char *args ) {    nsresult rv = NS_OK;    // Open the argument URL in the most recently used Navigator window.    // If there is no Nav window, open a new one.    nsCOMPtr<nsIWindowMediator>    med( do_GetService( kWindowMediatorCID ) );    nsCOMPtr<nsIDOMWindowInternal> navWin;    nsCOMPtr<nsIDOMWindow>         content;    nsCOMPtr<nsIDOMWindowInternal> internalContent;    nsCOMPtr<nsIDOMLocation>       location;    // This isn't really a loop.  We just use "break" statements to fall    // out to the OpenWindow call when things go awry.    do {        if ( !med ) {            break;        }        // Get most recently used Nav window.        med->GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) );        if ( !navWin ) {            // Have to open a new one.            break;        }        // Get content window.        navWin->GetContent( getter_AddRefs( content ) );        if ( !content ) {            break;        }        // Convert that to internal interface.        internalContent = do_QueryInterface( content );        if ( !internalContent ) {            break;        }        // Get location.        internalContent->GetLocation( getter_AddRefs( location ) );        if ( !location ) {            break;        }        // Set up environment.        SafeJSContext context;        if ( NS_FAILED( context.Push() ) ) {            break;        }        // Set href.        nsAutoString url; url.AssignWithConversion( args );        if ( NS_FAILED( location->SetHref( url ) ) ) {            break;        }        // Finally, if we get here, we're done.        return NS_OK;    } while ( PR_FALSE );    // Last resort is to open a brand new window.    return OpenWindow( "chrome://navigator/content", args );}