Use the W3C Permissions API where possible. At the time of this writing this is supported in Chrome >= 64.