2005-08-05 04:02:24 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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/MPL/
|
|
|
|
*
|
|
|
|
* 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 Minimo.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Doug Turner <dougt@meer.net>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "MinimoPrivate.h"
|
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
#include "nsIFullScreen.h"
|
|
|
|
#include "nsIGenericFactory.h"
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
#ifdef _BUILD_STATIC_BIN
|
|
|
|
#include "nsStaticComponents.h"
|
|
|
|
#endif
|
|
|
|
|
2005-09-16 06:57:27 +04:00
|
|
|
#define MINIMO_PROPERTIES_URL "chrome://minimo/locale/minimo.properties"
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
// Global variables
|
|
|
|
const static char* start_url = "chrome://minimo/content/minimo.xul";
|
2005-09-28 21:56:07 +04:00
|
|
|
|
2005-11-15 03:20:55 +03:00
|
|
|
//const static char* start_url = "http://www.mozilla.org";
|
2005-08-05 04:02:24 +04:00
|
|
|
//const static char* start_url = "http://www.meer.net/~dougt/test.html";
|
|
|
|
//const static char* start_url = "resource://gre/res/start.html";
|
2005-09-28 21:56:07 +04:00
|
|
|
//const static char* start_url = "resource://gre/res/1.html";
|
2005-08-05 04:02:24 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|
|
|
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
|
|
|
|
|
|
|
class ApplicationObserver: public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ApplicationObserver(nsIAppShell* aAppShell);
|
|
|
|
~ApplicationObserver();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAppShell> mAppShell;
|
|
|
|
int mWindowCount;
|
2005-09-16 06:57:27 +04:00
|
|
|
int mSeenLoadLibraryFailure;
|
2005-08-05 04:02:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationObserver::ApplicationObserver(nsIAppShell* aAppShell)
|
|
|
|
{
|
|
|
|
mAppShell = aAppShell;
|
|
|
|
mWindowCount = 0;
|
2005-09-16 06:57:27 +04:00
|
|
|
mSeenLoadLibraryFailure = 0;
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
|
|
|
|
|
|
|
|
os->AddObserver(this, "nsIEventQueueActivated", PR_FALSE);
|
|
|
|
os->AddObserver(this, "nsIEventQueueDestroyed", PR_FALSE);
|
|
|
|
|
|
|
|
os->AddObserver(this, "xul-window-registered", PR_FALSE);
|
|
|
|
os->AddObserver(this, "xul-window-destroyed", PR_FALSE);
|
|
|
|
os->AddObserver(this, "xul-window-visible", PR_FALSE);
|
2005-09-16 06:57:27 +04:00
|
|
|
|
|
|
|
os->AddObserver(this, "xpcom-loader", PR_FALSE);
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationObserver::~ApplicationObserver()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(ApplicationObserver, nsIObserver)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ApplicationObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
|
|
|
{
|
|
|
|
if (!strcmp(aTopic, "nsIEventQueueActivated"))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIEventQueue> eq(do_QueryInterface(aSubject));
|
|
|
|
if (eq)
|
|
|
|
{
|
|
|
|
PRBool isNative = PR_TRUE;
|
|
|
|
// we only add native event queues to the appshell
|
|
|
|
eq->IsQueueNative(&isNative);
|
|
|
|
if (isNative)
|
|
|
|
mAppShell->ListenToEventQueue(eq, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "nsIEventQueueDestroyed"))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIEventQueue> eq(do_QueryInterface(aSubject));
|
|
|
|
if (eq)
|
|
|
|
{
|
|
|
|
PRBool isNative = PR_TRUE;
|
|
|
|
// we only remove native event queues from the appshell
|
|
|
|
eq->IsQueueNative(&isNative);
|
|
|
|
if (isNative)
|
|
|
|
mAppShell->ListenToEventQueue(eq, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "xul-window-visible"))
|
|
|
|
{
|
|
|
|
KillSplashScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(aTopic, "xul-window-registered"))
|
|
|
|
{
|
|
|
|
mWindowCount++;
|
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "xul-window-destroyed"))
|
|
|
|
{
|
|
|
|
mWindowCount--;
|
|
|
|
if (mWindowCount == 0)
|
|
|
|
mAppShell->Exit();
|
|
|
|
}
|
2005-09-16 06:57:27 +04:00
|
|
|
else if (!strcmp(aTopic, "xpcom-loader"))
|
|
|
|
{
|
|
|
|
if (mWindowCount == 0 || mSeenLoadLibraryFailure != 0)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
mSeenLoadLibraryFailure++;
|
|
|
|
|
|
|
|
nsIFile* file = (nsIFile*) aSubject;
|
|
|
|
nsAutoString filePath;
|
|
|
|
file->GetPath(filePath);
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-09-16 06:57:27 +04:00
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
|
|
|
if (!bundleService)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
|
|
|
bundleService->CreateBundle(MINIMO_PROPERTIES_URL, getter_AddRefs(bundle));
|
|
|
|
|
|
|
|
if (!bundle)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
const PRUnichar *formatStrings[] = { filePath.get() };
|
|
|
|
nsXPIDLString message;
|
|
|
|
bundle->FormatStringFromName(NS_LITERAL_STRING("loadFailed").get(),
|
|
|
|
formatStrings,
|
|
|
|
NS_ARRAY_LENGTH(formatStrings),
|
|
|
|
getter_Copies(message));
|
|
|
|
|
|
|
|
nsXPIDLString title;
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("loadFailedTitle").get(), getter_Copies(title));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPromptService> promptService = do_GetService("@mozilla.org/embedcomp/prompt-service;1");
|
|
|
|
promptService->Alert(nsnull, title.get(), message.get());
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
|
|
|
|
class nsFullScreen : public nsIFullScreen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFULLSCREEN
|
|
|
|
|
|
|
|
nsFullScreen();
|
|
|
|
~nsFullScreen();
|
|
|
|
|
|
|
|
#ifdef WINCE
|
|
|
|
HWND hTaskBarWnd;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsFullScreen, nsIFullScreen)
|
|
|
|
|
|
|
|
nsFullScreen::nsFullScreen()
|
|
|
|
{
|
|
|
|
#ifdef WINCE
|
|
|
|
hTaskBarWnd = FindWindow("HHTaskBar", NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFullScreen::~nsFullScreen()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFullScreen::HideAllOSChrome()
|
|
|
|
{
|
|
|
|
#ifndef WINCE
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
|
|
|
if (!hTaskBarWnd)
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
|
|
|
SetWindowPos(hTaskBarWnd,
|
|
|
|
HWND_NOTOPMOST,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
|
|
|
|
ShowWindow(hTaskBarWnd, SW_HIDE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFullScreen::ShowAllOSChrome()
|
|
|
|
{
|
|
|
|
#ifndef WINCE
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
|
|
|
if (!hTaskBarWnd)
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
|
|
|
SetWindowPos(hTaskBarWnd,
|
|
|
|
HWND_TOPMOST,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
|
|
|
|
ShowWindow(hTaskBarWnd, SW_SHOW);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFullScreen::GetChromeItems(nsISimpleEnumerator **_retval)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
class nsBadCertListener : public nsIBadCertListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIBADCERTLISTENER
|
|
|
|
|
|
|
|
nsBadCertListener();
|
|
|
|
~nsBadCertListener();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
nsBadCertListener::nsBadCertListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBadCertListener::~nsBadCertListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsBadCertListener, nsIBadCertListener)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBadCertListener::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo, nsIX509Cert *cert, PRInt16 *certAddType, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
|
|
|
if (!bundleService)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
|
|
|
bundleService->CreateBundle(MINIMO_PROPERTIES_URL, getter_AddRefs(bundle));
|
|
|
|
|
|
|
|
if (!bundle)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsXPIDLString message;
|
|
|
|
nsXPIDLString title;
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("confirmUnknownIssuer").get(), getter_Copies(message));
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("securityWarningTitle").get(), getter_Copies(title));
|
|
|
|
|
2005-11-15 03:20:55 +03:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
|
|
|
if (!wwatcher)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
if (!parent)
|
|
|
|
wwatcher->GetActiveWindow(getter_AddRefs(parent));
|
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
PRBool result;
|
|
|
|
nsCOMPtr<nsIPromptService> dlgService(do_GetService(NS_PROMPTSERVICE_CONTRACTID));
|
2005-11-15 03:20:55 +03:00
|
|
|
dlgService->Confirm(parent, title, message, &result);
|
2005-09-01 22:22:19 +04:00
|
|
|
|
|
|
|
*_retval = result;
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
*certAddType = ADD_TRUSTED_FOR_SESSION;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBadCertListener::ConfirmMismatchDomain(nsIInterfaceRequestor *socketInfo, const nsACString & targetURL, nsIX509Cert *cert, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
|
|
|
if (!bundleService)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
|
|
|
bundleService->CreateBundle(MINIMO_PROPERTIES_URL, getter_AddRefs(bundle));
|
|
|
|
|
|
|
|
if (!bundle)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsXPIDLString message;
|
|
|
|
nsXPIDLString title;
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("confirmMismatch").get(), getter_Copies(message));
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("securityWarningTitle").get(), getter_Copies(title));
|
|
|
|
|
2005-11-15 03:20:55 +03:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
|
|
|
if (!wwatcher)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
if (!parent)
|
|
|
|
wwatcher->GetActiveWindow(getter_AddRefs(parent));
|
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
PRBool result;
|
|
|
|
nsCOMPtr<nsIPromptService> dlgService(do_GetService(NS_PROMPTSERVICE_CONTRACTID));
|
2005-11-15 03:20:55 +03:00
|
|
|
dlgService->Confirm(parent, title, message, &result);
|
2005-09-01 22:22:19 +04:00
|
|
|
|
|
|
|
*_retval = result;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBadCertListener::ConfirmCertExpired(nsIInterfaceRequestor *socketInfo, nsIX509Cert *cert, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
|
|
|
if (!bundleService)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
|
|
|
bundleService->CreateBundle(MINIMO_PROPERTIES_URL, getter_AddRefs(bundle));
|
|
|
|
|
|
|
|
if (!bundle)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsXPIDLString message;
|
|
|
|
nsXPIDLString title;
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("confirmCertExpired").get(), getter_Copies(message));
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("securityWarningTitle").get(), getter_Copies(title));
|
|
|
|
|
2005-11-15 03:20:55 +03:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
|
|
|
if (!wwatcher)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
if (!parent)
|
|
|
|
wwatcher->GetActiveWindow(getter_AddRefs(parent));
|
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
PRBool result;
|
|
|
|
nsCOMPtr<nsIPromptService> dlgService(do_GetService(NS_PROMPTSERVICE_CONTRACTID));
|
2005-11-15 03:20:55 +03:00
|
|
|
dlgService->Confirm(parent, title, message, &result);
|
2005-09-01 22:22:19 +04:00
|
|
|
|
|
|
|
*_retval = result;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBadCertListener::NotifyCrlNextupdate(nsIInterfaceRequestor *socketInfo, const nsACString & targetURL, nsIX509Cert *cert)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
nsresult StartupProfile()
|
|
|
|
{
|
|
|
|
NS_TIMELINE_MARK_FUNCTION("Profile Startup");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> appDataDir;
|
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, getter_AddRefs(appDataDir));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
rv = appDataDir->Append(NS_LITERAL_STRING("minimo"));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> localAppDataDir(do_QueryInterface(appDataDir));
|
|
|
|
|
|
|
|
nsCOMPtr<nsProfileDirServiceProvider> locProvider;
|
|
|
|
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
|
|
|
|
if (!locProvider)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
rv = locProvider->Register();
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
return locProvider->SetProfileDir(localAppDataDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoPreferences()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (!prefBranch)
|
|
|
|
return;
|
|
|
|
|
|
|
|
prefBranch->SetIntPref("snav.keyCode.modifier", 0);
|
2005-11-15 03:20:55 +03:00
|
|
|
prefBranch->SetBoolPref("snav.enabled", true);
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
#define NS_FULLSCREEN_CID \
|
|
|
|
{ /* aca93a4e-53f8-40e2-a59b-9363a0bf9a87 */ \
|
|
|
|
0xaca93a4e, \
|
|
|
|
0x53f8, \
|
|
|
|
0x40e2, \
|
|
|
|
{0xa5, 0x9b, 0x93, 0x63, 0xa0, 0xbf, 0x9a, 0x87} \
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
#define NS_BADCERTLISTENER_CID \
|
|
|
|
{ /* a4bdf79a-ed05-4256-bf12-4581a03f966e */ \
|
|
|
|
0xa4bdf79a, \
|
|
|
|
0xed05, \
|
|
|
|
0x4256, \
|
|
|
|
{0xbf, 0x12, 0x45, 0x81, 0xa0, 0x3f, 0x96, 0x6e} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-16 23:28:09 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFullScreen)
|
2005-09-01 22:22:19 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBadCertListener)
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
static const nsModuleComponentInfo defaultAppComps[] = {
|
|
|
|
{
|
|
|
|
NS_BROWSERSTATUSFILTER_CLASSNAME,
|
|
|
|
NS_BROWSERSTATUSFILTER_CID,
|
|
|
|
NS_BROWSERSTATUSFILTER_CONTRACTID,
|
|
|
|
nsBrowserStatusFilterConstructor
|
|
|
|
},
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
{
|
|
|
|
"FullScreen",
|
|
|
|
NS_FULLSCREEN_CID,
|
|
|
|
"@mozilla.org/browser/fullscreen;1",
|
|
|
|
nsFullScreenConstructor
|
|
|
|
},
|
|
|
|
|
2005-09-01 22:22:19 +04:00
|
|
|
{
|
|
|
|
"Bad Cert Dialogs",
|
|
|
|
NS_BADCERTLISTENER_CID,
|
|
|
|
NS_BADCERTLISTENER_CONTRACTID,
|
|
|
|
nsBadCertListenerConstructor
|
|
|
|
},
|
2005-08-14 09:49:09 +04:00
|
|
|
};
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-08-14 09:49:09 +04:00
|
|
|
void OverrideComponents()
|
|
|
|
{
|
|
|
|
int count = sizeof(defaultAppComps) / sizeof(nsModuleComponentInfo);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIComponentRegistrar> cr;
|
|
|
|
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIComponentManager> cm;
|
|
|
|
NS_GetComponentManager (getter_AddRefs (cm));
|
|
|
|
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIGenericFactory> componentFactory;
|
|
|
|
nsresult rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), &(defaultAppComps[i]));
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Unable to create factory for component");
|
|
|
|
continue; // don't abort registering other components
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = cr->RegisterFactory(defaultAppComps[i].mCID,
|
|
|
|
defaultAppComps[i].mDescription,
|
|
|
|
defaultAppComps[i].mContractID,
|
|
|
|
componentFactory);
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
*
|
|
|
|
* Complete hack below. We to ensure that the layout of all
|
|
|
|
* of the shared libaries are at tightly packed as possible.
|
|
|
|
* We do this by explictly loading all of the modules we
|
|
|
|
* know about at compile time. This seams to work for our
|
|
|
|
* purposes. Ultimately, we should statically link all of
|
|
|
|
* these libraries.
|
|
|
|
*
|
|
|
|
* If you are building this to put on a ROM where XIP exists.
|
|
|
|
*
|
|
|
|
* For more information:
|
|
|
|
* 1) http://msdn.microsoft.com/library/default.asp?url=/ \
|
|
|
|
library/en-us/dncenet/html/advmemmgmt.asp
|
|
|
|
*
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#ifdef WINCE
|
2005-09-19 21:58:08 +04:00
|
|
|
#define HACKY_PRE_LOAD_LIBRARY 1
|
2005-08-05 04:02:24 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HACKY_PRE_LOAD_LIBRARY
|
|
|
|
typedef struct _library
|
|
|
|
{
|
|
|
|
const unsigned short* name;
|
|
|
|
HMODULE module;
|
|
|
|
} _library;
|
|
|
|
|
|
|
|
_library Libraries[] =
|
|
|
|
{
|
2005-11-15 03:20:55 +03:00
|
|
|
{ L"nssckbi.dll", NULL },
|
2005-08-05 04:02:24 +04:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
void LoadKnownLibs()
|
|
|
|
{
|
|
|
|
for (int i=0; Libraries[i].name; i++)
|
|
|
|
Libraries[i].module = LoadLibraryW(Libraries[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnloadKnownLibs()
|
|
|
|
{
|
|
|
|
for (int i=0; Libraries[i].name; i++)
|
|
|
|
if (Libraries[i].module)
|
|
|
|
FreeLibrary(Libraries[i].module);
|
|
|
|
}
|
|
|
|
#endif // HACKY_PRE_LOAD_LIBRARY
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2005-08-14 09:49:09 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
|
|
|
gtk_set_locale();
|
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
#endif
|
2005-09-02 22:15:00 +04:00
|
|
|
|
|
|
|
CreateSplashScreen();
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
#ifdef HACKY_PRE_LOAD_LIBRARY
|
2005-09-02 22:15:00 +04:00
|
|
|
LoadKnownLibs();
|
2005-08-05 04:02:24 +04:00
|
|
|
#endif
|
2005-09-02 22:15:00 +04:00
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
#ifdef _BUILD_STATIC_BIN
|
2005-09-02 22:15:00 +04:00
|
|
|
NS_InitEmbedding(nsnull, nsnull, kPStaticModules, kStaticModuleCount);
|
2005-08-05 04:02:24 +04:00
|
|
|
#else
|
2005-09-02 22:15:00 +04:00
|
|
|
NS_InitEmbedding(nsnull, nsnull);
|
2005-08-05 04:02:24 +04:00
|
|
|
#endif
|
2005-09-16 06:57:27 +04:00
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
// Choose the new profile
|
2005-09-02 22:15:00 +04:00
|
|
|
if (NS_FAILED(StartupProfile()))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
DoPreferences();
|
|
|
|
OverrideComponents();
|
|
|
|
|
|
|
|
NS_TIMELINE_ENTER("appStartup");
|
|
|
|
nsCOMPtr<nsIAppShell> appShell = do_CreateInstance(kAppShellCID);
|
2005-09-16 06:57:27 +04:00
|
|
|
if (!appShell)
|
|
|
|
{
|
|
|
|
// if we can't get the nsIAppShell, then we should auto reg.
|
|
|
|
nsCOMPtr<nsIComponentRegistrar> registrar;
|
|
|
|
NS_GetComponentRegistrar(getter_AddRefs(registrar));
|
|
|
|
if (!registrar)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
registrar->AutoRegister(nsnull);
|
|
|
|
|
|
|
|
appShell = do_CreateInstance(kAppShellCID);
|
|
|
|
|
|
|
|
if (!appShell)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-09-02 22:15:00 +04:00
|
|
|
appShell->Create(nsnull, nsnull);
|
|
|
|
|
|
|
|
ApplicationObserver *appObserver = new ApplicationObserver(appShell);
|
|
|
|
if (!appObserver)
|
|
|
|
return 1;
|
|
|
|
NS_ADDREF(appObserver);
|
|
|
|
|
|
|
|
WindowCreator *creatorCallback = new WindowCreator(appShell);
|
|
|
|
if (!creatorCallback)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
|
|
|
wwatch->SetWindowCreator(creatorCallback);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> newWindow;
|
|
|
|
wwatch->OpenWindow(nsnull, start_url, "_blank", "chrome,dialog=no,all", nsnull, getter_AddRefs(newWindow));
|
|
|
|
|
|
|
|
appShell->Run();
|
|
|
|
|
|
|
|
appShell = nsnull;
|
|
|
|
wwatch = nsnull;
|
|
|
|
newWindow = nsnull;
|
|
|
|
|
|
|
|
delete appObserver;
|
|
|
|
delete creatorCallback;
|
|
|
|
|
2005-09-21 01:12:38 +04:00
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (!prefBranch)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
PRBool dumpJSConsole = PR_FALSE;
|
2005-09-02 22:15:00 +04:00
|
|
|
|
2005-09-21 01:12:38 +04:00
|
|
|
prefBranch->GetBoolPref("config.wince.dumpJSConsole", &dumpJSConsole);
|
|
|
|
prefBranch = 0;
|
|
|
|
|
|
|
|
if (dumpJSConsole)
|
2005-11-15 03:20:55 +03:00
|
|
|
WriteConsoleLog();
|
2005-09-21 01:12:38 +04:00
|
|
|
|
2005-09-02 22:15:00 +04:00
|
|
|
// Close down Embedding APIs
|
|
|
|
NS_TermEmbedding();
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
#ifdef HACKY_PRE_LOAD_LIBRARY
|
2005-09-02 22:15:00 +04:00
|
|
|
UnloadKnownLibs();
|
2005-08-05 04:02:24 +04:00
|
|
|
#endif
|
2005-09-02 22:15:00 +04:00
|
|
|
return NS_OK;
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
2005-09-02 22:15:00 +04:00
|
|
|
|
|
|
|
|