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 f29ea6bb authored by Thomas Rientjes's avatar Thomas Rientjes

Add logic for selecting existing settings tabs

parent ba0572f0
......@@ -14,6 +14,14 @@
*/
const BROWSER_NAME = 'Orfox';
/**
* The location of the settings page.
*
* @constant SETTINGS_URI
* @type {String}
*/
const SETTINGS_URI = 'chrome://tor-browser-settings/content/settings.html';
/**
* Application settings module.
*
......@@ -61,12 +69,32 @@ exports.main = function () {
name: _('settings_label', BROWSER_NAME),
callback: function () {
let tabBrowser = chromeWindow.BrowserApp;
let tabBrowser, settingsTab;
tabBrowser = chromeWindow.BrowserApp;
settingsTab = null;
tabBrowser.addTab('chrome://tor-browser-settings/content/settings.html', {
selected: true,
parentId: tabBrowser.selectedTab.id
tabBrowser.tabs.some(function (tab) {
if (tab.browser.currentURI.spec === SETTINGS_URI) {
settingsTab = tab;
return true;
}
return false;
});
if (settingsTab === null) {
tabBrowser.addTab(SETTINGS_URI, {
selected: true,
parentId: tabBrowser.selectedTab.id
});
} else {
tabBrowser.selectTab(settingsTab);
}
}
});
};
......
......@@ -16,6 +16,14 @@
*/
const BROWSER_NAME = 'Orfox';
/**
* The location of the settings page.
*
* @constant SETTINGS_URI
* @type {String}
*/
const SETTINGS_URI = 'chrome://tor-browser-settings/content/settings.html';
/**
* Can be used to get localization entries by key name.
*
......@@ -50,7 +58,7 @@ var settings = require('sdk/simple-prefs').prefs;
exports.initialize = function () {
pageMod.PageMod({
include: 'chrome://tor-browser-settings/content/settings.html',
include: SETTINGS_URI,
contentScriptFile: self.data.url('content-scripts/settings.js'),
contentScriptWhen: 'ready',
onAttach: startListening
......
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