WindowCreator *creatorCallback = new WindowCreator(); if (creatorCallback) { nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)); if (windowCreator) { nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { wwatch->SetWindowCreator(windowCreator); return NS_OK; } } } return NS_ERROR_FAILURE;
nsCOMPtr<nsIWindowCreator> creator(new WindowCreator()); if (!creator) return NS_ERROR_OUT_OF_MEMORY;  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (!wwatch) return NS_ERROR_UNEXPECTED;  return wwatch->SetWindowCreator(creator);
nsresult InitializeWindowCreator(){    // create an nsWindowCreator and give it to the WindowWatcher service    WindowCreator *creatorCallback = new WindowCreator();    if (creatorCallback)    {        nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));        if (windowCreator)        {            nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));            if (wwatch)            {                wwatch->SetWindowCreator(windowCreator);                return NS_OK;            }        }    }    return NS_ERROR_FAILURE;}