Bug 451909 - kill MOZ_XUL_APP now that all apps set it; 'xpfe' part; r=neil

This commit is contained in:
Arpad Borsos 2008-09-15 15:07:44 +02:00
parent 8162c27dbd
commit 17cad329ae
6 changed files with 1 additions and 451 deletions

View File

@ -909,7 +909,7 @@ void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
#if defined(XP_MACOSX) && defined(MOZ_XUL_APP)
#if defined(XP_MACOSX)
// On OS X, treat the titlemodifier like it's the titledefault, and don't ever append
// the separator + appname.
if (mTitleDefault.IsEmpty()) {

View File

@ -56,10 +56,7 @@
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_XUL_APP
#include "nsAppRunner.h"
#endif
/*----------------------------------------------------------------------------
AEApplicationClass
@ -333,18 +330,8 @@ void AEApplicationClass::HandleReOpen(AEDesc *token, const AppleEvent *appleEven
nsresult rv = NS_OK;
nsCOMPtr<nsINativeAppSupport> nas;
#ifdef MOZ_XUL_APP
nas = do_CreateInstance(NS_NATIVEAPPSUPPORT_CONTRACTID);
if (!nas) ThrowIfOSErr(errAEEventNotHandled);
#else
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
NS_ASSERTION(appStartup, "Failed to get appstartup service");
if(!appStartup) ThrowIfOSErr(errAEEventNotHandled);
rv = appStartup->GetNativeAppSupport(getter_AddRefs(nas));
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get NativeAppSupport");
if(NS_FAILED(rv)) ThrowIfOSErr(errAEEventNotHandled);
#endif
rv = nas->ReOpen();
if(NS_FAILED(rv)) ThrowIfOSErr(errAEEventNotHandled);

View File

@ -93,10 +93,6 @@
#include "nsDirectoryServiceDefs.h"
#include "nsNetUtil.h"
#ifndef MOZ_XUL_APP
#include "nsIBrowserHistory.h"
#include "nsICmdLineService.h"
#endif
// Stuff to implement file download dialog.
#include "nsIProxyObjectManager.h"
@ -498,57 +494,6 @@ NS_IMETHODIMP
nsBrowserInstance::StartPageCycler(PRBool* aIsPageCycling)
{
*aIsPageCycling = PR_FALSE;
#ifndef MOZ_XUL_APP
nsresult rv;
if (!sCmdLineURLUsed) {
nsCOMPtr<nsICmdLineService> cmdLineArgs =
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
if (APP_DEBUG) fprintf(stderr, "Could not obtain CmdLine processing service\n");
return NS_ERROR_FAILURE;
}
#ifdef ENABLE_PAGE_CYCLER
// First, check if there's a URL file to load (for testing), and if there
// is, process it instead of anything else.
nsAutoString urlstr;
nsXPIDLCString file;
rv = cmdLineArgs->GetCmdLineValue("-f", getter_Copies(file));
if (NS_SUCCEEDED(rv) && (const char*)file) {
// see if we have a timeout value corresponding to the url-file
nsXPIDLCString timeoutVal;
rv = cmdLineArgs->GetCmdLineValue("-ftimeout", getter_Copies(timeoutVal));
// see if we have a wait value corresponding to the url-file
nsXPIDLCString waitVal;
rv = cmdLineArgs->GetCmdLineValue("-fwait", getter_Copies(waitVal));
// cereate the cool PageCycler instance
PageCycler* bb = new PageCycler(this, timeoutVal, waitVal);
if (bb == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(bb);
rv = bb->Init(file);
if (NS_FAILED(rv)) return rv;
rv = bb->GetNextURL(urlstr);
NS_RELEASE(bb);
*aIsPageCycling = PR_TRUE;
}
if (!urlstr.IsEmpty()) {
// A url was provided. Load it
if (APP_DEBUG) printf("Got Command line URL to load %s\n", NS_ConvertUTF16toUTF8(urlstr).get());
rv = LoadUrl( urlstr.get() );
sCmdLineURLUsed = PR_TRUE;
return rv;
}
#endif //ENABLE_PAGE_CYCLER
}
#endif // MOZ_XUL_APP
return NS_OK;
}
@ -593,241 +538,3 @@ nsBrowserInstance::Close()
return NS_OK;
}
#ifndef MOZ_XUL_APP
//*****************************************************************************
// nsBrowserInstance: Helpers
//*****************************************************************************
////////////////////////////////////////////////////////////////////////
// browserCntHandler is a content handler component that registers
// the browse as the preferred content handler for various content
// types like text/html, image/jpeg, etc. When the uri loader
// has a content type that no currently open window wants to handle,
// it will ask the registry for a registered content handler for this
// type. If the browser is registered to handle that type, we'll end
// up in here where we create a new browser window for the url.
//
// I had intially written this as a JS component and would like to do
// so again. However, JS components can't access xpconnect objects that
// return DOM objects. And we need a dom window to bootstrap the browser
/////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS1(nsChromeStartupHandler, nsICmdLineHandler)
CMDLINEHANDLER_IMPL(nsChromeStartupHandler, "-chrome", "", "",
"Load the specified chrome.",
NS_CHROMESTARTUPHANDLER_CONTRACTID,
"Chrome Startup Handler", PR_TRUE, "", PR_FALSE)
NS_IMPL_ISUPPORTS2(nsBrowserContentHandler, nsIContentHandler, nsICmdLineHandler)
CMDLINEHANDLER_OTHERS_IMPL(nsBrowserContentHandler, "-browser",
"general.startup.browser", "Load the browser.",
PR_TRUE, PR_TRUE)
CMDLINEHANDLER_REGISTERPROC_IMPL(nsBrowserContentHandler,
"Browser Startup Handler",
NS_BROWSERSTARTUPHANDLER_CONTRACTID)
NS_IMETHODIMP nsBrowserContentHandler::GetChromeUrlForTask(char **aChromeUrlForTask) {
if (!aChromeUrlForTask)
return NS_ERROR_NULL_POINTER;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
rv = prefs->GetCharPref("browser.chromeURL", aChromeUrlForTask);
if (NS_SUCCEEDED(rv) && (*aChromeUrlForTask)[0] == '\0') {
PL_strfree(*aChromeUrlForTask);
rv = NS_ERROR_FAILURE;
}
}
if (NS_FAILED(rv))
*aChromeUrlForTask = PL_strdup("chrome://navigator/content/navigator.xul");
return NS_OK;
}
PRBool nsBrowserContentHandler::NeedHomepageOverride(nsIPrefBranch *aPrefService)
{
NS_ASSERTION(aPrefService, "Null pointer to prefs service!");
// get saved milestone from user's prefs
nsXPIDLCString savedMilestone;
aPrefService->GetCharPref(PREF_HOMEPAGE_OVERRIDE_MSTONE,
getter_Copies(savedMilestone));
// Mozilla never saves this value, but a fed-up advanced user might
if (savedMilestone.Equals(kIgnoreOverrideMilestone))
return PR_FALSE;
// get browser's current milestone
nsCOMPtr<nsIHttpProtocolHandler> httpHandler(
do_GetService("@mozilla.org/network/protocol;1?name=http"));
if (!httpHandler)
return PR_TRUE;
nsCAutoString currMilestone;
httpHandler->GetMisc(currMilestone);
// failed to get pref -or- saved milestone older than current milestone,
// write out known current milestone and show URL this time
if (!(currMilestone.Equals(savedMilestone))) {
// update milestone in "homepage override" pref
aPrefService->SetCharPref(PREF_HOMEPAGE_OVERRIDE_MSTONE,
currMilestone.get());
return PR_TRUE;
}
// don't override if saved and current are same
return PR_FALSE;
}
nsresult GetHomePageGroup(nsIPrefBranch* aPref, PRUnichar** aResult)
{
nsresult rv;
nsCOMPtr<nsIPrefLocalizedString> uri;
rv = aPref->GetComplexValue(PREF_BROWSER_STARTUP_HOMEPAGE,
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(uri));
if (NS_FAILED(rv))
return rv;
PRInt32 count = 0;
rv = aPref->GetIntPref("browser.startup.homepage.count", &count);
// if we couldn't get the pref (unlikely) or only have one homepage
if (NS_FAILED(rv) || count <= 1) {
return uri->ToString(aResult);
}
// The "homepage" is a group of pages, put them in uriList separated by '\n'
nsString uriList;
rv = uri->GetData(getter_Copies(uriList));
if (NS_FAILED(rv))
return rv;
for (PRInt32 i = 1; i < count; ++i) {
nsCAutoString pref(NS_LITERAL_CSTRING("browser.startup.homepage."));
pref.AppendInt(i);
rv = aPref->GetComplexValue(pref.get(),
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(uri));
if (NS_FAILED(rv))
return rv;
nsString uriString;
rv = uri->GetData(getter_Copies(uriString));
if (NS_FAILED(rv))
return rv;
uriList.Append(PRUnichar('\n'));
uriList.Append(uriString);
}
*aResult = ToNewUnicode(uriList);
return NS_OK;
}
NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs)
{
if (!aDefaultArgs)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
if (NeedHomepageOverride(prefs)) {
nsCOMPtr<nsIPrefLocalizedString> overrideURL;
rv = prefs->GetComplexValue(PREF_HOMEPAGE_OVERRIDE_URL,
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(overrideURL));
if (NS_SUCCEEDED(rv)) {
rv = overrideURL->ToString(aDefaultArgs);
if (NS_SUCCEEDED(rv) && *aDefaultArgs)
return NS_OK;
}
}
PRInt32 choice = 0;
rv = prefs->GetIntPref(PREF_BROWSER_STARTUP_PAGE, &choice);
if (NS_SUCCEEDED(rv)) {
switch (choice) {
case 1: {
// skip the code below
rv = GetHomePageGroup(prefs, aDefaultArgs);
if (NS_SUCCEEDED(rv) && *aDefaultArgs)
return NS_OK;
}
case 2: {
nsCOMPtr<nsIBrowserHistory> history(do_GetService(NS_GLOBALHISTORY2_CONTRACTID));
if (history) {
nsCAutoString curl;
rv = history->GetLastPageVisited(curl);
if (NS_SUCCEEDED(rv)) {
*aDefaultArgs = UTF8ToNewUnicode(curl);
if (*aDefaultArgs) return NS_OK;
}
}
}
}
}
}
// the default, in case we fail somewhere
*aDefaultArgs = ToNewUnicode(NS_LITERAL_STRING("about:blank"));
if (!*aDefaultArgs) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
nsIInterfaceRequestor * aWindowContext,
nsIRequest * aRequest)
{
NS_PRECONDITION(aContentType, "Must have a content type");
// Verify that we can handle this content, to avoid infinite window opening
// loops
nsresult rv;
nsCOMPtr<nsIWebNavigationInfo> webNavInfo =
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 typeSupported;
rv = webNavInfo->IsTypeSupported(nsDependentCString(aContentType), nsnull,
&typeSupported);
NS_ENSURE_SUCCESS(rv, rv);
if (!typeSupported)
return NS_ERROR_WONT_HANDLE_CONTENT;
// create a new browser window to handle the content
NS_ENSURE_ARG(aRequest);
nsCOMPtr<nsIDOMWindow> parentWindow;
if (aWindowContext)
parentWindow = do_GetInterface(aWindowContext);
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(aRequest);
if (!aChannel) return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
nsCAutoString spec;
uri->GetSpec(spec);
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> newWindow;
wwatch->OpenWindow(parentWindow, spec.get(), "", 0, 0,
getter_AddRefs(newWindow));
}
// now abort the current channel load...
aRequest->Cancel(NS_BINDING_ABORTED);
return NS_OK;
}
#endif // MOZ_XUL_APP

View File

@ -47,12 +47,6 @@
#include "nscore.h"
#include "nsISupports.h"
#ifndef MOZ_XUL_APP
// for nsBrowserStatusHandler
#include "nsIContentHandler.h"
#include "nsICmdLineHandler.h"
#endif
class nsIDocShell;
class nsIDOMWindowInternal;
class nsIPrefBranch;
@ -96,26 +90,4 @@ class nsBrowserInstance : public nsIBrowserInstance,
#endif
};
#ifndef MOZ_XUL_APP
class nsChromeStartupHandler : public nsICmdLineHandler
{
public:
NS_DECL_NSICMDLINEHANDLER
NS_DECL_ISUPPORTS
CMDLINEHANDLER_REGISTERPROC_DECLS
};
class nsBrowserContentHandler : public nsIContentHandler, public nsICmdLineHandler
{
public:
NS_DECL_NSICONTENTHANDLER
NS_DECL_NSICMDLINEHANDLER
NS_DECL_ISUPPORTS
CMDLINEHANDLER_REGISTERPROC_DECLS
protected:
PRBool NeedHomepageOverride(nsIPrefBranch *aPrefService);
};
#endif
#endif // nsBrowserInstance_h___

View File

@ -99,12 +99,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGlobalHistory, Init)
#endif // MOZ_SUITE
#if (!defined(MOZ_XUL_APP)) && !defined(MOZ_MACBROWSER)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserContentHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeStartupHandler)
#endif
static NS_METHOD
RegisterProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
@ -183,114 +177,6 @@ static const nsModuleComponentInfo components[] = {
},
#endif
#if (!defined(MOZ_XUL_APP)) && !defined(MOZ_MACBROWSER)
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/html",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/vnd.mozilla.xul+xml",
nsBrowserContentHandlerConstructor
},
#ifdef MOZ_SVG
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/svg+xml",
nsBrowserContentHandlerConstructor
},
#endif // MOZ_SVG
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/rdf",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/xml",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/xml",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/xhtml+xml",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/css",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/plain",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/gif",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/jpeg",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/jpg",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/png",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/bmp",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/x-icon",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/vnd.microsoft.icon",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/x-xbitmap",
nsBrowserContentHandlerConstructor
},
{ "Browser Content Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/http-index-format",
nsBrowserContentHandlerConstructor
},
{ "Browser Startup Handler",
NS_BROWSERCONTENTHANDLER_CID,
NS_BROWSERSTARTUPHANDLER_CONTRACTID,
nsBrowserContentHandlerConstructor,
nsBrowserContentHandler::RegisterProc,
nsBrowserContentHandler::UnregisterProc,
},
{ "Chrome Startup Handler",
NS_CHROMESTARTUPHANDLER_CID,
NS_CHROMESTARTUPHANDLER_CONTRACTID,
nsChromeStartupHandlerConstructor,
nsChromeStartupHandler::RegisterProc,
nsChromeStartupHandler::UnregisterProc
},
#endif //!defined(MOZ_XUL_APP) && !defined(MOZ_MACBROWSER)
};
NS_IMPL_NSGETMODULE(application, components)

View File

@ -64,9 +64,7 @@
#include "nsIAlertsService.h"
#include "nsEmbedCID.h"
#include "nsInt64.h"
#ifdef MOZ_XUL_APP
#include "nsToolkitCompsCID.h"
#endif
/* Outstanding issues/todo:
* 1. Implement pause/resume.