Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app

I need to use the fileSystem permission in the manifest.js, so I can read/write files from my Chrome extension.

When I load my extension with the "Load unpacked extension" button, Chrome displays:

'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app.

So for Chrome my extension is a legacy packaged app.

My question is how to technically convert a "legacy packaged app" into a "packaged apps" so I can test the fileSystem API ?

Here is my manifest:

{
 "name": "MyApp",
 "version": "1.0",
 "manifest_version": 2,
  "app": {
  "launch": {
  "local_path": "index.html"
  }
 },
 "icons": {
 "128": "favicon.ico"
 },
  "permissions" : [
    "fileSystem"
  ]
}

Indeed I'm already using "manifest_version": 2.

like image 567
Stephaneuh Avatar asked Apr 23 '13 14:04

Stephaneuh


People also ask

What is a legacy packaged app?

A legacy packaged app is a web app that's bundled into a . crx file. In the past, legacy packaged apps could use most of the extension APIs, but since November 2012, the feature set of legacy packaged apps was reduced.

What is packaged app?

A packaged application is a fully functional application that you can view, use, and customize. Each packaged application includes installation scripts that define the application's supporting objects (including database objects, images, and seed data) as well as any preinstallation validations.

What is a chrome packaged app?

Types. Chrome apps can be hosted or packaged. Hosted apps have their background web pages on a remote server and the app acts like a bookmark or shortcut; packaged apps have off-line functionality making use of local storage.


1 Answers

Packaged apps have a different structure in the "app" section of the manifest. Your manifest.json would be something like:

{
  "name": "MyApp",
  "version": "1.0",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": [
        "main.js"
      ]
    }
  },
  "icons": {
    "128": "favicon.ico"
  },
  "permissions": [
    "fileSystem"
  ]
}

and you would also need a background script ("main.js" in this sample) that opens your index.html when the user clicks on the app icon:

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('index.html', {
    bounds: {
      width: 500,
      height: 300
    }
  });
});
like image 69
mangini Avatar answered Nov 16 '22 03:11

mangini