diff options
| -rw-r--r-- | background_scripts/exclusions.coffee | 26 | ||||
| -rw-r--r-- | lib/settings.coffee | 24 | 
2 files changed, 15 insertions, 35 deletions
| diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee index 21342d61..95100935 100644 --- a/background_scripts/exclusions.coffee +++ b/background_scripts/exclusions.coffee @@ -48,32 +48,6 @@ root.Exclusions = Exclusions =    postUpdateHook: (@rules) ->      RegexpCache.clear() -# Development and debug only. -# Enable this (temporarily) to restore legacy exclusion rules from backup. -if false and Settings.has("excludedUrlsBackup") -  Settings.clear("exclusionRules") -  Settings.set("excludedUrls", Settings.get("excludedUrlsBackup")) - -if not Settings.has("exclusionRules") and Settings.has("excludedUrls") -  # Migration from the legacy representation of exclusion rules. -  # -  # In Vimium 1.45 and in github/master on 27 August, 2014, exclusion rules are represented by the setting: -  #   excludedUrls: "http*://www.google.com/reader/*\nhttp*://mail.google.com/* jk" -  # -  # The new (equivalent) settings is: -  #   exclusionRules: [ { pattern: "http*://www.google.com/reader/*", passKeys: "" }, { pattern: "http*://mail.google.com/*", passKeys: "jk" } ] - -  parseLegacyRules = (lines) -> -    for line in lines.trim().split("\n").map((line) -> line.trim()) -      if line.length and line.indexOf("#") != 0 and line.indexOf('"') != 0 -        parse = line.split(/\s+/) -        { pattern: parse[0], passKeys: parse[1..].join("") } - -  Exclusions.setRules(parseLegacyRules(Settings.get("excludedUrls"))) -  # We'll keep a backup of the "excludedUrls" setting, just in case. -  Settings.set("excludedUrlsBackup", Settings.get("excludedUrls")) if not Settings.has("excludedUrlsBackup") -  Settings.clear("excludedUrls") -  # Register postUpdateHook for exclusionRules setting.  Settings.postUpdateHooks["exclusionRules"] = (value) ->    Exclusions.postUpdateHook value diff --git a/lib/settings.coffee b/lib/settings.coffee index 8b7f6062..31aad7ad 100644 --- a/lib/settings.coffee +++ b/lib/settings.coffee @@ -91,6 +91,13 @@ Settings =    postUpdateHooks: {}    performPostUpdateHook: (key, value) -> @postUpdateHooks[key]? value +  # Completely remove a settings value, e.g. after migration to a new setting.  This should probably only be +  # called from the background page. +  nuke: (key) -> +    delete localStorage[key] +    chrome.storage.local.remove key +    chrome.storage.sync.remove key +    # For development only.    log: (args...) ->      console.log "settings:", args... if @debug @@ -174,17 +181,16 @@ Settings.init()  if Utils.isBackgroundPage()    # We use settingsVersion to coordinate any necessary schema changes. -  if Utils.compareVersions("1.42", Settings.get("settingsVersion")) != -1 -    Settings.set("scrollStepSize", parseFloat Settings.get("scrollStepSize"))    Settings.set("settingsVersion", Utils.getCurrentVersion()) -  # Migration (after 1.49, 2015/2/1). -  # Legacy setting: findModeRawQuery (a string). -  # New setting: findModeRawQueryList (a list of strings), now stored in chrome.storage.local (not localStorage). -  chrome.storage.local.get "findModeRawQueryList", (items) -> -    unless chrome.runtime.lastError or items.findModeRawQueryList -      rawQuery = Settings.get "findModeRawQuery" -      chrome.storage.local.set findModeRawQueryList: (if rawQuery then [ rawQuery ] else []) +  # In 1.46 we migrated the old "excludedUrls" setting to the new "exclusionRules" setting.  And we kept a +  # backup in "excludedUrlsBackup".  Now (post 1.54, post 2016-02-12) we can clear up that backup (and any +  # extraordinalrily old "excludedUrls" setting). +  Settings.nuke "excludedUrlsBackup" +  Settings.nuke "excludedUrls" + +  # Migration (post 1.54, post 2016-2-12).  Nuke legacy "findModeRawQuery" setting. +  Settings.nuke "findModeRawQuery"    # Migration (after 1.51, 2015/6/17).    # Copy options with non-default values (and which are not in synced storage) to chrome.storage.local; | 
