Verified Commit b5403b95 authored by Thomas Rientjes's avatar Thomas Rientjes
Browse files

Refactor existing codebase

parent 1dbdc455
......@@ -20,7 +20,6 @@
var {Cc, Ci} = require('chrome');
var self = require('sdk/self');
//noinspection JSUnresolvedFunction
var ioService = Cc['@mozilla.org/network/io-service;1']
.getService(Ci.nsIIOService);
......@@ -82,7 +81,6 @@ function _buildDataURI (type, characterSet, data) {
var addNotice, dataURI;
//noinspection JSUnresolvedVariable
addNotice = require('sdk/simple-prefs').prefs.addNotice;
dataURI = `data:${type};charset=${characterSet},`;
......
......@@ -35,7 +35,6 @@ var simplePreferences = require('sdk/simple-prefs');
*/
var simpleStorage = require('sdk/simple-storage');
//noinspection JSUnresolvedFunction
var observerService = Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService);
......@@ -119,7 +118,6 @@ var Interceptor = new Class({
// Redirect the HTTP channel to the the local destination.
httpChannel.redirectTo(redirectionURI);
//noinspection JSUnresolvedVariable
preferences.amountInjected++;
main.broadcastInjection();
},
......@@ -130,7 +128,6 @@ var Interceptor = new Class({
*/
'handleMissingCandidate': function (httpChannel) {
//noinspection JSUnresolvedVariable
if (preferences.blockMissing) {
httpChannel.cancel(Cr.NS_ERROR_NOT_AVAILABLE);
}
......
......@@ -23,6 +23,9 @@ var {Cc, Ci, Cu} = require('chrome');
var xpcom = require('sdk/platform/xpcom');
var categoryManager = Cc['@mozilla.org/categorymanager;1']
.getService(Ci.nsICategoryManager);
/**
* Resource version mappings.
* @var {object} mappings
......@@ -35,10 +38,6 @@ var mappings = require('./mappings');
*/
var simpleStorage = require('sdk/simple-storage');
//noinspection JSUnresolvedFunction
var categoryManager = Cc['@mozilla.org/categorymanager;1']
.getService(Ci.nsICategoryManager);
/**
* Constants
*/
......
......@@ -17,12 +17,17 @@
* Imports
*/
var preferences = require('sdk/simple-prefs');
var webextension = null;
var self = require('sdk/self');
var tabs = require('sdk/tabs');
/**
* Gets and sets add-on specific preferences.
* @var {object} simplePreferences
*/
var simplePreferences = require('sdk/simple-prefs');
var Interceptor = require('./interceptor');
var LoadWatcher = require('./load-watcher');
......@@ -30,6 +35,7 @@ var LoadWatcher = require('./load-watcher');
* Variables
*/
var preferences = simplePreferences.prefs;
var webextensionPort = null;
/**
......@@ -56,14 +62,14 @@ exports.main = function (options) {
loadWatcher.register();
// Display the release notes if desired.
if (preferences.prefs.showReleaseNotes) {
if (preferences.showReleaseNotes) {
let loadReason = options.loadReason;
if (loadReason === 'install' || (loadReason === 'upgrade' && !featurelessVersions[self.version])) {
if (preferences.prefs['sdk.baseURI']) {
tabs.open(`${preferences.prefs['sdk.baseURI']}static/release-notes.html`);
if (preferences['sdk.baseURI']) {
tabs.open(`${preferences['sdk.baseURI']}static/release-notes.html`);
}
}
}
......@@ -83,7 +89,7 @@ exports.main = function (options) {
webextensionPort = port;
preferences.on('', function (preferenceName) {
simplePreferences.on('', function (preferenceName) {
let content = null;
......@@ -93,7 +99,7 @@ exports.main = function (options) {
if (preferenceName === 'domainWhitelist') {
let domainWhitelist = preferences.prefs['domainWhitelist'];
let domainWhitelist = preferences['domainWhitelist'];
content = {
'whitelistedDomains': _parseDomainWhitelist(domainWhitelist)
......@@ -102,7 +108,7 @@ exports.main = function (options) {
} else {
content = {
[preferenceName]: preferences.prefs[preferenceName]
[preferenceName]: preferences[preferenceName]
};
}
......@@ -112,15 +118,15 @@ exports.main = function (options) {
});
});
let domainWhitelist = preferences.prefs['domainWhitelist'];
let domainWhitelist = preferences['domainWhitelist'];
port.postMessage({
'subject': 'migrate-preferences',
'content': {
'amountInjected': preferences.prefs['amountInjected'],
'blockMissing': preferences.prefs['blockMissing'],
'amountInjected': preferences['amountInjected'],
'blockMissing': preferences['blockMissing'],
'whitelistedDomains': _parseDomainWhitelist(domainWhitelist),
'showReleaseNotes': preferences.prefs['showReleaseNotes']
'showReleaseNotes': preferences['showReleaseNotes']
}
});
}
......
......@@ -209,7 +209,6 @@ function _applyWhitelistPreference () {
whitelistedDomains = {};
//noinspection JSUnresolvedVariable
preferences.domainWhitelist.split(VALUE_SEPARATOR).forEach(function (domain) {
whitelistedDomains[_normalizeDomain(domain)] = true;
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment