tor-browser

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

migration-wizard-constants.mjs (3874B)


      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 MigrationWizardConstants = Object.freeze({
      6  MIGRATOR_TYPES: Object.freeze({
      7    BROWSER: "browser",
      8    FILE: "file",
      9  }),
     10 
     11  /**
     12   * A mapping of a page identification string to the IDs used by the
     13   * various wizard pages. These are used by MigrationWizard.setState
     14   * to set the current page.
     15   */
     16  PAGES: Object.freeze({
     17    LOADING: "loading",
     18    SELECTION: "selection",
     19    PROGRESS: "progress",
     20    FILE_IMPORT_PROGRESS: "file-import-progress",
     21    SAFARI_PERMISSION: "safari-permission",
     22    SAFARI_PASSWORD_PERMISSION: "safari-password-permission",
     23    CHROME_WINDOWS_PASSWORD_PERMISSION: "chrome-windows-password-permission",
     24    NO_BROWSERS_FOUND: "no-browsers-found",
     25  }),
     26 
     27  /**
     28   * A mapping of a progress value string. These are used by
     29   * MigrationWizard.#onShowingProgress to update the UI accordingly.
     30   */
     31  PROGRESS_VALUE: Object.freeze({
     32    LOADING: 1,
     33    SUCCESS: 2,
     34    WARNING: 3,
     35    INFO: 4,
     36  }),
     37 
     38  /**
     39   * Returns a mapping of a resource type to a string used to identify
     40   * the associated resource group in the wizard via a data-resource-type
     41   * attribute. The keys are used to set which items should be shown and
     42   * in what state in #onShowingProgress.
     43   */
     44  DISPLAYED_RESOURCE_TYPES: Object.freeze({
     45    // The DISPLAYED_RESOURCE_TYPES should have their keys match those
     46    // in MigrationUtils.resourceTypes.
     47 
     48    // This is a little silly, but JavaScript doesn't have a notion of
     49    // enums. The advantage of this set-up is that these constants values
     50    // can be used to access the MigrationUtils.resourceTypes constants,
     51    // are reasonably readable as DOM attributes, and easily serialize /
     52    // deserialize.
     53    HISTORY: "HISTORY",
     54    FORMDATA: "FORMDATA",
     55    PASSWORDS: "PASSWORDS",
     56    BOOKMARKS: "BOOKMARKS",
     57    PAYMENT_METHODS: "PAYMENT_METHODS",
     58    EXTENSIONS: "EXTENSIONS",
     59 
     60    COOKIES: "COOKIES",
     61    SESSION: "SESSION",
     62    OTHERDATA: "OTHERDATA",
     63  }),
     64 
     65  DISPLAYED_FILE_RESOURCE_TYPES: Object.freeze({
     66    // When migrating passwords from a file, we first show the progress
     67    // for a single PASSWORDS_FROM_FILE resource type, and then upon
     68    // completion, show two different resource types - one for new
     69    // passwords imported from the file, and one for existing passwords
     70    // that were updated from the file.
     71    PASSWORDS_FROM_FILE: "PASSWORDS_FROM_FILE",
     72    PASSWORDS_NEW: "PASSWORDS_NEW",
     73    PASSWORDS_UPDATED: "PASSWORDS_UPDATED",
     74    BOOKMARKS_FROM_FILE: "BOOKMARKS_FROM_FILE",
     75  }),
     76 
     77  /**
     78   * Returns a mapping of a resource type to a string used to identify
     79   * the associated resource group in the wizard via a data-resource-type
     80   * attribute. The keys are for resource types that are only ever shown
     81   * for profile resets.
     82   */
     83  PROFILE_RESET_ONLY_RESOURCE_TYPES: Object.freeze({
     84    COOKIES: "COOKIES",
     85    SESSION: "SESSION",
     86    OTHERDATA: "OTHERDATA",
     87  }),
     88 
     89  /**
     90   * The set of keys that maps to migrators that use the term "favorites"
     91   * in the place of "bookmarks". This tends to be browsers from Microsoft.
     92   */
     93  USES_FAVORITES: Object.freeze([
     94    "chromium-edge",
     95    "chromium-edge-beta",
     96    "edge",
     97    "ie",
     98  ]),
     99 
    100  /**
    101   * The values that are set on the extension extra key for the
    102   * migration_finished telemetry event. The definition of that event
    103   * defines it as:
    104   *
    105   * "3" if all extensions were matched after import. "2" if only some
    106   * extensions were matched. "1" if none were matched, and "0" if extensions
    107   * weren't selected for import.
    108   */
    109  EXTENSIONS_IMPORT_RESULT: Object.freeze({
    110    NOT_IMPORTED: "0",
    111    NONE_MATCHED: "1",
    112    PARTIAL_MATCH: "2",
    113    ALL_MATCHED: "3",
    114  }),
    115 });