182
182
* @note If the window is already opened, the aPane argument will not be honored.
184
184
showPreferencesDialogue: function(window, aPane) {
185
var ckws = CookieKeeperPrivate.getCookieWindows();
185
const SHOW_HTML_PREFS = "extensions.cookiekeeper.use_html_prefs";
186
const PREF_HTML_URL = "chrome://cookiekeeper/content/preferences.html";
187
let showHTMLPanel = false;
189
if (Services.prefs.getPrefType(SHOW_HTML_PREFS) == Services.prefs.PREF_BOOL) {
190
showHTMLPanel = Services.prefs.getBoolPref(SHOW_HTML_PREFS);
194
let url = PREF_HTML_URL;
195
if (typeof(aPane) == "string" && aPane.length > 0) {
196
url = PREF_HTML_URL + "#" + aPane;
199
// Search for an existing opened tab first
200
// https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser
201
let browserEnumerator = Services.wm.getEnumerator("navigator:browser");
203
while (!found && browserEnumerator.hasMoreElements()) {
204
let browserWin = browserEnumerator.getNext();
205
let tabbrowser = browserWin.gBrowser;
206
// Check each tab of this browser instance
207
let numTabs = tabbrowser.browsers.length;
208
for (let index = 0; index < numTabs; index++) {
209
let currentBrowser = tabbrowser.getBrowserAtIndex(index);
210
if (PREF_HTML_URL == currentBrowser.currentURI.spec) {
211
// The URL is already opened. Select this tab.
212
tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];
213
// Focus *this* browser-window
222
let recentWindow = Services.wm.getMostRecentWindow("navigator:browser");
224
// Use an existing browser window
225
recentWindow.delayedOpenTab(url, null, null, null, null);
229
// let gBrowser = window.document.defaultView.top.gBrowser;
230
// gBrowser.selectedTab = gBrowser.addTab(url);
231
// log.d(gBrowser.selectedTab);
240
let ckws = CookieKeeperPrivate.getCookieWindows();
187
242
for (let i=0; i<ckws.length && opened == false; i++) {
188
243
let ckw = ckws[i];
189
244
if (ckw.id == CK_WINDOWS_ID[CK_WINDOW_PREFS_IDX]) {