summaryrefslogtreecommitdiffstats
path: root/xpcom/glue/AppData.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /xpcom/glue/AppData.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'xpcom/glue/AppData.cpp')
-rw-r--r--xpcom/glue/AppData.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/xpcom/glue/AppData.cpp b/xpcom/glue/AppData.cpp
new file mode 100644
index 000000000..845267e60
--- /dev/null
+++ b/xpcom/glue/AppData.cpp
@@ -0,0 +1,95 @@
+/* -*- 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 "mozilla/AppData.h"
+#include "nsXULAppAPI.h"
+#include "nsINIParser.h"
+#include "nsIFile.h"
+#include "nsCRTGlue.h"
+#include "nsAutoPtr.h"
+
+namespace mozilla {
+
+void
+SetAllocatedString(const char*& aStr, const char* aNewValue)
+{
+ NS_Free(const_cast<char*>(aStr));
+ if (aNewValue) {
+ aStr = NS_strdup(aNewValue);
+ } else {
+ aStr = nullptr;
+ }
+}
+
+void
+SetAllocatedString(const char*& aStr, const nsACString& aNewValue)
+{
+ NS_Free(const_cast<char*>(aStr));
+ if (aNewValue.IsEmpty()) {
+ aStr = nullptr;
+ } else {
+ aStr = ToNewCString(aNewValue);
+ }
+}
+
+ScopedAppData::ScopedAppData(const nsXREAppData* aAppData)
+{
+ Zero();
+
+ this->size = aAppData->size;
+
+ SetAllocatedString(this->vendor, aAppData->vendor);
+ SetAllocatedString(this->name, aAppData->name);
+ SetAllocatedString(this->remotingName, aAppData->remotingName);
+ SetAllocatedString(this->version, aAppData->version);
+ SetAllocatedString(this->buildID, aAppData->buildID);
+ SetAllocatedString(this->ID, aAppData->ID);
+ SetAllocatedString(this->copyright, aAppData->copyright);
+ SetAllocatedString(this->profile, aAppData->profile);
+ SetStrongPtr(this->directory, aAppData->directory);
+ this->flags = aAppData->flags;
+
+ if (aAppData->size > offsetof(nsXREAppData, xreDirectory)) {
+ SetStrongPtr(this->xreDirectory, aAppData->xreDirectory);
+ SetAllocatedString(this->minVersion, aAppData->minVersion);
+ SetAllocatedString(this->maxVersion, aAppData->maxVersion);
+ }
+
+ if (aAppData->size > offsetof(nsXREAppData, crashReporterURL)) {
+ SetAllocatedString(this->crashReporterURL, aAppData->crashReporterURL);
+ }
+
+ if (aAppData->size > offsetof(nsXREAppData, UAName)) {
+ SetAllocatedString(this->UAName, aAppData->UAName);
+ }
+
+#if defined(XP_WIN) && defined(MOZ_SANDBOX)
+ sandboxBrokerServices = aAppData->sandboxBrokerServices;
+#endif
+}
+
+ScopedAppData::~ScopedAppData()
+{
+ SetAllocatedString(this->vendor, nullptr);
+ SetAllocatedString(this->name, nullptr);
+ SetAllocatedString(this->remotingName, nullptr);
+ SetAllocatedString(this->version, nullptr);
+ SetAllocatedString(this->buildID, nullptr);
+ SetAllocatedString(this->ID, nullptr);
+ SetAllocatedString(this->copyright, nullptr);
+ SetAllocatedString(this->profile, nullptr);
+
+ NS_IF_RELEASE(this->directory);
+
+ SetStrongPtr(this->xreDirectory, (nsIFile*)nullptr);
+ SetAllocatedString(this->minVersion, nullptr);
+ SetAllocatedString(this->maxVersion, nullptr);
+
+ SetAllocatedString(this->crashReporterURL, nullptr);
+ SetAllocatedString(this->UAName, nullptr);
+}
+
+} // namespace mozilla