diff --git a/caps/BasePrincipal.h b/caps/BasePrincipal.h index 132c53fc347a..4f74badb205d 100644 --- a/caps/BasePrincipal.h +++ b/caps/BasePrincipal.h @@ -256,6 +256,16 @@ class BasePrincipal : public nsJSPrincipals { void FinishInit(BasePrincipal* aOther, const OriginAttributes& aOriginAttributes); + // KeyValT holds a principal subtype-specific key value and the associated + // parsed value after JSON parsing. + template + struct KeyValT + { + bool valueWasSerialized; + nsCString value; + SerializedKey key; + }; + private: static already_AddRefed CreateContentPrincipal( nsIURI* aURI, const OriginAttributes& aAttrs, diff --git a/caps/ContentPrincipal.h b/caps/ContentPrincipal.h index 0e7dac44d7be..653ee8e25de0 100644 --- a/caps/ContentPrincipal.h +++ b/caps/ContentPrincipal.h @@ -60,14 +60,8 @@ class ContentPrincipal final : public BasePrincipal { virtual nsresult PopulateJSONObject(Json::Value& aObject) override; // Serializable keys are the valid enum fields the serialization supports enum SerializableKeys { eURI = 0, eDomain, eSuffix, eMax = eSuffix }; - // KeyVal is a lightweight storage that passes - // SerializableKeys and values after JSON parsing in the BasePrincipal to - // FromProperties - struct KeyVal { - bool valueWasSerialized; - nsCString value; - SerializableKeys key; - }; + typedef mozilla::BasePrincipal::KeyValT KeyVal; + static already_AddRefed FromProperties( nsTArray& aFields); diff --git a/caps/ExpandedPrincipal.h b/caps/ExpandedPrincipal.h index 98ff40437f4d..71dcceb1fd5e 100644 --- a/caps/ExpandedPrincipal.h +++ b/caps/ExpandedPrincipal.h @@ -63,14 +63,8 @@ class ExpandedPrincipal : public nsIExpandedPrincipal, virtual nsresult PopulateJSONObject(Json::Value& aObject) override; // Serializable keys are the valid enum fields the serialization supports enum SerializableKeys { eSpecs = 0, eSuffix, eMax = eSuffix }; - // KeyVal is a lightweight storage that passes - // SerializableKeys and values after JSON parsing in the BasePrincipal to - // FromProperties - struct KeyVal { - bool valueWasSerialized; - nsCString value; - SerializableKeys key; - }; + typedef mozilla::BasePrincipal::KeyValT KeyVal; + static already_AddRefed FromProperties( nsTArray& aFields); diff --git a/caps/NullPrincipal.h b/caps/NullPrincipal.h index 09f09581bed4..268555119b54 100644 --- a/caps/NullPrincipal.h +++ b/caps/NullPrincipal.h @@ -87,14 +87,8 @@ class NullPrincipal final : public BasePrincipal { // Serializable keys are the valid enum fields the serialization supports enum SerializableKeys { eSpec = 0, eSuffix, eMax = eSuffix }; - // KeyVal is a lightweight storage that passes - // SerializableKeys and values after JSON parsing in the BasePrincipal to - // FromProperties - struct KeyVal { - bool valueWasSerialized; - nsCString value; - SerializableKeys key; - }; + typedef mozilla::BasePrincipal::KeyValT KeyVal; + static already_AddRefed FromProperties( nsTArray& aFields);