diff options
| -rw-r--r-- | background_scripts/main.coffee | 33 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 8 | 
2 files changed, 13 insertions, 28 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 1a67f2b2..0d82e61c 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -311,24 +311,6 @@ selectTab = (direction, count = 1) ->              Math.max 0, tabs.length - count        chrome.tabs.update tabs[toSelect].id, selected: true -# Here's how we set the page icon.  The default is "disabled", so if we do nothing else, then we get the -# grey-out disabled icon.  Thereafter, we only set tab-specific icons, so there's no need to update the icon -# when we visit a tab on which Vimium isn't running. -# -# For active tabs, when a frame starts, it requests its active state via isEnabledForUrl.  We also check the -# state every time a frame gets the focus.  In both cases, the frame then updates the tab's icon accordingly. -# -# Exclusion rule changes (from either the options page or the page popup) propagate via the subsequent focus -# change.  In particular, whenever a frame next gets the focus, it requests its new state and sets the icon -# accordingly. -# -setIcon = (request, sender) -> -  path = switch request.icon -    when "enabled" then "icons/browser_action_enabled.png" -    when "partial" then "icons/browser_action_partial.png" -    when "disabled" then "icons/browser_action_disabled.png" -  chrome.browserAction.setIcon tabId: sender.tab.id, path: path -  chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->    return unless changeInfo.status == "loading" # only do this once per URL change    cssConf = @@ -373,10 +355,22 @@ Frames =    isEnabledForUrl: ({request, tabId, port}) ->      urlForTab[tabId] = request.url if request.frameIsFocused      rule = Exclusions.getRule request.url -    port.postMessage extend request, +    enabledState =        isEnabledForUrl: not rule or 0 < rule.passKeys.length        passKeys: rule?.passKeys ? "" +    if request.frameIsFocused +      chrome.browserAction.setIcon tabId: tabId, path: +        if not enabledState.isEnabledForUrl +          "icons/browser_action_disabled.png" +        else if 0 < enabledState.passKeys.length +          "icons/browser_action_partial.png" +        else +          "icons/browser_action_enabled.png" + +    # Send the response.  The tests require this to be last. +    port.postMessage extend request, enabledState +    domReady: ({tabId, frameId}) ->      if frameId == 0        tabLoadedHandlers[tabId]?() @@ -423,7 +417,6 @@ sendRequestHandlers =    selectSpecificTab: selectSpecificTab    createMark: Marks.create.bind(Marks)    gotoMark: Marks.goto.bind(Marks) -  setIcon: setIcon    sendMessageToFrames: sendMessageToFrames    log: bgLog    fetchFileContents: (request, sender) -> fetchFileContents request.fileName diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 9a42266a..71327fb6 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -449,14 +449,6 @@ checkIfEnabledForUrl = do ->      else if HUD.isReady()        # Quickly hide any HUD we might already be showing, e.g. if we entered insert mode on page load.        HUD.hide() -    # Update the page icon, if necessary. -    if windowIsFocused() -      chrome.runtime.sendMessage -        handler: "setIcon" -        icon: -          if isEnabledForUrl and not passKeys then "enabled" -          else if isEnabledForUrl then "partial" -          else "disabled"    (frameIsFocused = windowIsFocused()) ->      Frame.postMessage "isEnabledForUrl", {frameIsFocused, url: window.location.toString()} | 
