/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"prio.h" #ifdefined(XP_WIN) # include <windows.h> #elifdefined(MOZ_WIDGET_COCOA) # include <CoreServices/CoreServices.h> # include "nsCocoaFeatures.h" #elifdefined(MOZ_WIDGET_GTK) # include <gtk/gtk.h> #endif
#ifdef MOZ_WIDGET_ANDROID # include "AndroidBuild.h" # include "mozilla/java/GeckoAppShellWrappers.h" #endif
#ifdef MOZ_BACKGROUNDTASKS # include "mozilla/BackgroundTasks.h" #endif
struct ManifestDirective { constchar* directive; int argc;
bool ischrome;
// The contentaccessible flags only apply to content/resource directives. bool contentflags;
// Function to handle this directive. This isn't a union because C++ still // hasn't learned how to initialize unions in a sane way. void (nsComponentManagerImpl::*mgrfunc)(
nsComponentManagerImpl::ManifestProcessingContext& aCx, int aLineNo, char* const* aArgv); void (nsChromeRegistry::*regfunc)(
nsChromeRegistry::ManifestProcessingContext& aCx, int aLineNo, char* const* aArgv, int aFlags);
}; staticconst ManifestDirective kParsingTable[] = { // clang-format off
{ "manifest", 1, true, false,
&nsComponentManagerImpl::ManifestManifest, nullptr,
},
{ "category", 3, false, false,
&nsComponentManagerImpl::ManifestCategory, nullptr,
},
{ "content", 2, true, true,
nullptr, &nsChromeRegistry::ManifestContent,
},
{ "locale", 3, true, false,
nullptr, &nsChromeRegistry::ManifestLocale,
},
{ "skin", 3, true, false,
nullptr, &nsChromeRegistry::ManifestSkin,
},
{ // NB: note that while skin manifests can use this, they are only allowed // to use it for chrome://../skin/ URLs "override", 2, true, false,
nullptr, &nsChromeRegistry::ManifestOverride,
},
{ "resource", 2, false, true,
nullptr, &nsChromeRegistry::ManifestResource,
} // clang-format on
};
nsCOMPtr<nsIScriptError> error = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); if (!error) { // This can happen early in component registration. Fall back to a // generic console message.
LogMessage("Warning: in '%s', line %i: %s", file.get(), aLineNumber,
formatted.get()); return;
}
nsCOMPtr<nsIConsoleService> console =
do_GetService(NS_CONSOLESERVICE_CONTRACTID); if (!console) { return;
}
nsresult rv = error->Init(
NS_ConvertUTF8toUTF16(formatted.get()), file, aLineNumber, 0,
nsIScriptError::warningFlag, "chrome registration"_ns, false/* from private window */, true /* from chrome context */); if (NS_FAILED(rv)) { return;
}
console->LogMessage(error);
}
/** * Check for a modifier flag of the following forms: * "flag" (same as "true") * "flag=yes|true|1" * "flag="no|false|0" * @param aFlag The flag to compare. * @param aData The tokenized data to check; this is lowercased * before being passed in. * @param aResult If the flag is found, the value is assigned here. * @return Whether the flag was handled.
*/ staticbool CheckFlag(const nsAString& aFlag, const nsAString& aData, bool& aResult) { if (!StringBeginsWith(aData, aFlag)) { returnfalse;
}
if (aFlag.Length() == aData.Length()) { // the data is simply "flag", which is the same as "flag=yes"
aResult = true; returntrue;
}
if (aData.CharAt(aFlag.Length()) != '=') { // the data is "flag2=", which is not anything we care about returnfalse;
}
/** * Check for a modifier flag of the following form: * "flag=string" * "flag!=string" * @param aFlag The flag to compare. * @param aData The tokenized data to check; this is lowercased * before being passed in. * @param aValue The value that is expected. * @param aResult If this is "ok" when passed in, this is left alone. * Otherwise if the flag is found it is set to eBad or eOK. * @return Whether the flag was handled.
*/ staticbool CheckStringFlag(const nsAString& aFlag, const nsAString& aData, const nsAString& aValue, TriState& aResult) { if (aData.Length() < aFlag.Length() + 1) { returnfalse;
}
if (!StringBeginsWith(aData, aFlag)) { returnfalse;
}
/** * Check for a modifier flag of the following form: * "flag=version" * "flag<=version" * "flag<version" * "flag>=version" * "flag>version" * @param aFlag The flag to compare. * @param aData The tokenized data to check; this is lowercased * before being passed in. * @param aValue The value that is expected. If this is empty then no * comparison will match. * @param aResult If this is eOK when passed in, this is left alone. * Otherwise if the flag is found it is set to eBad or eOK. * @return Whether the flag was handled.
*/
constexpr auto kContentAccessible = u"contentaccessible"_ns;
constexpr auto kRemoteEnabled = u"remoteenabled"_ns;
constexpr auto kRemoteRequired = u"remoterequired"_ns;
constexpr auto kApplication = u"application"_ns;
constexpr auto kAppVersion = u"appversion"_ns;
constexpr auto kGeckoVersion = u"platformversion"_ns;
constexpr auto kOs = u"os"_ns;
constexpr auto kOsVersion = u"osversion"_ns;
constexpr auto kABI = u"abi"_ns;
constexpr auto kProcess = u"process"_ns; #ifdefined(MOZ_WIDGET_ANDROID)
constexpr auto kTablet = u"tablet"_ns; #endif // You might expect this to be guarded by MOZ_BACKGROUNDTASKS, but it's not // possible to have conditional manifest contents, so we need to recognize and // discard these tokens even when MOZ_BACKGROUNDTASKS is not set.
constexpr auto kBackgroundTask = u"backgroundtask"_ns;
constexpr auto kMain = u"main"_ns;
constexpr auto kContent = u"content"_ns;
// Obsolete
constexpr auto kXPCNativeWrappers = u"xpcnativewrappers"_ns;
// You might expect this to be guarded by MOZ_BACKGROUNDTASKS, it's not // possible to have conditional manifest contents. bool flag; if (CheckFlag(kBackgroundTask, wtoken, flag)) { #ifdefined(MOZ_BACKGROUNDTASKS) // Background task mode is active: filter.
stBackgroundTask =
(flag == BackgroundTasks::IsBackgroundTaskMode()) ? eOK : eBad; #endif/* defined(MOZ_BACKGROUNDTASKS) */ continue;
}
if (directive->contentflags) { bool flag; if (CheckFlag(kContentAccessible, wtoken, flag)) { if (flag) flags |= nsChromeRegistry::CONTENT_ACCESSIBLE; continue;
} if (CheckFlag(kRemoteEnabled, wtoken, flag)) { if (flag) flags |= nsChromeRegistry::REMOTE_ALLOWED; continue;
} if (CheckFlag(kRemoteRequired, wtoken, flag)) { if (flag) flags |= nsChromeRegistry::REMOTE_REQUIRED; continue;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.