aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/commands.coffee6
-rw-r--r--background_scripts/exclusions.coffee4
-rw-r--r--background_scripts/settings.coffee13
-rw-r--r--manifest.json2
-rw-r--r--tests/unit_tests/commands_test.coffee1
5 files changed, 15 insertions, 11 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index abfbd9e2..5857665c 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -359,5 +359,11 @@ commandDescriptions =
Commands.init()
+# Register postUpdateHook for keyMappings setting.
+Settings.postUpdateHooks["keyMappings"] = (value) ->
+ Commands.clearKeyMappingsAndSetDefaults()
+ Commands.parseCustomKeyMappings value
+ refreshCompletionKeysAfterMappingSave()
+
root = exports ? window
root.Commands = Commands
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee
index 5ec76e2a..21342d61 100644
--- a/background_scripts/exclusions.coffee
+++ b/background_scripts/exclusions.coffee
@@ -73,3 +73,7 @@ if not Settings.has("exclusionRules") and Settings.has("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/background_scripts/settings.coffee b/background_scripts/settings.coffee
index 44676ad7..6b33d239 100644
--- a/background_scripts/settings.coffee
+++ b/background_scripts/settings.coffee
@@ -75,17 +75,10 @@ root.Settings = Settings =
has: (key) -> key of localStorage
- # For settings which require action when their value changes, add hooks here called from
- # options/options.coffee (when the options page is saved), and from background_scripts/sync.coffee (when an
+ # For settings which require action when their value changes, add hooks to this object, to be called from
+ # options/options.coffee (when the options page is saved), and by Settings.storeAndPropagate (when an
# update propagates from chrome.storage.sync).
- postUpdateHooks:
- keyMappings: (value) ->
- root.Commands.clearKeyMappingsAndSetDefaults()
- root.Commands.parseCustomKeyMappings value
- root.refreshCompletionKeysAfterMappingSave()
-
- exclusionRules: (value) ->
- root.Exclusions.postUpdateHook value
+ postUpdateHooks: {}
# postUpdateHooks convenience wrapper
performPostUpdateHook: (key, value) ->
diff --git a/manifest.json b/manifest.json
index 5b65b6fd..390b8c8c 100644
--- a/manifest.json
+++ b/manifest.json
@@ -9,9 +9,9 @@
"background": {
"scripts": [
"lib/utils.js",
+ "background_scripts/settings.js",
"background_scripts/commands.js",
"lib/clipboard.js",
- "background_scripts/settings.js",
"background_scripts/exclusions.js",
"background_scripts/completion_engines.js",
"background_scripts/completion_search.js",
diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee
index daaef016..e55dc0f2 100644
--- a/tests/unit_tests/commands_test.coffee
+++ b/tests/unit_tests/commands_test.coffee
@@ -1,5 +1,6 @@
require "./test_helper.js"
extend global, require "./test_chrome_stubs.js"
+global.Settings = {postUpdateHooks: {}}
{Commands} = require "../../background_scripts/commands.js"
context "Key mappings",