简体   繁体   中英

Run Chrome Packaged apps inside of browser tab

I'd like to use new APIs provided for Chrome Packaged Apps, but also want to preserve ability to open some local URL in my current browser environment, is it possible? All Packaged Apps tutorials are focused on creating separate window and using app as first class citizen in the system.

Maybe its possible somehow to use chrome.socket and other APIs as usual, probably even only in developer mode?

No, it is not possible by design. Chrome packaged apps run separately from the browser and have no access to browser-specific features, like tabs. The closest you can get is to open an external (not in the packaged app) URL in the browser through window.open.

However, you can kind of emulate a browser by using the webview tag. See the code of the Browser sample to learn how to do it.

You can also install an extension that talks to your packaged app using the just released messaging API. See the messaging sample to learn how - it is pretty simple as long as you know the app and the extension IDs.

Edit: this is unsupported/likely to break in Chrome 44/45+ or so. There was around March 3rd a code review which does indeed break window.open from background page, but was reverted temporarily. So expect this to not work starting around Chrome 50?

It actually is possible (in Chrome 43) to run your chrome platform packaged app in a browser tab. From your background page, simply call window.open with a URL of some content in your app. for example if index.html is in your app's directory, it will open your app in a browser tab with URL chrome-extension://{{ extension id }}/index.html

This should not require any extra manifest permissions.

Note that it will not work if you simply type the url chrome-extension://{{ extension id }}/index.html into your browser. You need to open it from the app's background script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM