~vono22/cookiekeeper/1.9.0

« back to all changes in this revision

Viewing changes to cookiekeeper/chrome/modules/cookiekeeper.jsm

  • Committer: Yvon Tanguy
  • Date: 2016-03-23 15:58:31 UTC
  • Revision ID: vono22@yahoo.fr-20160323155831-9ff8oe52crtm4dav
- HTML Prefs: Add the permissions panel.
- HTML Prefs: Add Flash player pref to the main tab.
- HTML Prefs: Add option to use the new HTML panel only (TODO add it to the XUL preferences too)
- Minor fix (mainly cookies permissions)

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
   * @note If the window is already opened, the aPane argument will not be honored.
183
183
   */
184
184
  showPreferencesDialogue: function(window, aPane) {
185
 
    var ckws = CookieKeeperPrivate.getCookieWindows();
186
 
    var opened = false;
 
185
    const SHOW_HTML_PREFS = "extensions.cookiekeeper.use_html_prefs";
 
186
    const PREF_HTML_URL   = "chrome://cookiekeeper/content/preferences.html";
 
187
    let showHTMLPanel = false;
 
188
 
 
189
    if (Services.prefs.getPrefType(SHOW_HTML_PREFS) == Services.prefs.PREF_BOOL) {
 
190
      showHTMLPanel = Services.prefs.getBoolPref(SHOW_HTML_PREFS);
 
191
    }
 
192
 
 
193
    if (showHTMLPanel) {
 
194
      let url = PREF_HTML_URL;
 
195
      if (typeof(aPane) == "string" && aPane.length > 0) {
 
196
        url = PREF_HTML_URL + "#" + aPane;
 
197
      }
 
198
      try {
 
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");
 
202
        let found = false;
 
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
 
214
              browserWin.focus();
 
215
              found = true;
 
216
              break;
 
217
            }
 
218
          }
 
219
        }
 
220
 
 
221
        if (!found) {
 
222
          let recentWindow = Services.wm.getMostRecentWindow("navigator:browser");
 
223
          if (recentWindow) {
 
224
            // Use an existing browser window
 
225
            recentWindow.delayedOpenTab(url, null, null, null, null);
 
226
          } else {
 
227
            window.open(url);
 
228
          }
 
229
          // let gBrowser = window.document.defaultView.top.gBrowser;
 
230
          // gBrowser.selectedTab = gBrowser.addTab(url);
 
231
          // log.d(gBrowser.selectedTab);
 
232
        }
 
233
      } catch (e) {
 
234
        log.e(e);
 
235
        window.open(url);
 
236
      }
 
237
      return;
 
238
    }
 
239
 
 
240
    let ckws = CookieKeeperPrivate.getCookieWindows();
 
241
    let opened = false;
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]) {