This file is indexed.

/usr/share/xul-ext/tabmixplus/modules/Services.jsm is in xul-ext-tabmixplus 0.5.0.0-1~deb8u1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
/* globals dump */
"use strict";

this.EXPORTED_SYMBOLS = ["TabmixSvc"];

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

XPCOMUtils.defineLazyModuleGetter(this, "TabmixPlacesUtils",
  "resource://tabmixplus/Places.jsm");

var tabStateCache;
var _versions = {};
function isVersion(aVersionNo) {
  if (TabmixSvc.isPaleMoonID) {
    let paleMoonVer = arguments.length > 1 ? arguments[1] : -1;
    if (aVersionNo > 240 && paleMoonVer == -1)
      return false;
    aVersionNo = paleMoonVer;
  }

  if (typeof _versions[aVersionNo] == "boolean")
    return _versions[aVersionNo];

  let v = Services.appinfo.version;
  return (_versions[aVersionNo] = Services.vc.compare(v, aVersionNo / 10 + ".0a1") >= 0);
}

this.TabmixSvc = {
  get selectedAtt() {
    delete this.selectedAtt;
    return (this.selectedAtt = isVersion(390) ?
            "visuallyselected" : "selected");
  },

  aboutBlank: "about:blank",
  aboutNewtab: "about:#".replace("#", "newtab"),
  newtabUrl: "browser.#.url".replace("#", "newtab"),

  debugMode: function() {
    return this.prefBranch.prefHasUserValue("enableDebug") &&
      this.prefBranch.getBoolPref("enableDebug");
  },

  version: function() {
    return isVersion.apply(null, arguments);
  },

  getString: function(aStringKey) {
    try {
      return this._strings.GetStringFromName(aStringKey);
    } catch (e) {
      dump("*** Failed to get string " + aStringKey + " in bundle: tabmix.properties\n");
      throw e;
    }
  },

  getFormattedString: function(aStringKey, aStringsArray) {
    try {
      return this._strings.formatStringFromName(aStringKey, aStringsArray, aStringsArray.length);
    } catch (e) {
      dump("*** Failed to format string " + aStringKey + " in bundle: tabmix.properties\n");
      throw e;
    }
  },

  getSMString: function(aStringKey) {
    try {
      return this.SMstrings.GetStringFromName(aStringKey);
    } catch (e) {
      dump("*** Failed to get string " + aStringKey + " in bundle: session-manager.properties\n");
      throw e;
    }
  },

  setLabel: function(property) {
    var label, key;
    if (property.startsWith("sm.")) {
      label = this.getSMString(property + ".label");
      key = this.getSMString(property + ".accesskey");
    } else {
      label = this.getString(property + ".label");
      key = this.getString(property + ".accesskey");
    }
    var accessKeyIndex = label.toLowerCase().indexOf(key.toLowerCase());
    if (accessKeyIndex > -1)
      label = label.substr(0, accessKeyIndex) + "&" + label.substr(accessKeyIndex);
    return label;
  },

  getDialogStrings: function(...keys) {
    let stringBundle = Services.strings.createBundle("chrome://global/locale/commonDialogs.properties");

    return keys.map(key => {
      try {
        return stringBundle.GetStringFromName(key);
      } catch (ex) {
        this.console.log("Failed to get string " + key + " in bundle: commonDialogs.properties");
        return key;
      }
    });
  },

  topWin: function() {
    return Services.wm.getMostRecentWindow("navigator:browser");
  },

  get direct2dDisabled() {
    delete this.direct2dDisabled;
    try {
      // this pref exist only in windows
      return (this.direct2dDisabled = Services.prefs.getBoolPref("gfx.direct2d.disabled"));
    } catch (ex) {}
    return (this.direct2dDisabled = false);
  },

  /**
   * call a callback for all currently opened browser windows
   * (might miss the most recent one)
   * @param aFunc
   *        Callback each window is passed to
   */
  forEachBrowserWindow: function(aFunc) {
    let windowsEnum = Services.wm.getEnumerator("navigator:browser");
    while (windowsEnum.hasMoreElements()) {
      let window = windowsEnum.getNext();
      if (!window.closed) {
        aFunc(window);
      }
    }
  },

  // some extensions override native JSON so we use nsIJSON
  JSON: {
    nsIJSON: null,
    parse: function TMP_parse(str) {
      try {
        return JSON.parse(str);
      } catch (ex) {
        try {
          return "decode" in this.nsIJSON ? this.nsIJSON.decode(str) : null;
        } catch (er) {
          return null;
        }
      }
    },
    stringify: function TMP_stringify(obj) {
      try {
        return JSON.stringify(obj);
      } catch (ex) {
        try {
          return "encode" in this.nsIJSON ? this.nsIJSON.encode(obj) : null;
        } catch (er) {
          return null;
        }
      }
    }
  },

  windowStartup: {
    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                           Ci.nsISupportsWeakReference]),
    _initialized: false,
    init: function(aWindow) {
      // windowStartup must only be called once for each window
      if ("firstWindowInSession" in aWindow.Tabmix)
        return;
      aWindow.Tabmix.firstWindowInSession = !this._initialized;
      if (this._initialized)
        return;
      this._initialized = true;

      try {
        // replace old Settings.
        // we must call this before any other tabmix function
        aWindow.gTMPprefObserver.updateSettings();
      } catch (ex) {
        TabmixSvc.console.assert(ex);
      }

      this.addMissingPrefs();

      Services.obs.addObserver(this, "quit-application", true);

      Cu.import("resource://tabmixplus/DownloadLastDir.jsm");

      TabmixPlacesUtils.init(aWindow);

      TabmixSvc.tabStylePrefs = {};
      let tmp = {};
      Cu.import("resource://tabmixplus/DynamicRules.jsm", tmp);
      tmp.DynamicRules.init(aWindow);
    },

    addMissingPrefs: function() {
      // add missing preference to the default branch
      let prefs = Services.prefs.getDefaultBranch("");

      if (TabmixSvc.australis) {
        prefs.setBoolPref("extensions.tabmix.squaredTabsStyle", false);
      }

      if (isVersion(320))
        prefs.setBoolPref("extensions.tabmix.tabcontext.openNonRemoteWindow", true);

      if (isVersion(410) && !TabmixSvc.isCyberfox) {
        prefs.setCharPref(TabmixSvc.newtabUrl, TabmixSvc.aboutNewtab);
        Cu.import("resource://tabmixplus/NewTabURL.jsm", {});
      }
    },

    observe: function(aSubject, aTopic) {
      switch (aTopic) {
        case "quit-application":
          TabmixPlacesUtils.onQuitApplication();
          for (let id of Object.keys(TabmixSvc.console._timers)) {
            let timer = TabmixSvc.console._timers[id];
            timer.cancel();
          }
          delete TabmixSvc.SessionStoreGlobal;
          delete TabmixSvc.SessionStore;
          break;
      }
    }
  },

  saveTabAttributes: function(tab, attrib, save) {
    tabStateCache.saveTabAttributes(tab, attrib, save);
  },

  sm: {
    lastSessionPath: null,
    persistTabAttributeSet: false,
    status: "",
    crashed: false,
    get sanitized() {
      delete this.sanitized;
      return (this.sanitized = TabmixSvc.prefBranch.prefHasUserValue("sessions.sanitized"));
    },
    set sanitized(val) {
      delete this.sanitized;
      return (this.sanitized = val);
    },
    private: true,
    settingPreference: false,
    statesToRestore: {},
  },

  isAustralisBgStyle: function(orient) {
    if (typeof orient != "string") {
      throw Components.Exception("orient is not valid", Components.results.NS_ERROR_INVALID_ARG);
    }
    return TabmixSvc.australis && orient == "horizontal" &&
      !this.prefBranch.getBoolPref("squaredTabsStyle");
  },

  isFixedGoogleUrl: () => false,

  blockedClickingOptions: []
};

XPCOMUtils.defineLazyGetter(TabmixSvc.JSON, "nsIJSON", function() {
  return Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
});

// check if australis tab shape is implemented
XPCOMUtils.defineLazyGetter(TabmixSvc, "australis", function() {
  return Boolean(this.topWin().document.getElementById("tab-curve-clip-path-start"));
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "prefs", function() {
  let tmp = {};
  Cu.import("resource://gre/modules/Preferences.jsm", tmp);
  return new tmp.Preferences("");
});

// Tabmix preference branch
XPCOMUtils.defineLazyGetter(TabmixSvc, "prefBranch", function() {
  return Services.prefs.getBranch("extensions.tabmix.");
});
// string bundle
XPCOMUtils.defineLazyGetter(TabmixSvc, "_strings", function() {
  let properties = "chrome://tabmixplus/locale/tabmix.properties";
  return Services.strings.createBundle(properties);
});
XPCOMUtils.defineLazyGetter(TabmixSvc, "SMstrings", function() {
  let properties = "chrome://tabmixplus/locale/session-manager.properties";
  return Services.strings.createBundle(properties);
});

XPCOMUtils.defineLazyGetter(this, "Platform", function() {
  if (isVersion(390)) {
    return (Cu.import("resource://gre/modules/AppConstants.jsm", {})).AppConstants.platform;
  }
  let platform,
      os = Services.appinfo.OS.toLowerCase();
  if (os.startsWith("win")) {
    platform = "win";
  } else if (os == "darwin") {
    platform = "macosx";
  } else if (os == "linux") {
    platform = "linux";
  }
  return platform;
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isWindows", function() {
  return Platform == "win";
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isMac", function() {
  return Platform == "macosx";
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isLinux", function() {
  return Platform == "linux";
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isCyberfox", function() {
  return Services.appinfo.name == "Cyberfox";
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isPaleMoon", function() {
  return Services.appinfo.name == "Pale Moon";
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "isPaleMoonID", function() {
  try {
    // noinspection SpellCheckingInspection
    return Services.appinfo.ID == "{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}";
  } catch (ex) {
  }
  return false;
});

XPCOMUtils.defineLazyModuleGetter(TabmixSvc, "FileUtils",
  "resource://gre/modules/FileUtils.jsm");

XPCOMUtils.defineLazyModuleGetter(TabmixSvc, "console",
  "resource://tabmixplus/log.jsm");

XPCOMUtils.defineLazyGetter(TabmixSvc, "ss", function() {
  let tmp = {};
  Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
  return tmp.SessionStore;
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "SessionStoreGlobal", function() {
  return Cu.getGlobalForObject(this.ss);
});

XPCOMUtils.defineLazyGetter(TabmixSvc, "SessionStore", function() {
  return this.SessionStoreGlobal.SessionStoreInternal;
});

tabStateCache = {
  get _update() {
    delete this._update;
    return (this._update = isVersion(260) ? "updateField" : "update");
  },

  get TabStateCache() {
    delete this.TabStateCache;
    if (isVersion(270))
      Cu.import("resource:///modules/sessionstore/TabStateCache.jsm", this);
    else
      this.TabStateCache = TabmixSvc.SessionStoreGlobal.TabStateCache;
    return this.TabStateCache;
  },

  saveTabAttributes: function(tab, attrib, save = true) {
    if (TabmixSvc.isPaleMoon) {
      return;
    }

    // force Sessionstore to save our persisted tab attributes
    if (save) {
      TabmixSvc.SessionStore.saveStateDelayed(tab.ownerDocument.defaultView);
    }

    // After bug 1166757 - Remove browser.__SS_data, we have nothing more to do.
    if (isVersion(410))
      return;

    let attribs = attrib.split(",");
    function update(attributes) {
      attribs.forEach(function(key) {
        if (tab.hasAttribute(key))
          attributes[key] = tab.getAttribute(key);
        else if (key in attributes)
          delete attributes[key];
      });
    }

    let browser = tab.linkedBrowser;
    if (browser.__SS_data) {
      if (!browser.__SS_data.attributes)
        browser.__SS_data.attributes = {};
      update(browser.__SS_data.attributes);
    }

    // Bug 905049 fixed by Bug 960903 - Broadcast session history
    if (isVersion(290))
      return;

    let tabHasCache = isVersion(270) ? this.TabStateCache.has(browser) :
                               this.TabStateCache._data.has(browser);
    if (tabHasCache) {
      let attributes = this.TabStateCache.get(browser).attributes || {};
      update(attributes);
      this.TabStateCache[this._update](browser, "attributes", attributes);
    }
  }
};