diff options
| author | mrmr1993 | 2017-09-07 12:55:57 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2017-09-12 11:42:35 +0100 | 
| commit | 504e63cd9a833b236b3d7f87ea71d58707db8804 (patch) | |
| tree | 3f1487d69a7e2597c67d5248301b952ee50c0903 | |
| parent | 4d148a48ec375db2dc86f09f274bf5c3f76cce39 (diff) | |
| download | vimium-504e63cd9a833b236b3d7f87ea71d58707db8804.tar.bz2 | |
Use browser.runtime.getBrowserInfo to identify Firefox
| -rw-r--r-- | background_scripts/main.coffee | 1 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 3 | ||||
| -rw-r--r-- | lib/utils.coffee | 8 | 
3 files changed, 10 insertions, 2 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 412b8781..379239ae 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -311,6 +311,7 @@ Frames =    isEnabledForUrl: ({request, tabId, port}) ->      urlForTab[tabId] = request.url if request.frameIsFocused +    request.isFirefox = Utils.isFirefox() # Update the value for Utils.isFirefox in the frontend.      enabledState = Exclusions.isEnabledForUrl request.url      if request.frameIsFocused diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index dae25f5c..02bdfa2c 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -493,7 +493,8 @@ extend window,  # the page icon.  checkIfEnabledForUrl = do ->    Frame.addEventListener "isEnabledForUrl", (response) -> -    {isEnabledForUrl, passKeys, frameIsFocused} = response +    {isEnabledForUrl, passKeys, frameIsFocused, isFirefox} = response +    Utils.isFirefox = -> isFirefox      initializeOnEnabledStateKnown isEnabledForUrl      normalMode.setPassKeys passKeys      # Hide the HUD if we're not enabled. diff --git a/lib/utils.coffee b/lib/utils.coffee index 520d5b8c..93cc3246 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -7,7 +7,13 @@ window.forTrusted ?= (handler) -> (event) ->      true  Utils = -  isFirefox: -> 0 <= navigator.userAgent.indexOf "Firefox" +  isFirefox: do -> +    # NOTE(mrmr1993): This test only works in the background page, this is overwritten by isEnabledForUrl for +    # content scripts. +    isFirefox = false +    browser?.runtime?.getBrowserInfo?()?.then? (browserInfo) -> +      isFirefox = browserInfo?.name == "Firefox" +    -> isFirefox    getCurrentVersion: ->      chrome.runtime.getManifest().version | 
