Back to index

lightning-sunbird  0.9+nobinonly
GeckoWindowCreator.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: Mozilla-sample-code 1.0
00003  *
00004  * Copyright (c) 2002 Netscape Communications Corporation and
00005  * other contributors
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this Mozilla sample software and associated documentation files
00009  * (the "Software"), to deal in the Software without restriction, including
00010  * without limitation the rights to use, copy, modify, merge, publish,
00011  * distribute, sublicense, and/or sell copies of the Software, and to permit
00012  * persons to whom the Software is furnished to do so, subject to the
00013  * following conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be included
00016  * in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00021  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00023  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00024  * DEALINGS IN THE SOFTWARE.
00025  *
00026  * Contributor(s):
00027  *   Adam Lock <adamlock@netscape.com>
00028  *
00029  * ***** END LICENSE BLOCK ***** */
00030 
00031 #include "GeckoWindowCreator.h"
00032 #include "GeckoContainer.h"
00033 
00034 #include "nsIWebBrowserChrome.h"
00035 #include "nsString.h"
00036 
00037 GeckoWindowCreator::GeckoWindowCreator()
00038 {
00039 }
00040 
00041 GeckoWindowCreator::~GeckoWindowCreator()
00042 {
00043 }
00044 
00045 NS_IMPL_ISUPPORTS1(GeckoWindowCreator, nsIWindowCreator)
00046 
00047 NS_IMETHODIMP
00048 GeckoWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *parent,
00049                                   PRUint32 chromeFlags,
00050                                   nsIWebBrowserChrome **_retval)
00051 {
00052     NS_ENSURE_ARG_POINTER(_retval);
00053 
00054     *_retval = nsnull;
00055 
00056     if (!parent)
00057         return NS_ERROR_FAILURE;
00058 
00059     nsCOMPtr<nsIGeckoContainer> geckoContainer = do_QueryInterface(parent);
00060     if (!geckoContainer)
00061         return NS_ERROR_FAILURE;
00062 
00063     nsCAutoString role;
00064     geckoContainer->GetRole(role);
00065     if (stricmp(role.get(), "browser") == 0)
00066     {
00067         GeckoContainerUI *pUI = NULL;
00068         geckoContainer->GetContainerUI(&pUI);
00069         if (pUI)
00070         {
00071             return pUI->CreateBrowserWindow(chromeFlags, parent, _retval);
00072         }
00073     }
00074 
00075     return NS_ERROR_FAILURE;
00076 }