user2461391
user2461391

Reputation: 1433

Using both activeTab and serial permissions

I am trying to use a hardware serial device to change what displays on a webpage in Chrome. I'm making a Chrome extension to do so, however it seems as if I cannot use both the activeTab and serial permissions at the same time. The activeTab permission requires the app to not be a packaged app, and the serial permission requires the app to be packaged.

How can I get around this if possible?

I am using the page redder sample code as the way to change the webpage, however it requires the activeTab permission. Maybe there is a workaround to this? Thanks

Upvotes: 1

Views: 153

Answers (2)

Xan
Xan

Reputation: 77523

An alternative is to make a Native Messaging host that communicates with the device and with your extension.

From architectural point of view this makes more sense, but limits your deployment options, as the host program can't be bundled with the extension in the Web Store.

Upvotes: 0

François Beaufort
François Beaufort

Reputation: 5649

The only way I can think of is to create one Chrome Extension and one Chrome App that communicates to each other: https://developer.chrome.com/extensions/messaging#external

// The ID of the extension we want to talk to.
var laserExtensionId = "abcdefghijklmnoabcdefhijklmnoabc";

// Make a simple request:
chrome.runtime.sendMessage(laserExtensionId, {getTargetData: true},
  function(response) {
    if (targetInRange(response.targetData))
      chrome.runtime.sendMessage(laserExtensionId, {activateLasers: true});
  });

// Start a long-running conversation:
var port = chrome.runtime.connect(laserExtensionId);
port.postMessage(...);

Upvotes: 4

Related Questions