Merge backout on a CLOSED TREE

This commit is contained in:
Marco Bonardo 2011-07-01 18:09:06 +02:00
commit e5f62e0edd
20 changed files with 220 additions and 376 deletions

View File

@ -1,25 +0,0 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Testcase for bug </title>
<style>
#ie {
border: 5px solid red;
}
#ie {
display: block;
}
#moz {
color: blue;
/* display: none; */
}
</style>
</head>
<body>
<p id="foo">foo</p>
<p id="ie">ie</p>
<p id="moz">moz</p>
</body>
</html>

View File

@ -22,7 +22,7 @@ include autofocus/reftest.list
== 596455-2b.html 596455-ref-2.html
== 610935.html 610935-ref.html
== 649134-1.html 649134-ref.html
== 649134-2.html 649134-2-ref.html
== 649134-2.html 649134-ref.html
== hidden-1a.html hidden-1-ref.html
== hidden-1b.html hidden-1-ref.html

View File

@ -397,6 +397,7 @@ nsHTMLLinkElement::GetStyleSheetURL(PRBool* aIsInline)
*aIsInline = PR_FALSE;
nsAutoString href;
GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
href.Trim(" \t\n\r\f"); // trim HTML5 whitespace
if (href.IsEmpty()) {
return nsnull;
}

View File

@ -55,10 +55,6 @@ ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
ifneq ($(OS_TEST),x86_64)
# FIXME: bug 413019
OS_COMPILE_CFLAGS += -GL-
endif
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif

View File

@ -55,10 +55,6 @@ ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
ifneq ($(OS_TEST),x86_64)
# FIXME: bug 413019
OS_COMPILE_CFLAGS += -GL-
endif
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif

View File

@ -49,12 +49,6 @@ LIBRARY_NAME = mozjpeg
ifeq ($(OS_ARCH),WINNT)
LIBRARY_NAME = jpeg32$(VERSION_NUMBER)
ifneq ($(OS_TEST),x86_64)
# FIXME: bug 413019
ifndef GNU_CC
OS_COMPILE_CFLAGS += -GL-
endif
endif
endif
GRE_MODULE = 1

View File

@ -49,15 +49,6 @@ LIBRARY_NAME = png
endif
LIBXUL_LIBRARY = 1
ifndef GNU_CC
ifeq ($(OS_ARCH),WINNT)
ifneq ($(OS_TEST),x86_64)
# FIXME: bug 413019
OS_COMPILE_CFLAGS += -GL-
endif
endif
endif
CSRCS = \
png.c \

View File

