aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-03-22 11:06:13 +0000
committerStephen Blott2015-03-22 11:06:13 +0000
commitf0ea21bf380de602376ee0934de1c3760e0a4316 (patch)
tree3a90aa1a366681b2fe5cf51973252dfdfd67faae
parenta9a6294323c0d6385e40c771adb0870024c16824 (diff)
downloadvimium-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.coffee37
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()