Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / reporting / FeaturePolicyViolationReportBody.cpp
blobf4d6b473ba54ba45fbcbe2ef81fa4d77f73e49b4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/FeaturePolicyViolationReportBody.h"
9 #include "mozilla/JSONWriter.h"
10 #include "mozilla/dom/FeaturePolicyBinding.h"
12 namespace mozilla {
13 namespace dom {
15 FeaturePolicyViolationReportBody::FeaturePolicyViolationReportBody(
16 nsIGlobalObject* aGlobal, const nsAString& aFeatureId,
17 const nsAString& aSourceFile, const Nullable<int32_t>& aLineNumber,
18 const Nullable<int32_t>& aColumnNumber, const nsAString& aDisposition)
19 : ReportBody(aGlobal),
20 mFeatureId(aFeatureId),
21 mSourceFile(aSourceFile),
22 mLineNumber(aLineNumber),
23 mColumnNumber(aColumnNumber),
24 mDisposition(aDisposition) {}
26 FeaturePolicyViolationReportBody::~FeaturePolicyViolationReportBody() = default;
28 JSObject* FeaturePolicyViolationReportBody::WrapObject(
29 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
30 return FeaturePolicyViolationReportBody_Binding::Wrap(aCx, this, aGivenProto);
33 void FeaturePolicyViolationReportBody::GetFeatureId(
34 nsAString& aFeatureId) const {
35 aFeatureId = mFeatureId;
38 void FeaturePolicyViolationReportBody::GetSourceFile(
39 nsAString& aSourceFile) const {
40 aSourceFile = mSourceFile;
43 Nullable<int32_t> FeaturePolicyViolationReportBody::GetLineNumber() const {
44 return mLineNumber;
47 Nullable<int32_t> FeaturePolicyViolationReportBody::GetColumnNumber() const {
48 return mColumnNumber;
51 void FeaturePolicyViolationReportBody::GetDisposition(
52 nsAString& aDisposition) const {
53 aDisposition = mDisposition;
56 void FeaturePolicyViolationReportBody::ToJSON(JSONWriter& aWriter) const {
57 aWriter.StringProperty("featureId", NS_ConvertUTF16toUTF8(mFeatureId));
59 if (mSourceFile.IsEmpty()) {
60 aWriter.NullProperty("sourceFile");
61 } else {
62 aWriter.StringProperty("sourceFile", NS_ConvertUTF16toUTF8(mSourceFile));
65 if (mLineNumber.IsNull()) {
66 aWriter.NullProperty("lineNumber");
67 } else {
68 aWriter.IntProperty("lineNumber", mLineNumber.Value());
71 if (mColumnNumber.IsNull()) {
72 aWriter.NullProperty("columnNumber");
73 } else {
74 aWriter.IntProperty("columnNumber", mColumnNumber.Value());
77 aWriter.StringProperty("disposition", NS_ConvertUTF16toUTF8(mDisposition));
80 } // namespace dom
81 } // namespace mozilla