aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/main.coffee30
-rw-r--r--content_scripts/vimium_frontend.coffee30
-rw-r--r--manifest.json1
3 files changed, 16 insertions, 45 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) ->
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index f3bbb868..2582d7a5 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -165,8 +165,6 @@ initializePreDomReady = ->
window.removeEventListener "focus", onFocus
requestHandlers =
- hideUpgradeNotification: -> HUD.hideUpgradeNotification()
- showUpgradeNotification: (request) -> HUD.showUpgradeNotification(request.version)
showHUDforDuration: (request) -> HUD.showForDuration request.text, request.duration
toggleHelpDialog: (request) -> toggleHelpDialog(request.dialogHtml, request.frameId)
focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame(request.highlight)
@@ -1069,7 +1067,6 @@ toggleHelpDialog = (html, fid) ->
HUD =
_tweenId: -1
_displayElement: null
- _upgradeNotificationElement: null
# This HUD is styled to precisely mimick the chrome HUD on Mac. Use the "has_popup_and_link_hud.html"
# test harness to tweak these styles to match Chrome's. One limitation of our HUD display is that
@@ -1087,26 +1084,6 @@ HUD =
HUD._tweenId = Tween.fade(HUD.displayElement(), 1.0, 150)
HUD.displayElement().style.display = ""
- showUpgradeNotification: (version) ->
- HUD.upgradeNotificationElement().innerHTML = "Vimium has been upgraded to #{version}. See
- <a class='vimiumReset' target='_blank'
- href='https://github.com/philc/vimium#release-notes'>
- what's new</a>.<a class='vimiumReset close-button' href='#'>&times;</a>"
- links = HUD.upgradeNotificationElement().getElementsByTagName("a")
- links[0].addEventListener("click", HUD.onUpdateLinkClicked, false)
- links[1].addEventListener "click", (event) ->
- event.preventDefault()
- HUD.onUpdateLinkClicked()
- Tween.fade(HUD.upgradeNotificationElement(), 1.0, 150)
-
- onUpdateLinkClicked: (event) ->
- HUD.hideUpgradeNotification()
- chrome.runtime.sendMessage({ handler: "upgradeNotificationClosed" })
-
- hideUpgradeNotification: (clickEvent) ->
- Tween.fade(HUD.upgradeNotificationElement(), 0, 150,
- -> HUD.upgradeNotificationElement().style.display = "none")
-
#
# Retrieves the HUD HTML element.
#
@@ -1117,13 +1094,6 @@ HUD =
HUD._displayElement.style.right = "150px"
HUD._displayElement
- upgradeNotificationElement: ->
- if (!HUD._upgradeNotificationElement)
- HUD._upgradeNotificationElement = HUD.createHudElement()
- # Position this just to the left of our normal HUD.
- HUD._upgradeNotificationElement.style.right = "315px"
- HUD._upgradeNotificationElement
-
createHudElement: ->
element = document.createElement("div")
element.className = "vimiumReset vimiumHUD"
diff --git a/manifest.json b/manifest.json
index beb68530..4ba222fb 100644
--- a/manifest.json
+++ b/manifest.json
@@ -27,6 +27,7 @@
"clipboardRead",
"storage",
"sessions",
+ "notifications",
"<all_urls>"
],
"content_scripts": [