Chrome desktop notification click to focus on content
google-chrome, google-chrome-extension, javascript
Solution
notification = webkitNotifications.createNotification(...)
notification.onclick = function(){
window.focus();
this.cancel();
};
notification.show()
...works as expected, without any additional permissions.
Problem
I am building desktop notification into my a chrome extension that I am working on. The functionality I need required that the user be taken to the tab that caused the notification when they click on the notification window. I can get that working using the chrome.tabs API, but what I can't manage to figure out is how to bring Chrome to the front when the notification is clicked. I know window.focus() is disabled in chrome, but this is definitely possible to do since that's the behavior of the Gmail desktop notifications.