mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b6b202b6bb
The -*- file variable lines -*- establish per-file settings that Emacs will pick up. This patch makes the following changes to those lines (and touches nothing else): - Never set the buffer's mode. Years ago, Emacs did not have a good JavaScript mode, so it made sense to use Java or C++ mode in .js files. However, Emacs has had js-mode for years now; it's perfectly serviceable, and is available and enabled by default in all major Emacs packagings. Selecting a mode in the -*- file variable line -*- is almost always the wrong thing to do anyway. It overrides Emacs's default choice, which is (now) reasonable; and even worse, it overrides settings the user might have made in their '.emacs' file for that file extension. It's only useful when there's something specific about that particular file that makes a particular mode appropriate. - Correctly propagate settings that establish the correct indentation level for this file: c-basic-offset and js2-basic-offset should be js-indent-level. Whatever value they're given should be preserved; different parts of our tree use different indentation styles. - We don't use tabs in Mozilla JS code. Always set indent-tabs-mode: nil. Remove tab-width: settings, at least in files that don't contain tab characters. - Remove js2-mode settings that belong in the user's .emacs file, like js2-skip-preprocessor-directives.
98 lines
3.0 KiB
JavaScript
98 lines
3.0 KiB
JavaScript
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
|
|
/* vim: set ft=javascript ts=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/. */
|
|
|
|
"use strict";
|
|
|
|
const Cu = Components.utils;
|
|
const Ci = Components.interfaces;
|
|
const Cc = Components.classes;
|
|
const Cr = Components.results;
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
this.EXPORTED_SYMBOLS = ["IdentityStore"];
|
|
|
|
// the data store for IDService
|
|
// written as a separate thing so it can easily be mocked
|
|
function IDServiceStore() {
|
|
this.reset();
|
|
}
|
|
|
|
// Note: eventually these methods may be async, but we haven no need for this
|
|
// for now, since we're not storing to disk.
|
|
IDServiceStore.prototype = {
|
|
addIdentity: function addIdentity(aEmail, aKeyPair, aCert) {
|
|
this._identities[aEmail] = {keyPair: aKeyPair, cert: aCert};
|
|
},
|
|
fetchIdentity: function fetchIdentity(aEmail) {
|
|
return aEmail in this._identities ? this._identities[aEmail] : null;
|
|
},
|
|
removeIdentity: function removeIdentity(aEmail) {
|
|
let data = this._identities[aEmail];
|
|
delete this._identities[aEmail];
|
|
return data;
|
|
},
|
|
getIdentities: function getIdentities() {
|
|
// XXX - should clone?
|
|
return this._identities;
|
|
},
|
|
clearCert: function clearCert(aEmail) {
|
|
// XXX - should remove key from store?
|
|
this._identities[aEmail].cert = null;
|
|
this._identities[aEmail].keyPair = null;
|
|
},
|
|
|
|
/**
|
|
* set the login state for a given origin
|
|
*
|
|
* @param aOrigin
|
|
* (string) a web origin
|
|
*
|
|
* @param aState
|
|
* (boolean) whether or not the user is logged in
|
|
*
|
|
* @param aEmail
|
|
* (email) the email address the user is logged in with,
|
|
* or, if not logged in, the default email for that origin.
|
|
*/
|
|
setLoginState: function setLoginState(aOrigin, aState, aEmail) {
|
|
if (aState && !aEmail) {
|
|
throw "isLoggedIn cannot be set to true without an email";
|
|
}
|
|
return this._loginStates[aOrigin] = {isLoggedIn: aState, email: aEmail};
|
|
},
|
|
getLoginState: function getLoginState(aOrigin) {
|
|
return aOrigin in this._loginStates ? this._loginStates[aOrigin] : null;
|
|
},
|
|
clearLoginState: function clearLoginState(aOrigin) {
|
|
delete this._loginStates[aOrigin];
|
|
},
|
|
|
|
reset: function Store_reset() {
|
|
// _identities associates emails with keypairs and certificates
|
|
this._identities = {};
|
|
|
|
// _loginStates associates. remote origins with a login status and
|
|
// the email the user has chosen as his or her identity when logging
|
|
// into that origin.
|
|
this._loginStates = {};
|
|
},
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
|
|
|
|
observe: function observe(aSubject, aTopic, aData) {
|
|
switch (aTopic) {
|
|
case "quit-application-granted":
|
|
Services.obs.removeObserver(this, "quit-application-granted");
|
|
this.reset();
|
|
break;
|
|
}
|
|
},
|
|
};
|
|
|
|
this.IdentityStore = new IDServiceStore();
|