1998-12-03 04:35:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsIAppShellService.h"
|
|
|
|
#include "nsISupportsArray.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-12-03 04:35:53 +03:00
|
|
|
#include "nsIURL.h"
|
1999-01-21 10:22:58 +03:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
|
|
|
#include "nsXPComCIID.h"
|
|
|
|
#include "nsXPComFactory.h" /* template implementation of a XPCOM factory */
|
1998-12-03 04:35:53 +03:00
|
|
|
|
|
|
|
#include "nsIAppShell.h"
|
|
|
|
#include "nsIWidget.h"
|
1999-02-17 19:12:10 +03:00
|
|
|
#include "nsIWebShellWindow.h"
|
1998-12-03 04:35:53 +03:00
|
|
|
#include "nsWebShellWindow.h"
|
1999-04-02 00:21:41 +04:00
|
|
|
#include "nsIGlobalHistory.h"
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-03-19 09:15:00 +03:00
|
|
|
/* For Javascript Namespace Access */
|
|
|
|
#include "nsDOMCID.h"
|
|
|
|
#include "nsIScriptNameSetRegistry.h"
|
1999-03-19 09:29:10 +03:00
|
|
|
#include "nsAppShellNameSet.h"
|
1999-03-19 09:15:00 +03:00
|
|
|
|
1998-12-03 04:35:53 +03:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-02-10 19:38:51 +03:00
|
|
|
#include "nsIStreamObserver.h"
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-02-04 21:17:02 +03:00
|
|
|
#ifdef MOZ_FULLCIRCLE
|
|
|
|
#include "fullsoft.h"
|
|
|
|
#endif
|
|
|
|
|
1999-05-07 09:32:31 +04:00
|
|
|
#ifdef XP_PC
|
|
|
|
#include "nsIPICS.h"
|
|
|
|
static NS_DEFINE_IID(kIPICSIID, NS_IPICS_IID);
|
|
|
|
static NS_DEFINE_IID(kPICSCID, NS_PICS_CID);
|
|
|
|
#endif
|
|
|
|
|
1998-12-03 04:35:53 +03:00
|
|
|
/* Define Class IDs */
|
1999-01-21 10:22:58 +03:00
|
|
|
static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID);
|
|
|
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1999-03-19 09:15:00 +03:00
|
|
|
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
|
1999-04-02 00:21:41 +04:00
|
|
|
static NS_DEFINE_IID(kCGlobalHistoryCID, NS_GLOBALHISTORY_CID);
|
1998-12-03 04:35:53 +03:00
|
|
|
|
|
|
|
/* Define Interface IDs */
|
|
|
|
|
1999-01-21 10:22:58 +03:00
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
|
|
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
|
|
|
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
|
|
|
|
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
1999-02-17 19:12:10 +03:00
|
|
|
static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID);
|
1999-03-19 09:15:00 +03:00
|
|
|
static NS_DEFINE_IID(kIScriptNameSetRegistryIID, NS_ISCRIPTNAMESETREGISTRY_IID);
|
1999-04-02 00:21:41 +04:00
|
|
|
static NS_DEFINE_IID(kIGlobalHistoryIID, NS_IGLOBALHISTORY_IID);
|
1998-12-03 04:35:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
class nsAppShellService : public nsIAppShellService
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAppShellService(void);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Initialize(void);
|
|
|
|
NS_IMETHOD Run(void);
|
|
|
|
NS_IMETHOD Shutdown(void);
|
1999-03-20 07:13:09 +03:00
|
|
|
NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIURL* aUrl,
|
1999-05-05 03:36:42 +04:00
|
|
|
PRBool showWindow,
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
1999-03-20 07:13:09 +03:00
|
|
|
NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIURL* aUrl,
|
1999-05-05 03:36:42 +04:00
|
|
|
PRBool showWindow,
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
1999-02-19 00:52:27 +03:00
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
1999-05-10 22:31:42 +04:00
|
|
|
NS_IMETHOD RunModalDialog( nsIWebShellWindow * aParent,
|
|
|
|
nsIURL* aUrl,
|
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver,
|
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
1999-03-20 07:13:09 +03:00
|
|
|
NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow);
|
|
|
|
NS_IMETHOD RegisterTopLevelWindow(nsIWebShellWindow* aWindow);
|
|
|
|
NS_IMETHOD UnregisterTopLevelWindow(nsIWebShellWindow* aWindow);
|
1998-12-03 04:35:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsAppShellService();
|
|
|
|
|
|
|
|
nsIAppShell* mAppShell;
|
|
|
|
nsISupportsArray* mWindowList;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
nsAppShellService::nsAppShellService()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
|
|
|
mAppShell = nsnull;
|
|
|
|
mWindowList = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAppShellService::~nsAppShellService()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mAppShell);
|
|
|
|
NS_IF_RELEASE(mWindowList);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implement the nsISupports methods...
|
|
|
|
*/
|
|
|
|
NS_IMPL_ISUPPORTS(nsAppShellService, kIAppShellServiceIID);
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAppShellService::Initialize(void)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-05-07 09:32:31 +04:00
|
|
|
#ifdef XP_PC
|
|
|
|
nsIPICS *pics = NULL;
|
|
|
|
#endif
|
1999-02-04 21:17:02 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_FULLCIRCLE
|
1999-02-05 01:57:13 +03:00
|
|
|
FCInitialize();
|
1999-02-04 21:17:02 +03:00
|
|
|
#endif
|
1999-01-21 10:22:58 +03:00
|
|
|
// Create the Event Queue for the UI thread...
|
1999-03-19 09:15:00 +03:00
|
|
|
nsIEventQueueService* eventQService;
|
1999-01-21 10:22:58 +03:00
|
|
|
rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
|
|
|
kIEventQueueServiceIID,
|
1999-03-19 09:15:00 +03:00
|
|
|
(nsISupports **)&eventQService);
|
1999-01-21 10:22:58 +03:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
// XXX: What if this fails?
|
1999-03-19 09:15:00 +03:00
|
|
|
rv = eventQService->CreateThreadEventQueue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register the nsAppShellNameSet with the global nameset registry...
|
|
|
|
nsIScriptNameSetRegistry *registry;
|
|
|
|
rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
|
|
|
kIScriptNameSetRegistryIID,
|
|
|
|
(nsISupports **)®istry);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
goto done;
|
1999-01-21 10:22:58 +03:00
|
|
|
}
|
1999-03-19 09:15:00 +03:00
|
|
|
|
|
|
|
nsAppShellNameSet* nameSet;
|
|
|
|
nameSet = new nsAppShellNameSet();
|
|
|
|
registry->AddExternalNameSet(nameSet);
|
1999-03-22 09:27:36 +03:00
|
|
|
/* XXX: do we need to release this service? When we do, it get deleted,and our name is lost. */
|
1999-01-21 10:22:58 +03:00
|
|
|
|
1999-03-19 09:15:00 +03:00
|
|
|
// Create the toplevel window list...
|
1998-12-03 04:35:53 +03:00
|
|
|
rv = NS_NewISupportsArray(&mWindowList);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
1999-05-07 09:32:31 +04:00
|
|
|
#ifdef XP_PC
|
|
|
|
rv = nsComponentManager::CreateInstance(kPICSCID,
|
|
|
|
NULL,
|
|
|
|
kIPICSIID,
|
|
|
|
(void **) &pics);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1999-04-02 00:21:41 +04:00
|
|
|
// Initialise the global History
|
|
|
|
nsIGlobalHistory * gHistory;
|
|
|
|
rv = nsServiceManager::GetService(kCGlobalHistoryCID,
|
|
|
|
kIGlobalHistoryIID,
|
|
|
|
(nsISupports **)&gHistory);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
gHistory->Init();
|
|
|
|
|
1998-12-03 04:35:53 +03:00
|
|
|
// Create widget application shell
|
1999-03-09 12:44:27 +03:00
|
|
|
rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID,
|
1998-12-03 04:35:53 +03:00
|
|
|
(void**)&mAppShell);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = mAppShell->Create(0, nsnull);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAppShellService::Run(void)
|
|
|
|
{
|
|
|
|
return mAppShell->Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAppShellService::Shutdown(void)
|
|
|
|
{
|
1999-02-17 19:18:17 +03:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
mAppShell->Exit();
|
|
|
|
#else
|
1999-02-17 19:12:10 +03:00
|
|
|
while (mWindowList->Count() > 0) {
|
|
|
|
nsISupports * winSupports = mWindowList->ElementAt(0);
|
|
|
|
nsCOMPtr<nsIWidget> window(do_QueryInterface(winSupports));
|
|
|
|
if (window) {
|
|
|
|
mWindowList->RemoveElementAt(0);
|
|
|
|
CloseTopLevelWindow(window);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIWebShellWindow> webShellWin(do_QueryInterface(winSupports));
|
|
|
|
if (webShellWin) {
|
|
|
|
nsIWidget * win;
|
|
|
|
webShellWin->GetWidget(win);
|
|
|
|
CloseTopLevelWindow(win);
|
|
|
|
}
|
|
|
|
//nsCOMPtr<nsIWebShellContainer> wsc(do_QueryInterface(winSupports));
|
|
|
|
//if (wsc) {
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-02-17 19:18:17 +03:00
|
|
|
#endif
|
1998-12-03 04:35:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new top level window and display the given URL within it...
|
1999-01-21 10:22:58 +03:00
|
|
|
*
|
1999-02-26 05:22:42 +03:00
|
|
|
* @param aParent - parent for the window to be created (generally null;
|
|
|
|
* included for compatibility with dialogs).
|
|
|
|
* (currently unused).
|
|
|
|
* @param aURL - location of XUL window contents description
|
1999-05-05 03:36:42 +04:00
|
|
|
* @param aShowWindow - whether or not to show the window initially.
|
1999-02-26 05:22:42 +03:00
|
|
|
* @param anObserver - a stream observer to give to the new window
|
|
|
|
* @param aConstructionCallbacks - methods which will be called during
|
|
|
|
* window construction. can be null.
|
|
|
|
* @param aInitialWidth - width of window, in pixels (currently unused)
|
|
|
|
* @param aInitialHeight - height of window, in pixels (currently unused)
|
1998-12-03 04:35:53 +03:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
1999-03-20 07:13:09 +03:00
|
|
|
nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
|
1999-05-05 03:36:42 +04:00
|
|
|
nsIURL* aUrl, PRBool showWindow,
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
1999-02-19 00:52:27 +03:00
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
1998-12-03 04:35:53 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsWebShellWindow* window;
|
|
|
|
|
|
|
|
window = new nsWebShellWindow();
|
|
|
|
if (nsnull == window) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
} else {
|
1999-03-14 11:24:21 +03:00
|
|
|
// temporarily disabling parentage because non-Windows platforms
|
|
|
|
// seem to be interpreting it in unexpected ways.
|
1999-05-05 03:36:42 +04:00
|
|
|
rv = window->Initialize((nsIWebShellWindow *) nsnull, mAppShell, aUrl,
|
1999-02-26 05:22:42 +03:00
|
|
|
anObserver, aCallbacks,
|
|
|
|
aInitialWidth, aInitialHeight);
|
1998-12-03 04:35:53 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-03-20 07:13:09 +03:00
|
|
|
rv = window->QueryInterface(kIWebShellWindowIID, (void **) &aResult);
|
|
|
|
RegisterTopLevelWindow(window);
|
1999-05-05 03:36:42 +04:00
|
|
|
if (showWindow)
|
|
|
|
window->Show(PR_TRUE);
|
1998-12-03 04:35:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-02-15 08:38:15 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-03-20 07:13:09 +03:00
|
|
|
nsAppShellService::CloseTopLevelWindow(nsIWebShellWindow* aWindow)
|
1999-02-15 08:38:15 +03:00
|
|
|
{
|
1999-03-27 03:09:04 +03:00
|
|
|
return aWindow->Close();
|
1999-02-15 08:38:15 +03:00
|
|
|
}
|
|
|
|
|
1999-02-10 19:38:51 +03:00
|
|
|
/*
|
1999-02-26 05:22:42 +03:00
|
|
|
* Like CreateTopLevelWindow, but with dialog window borders. This
|
|
|
|
* method is necessary because of the current misfortune that the window
|
|
|
|
* is created before its XUL description has been parsed, so the description
|
|
|
|
* can't affect attributes like window type.
|
1999-02-10 19:38:51 +03:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
1999-03-20 07:13:09 +03:00
|
|
|
nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent,
|
1999-05-05 03:36:42 +04:00
|
|
|
nsIURL* aUrl, PRBool showWindow,
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver,
|
1999-02-26 05:22:42 +03:00
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
1999-02-19 00:52:27 +03:00
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
1999-02-10 19:38:51 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsWebShellWindow* window;
|
|
|
|
|
|
|
|
window = new nsWebShellWindow();
|
|
|
|
if (nsnull == window) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
} else {
|
1999-03-14 11:24:21 +03:00
|
|
|
// temporarily disabling parentage because non-Windows platforms
|
|
|
|
// seem to be interpreting it in unexpected ways.
|
1999-05-05 03:36:42 +04:00
|
|
|
rv = window->Initialize((nsIWebShellWindow *) nsnull, mAppShell, aUrl,
|
1999-02-26 05:22:42 +03:00
|
|
|
anObserver, aCallbacks,
|
1999-02-19 00:52:27 +03:00
|
|
|
aInitialWidth, aInitialHeight);
|
1999-02-10 19:38:51 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-03-20 07:13:09 +03:00
|
|
|
rv = window->QueryInterface(kIWebShellWindowIID, (void **) &aResult);
|
|
|
|
RegisterTopLevelWindow(window);
|
1999-05-05 03:36:42 +04:00
|
|
|
if (showWindow)
|
|
|
|
window->Show(PR_TRUE);
|
1999-02-10 19:38:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-02-15 08:38:15 +03:00
|
|
|
|
1999-05-10 22:31:42 +04:00
|
|
|
/* CreateDialogWindow, run it modally, and destroy it. To make initial control
|
|
|
|
settings or get information out of the dialog before dismissal, use
|
|
|
|
event handlers. This wrapper method is desirable because of the
|
|
|
|
complications creeping in to the modal window story: there's a lot of setup.
|
|
|
|
See the code.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAppShellService::RunModalDialog(
|
|
|
|
nsIWebShellWindow *aParent, nsIURL* aUrl,
|
|
|
|
nsIWebShellWindow*& aResult, nsIStreamObserver *anObserver,
|
|
|
|
nsIXULWindowCallbacks *aCallbacks,
|
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
|
|
|
{
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef XP_PC // XXX: Won't work with any other platforms yet.
|
|
|
|
// First push a nested event queue for event processing from netlib
|
|
|
|
// onto our UI thread queue stack.
|
|
|
|
// nsCOMPtr<nsIEventQueue> innerQueue;
|
|
|
|
NS_WITH_SERVICE(nsIEventQueueService, eQueueService, kEventQueueServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("RunModalDialog unable to obtain eventqueue service.");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
eQueueService->PushThreadEventQueue();
|
|
|
|
#endif
|
|
|
|
|
1999-05-11 23:42:14 +04:00
|
|
|
rv = CreateDialogWindow(aParent, aUrl, PR_TRUE, aResult, anObserver, aCallbacks,
|
1999-05-10 22:31:42 +04:00
|
|
|
aInitialWidth, aInitialHeight);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIWidget> parentWindowWidgetThing;
|
|
|
|
nsresult gotParent;
|
|
|
|
gotParent = aParent ? aParent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) :
|
|
|
|
NS_ERROR_FAILURE;
|
|
|
|
// Windows OS wants the parent disabled for modality
|
|
|
|
if (NS_SUCCEEDED(gotParent))
|
|
|
|
parentWindowWidgetThing->Enable(PR_FALSE);
|
1999-05-11 23:42:14 +04:00
|
|
|
aResult->ShowModal();
|
1999-05-10 22:31:42 +04:00
|
|
|
if (NS_SUCCEEDED(gotParent))
|
|
|
|
parentWindowWidgetThing->Enable(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Release the event queue
|
|
|
|
#ifdef XP_PC // XXX Won't work on other platforms yet
|
|
|
|
eQueueService->PopThreadEventQueue();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-15 08:38:15 +03:00
|
|
|
/*
|
|
|
|
* Register a new top level window (created elsewhere)
|
|
|
|
*/
|
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
1998-12-03 04:35:53 +03:00
|
|
|
NS_IMETHODIMP
|
1999-03-20 07:13:09 +03:00
|
|
|
nsAppShellService::RegisterTopLevelWindow(nsIWebShellWindow* aWindow)
|
1998-12-03 04:35:53 +03:00
|
|
|
{
|
1999-02-15 08:38:15 +03:00
|
|
|
nsresult rv;
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellContainer* wsc;
|
|
|
|
rv = aWindow->QueryInterface(kIWebShellContainerIID, (void **) &wsc);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mWindowList->AppendElement(wsc);
|
|
|
|
NS_RELEASE(wsc);
|
1998-12-03 04:35:53 +03:00
|
|
|
}
|
1999-02-15 08:38:15 +03:00
|
|
|
return rv;
|
|
|
|
}
|
1998-12-03 04:35:53 +03:00
|
|
|
|
|
|
|
|
1999-02-15 08:38:15 +03:00
|
|
|
NS_IMETHODIMP
|
1999-03-20 07:13:09 +03:00
|
|
|
nsAppShellService::UnregisterTopLevelWindow(nsIWebShellWindow* aWindow)
|
1999-02-15 08:38:15 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-03-20 07:13:09 +03:00
|
|
|
nsIWebShellContainer* wsc;
|
|
|
|
rv = aWindow->QueryInterface(kIWebShellContainerIID, (void **) &wsc);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mWindowList->RemoveElement(wsc);
|
|
|
|
NS_RELEASE(wsc);
|
1998-12-03 04:35:53 +03:00
|
|
|
}
|
1999-03-27 03:09:04 +03:00
|
|
|
if (0 == mWindowList->Count())
|
|
|
|
mAppShell->Exit();
|
1998-12-03 04:35:53 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-02-15 08:38:15 +03:00
|
|
|
|
1998-12-03 04:35:53 +03:00
|
|
|
NS_EXPORT nsresult NS_NewAppShellService(nsIAppShellService** aResult)
|
|
|
|
{
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = new nsAppShellService();
|
|
|
|
if (nsnull == *aResult) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-01-21 10:22:58 +03:00
|
|
|
// Entry point to create nsAppShellService factory instances...
|
1999-03-08 12:44:16 +03:00
|
|
|
NS_DEF_FACTORY(AppShellService,nsAppShellService)
|
1998-12-03 04:35:53 +03:00
|
|
|
|
1999-01-21 10:22:58 +03:00
|
|
|
nsresult NS_NewAppShellServiceFactory(nsIFactory** aResult)
|
1998-12-03 04:35:53 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
1999-03-08 12:44:16 +03:00
|
|
|
nsIFactory* inst = new nsAppShellServiceFactory;
|
1998-12-03 04:35:53 +03:00
|
|
|
if (nsnull == inst) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ADDREF(inst);
|
|
|
|
}
|
1999-01-21 10:22:58 +03:00
|
|
|
*aResult = inst;
|
1998-12-03 04:35:53 +03:00
|
|
|
return rv;
|
|
|
|
}
|