Created
September 11, 2013 16:11
-
-
Save adamterlson/6525873 to your computer and use it in GitHub Desktop.
Shim Notification API in chrome to expose permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translateWebkitPermission(code) { | |
switch (code) { | |
case 0: | |
return 'granted'; | |
case 1: | |
return 'default'; | |
case 2: | |
return 'denied'; | |
} | |
} | |
if (!Notification.permission) { | |
Object.defineProperty(Notification, "permission", { | |
get: function() { | |
return webkitNotifications && translateWebkitPermission(webkitNotifications.checkPermission()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment