Microsoft is acquiring GitHub. Decentraleyes is leaving GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Commit a1e1d6a0 authored by Thomas Rientjes's avatar Thomas Rientjes

Refactor the application entry point

parent a1d72553
......@@ -30,11 +30,11 @@ const SETTINGS_URI = 'chrome://tor-browser-settings/content/settings.html';
var settings = require('./settings');
/**
* Application security prefs module.
* Browser security preferences module.
*
* @var {object} SecurityPrefs
* @var {object} securityPrefs
*/
let SecurityPrefs = require('./modules/security-prefs.js');
var securityPrefs = require('./modules/security-prefs.js');
/**
* Can be used to get localization entries by key name.
......@@ -69,49 +69,59 @@ var chromeMenuItemIdentifier = null;
*/
exports.main = function () {
// Initialize the application settings module.
settings.initialize();
SecurityPrefs.initialize();
// Initialize the security preferences module.
securityPrefs.initialize();
// Add the extension's chrome menu item to the main browser menu.
chromeMenuItemIdentifier = chromeWindow.NativeWindow.menu.add({
name: _('settings_label', BROWSER_NAME),
callback: function () {
let tabBrowser, settingsTab;
callback: showSettingsPanel
});
};
tabBrowser = chromeWindow.BrowserApp;
settingsTab = null;
/**
* Executed when the add-on is unloaded.
*/
exports.onUnload = function () {
tabBrowser.tabs.some(function (tab) {
// Clean up add-on state.
chromeWindow.NativeWindow.menu.remove(chromeMenuItemIdentifier);
};
if (tab.browser.currentURI.spec === SETTINGS_URI) {
/**
* Brings up the application settings panel.
*
* @private
*/
function showSettingsPanel () {
settingsTab = tab;
return true;
}
let tabBrowser, settingsTab;
return false;
});
tabBrowser = chromeWindow.BrowserApp;
settingsTab = null;
if (settingsTab === null) {
tabBrowser.tabs.some(function (tab) {
tabBrowser.addTab(SETTINGS_URI, {
selected: true,
parentId: tabBrowser.selectedTab.id
});
if (tab.browser.currentURI.spec === SETTINGS_URI) {
} else {
tabBrowser.selectTab(settingsTab);
}
settingsTab = tab;
return true;
}
return false;
});
};
/**
* Executed when the add-on is unloaded.
*/
exports.onUnload = function () {
if (settingsTab === null) {
// Clean up add-on state.
chromeWindow.NativeWindow.menu.remove(chromeMenuItemIdentifier);
};
tabBrowser.addTab(SETTINGS_URI, {
selected: true,
parentId: tabBrowser.selectedTab.id
});
} else {
tabBrowser.selectTab(settingsTab);
}
}
......@@ -3,7 +3,7 @@
// ### Utilities
var { get, set } = require("sdk/preferences/service");
let utils = require('./utils.js');
let utils = require('./utils.js');
// ### Constants
......
/**
* Browser preferences module.
*
* @module preferences
*/
'use strict';
// TODO
Markdown is supported
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