Skip to content Skip to sidebar Skip to footer

How To Allow Popup Windows And Redirects Using In Google Chrome Apps?

I have a Google Chrome App that uses a component. Inside the , at the URL of the guest, user authentication is handled using a popup and redirect man

Solution 1:

Your script needs to be split into two parts.

The background script runs in a different document than window.html, the Event page. Your app should look like this:

enter image description here

// This should be split off to app.jsvar webview = null;
functionisSafeUrl(url) {
    // This is Hello world test for now; permissions code will go here laterreturntrue;
}

functiononPermissionRequest(e) {
    e.request.allow();
    // This is Hello world test for now; permissions code will go here later
}

functiononDomReady() {
    webview = document.getElementById('webview');
    webview.addEventListener('permissionrequest', onPermissionRequest);
}

document.addEventListener('DOMContentLoaded', onDomReady);

Then include a <script> tag for the new script to window.html.


Since there is no such concept as "webview window" in a Chrome App, it's going to be more complicated than allowing everything.

You need to catch the newwindow event and process it by creating a new <webview>, possibly in another window. It's not very easy, but there may be implementations already if you look for them.

For the authentication to actually proceed, you need to make sure that the two webviews share a partition.

..as you can see, it's quite a bit more complicated than iframes.


However! I do believe you're going down an incorrect path altogether. If your task is to get an OAuth token, you should consider chrome.identity API, specifically launchWebAuthFlow.

Post a Comment for "How To Allow Popup Windows And Redirects Using In Google Chrome Apps?"