tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

tabs.js (1465B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 export const getOpenedURLs = state => state.tabs.urls;
      6 
      7 // Return the list of source objects which are opened.
      8 // i.e. sources which have a tab currently opened.
      9 export const getOpenedSources = state => state.tabs.openedSources;
     10 
     11 export const getPrettyPrintedURLs = state => state.tabs.prettyPrintedURLs;
     12 
     13 export function tabExists(state, source) {
     14  // Minimized(=generatedSource) and its related pretty printed source will both share the same tab,
     15  // so we should consider that the tab is already opened if the tab relates to the passed minimized source.
     16  return getOpenedSources(state).some(
     17    s => s == (source.isPrettyPrinted ? source.generatedSource : source)
     18  );
     19 }
     20 
     21 /**
     22 * For a given non-original source, returns true only if this source has been pretty printed
     23 * and has a tab currently opened with pretty printing enabled.
     24 *
     25 * @return {boolean}
     26 */
     27 export function isPrettyPrinted(state, source) {
     28  return source.url && state.tabs.prettyPrintedURLs.has(source.url);
     29 }
     30 
     31 /**
     32 * Reports if a given source was ignored by auto-pretty printing,
     33 * or if the user manually disabled pretty printing on it
     34 */
     35 export function isPrettyPrintedDisabled(state, source) {
     36  return source.url && state.tabs.prettyPrintedDisabledURLs.has(source.url);
     37 }