aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pages/options.coffee13
-rw-r--r--pages/options.html1
2 files changed, 10 insertions, 4 deletions
diff --git a/pages/options.coffee b/pages/options.coffee
index ddab2bf4..99492291 100644
--- a/pages/options.coffee
+++ b/pages/options.coffee
@@ -2,6 +2,12 @@
$ = (id) -> document.getElementById id
bgExclusions = chrome.extension.getBackgroundPage().Exclusions
+# We have to use Settings from the background page here (not Settings, directly) to avoid a race condition for
+# the page popup. Specifically, we must ensure that the settings have been updated on the background page
+# *before* the popup closes. This ensures that any exclusion-rule changes are in place before the page
+# regains the focus.
+bgSettings = chrome.extension.getBackgroundPage().Settings
+
#
# Class hierarchy for various types of option.
class Option
@@ -20,20 +26,21 @@ class Option
# Fetch a setting from localStorage, remember the @previous value and populate the DOM element.
# Return the fetched value.
fetch: ->
- @populateElement @previous = Settings.get @field
+ @populateElement @previous = bgSettings.get @field
@previous
# Write this option's new value back to localStorage, if necessary.
save: ->
value = @readValueFromElement()
if not @areEqual value, @previous
- Settings.set @field, @previous = value
+ bgSettings.set @field, @previous = value
+ bgSettings.performPostUpdateHook @field, value
# Compare values; this is overridden by sub-classes.
areEqual: (a,b) -> a == b
restoreToDefault: ->
- Settings.clear @field
+ bgSettings.clear @field
@fetch()
# Static method.
diff --git a/pages/options.html b/pages/options.html
index b14c454f..441bd9da 100644
--- a/pages/options.html
+++ b/pages/options.html
@@ -3,7 +3,6 @@
<title>Vimium Options</title>
<link rel="stylesheet" type="text/css" href="options.css">
<script src="content_script_loader.js"></script>
- <script type="text/javascript" src="../lib/settings.js"></script>
<script type="text/javascript" src="options.js"></script>
</head>