Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bubbling Up Notifications Through Google Chrome App Webview

I have a Google Chrome Packaged App and uses a webview tag to load a remote page (that I don't control). That remote page is trying to request notification privileges and that permissions request doesn't seem to be bubbling up through to the wrapping Chrome App.

I'm using the following (overly permissive) code to allow all permission requests from the webview (and echo all console output):

  webview.addEventListener('permissionrequest', function(e) {
    console.log("webview requested " + e.permission);
    e.request.allow();
  });

  webview.addEventListener('consolemessage', function(e) {
    console.log('From webview: ', e.message);
  });

I can't find confirmation online, but I'm thinking notification permissions are not yet allowed in webviews. If we assume that is the case, are there any other ways to potentially force notification permission for the webview'ed site that won't be blocked by CORS?

like image 499
Mike Flynn Avatar asked Aug 13 '14 21:08

Mike Flynn


1 Answers

You are correct (as far as the docs go) that notification permission requests don't exist, nor there is any event to indicate that a notification wants to be shown.

What you could conceivably do is to inject a content script that will, in turn, inject a page-level script that replaces the Notification object with something that passes a message to your content script, which relays it to your app, which can show the notification using chrome.notifications. Here's an answer that explains this injection in more detail.

like image 88
Xan Avatar answered Oct 21 '22 15:10

Xan