@ -118,7 +118,6 @@
#include "nsITextToSubURI.h" // to unescape the filename
#include "nsIMIMEHeaderParam.h"
#include "nsIPrefService.h"
#include "nsIWindowWatcher.h"
#include "nsIDownloadHistory.h" // to mark downloads as visited
@ -149,6 +148,10 @@
#include "AndroidBridge.h"
#endif
#include "mozilla/Preferences.h"
using namespace mozilla;
// Buffer file writes in 32kb chunks
#define BUFFERED_OUTPUT_SIZE (1024 * 32)
@ -172,9 +175,10 @@ PRLogModuleInfo* nsExternalHelperAppService::mLog = nsnull;
#define LOG(args) PR_LOG(mLog, 3, args)
#define LOG_ENABLED() PR_LOG_TEST(mLog, 3)
static const char NEVER_ASK_PREF_BRANCH[] = "browser.helperApps.neverAsk.";
static const char NEVER_ASK_FOR_SAVE_TO_DISK_PREF[] = "saveToDisk";
static const char NEVER_ASK_FOR_OPEN_FILE_PREF[] = "openFile";
static const char NEVER_ASK_FOR_SAVE_TO_DISK_PREF[] =
"browser.helperApps.neverAsk.saveToDisk";
static const char NEVER_ASK_FOR_OPEN_FILE_PREF[] =
"browser.helperApps.neverAsk.openFile";
/**
* Contains a pointer to the helper app service, set in its constructor
@ -420,21 +424,15 @@ static nsresult GetDownloadDirectory(nsIFile **_directory)
nsCOMPtr<nsIFile> dir;
#ifdef XP_MACOSX
// On OS X, we first try to get the users download location, if it's set.
nsCOMPtr<nsIPrefBranch> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefs, NS_ERROR_UNEXPECTED);
PRInt32 folderValue = -1;
(void) prefs->GetIntPref(NS_PREF_DOWNLOAD_FOLDERLIST, &folderValue);
switch (folderValue) {
switch (Preferences::GetInt(NS_PREF_DOWNLOAD_FOLDERLIST, -1)) {
case NS_FOLDER_VALUE_DESKTOP:
(void) NS_GetSpecialDirectory(NS_OS_DESKTOP_DIR, getter_AddRefs(dir));
break;
case NS_FOLDER_VALUE_CUSTOM:
{
(void) prefs->GetComplexValue(NS_PREF_DOWNLOAD_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(dir));
Preferences::GetComplex(NS_PREF_DOWNLOAD_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(dir));
if (!dir) break;
// We have the directory, and now we need to make sure it exists
@ -940,35 +938,23 @@ NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(const ch
NS_IMETHODIMP nsExternalHelperAppService::IsExposedProtocol(const char * aProtocolScheme, PRBool * aResult)
{
// check the per protocol setting first. it always takes precedence.
// if not set, then use the global setting.
nsCAutoString prefName("network.protocol-handler.expose.");
prefName += aProtocolScheme;
PRBool val;
if (NS_SUCCEEDED(Preferences::GetBool(prefName.get(), &val))) {
*aResult = val;
return NS_OK;
}
// by default, no protocol is exposed. i.e., by default all link clicks must
// go through the external protocol service. most applications override this
// default behavior.
*aResult = PR_FALSE;
*aResult =
Preferences::GetBool("network.protocol-handler.expose-all", PR_FALSE);
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs)
{
PRBool val;
nsresult rv;
// check the per protocol setting first. it always takes precidence.
// if not set, then use the global setting.
nsCAutoString name;
name = NS_LITERAL_CSTRING("network.protocol-handler.expose.")
+ nsDependentCString(aProtocolScheme);
rv = prefs->GetBoolPref(name.get(), &val);
if (NS_SUCCEEDED(rv))
{
*aResult = val;
}
else
{
rv = prefs->GetBoolPref("network.protocol-handler.expose-all", &val);
if (NS_SUCCEEDED(rv) && val)
*aResult = PR_TRUE;
}
}
return NS_OK;
}
@ -1010,22 +996,21 @@ nsExternalHelperAppService::LoadURI(nsIURI *aURI,
if (scheme.IsEmpty())
return NS_OK; // must have a scheme
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs)
return NS_OK; // deny if we can't check prefs
// Deny load if the prefs say to do so
nsCAutoString externalPref(kExternalProtocolPrefPrefix);
externalPref += scheme;
PRBool allowLoad = PR_FALSE;
rv = prefs->GetBoolPref(externalPref.get(), &allowLoad);
if (NS_FAILED(rv))
{
if (NS_FAILED(Preferences::GetBool(externalPref.get(), &allowLoad))) {
// no scheme-specific value, check the default
rv = prefs->GetBoolPref(kExternalProtocolDefaultPref, &allowLoad);
if (NS_FAILED(Preferences::GetBool(kExternalProtocolDefaultPref,
&allowLoad))) {
return NS_OK; // missing default pref
}
}
if (!allowLoad) {
return NS_OK; // explicitly denied
}
if (NS_FAILED(rv) || !allowLoad)
return NS_OK; // explicitly denied or missing default pref
nsCOMPtr<nsIHandlerInfo> handler;
@ -1167,20 +1152,15 @@ nsExternalHelperAppService::SetProtocolHandlerDefaults(nsIHandlerInfo *aHandlerI
aHandlerInfo->SetPreferredAction(nsIHandlerInfo::useSystemDefault);
// whether or not to ask the user depends on the warning preference
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs)
return NS_OK; // deny if we can't check prefs
nsCAutoString scheme;
aHandlerInfo->GetType(scheme);
nsCAutoString warningPref(kExternalWarningPrefPrefix);
warningPref += scheme;
PRBool warn = PR_TRUE;
nsresult rv = prefs->GetBoolPref(warningPref.get(), &warn);
if (NS_FAILED(rv)) {
PRBool warn;
if (NS_FAILED(Preferences::GetBool(warningPref.get(), &warn))) {
// no scheme-specific value, check the default
prefs->GetBoolPref(kExternalWarningDefaultPref, &warn);
warn = Preferences::GetBool(kExternalWarningDefaultPref, PR_TRUE);
}
aHandlerInfo->SetAlwaysAskBeforeHandling(warn);
} else {
@ -1276,17 +1256,7 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
gExtProtSvc->AddRef();
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs)
return;
mBufferSize = 4096;
PRInt32 size;
nsresult rv = prefs->GetIntPref("network.buffer.cache.size", &size);
if (NS_SUCCEEDED(rv)) {
mBufferSize = size;
}
mBufferSize = Preferences::GetUint("network.buffer.cache.size", 4096);
mDataBuffer = (char*) malloc(mBufferSize);
if (!mDataBuffer)
return;
@ -2338,20 +2308,18 @@ nsresult nsExternalAppHandler::OpenWithApplication()
// if a stop request was already issued then proceed with launching the application.
if (mStopRequestIssued)
{
PRBool deleteTempFileOnExit;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs || NS_FAILED(prefs->GetBoolPref(
"browser.helperApps.deleteTempFileOnExit", &deleteTempFileOnExit))) {
// No prefservice or no pref set; use default value
// Note for the default value:
// Mac users have been very verbal about temp files being deleted on
// app exit - they don't like it - but we'll continue to do this on
// other platforms for now.
PRBool deleteTempFileOnExit =
Preferences::GetBool("browser.helperApps.deleteTempFileOnExit",
#if !defined(XP_MACOSX)
// Mac users have been very verbal about temp files being deleted on
// app exit - they don't like it - but we'll continue to do this on
// other platforms for now.
deleteTempFileOnExit = PR_TRUE;
PR_TRUE);
#else
deleteTempFileOnExit = PR_FALSE;
PR_FALSE);
#endif
}
// make the tmp file readonly so users won't edit it and lose the changes
// only if we're going to delete the file
@ -2528,28 +2496,18 @@ void nsExternalAppHandler::ProcessAnyRefreshTags()
PRBool nsExternalAppHandler::GetNeverAskFlagFromPref(const char * prefName, const char * aContentType)
{
// Search the obsolete pref strings.
nsresult rv;
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
if (prefs)
rv = prefs->GetBranch(NEVER_ASK_PREF_BRANCH, getter_AddRefs(prefBranch));
if (NS_SUCCEEDED(rv) && prefBranch)
{
nsXPIDLCString prefCString;
nsCAutoString prefValue;
rv = prefBranch->GetCharPref(prefName, getter_Copies(prefCString));
if (NS_SUCCEEDED(rv) && !prefCString.IsEmpty())
{
NS_UnescapeURL(prefCString);
nsACString::const_iterator start, end;
prefCString.BeginReading(start);
prefCString.EndReading(end);
if (CaseInsensitiveFindInReadable(nsDependentCString(aContentType), start, end))
return PR_FALSE;
}
nsAdoptingCString prefCString = Preferences::GetCString(prefName);
if (prefCString.IsEmpty()) {
// Default is true, if not found in the pref string.
return PR_TRUE;
}
// Default is true, if not found in the pref string.
return PR_TRUE;
NS_UnescapeURL(prefCString);
nsACString::const_iterator start, end;
prefCString.BeginReading(start);
prefCString.EndReading(end);
return !CaseInsensitiveFindInReadable(nsDependentCString(aContentType),
start, end);
}
nsresult nsExternalAppHandler::MaybeCloseWindow()

View File

@ -58,6 +58,9 @@
#include "nsArrayEnumerator.h"
#include "nsIRwsService.h"
#include <stdlib.h>
#include "mozilla/Preferences.h"
using namespace mozilla;
//------------------------------------------------------------------------
@ -296,10 +299,7 @@ void nsMIMEInfoOS2::SetDefaultAppHandle(PRUint32 aHandle)
nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI *aURL)
{
nsresult rv;
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (!thePrefsService) {
return NS_ERROR_FAILURE;
}
NS_ENSURE_TRUE(Preferences::GetRootBranch(), NS_ERROR_FAILURE);
/* Convert SimpleURI to StandardURL */
nsCOMPtr<nsIURI> uri = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
@ -314,20 +314,14 @@ nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI *aURL)
nsCAutoString uProtocol;
uri->GetScheme(uProtocol);
nsCAutoString prefName;
prefName = NS_LITERAL_CSTRING("applications.") + uProtocol;
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
nsXPIDLCString prefString;
if (NS_SUCCEEDED(rv)) {
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
}
nsCAutoString branchName = NS_LITERAL_CSTRING("applications.") + uProtocol;
nsCAutoString prefName = branchName + branchName;
nsAdoptingCString prefString = Preferences::GetCString(prefName.get());
nsCAutoString applicationName;
nsCAutoString parameters;
if (NS_FAILED(rv) || prefString.IsEmpty()) {
if (prefString.IsEmpty()) {
char szAppFromINI[CCHMAXPATH];
char szParamsFromINI[MAXINIPARAMLENGTH];
/* did OS2.INI contain application? */
@ -385,57 +379,58 @@ nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI *aURL)
/* Put application name in parameters */
applicationName.Append(prefString);
prefName.Append(".");
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
if (NS_SUCCEEDED(rv) && prefBranch) {
rv = prefBranch->GetCharPref("parameters", getter_Copies(prefString));
/* If parameters have been specified, use them instead of the separate entities */
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
branchName.Append(".");
prefName = branchName + NS_LITERAL_CSTRING("parameters");
prefString = Preferences::GetCString(prefName.get());
/* If parameters have been specified, use them instead of the separate entities */
if (!prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
PRInt32 pos = parameters.Find(url.get());
if (pos != kNotFound) {
nsCAutoString uURL;
aURL->GetSpec(uURL);
NS_UnescapeURL(uURL);
uURL.Cut(0, uProtocol.Length()+1);
parameters.Replace(pos, url.Length(), uURL);
replaced = PR_TRUE;
PRInt32 pos = parameters.Find(url.get());
if (pos != kNotFound) {
nsCAutoString uURL;
aURL->GetSpec(uURL);
NS_UnescapeURL(uURL);
uURL.Cut(0, uProtocol.Length()+1);
parameters.Replace(pos, url.Length(), uURL);
replaced = PR_TRUE;
}
} else {
/* port */
if (!uPort.IsEmpty()) {
prefName = branchName + NS_LITERAL_CSTRING("port");
prefString = Preferences::GetCString(prefName.get());
if (!prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
} else {
/* port */
if (!uPort.IsEmpty()) {
rv = prefBranch->GetCharPref("port", getter_Copies(prefString));
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
}
/* username */
if (!uUsername.IsEmpty()) {
prefName = branchName + NS_LITERAL_CSTRING("username");
prefString = Preferences::GetCString(prefName.get());
if (!prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
/* username */
if (!uUsername.IsEmpty()) {
rv = prefBranch->GetCharPref("username", getter_Copies(prefString));
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
}
/* password */
if (!uPassword.IsEmpty()) {
prefName = branchName + NS_LITERAL_CSTRING("password");
prefString = Preferences::GetCString(prefName.get());
if (!prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
/* password */
if (!uPassword.IsEmpty()) {
rv = prefBranch->GetCharPref("password", getter_Copies(prefString));
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
}
/* host */
if (!uHost.IsEmpty()) {
rv = prefBranch->GetCharPref("host", getter_Copies(prefString));
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
}
/* host */
if (!uHost.IsEmpty()) {
prefName = branchName + NS_LITERAL_CSTRING("host");
prefString = Preferences::GetCString(prefName.get());
if (!prefString.IsEmpty()) {
parameters.Append(" ");
parameters.Append(prefString);
}
}
}

View File

@ -44,8 +44,6 @@
#include "nsMIMEInfoImpl.h"
#include "nsIPropertyBag.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsNetCID.h"
#include "nsEscape.h"

View File

@ -63,8 +63,11 @@
#include "nsIStringBundle.h"
#include "nsLocalHandlerApp.h"
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
#include <stdlib.h> // for system()
using namespace mozilla;
//------------------------------------------------------------------------
// reduces overhead by preventing calls to nsRws when it isn't present
@ -196,39 +199,27 @@ ParseMIMEType(const nsAString::const_iterator& aStart_iter,
nsresult
nsOSHelperAppService::GetFileLocation(const char* aPrefName,
const char* aEnvVarName,
PRUnichar** aFileLocation) {
nsAString& aFileLocation) {
LOG(("-- GetFileLocation. Pref: '%s' EnvVar: '%s'\n",
aPrefName,
aEnvVarName));
NS_PRECONDITION(aPrefName, "Null pref name passed; don't do that!");
nsresult rv;
*aFileLocation = nsnull;
aFileLocation.Truncate();
/* The lookup order is:
1) user pref
2) env var
3) pref
*/
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(Preferences::GetRootBranch(), NS_ERROR_FAILURE);
/*
If we have an env var we should check whether the pref is a user
pref. If we do not, we don't care.
*/
nsCOMPtr<nsISupportsString> prefFileName;
PRBool isUserPref = PR_FALSE;
prefBranch->PrefHasUserValue(aPrefName, &isUserPref);
if (isUserPref) {
rv = prefBranch->GetComplexValue(aPrefName,
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefFileName));
if (NS_SUCCEEDED(rv)) {
return prefFileName->ToString(aFileLocation);
}
if (Preferences::HasUserValue(aPrefName) &&
NS_SUCCEEDED(Preferences::GetString(aPrefName, &aFileLocation))) {
return NS_OK;
}
if (aEnvVarName && *aEnvVarName) {
@ -244,25 +235,13 @@ nsOSHelperAppService::GetFileLocation(const char* aPrefName,
rv = file->InitWithNativePath(nsDependentCString(prefValue));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString unicodePath;
rv = file->GetPath(unicodePath);
rv = file->GetPath(aFileLocation);
NS_ENSURE_SUCCESS(rv, rv);
*aFileLocation = ToNewUnicode(unicodePath);
if (!*aFileLocation)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
}
rv = prefBranch->GetComplexValue(aPrefName,
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefFileName));
if (NS_SUCCEEDED(rv)) {
return prefFileName->ToString(aFileLocation);
}
return rv;
return Preferences::GetString(aPrefName, &aFileLocation);
}
@ -277,11 +256,10 @@ nsOSHelperAppService::LookUpTypeAndDescription(const nsAString& aFileExtension,
LOG(("-- LookUpTypeAndDescription for extension '%s'\n",
NS_LossyConvertUTF16toASCII(aFileExtension).get()));
nsresult rv = NS_OK;
nsXPIDLString mimeFileName;
nsAutoString mimeFileName;
rv = GetFileLocation("helpers.private_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetTypeAndDescriptionFromMimetypesFile(mimeFileName,
aFileExtension,
@ -293,8 +271,7 @@ nsOSHelperAppService::LookUpTypeAndDescription(const nsAString& aFileExtension,
}
if (NS_FAILED(rv) || aMajorType.IsEmpty()) {
rv = GetFileLocation("helpers.global_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetTypeAndDescriptionFromMimetypesFile(mimeFileName,
aFileExtension,
@ -506,11 +483,10 @@ nsOSHelperAppService::LookUpExtensionsAndDescription(const nsAString& aMajorType
NS_LossyConvertUTF16toASCII(aMajorType).get(),
NS_LossyConvertUTF16toASCII(aMinorType).get()));
nsresult rv = NS_OK;
nsXPIDLString mimeFileName;
nsAutoString mimeFileName;
rv = GetFileLocation("helpers.private_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetExtensionsAndDescriptionFromMimetypesFile(mimeFileName,
aMajorType,
@ -522,8 +498,7 @@ nsOSHelperAppService::LookUpExtensionsAndDescription(const nsAString& aMajorType
}
if (NS_FAILED(rv) || aFileExtensions.IsEmpty()) {
rv = GetFileLocation("helpers.global_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetExtensionsAndDescriptionFromMimetypesFile(mimeFileName,
aMajorType,
@ -909,11 +884,10 @@ nsOSHelperAppService::LookUpHandlerAndDescription(const nsAString& aMajorType,
NS_LossyConvertUTF16toASCII(aMajorType).get(),
NS_LossyConvertUTF16toASCII(aMinorType).get()));
nsresult rv = NS_OK;
nsXPIDLString mailcapFileName;
nsAutoString mailcapFileName;
rv = GetFileLocation("helpers.private_mailcap_file",
"PERSONAL_MAILCAP",
getter_Copies(mailcapFileName));
"PERSONAL_MAILCAP", mailcapFileName);
if (NS_SUCCEEDED(rv) && !mailcapFileName.IsEmpty()) {
rv = GetHandlerAndDescriptionFromMailcapFile(mailcapFileName,
aMajorType,
@ -927,8 +901,7 @@ nsOSHelperAppService::LookUpHandlerAndDescription(const nsAString& aMajorType,
}
if (NS_FAILED(rv) || aHandler.IsEmpty()) {
rv = GetFileLocation("helpers.global_mailcap_file",
"MAILCAP",
getter_Copies(mailcapFileName));
"MAILCAP", mailcapFileName);
if (NS_SUCCEEDED(rv) && !mailcapFileName.IsEmpty()) {
rv = GetHandlerAndDescriptionFromMailcapFile(mailcapFileName,
aMajorType,
@ -1145,22 +1118,16 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch
/* if applications.protocol is in prefs, then we have an external protocol handler */
nsresult rv;
nsCAutoString prefName;
prefName = NS_LITERAL_CSTRING("applications.") + nsDependentCString(aProtocolScheme);
nsCAutoString branchName =
NS_LITERAL_CSTRING("applications.") + nsDependentCString(aProtocolScheme);
nsCAutoString prefName = branchName + branchName;
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
if (NS_SUCCEEDED(rv)) {
nsXPIDLCString prefString;
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
*aHandlerExists = NS_SUCCEEDED(rv) && !prefString.IsEmpty();
if (*aHandlerExists) {
return NS_OK;
}
}
nsAdoptingCString prefString = Preferences::GetCString(prefName.get());
*aHandlerExists = !prefString.IsEmpty();
if (*aHandlerExists) {
return NS_OK;
}
/* Check the OS/2 INI for the protocol */
char szAppFromINI[CCHMAXPATH];
char szParamsFromINI[MAXINIPARAMLENGTH];
@ -1642,14 +1609,12 @@ NS_IMETHODIMP
nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
{
nsresult rv;
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString prefName = NS_LITERAL_CSTRING("applications.") + aScheme;
nsCOMPtr<nsIPrefBranch> prefBranch;
nsCAutoString branchName = NS_LITERAL_CSTRING("applications.") + aScheme;
nsCAutoString applicationName;
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
if (NS_FAILED(rv)) {
nsCAutoString prefName = branchName + branchName;
nsAdoptingCString prefString = Preferences::GetCString(prefName.get());
if (!prefString) { // failed
char szAppFromINI[CCHMAXPATH];
char szParamsFromINI[MAXINIPARAMLENGTH];
/* did OS2.INI contain application? */
@ -1661,12 +1626,8 @@ nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsASt
} else {
return NS_ERROR_NOT_AVAILABLE;
}
} else {
nsXPIDLCString prefString;
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
applicationName.Append(prefString);
}
} else if (!prefString.IsEmpty()) { // succeeded and not empty
applicationName.Append(prefString);
}

View File

@ -92,7 +92,7 @@ private:
nsACString& aUnEscapedCommand);
static nsresult GetFileLocation(const char* aPrefName,
const char* aEnvVarName,
PRUnichar** aFileLocation);
nsAString& aFileLocation);
static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension,
nsAString& aMajorType,
nsAString& aMinorType,

View File

@ -61,8 +61,6 @@
#include "nsILineInputStream.h"
#include "nsILocalFile.h"
#include "nsIProcess.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsNetCID.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
@ -72,6 +70,9 @@
#include "nsDirectoryServiceUtils.h"
#include "prenv.h" // for PR_GetEnv()
#include "nsAutoPtr.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
#define LOG(args) PR_LOG(mLog, PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(mLog, PR_LOG_DEBUG)
@ -203,39 +204,27 @@ ParseMIMEType(const nsAString::const_iterator& aStart_iter,
nsresult
nsOSHelperAppService::GetFileLocation(const char* aPrefName,
const char* aEnvVarName,
PRUnichar** aFileLocation) {
nsAString& aFileLocation) {
LOG(("-- GetFileLocation. Pref: '%s' EnvVar: '%s'\n",
aPrefName,
aEnvVarName));
NS_PRECONDITION(aPrefName, "Null pref name passed; don't do that!");
nsresult rv;
*aFileLocation = nsnull;
aFileLocation.Truncate();
/* The lookup order is:
1) user pref
2) env var
3) pref
*/
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(Preferences::GetRootBranch(), NS_ERROR_FAILURE);
/*
If we have an env var we should check whether the pref is a user
pref. If we do not, we don't care.
*/
nsCOMPtr<nsISupportsString> prefFileName;
PRBool isUserPref = PR_FALSE;
prefBranch->PrefHasUserValue(aPrefName, &isUserPref);
if (isUserPref) {
rv = prefBranch->GetComplexValue(aPrefName,
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefFileName));
if (NS_SUCCEEDED(rv)) {
return prefFileName->ToString(aFileLocation);
}
if (Preferences::HasUserValue(aPrefName) &&
NS_SUCCEEDED(Preferences::GetString(aPrefName, &aFileLocation))) {
return NS_OK;
}
if (aEnvVarName && *aEnvVarName) {
@ -245,31 +234,21 @@ nsOSHelperAppService::GetFileLocation(const char* aPrefName,
// natural way to do the charset conversion is by just initing
// an nsIFile with the native path and asking it for the Unicode
// version.
nsresult rv;
nsCOMPtr<nsILocalFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = file->InitWithNativePath(nsDependentCString(prefValue));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString unicodePath;
rv = file->GetPath(unicodePath);
rv = file->GetPath(aFileLocation);
NS_ENSURE_SUCCESS(rv, rv);
*aFileLocation = ToNewUnicode(unicodePath);
if (!*aFileLocation)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
}
rv = prefBranch->GetComplexValue(aPrefName,
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefFileName));
if (NS_SUCCEEDED(rv)) {
return prefFileName->ToString(aFileLocation);
}
return rv;
return Preferences::GetString(aPrefName, &aFileLocation);
}
@ -285,14 +264,12 @@ nsOSHelperAppService::LookUpTypeAndDescription(const nsAString& aFileExtension,
LOG(("-- LookUpTypeAndDescription for extension '%s'\n",
NS_LossyConvertUTF16toASCII(aFileExtension).get()));
nsresult rv = NS_OK;
nsXPIDLString mimeFileName;
nsAutoString mimeFileName;
const char* filenamePref = aUserData ?
"helpers.private_mime_types_file" : "helpers.global_mime_types_file";
rv = GetFileLocation(filenamePref,
nsnull,
getter_Copies(mimeFileName));
rv = GetFileLocation(filenamePref, nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetTypeAndDescriptionFromMimetypesFile(mimeFileName,
aFileExtension,
@ -503,11 +480,9 @@ nsOSHelperAppService::LookUpExtensionsAndDescription(const nsAString& aMajorType
NS_LossyConvertUTF16toASCII(aMajorType).get(),
NS_LossyConvertUTF16toASCII(aMinorType).get()));
nsresult rv = NS_OK;
nsXPIDLString mimeFileName;
nsAutoString mimeFileName;
rv = GetFileLocation("helpers.private_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
rv = GetFileLocation("helpers.private_mime_types_file", nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetExtensionsAndDescriptionFromMimetypesFile(mimeFileName,
aMajorType,
@ -519,8 +494,7 @@ nsOSHelperAppService::LookUpExtensionsAndDescription(const nsAString& aMajorType
}
if (NS_FAILED(rv) || aFileExtensions.IsEmpty()) {
rv = GetFileLocation("helpers.global_mime_types_file",
nsnull,
getter_Copies(mimeFileName));
nsnull, mimeFileName);
if (NS_SUCCEEDED(rv) && !mimeFileName.IsEmpty()) {
rv = GetExtensionsAndDescriptionFromMimetypesFile(mimeFileName,
aMajorType,
@ -964,16 +938,14 @@ nsOSHelperAppService::DoLookUpHandlerAndDescription(const nsAString& aMajorType,
NS_LossyConvertUTF16toASCII(aMajorType).get(),
NS_LossyConvertUTF16toASCII(aMinorType).get()));
nsresult rv = NS_OK;
nsXPIDLString mailcapFileName;
nsAutoString mailcapFileName;
const char * filenamePref = aUserData ?
"helpers.private_mailcap_file" : "helpers.global_mailcap_file";
const char * filenameEnvVar = aUserData ?
"PERSONAL_MAILCAP" : "MAILCAP";
rv = GetFileLocation(filenamePref,
filenameEnvVar,
getter_Copies(mailcapFileName));
rv = GetFileLocation(filenamePref, filenameEnvVar, mailcapFileName);
if (NS_SUCCEEDED(rv) && !mailcapFileName.IsEmpty()) {
rv = GetHandlerAndDescriptionFromMailcapFile(mailcapFileName,
aMajorType,

View File

@ -93,7 +93,7 @@ private:
nsACString& aUnEscapedCommand);
static nsresult GetFileLocation(const char* aPrefName,
const char* aEnvVarName,
PRUnichar** aFileLocation);
nsAString& aFileLocation);
static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension,
nsAString& aMajorType,
nsAString& aMinorType,

View File

@ -61,8 +61,6 @@
#include "nsICacheEntryDescriptor.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsServiceManagerUtils.h"
@ -71,9 +69,12 @@
#include "nsProxyRelease.h"
#include "prlog.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "mozilla/Preferences.h"
#include "nsXULAppAPI.h"
using namespace mozilla;
static const PRUint32 kRescheduleLimit = 3;
#if defined(PR_LOGGING)
@ -1029,11 +1030,8 @@ nsOfflineManifestItem::CheckNewManifestContentHash(nsIRequest *aRequest)
void
nsOfflineManifestItem::ReadStrictFileOriginPolicyPref()
{
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
mStrictFileOriginPolicy =
(!prefs ||
NS_FAILED(prefs->GetBoolPref("security.fileuri.strict_origin_policy",
&mStrictFileOriginPolicy)));
Preferences::GetBool("security.fileuri.strict_origin_policy", PR_TRUE);
}
NS_IMETHODIMP

View File

@ -64,8 +64,6 @@
#include "nsICacheEntryDescriptor.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsServiceManagerUtils.h"
@ -74,6 +72,9 @@
#include "nsProxyRelease.h"
#include "prlog.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
static nsOfflineCacheUpdateService *gOfflineCacheUpdateService = nsnull;
@ -569,15 +570,11 @@ nsOfflineCacheUpdateService::OfflineAppAllowedForURI(nsIURI *aURI,
permissionManager->TestExactPermission(innerURI, "offline-app", &perm);
if (perm == nsIPermissionManager::UNKNOWN_ACTION) {
nsCOMPtr<nsIPrefBranch> branch = aPrefBranch;
if (!branch) {
branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
}
if (branch) {
rv = branch->GetBoolPref("offline-apps.allow_by_default", aAllowed);
if (NS_FAILED(rv)) {
*aAllowed = PR_FALSE;
}
static const char kPrefName[] = "offline-apps.allow_by_default";
if (aPrefBranch) {
aPrefBranch->GetBoolPref(kPrefName, aAllowed);
} else {
*aAllowed = Preferences::GetBool(kPrefName, PR_FALSE);
}
return NS_OK;

View File

@ -41,8 +41,6 @@
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsIObserverService.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch2.h"
#include "nsIDocCharset.h"
#include "nsIWebProgress.h"
#include "nsCURILoader.h"
@ -61,6 +59,9 @@
#include "prlog.h"
#include "plstr.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
#if defined(PR_LOGGING)
//
@ -414,6 +415,7 @@ nsPrefetchService::nsPrefetchService()
nsPrefetchService::~nsPrefetchService()
{
Preferences::RemoveObserver(this, PREFETCH_PREF);
// cannot reach destructor if prefetch in progress (listener owns reference
// to this service)
EmptyQueue();
@ -430,15 +432,8 @@ nsPrefetchService::Init()
nsresult rv;
// read prefs and hook up pref observer
nsCOMPtr<nsIPrefBranch2> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
PRBool enabled;
rv = prefs->GetBoolPref(PREFETCH_PREF, &enabled);
if (NS_SUCCEEDED(rv) && enabled)
mDisabled = PR_FALSE;
prefs->AddObserver(PREFETCH_PREF, this, PR_TRUE);
}
mDisabled = !Preferences::GetBool(PREFETCH_PREF, !mDisabled);
Preferences::AddWeakObserver(this, PREFETCH_PREF);
// Observe xpcom-shutdown event
nsCOMPtr<nsIObserverService> observerService =
@ -945,10 +940,7 @@ nsPrefetchService::Observe(nsISupports *aSubject,
mDisabled = PR_TRUE;
}
else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsCOMPtr<nsIPrefBranch> prefs(do_QueryInterface(aSubject));
PRBool enabled;
nsresult rv = prefs->GetBoolPref(PREFETCH_PREF, &enabled);
if (NS_SUCCEEDED(rv) && enabled) {
if (Preferences::GetBool(PREFETCH_PREF, PR_FALSE)) {
if (mDisabled) {
LOG(("enabling prefetching\n"));
mDisabled = PR_FALSE;

View File

@ -99,8 +99,8 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpDa
// Callback hook which will dynamically allocate a buffer large
// enough for the file picker dialog.
static unsigned int CALLBACK FilePickerHook(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
static UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:

View File

@ -400,7 +400,16 @@ RealBreak()
#elif defined(__GNUC__) && (defined(__i386__) || defined(__i386) || defined(__x86_64__))
asm("int $3");
#elif defined(__arm__)
asm("BKPT #0");
asm(
#ifdef __ARM_ARCH_4T__
/* ARMv4T doesn't support the BKPT instruction, so if the compiler target
* is ARMv4T, we want to ensure the assembler will understand that ARMv5T
* instruction, while keeping the resulting object tagged as ARMv4T.
*/
".arch armv5t\n"
".object_arch armv4t\n"
#endif
"BKPT #0");
#elif defined(SOLARIS)
#if defined(__i386__) || defined(__i386) || defined(__x86_64__)
asm("int $3");

View File

@ -263,8 +263,12 @@ main(int argc, char **argv)
// 3) give up
struct stat fileStat;
if (!realpath(argv[0], iniPath) || stat(iniPath, &fileStat)) {
strncpy(tmpPath, argv[0], sizeof(tmpPath));
lastSlash = strrchr(tmpPath, '/');
if (lastSlash) {
*lastSlash = 0;
realpath(tmpPath, iniPath);
} else {
const char *path = getenv("PATH");
if (!path)
return 1;
@ -277,8 +281,11 @@ main(int argc, char **argv)
char *token = strtok(pathdup, ":");
while (token) {
sprintf(tmpPath, "%s/%s", token, argv[0]);
if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) {
if (stat(tmpPath, &fileStat) == 0) {
found = PR_TRUE;
lastSlash = strrchr(tmpPath, '/');
*lastSlash = 0;
realpath(tmpPath, iniPath);
break;
}
token = strtok(NULL, ":");
@ -287,11 +294,15 @@ main(int argc, char **argv)
if (!found)
return 1;
}
lastSlash = iniPath + strlen(iniPath);
*lastSlash = '/';
#endif
#ifndef XP_UNIX
lastSlash = strrchr(iniPath, PATH_SEPARATOR_CHAR);
if (!lastSlash)
return 1;
#endif
*(++lastSlash) = '\0';