Reputation: 21
I am trying to read data from serial device arduino (serial monitor). But I dont want app to open in new window. It should open in chrome tab.
//manifest.json
{
"manifest_version": 2,
"name": "Serial Monitor",
"description": "Monitors your serial port and allows you to read and write to it like you could with Arduino's IDE.",
"version": "1.0.4",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "extentionAssets/icon-16x16.jpeg",
"128": "extentionAssets/icon-128x128.jpeg"
},
"permissions": [
"tabs","serial"
]
}
//background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('demo.html', {
bounds: {
width: 1160,
height: 960,
left: 100,
top: 100
},
minWidth: 1160,
minHeight: 960
});
});
chrome.runtime.onSuspend.addListener(function() {
// Do some simple clean-up tasks.
});
chrome.runtime.onInstalled.addListener(function() {
// chrome.storage.local.set(object items, function callback);
});
I also used chrome.create.tabs
function, but it is not helping.. new tab opens and closes immediately.
Upvotes: 1
Views: 1902
Reputation: 1174
Yup, Chrome packaged apps do not open in a Chrome tab (http://developer.chrome.com/apps/about_apps.html#look) and also do not have access to the Chrome tab (i.e. no access to chrome.tabs API which is limited to extensions).
Also, the chrome.serial API (http://developer.chrome.com/apps/serial.html) is limited to packaged apps and not available to extensions. To use the serial API you need to be a packaged app. To access a tab, you need to be an extension.
However, note that an app and an extension can communicate (if that's what you need) using: http://developer.chrome.com/apps/runtime.html#method-sendMessage
Upvotes: 0
Reputation: 171
It seems that you are confusing chrome extensions with chrome apps.
What you are trying to do is not possible in a chrome packaged app, your manifest file seems to be the one you need for a CPA not for an extension. Even more, you are using a background.js script that will open a new chrome app window with the demo.html page in it.
If you are refering to a chrome extension then you might want to tag your question as google-chrome-extension.
If not, then the answer is easy: It is not possible to open tabs in chrome packaged apps, the concept of a chrome browser tab doesn't apply.
Upvotes: 4