Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 781
Nik Avatar asked Jan 12 '13 21:01

Nik


People also ask

How can I force Chrome to open links in a new tab that is in the foreground?

For this, you have to hold the CTRL button and then click on the left mouse button while pointing the cursor to the web address. If you click on a link in this manner, the website won't open in your current tab; instead, you'll see a new tab with your preferred web page.


2 Answers

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.

like image 173
mangini Avatar answered Sep 28 '22 09:09

mangini


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.

like image 43
kzahel Avatar answered Sep 28 '22 08:09

kzahel