aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-03-15 12:38:39 +0000
committerStephen Blott2016-03-17 11:17:03 +0000
commit4009213f0dbe1326263535e0a50a165d179ae47d (patch)
treed1713025be04a9dbbdcf9f002c3cb0cedfaebfb4 /content_scripts
parent5a6cb052b14fcaa11189b7760ebf480a38db682d (diff)
downloadvimium-4009213f0dbe1326263535e0a50a165d179ae47d.tar.bz2
Open frames port pre documentReady.
The intention is to move checkIfEnabledForUrl to the frames port. That needs to run pre domReady, so first -- here -- we separate the two ports.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/vimium_frontend.coffee18
1 files changed, 10 insertions, 8 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index ce01695a..4b461847 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -136,6 +136,7 @@ window.initializeModes = ->
# Complete initialization work that sould be done prior to DOMReady.
#
initializePreDomReady = ->
+ Frame.init()
checkIfEnabledForUrl()
requestHandlers =
@@ -207,18 +208,20 @@ onFocus = (event) ->
window.addEventListener "focus", onFocus
window.addEventListener "hashchange", onFocus
+DomUtils.documentReady ->
+ # Tell the background page we're in the domReady state.
+ chrome.runtime.connect({name: "domReady"}).onDisconnect.addListener ->
+ # We disable content scripts when we lose contact with the background page.
+ isEnabledForUrl = false
+ chrome.runtime.sendMessage = ->
+ window.removeEventListener "focus", onFocus
+
Frame =
port: null
init: ->
- # Tell the background page we're in the domReady state.
- @port = chrome.runtime.connect name: "domReady"
+ @port = chrome.runtime.connect name: "frames"
@port.onMessage.addListener (request) => this[request.name] request
- @port.onDisconnect.addListener ->
- # We disable content scripts when we lose contact with the background page.
- isEnabledForUrl = false
- chrome.runtime.sendMessage = ->
- window.removeEventListener "focus", onFocus
registerFrameId: ({chromeFrameId}) -> frameId = window.frameId = chromeFrameId
@@ -649,7 +652,6 @@ window.HelpDialog ?=
if @showing then @hide() else @show html
initializePreDomReady()
-DomUtils.documentReady Frame.init.bind Frame
root = exports ? window
root.handlerStack = handlerStack