diff options
| author | Stephen Blott | 2015-03-22 10:39:14 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-03-22 10:39:14 +0000 |
| commit | a9a6294323c0d6385e40c771adb0870024c16824 (patch) | |
| tree | 3af2f0fd7bbdcb963f211fbcc64abe0f893e9db9 /background_scripts | |
| parent | 5abde2faa3cbcf070de82c5dffef93c553c7ad02 (diff) | |
| download | vimium-a9a6294323c0d6385e40c771adb0870024c16824.tar.bz2 | |
Use chrome.notifications for upgrade notifications.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index f70cd8f3..4cb9465f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -70,11 +70,6 @@ chrome.runtime.onConnect.addListener((port, name) -> delete tabLoadedHandlers[senderTabId] toCall.call() - # domReady is the appropriate time to show the "vimium has been upgraded" message. - # TODO: This might be broken on pages with frames. - if (shouldShowUpgradeMessage()) - chrome.tabs.sendMessage(senderTabId, { name: "showUpgradeNotification", version: currentVersion }) - if (portHandlers[port.name]) port.onMessage.addListener(portHandlers[port.name]) ) @@ -184,14 +179,6 @@ openUrlInIncognito = (request) -> chrome.windows.create({ url: Utils.convertToUrl(request.url), incognito: true}) # -# Called when the user has clicked the close icon on the "Vimium has been updated" message. -# We should now dismiss that message in all tabs. -# -upgradeNotificationClosed = (request) -> - Settings.set("previousVersion", currentVersion) - sendRequestToAllTabs({ name: "hideUpgradeNotification" }) - -# # Copies or pastes some data (request.data) to/from the clipboard. # We return null to avoid the return value from the copy operations being passed to sendResponse. # @@ -662,7 +649,6 @@ sendRequestHandlers = unregisterFrame: unregisterFrame frameFocused: handleFrameFocused nextFrame: (request) -> BackgroundCommands.nextFrame 1, request.frameId - upgradeNotificationClosed: upgradeNotificationClosed updateScrollPosition: handleUpdateScrollPosition copyToClipboard: copyToClipboard pasteFromClipboard: pasteFromClipboard @@ -701,8 +687,22 @@ if Settings.has("keyMappings") populateValidFirstKeys() populateSingleKeyCommands() + +# Show notification on upgrade. if shouldShowUpgradeMessage() - sendRequestToAllTabs({ name: "showUpgradeNotification", version: currentVersion }) + 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) -> |
