diff options
| author | Stephen Blott | 2015-02-13 06:53:51 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-02-13 07:32:06 +0000 |
| commit | 358f1ebfddacf75c02bb3a2e8993bab6d2fe28d8 (patch) | |
| tree | f69c6598692343474c53fad77b65f9fb832f2f63 /content_scripts | |
| parent | ffc49d3057daee2354fb77d939fffc0cf77ff2e1 (diff) | |
| download | vimium-358f1ebfddacf75c02bb3a2e8993bab6d2fe28d8.tar.bz2 | |
Tweaks for grab-back-focus.
- Fix incorrect camel case in option name.
- Better text on options page.
- Loud comments re. using option directly from chrome.storage.sync.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 3cbf2d53..51b0695f 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -96,7 +96,8 @@ settings = # frameId = Math.floor(Math.random()*999999999) -# If an input grabs the focus before the user has interacted with the page, then grab it back. +# If an input grabs the focus before the user has interacted with the page, then grab it back (if the +# grabBackFocus option is set). class GrabBackFocus extends Mode constructor: -> super @@ -107,8 +108,12 @@ class GrabBackFocus extends Mode _name: "grab-back-focus-mousedown" mousedown: => @alwaysContinueBubbling => @exit() - chrome.storage.sync.get "grabBackfocus", (items) => - return @exit() unless items.grabBackfocus and not chrome.runtime.lastError + # HACK. We use chrome.storage.sync directly here (rather than settings). This avoids a race condition. + # An input can be focused by the page either before we install our handlers or after, and we handle both + # cases. There's no uncertainty period while we wait to learn whether the option is set or not. + # Note. We also assume that the default value for grabBackFocus is false. + chrome.storage.sync.get "grabBackFocus", (items) => + return @exit() if chrome.runtime.lastError or not items.grabBackFocus @push _name: "grab-back-focus-focus" focus: (event) => @grabBackFocus event.target |
