if (chromeMask & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) { nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID)); NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE); nsCOMPtr<nsIXULWindow> newWindow; appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, PR_FALSE, chromeMask, NS_SIZETOCONTENT, NS_SIZETOCONTENT, getter_AddRefs(newWindow));  NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE); nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow)); if (browserChrome) browserChrome->SetChromeFlags(chromeMask);  nsCOMPtr<nsIDocShell> docShell; newWindow->GetDocShell(getter_AddRefs(docShell)); CallQueryInterface(docShell, _retval);  return NS_OK; }
GtkMozEmbedListenerImpl::NewBrowser(PRUint32 chromeMask,				    nsIDocShellTreeItem **_retval){  GtkMozEmbed *newEmbed = NULL;  gtk_signal_emit(GTK_OBJECT(mEmbed), moz_embed_signals[NEW_WINDOW],		  &newEmbed, (guint)chromeMask);  if (newEmbed)  {   // We need to create a new top level window and then enter a nested   // loop. Eventually the new window will be told that it has loaded,   // at which time we know it is safe to spin out of the nested loop   // and allow the opening code to proceed.    // The window _must_ be realized before we pass it back to the    // function that created it. Functions that create new windows    // will do things like GetDocShell() and the widget has to be    // realized before that can happen.    gtk_widget_realize(GTK_WIDGET(newEmbed));    GtkMozEmbedPrivate *embed_private = (GtkMozEmbedPrivate *)newEmbed->data;   // now that the content area has been loaded, get the   // nsIDocShellTreeItem for the content area   // get the browser as an item   nsCOMPtr<nsIDocShellTreeItem> browserAsItem;   browserAsItem = do_QueryInterface(embed_private->mWebBrowser);   // get the owner for that item   nsCOMPtr<nsIDocShellTreeOwner> treeOwner;   browserAsItem->GetTreeOwner(getter_AddRefs(treeOwner));   NS_ASSERTION(treeOwner, "failed to get tree owner");   // get the primary content shell as an item   return treeOwner->GetPrimaryContentShell(_retval);  }  return NS_OK;}