Blob Blame History Raw
--- mozilla/modules/libpref/Preferences.cpp.orig	2023-06-10 13:41:20.000000000 +0300
+++ mozilla/modules/libpref/Preferences.cpp	2023-06-15 17:03:50.450004924 +0300
@@ -802,6 +802,7 @@
              PrefValueKind aKind,
              PrefValue aValue,
              bool aIsSticky,
+             bool aIsLocked,
              bool aFromFile)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -840,6 +841,10 @@
 
     return rv;
   }
+  if (aIsLocked) {
+    pref->SetIsLocked(true);
+    gIsAnyPrefLocked = true;
+  }
 
   if (valueChanged) {
     if (aKind == PrefValueKind::User && XRE_IsParentProcess()) {
@@ -940,6 +945,7 @@
     , mVtype()
     , mIsDefault()
     , mIsSticky()
+    , mIsLocked()
   {
   }
 
@@ -953,7 +959,8 @@
                    PrefType aType,
                    PrefValue aValue,
                    bool aIsDefault,
-                   bool aIsSticky);
+                   bool aIsSticky,
+                   bool aIsLocked);
 
   void ReportProblem(const char* aMessage, int aLine, bool aError);
 
@@ -987,6 +994,7 @@
   static constexpr const char* kUserPref = "user_pref";
   static constexpr const char* kPref = "pref";
   static constexpr const char* kStickyPref = "sticky_pref";
+  static constexpr const char* kLockedPref = "lockPref";
   static constexpr const char* kTrue = "true";
   static constexpr const char* kFalse = "false";
 
@@ -1006,6 +1014,7 @@
   Maybe<PrefType> mVtype; // pref value type
   bool mIsDefault;        // true if (default) pref
   bool mIsSticky;         // true if (sticky) pref
+  bool mIsLocked;         // true if (locked) pref
 };
 
 // This function will increase the size of the buffer owned by the given pref
@@ -1052,11 +1061,12 @@
                     PrefType aType,
                     PrefValue aValue,
                     bool aIsDefault,
-                    bool aIsSticky)
+                    bool aIsSticky,
+                    bool aIsLocked)
 {
   PrefValueKind kind =
     aIsDefault ? PrefValueKind::Default : PrefValueKind::User;
-  pref_SetPref(aPrefName, aType, kind, aValue, aIsSticky, /* fromFile */ true);
+  pref_SetPref(aPrefName, aType, kind, aValue, aIsSticky, aIsLocked, /* fromFile */ true);
 }
 
 // Report an error or a warning. If not specified, just dump to stderr.
@@ -1125,6 +1135,7 @@
           mVtype = Nothing();
           mIsDefault = false;
           mIsSticky = false;
+          mIsLocked = false;
         }
         switch (c) {
           case '/': // begin comment block or line?
@@ -1136,10 +1147,13 @@
           case 'u': // indicating user_pref
           case 's': // indicating sticky_pref
           case 'p': // indicating pref
+          case 'l': // indicating lockPref
             if (c == 'u') {
               mStrMatch = kUserPref;
             } else if (c == 's') {
               mStrMatch = kStickyPref;
+            } else if (c == 'l') {
+              mStrMatch = kLockedPref;
             } else {
               mStrMatch = kPref;
             }
@@ -1187,8 +1201,9 @@
       // name parsing
       case State::eUntilName:
         if (c == '\"' || c == '\'') {
-          mIsDefault = (mStrMatch == kPref || mStrMatch == kStickyPref);
+          mIsDefault = (mStrMatch == kPref || mStrMatch == kStickyPref || mStrMatch == kLockedPref);
           mIsSticky = (mStrMatch == kStickyPref);
+          mIsLocked = (mStrMatch == kLockedPref);
           mQuoteChar = c;
           mNextState = State::eUntilComma; // return here when done
           state = State::eQuotedString;
@@ -1505,7 +1520,7 @@
           }
 
           // We've extracted a complete name/value pair.
-          HandleValue(mLb, *mVtype, value, mIsDefault, mIsSticky);
+          HandleValue(mLb, *mVtype, value, mIsDefault, mIsSticky, mIsLocked);
 
           state = State::eInit;
         } else if (c == '/') {
@@ -4496,6 +4511,7 @@
                       aKind,
                       prefValue,
                       /* isSticky */ false,
+                      /* isLocked */ false,
                       /* fromFile */ false);
 }
 
@@ -4522,6 +4538,7 @@
                       aKind,
                       prefValue,
                       /* isSticky */ false,
+                      /* isLocked */ false,
                       /* fromFile */ false);
 }
 
@@ -4546,6 +4563,7 @@
                       aKind,
                       prefValue,
                       /* isSticky */ false,
+                      /* isLocked */ false,
                       /* fromFile */ false);
 }