diff options
| author | Stephen Blott | 2015-03-22 11:06:13 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-03-22 11:06:13 +0000 | 
| commit | f0ea21bf380de602376ee0934de1c3760e0a4316 (patch) | |
| tree | 3a90aa1a366681b2fe5cf51973252dfdfd67faae | |
| parent | a9a6294323c0d6385e40c771adb0870024c16824 (diff) | |
| download | vimium-f0ea21bf380de602376ee0934de1c3760e0a4316.tar.bz2 | |
Upgrade message; show after permission accepted.
We're asking for the "notifications" permission.  I'm not sure what
happens.  If the user is asked to accept the permission, then we
wouldn't show the notification until the next time Vimium starts.
Instead, we check more frequently.  So the notification will show the
next time a tab is created (or changes page).
| -rw-r--r-- | background_scripts/main.coffee | 37 | 
1 files changed, 21 insertions, 16 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 4cb9465f..5dac2681 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -58,7 +58,7 @@ completers =    bookmarks: new MultiCompleter([completionSources.bookmarks])    tabs: new MultiCompleter([completionSources.tabs]) -chrome.runtime.onConnect.addListener((port, name) -> +chrome.runtime.onConnect.addListener (port, name) ->    senderTabId = if port.sender.tab then port.sender.tab.id else null    # If this is a tab we've been waiting to open, execute any "tab loaded" handlers, e.g. to restore    # the tab's scroll position. Wait until domReady before doing this; otherwise operations like restoring @@ -72,7 +72,10 @@ chrome.runtime.onConnect.addListener((port, name) ->    if (portHandlers[port.name])      port.onMessage.addListener(portHandlers[port.name]) -) + +  # If the user has accepted the "notifications" permission since we started, then we should try showing the +  # upgrade massge again. +  showUpgradeMessage()  chrome.runtime.onMessage.addListener((request, sender, sendResponse) ->    if (sendRequestHandlers[request.handler]) @@ -689,20 +692,21 @@ populateValidFirstKeys()  populateSingleKeyCommands()  # Show notification on upgrade. -if shouldShowUpgradeMessage() -  notificationId = "VimiumUpgradeNotification" -  notification = -    type: "basic" -    iconUrl: chrome.runtime.getURL "icons/vimium.png" -    title: "Vimium Upgrade" -    message: "Vimium has been upgraded to version #{currentVersion}. Click here for more information" -    isClickable: true -  chrome.notifications.create notificationId, notification, -> -    unless chrome.runtime.lastError -      Settings.set "previousVersion", currentVersion -      chrome.notifications.onClicked.addListener (id) -> -        if id == notificationId -          openUrlInNewTab url: "https://github.com/philc/vimium#release-notes" +showUpgradeMessage = -> +  if shouldShowUpgradeMessage() +    notificationId = "VimiumUpgradeNotification" +    notification = +      type: "basic" +      iconUrl: chrome.runtime.getURL "icons/vimium.png" +      title: "Vimium Upgrade" +      message: "Vimium has been upgraded to version #{currentVersion}. Click here for more information" +      isClickable: true +    chrome.notifications.create notificationId, notification, -> +      unless chrome.runtime.lastError +        Settings.set "previousVersion", currentVersion +        chrome.notifications.onClicked.addListener (id) -> +          if id == notificationId +            openUrlInNewTab url: "https://github.com/philc/vimium#release-notes"  # Ensure that tabInfoMap is populated when Vimium is installed.  chrome.windows.getAll { populate: true }, (windows) -> @@ -715,3 +719,4 @@ chrome.windows.getAll { populate: true }, (windows) ->  # Start pulling changes from synchronized storage.  Sync.init() +showUpgradeMessage() | 
