Packaged offline app development - newbie problems

144 views
Skip to first unread message

Jindřich Vavruška

unread,
Jul 27, 2012, 4:04:20 AM7/27/12
to chromi...@chromium.org
Hello,

I am developing my first app, to be used offline as packaged app. So far I have four files: manifest.json, a HTML page, a JS script file and CSS file.

My first problem is the start up. The HTML page contains <script type="text/javascript" src="main.js" ></script> and <body onLoad="initOnLoad();"> , so when loaded offline as file:// URL javascript function initOnLoad() does what it is supposed to do - populate some additional HTML content based on data included in main.js.

When I try to load my work in progress as unpacked app, it does not start properly. I tried to include some "background" stuff in the manifest, but the best result was opening the uninitialized page (all content generated by initOnLoad() was missing). I did this by including this in the manifest:

"app" { "launch": { "localpath": "my-page.html" } },

However, Chrome security model will not allow the inline javascript code to be started, so that is why it does not work. I also tried, following tutorials, to create background.js file containing call to addListener:

chrome.experimental.app.onLaunched.addListener(function() {
  chrome.windows.create({
      url: 'qsoinput.html',
      type: 'shell',
      width: 600,
      height: 450
  });
});
and I also added "background": { "scripts": ["background.js"] }, "permissions" : ["experimental"], to the manifest and reloaded the app. I am puzzled that it generates one more HTML page from this code, but nevertheless it still does not start. I also activated some experimental functions to let background tasks and other stuff run in my installation of Chrome, using chrome://flags.

I would like to ask someone to help me with this. Developer mode in Chrome does not show enough information, especially it does not show whether the background.js code is running and if there were any exceptions. My general impression is that Chrome, in app mode, does not start any javascript code and hence the whole package appears dead.

My Chrome version is 20.0.1132.57 Windows 64 bit; 
my chrome://flags : 
 - Applications without CRX file - activated
 - Allow experimental extension API - activated
 - Allow experimantal javascript - activated
 - Allow shadow DOM - activated (although it is not clear for me what this is supposed to do, there's only vague description)
 - Allow platform applications - activated (but this one should not have effect on my app)

Anybody could help? Pointer to a tutorial that makes sense and does what the author says it should do? Google original tutorials either do not work with this version of Chrome, or they are not written for packaged apps. When I try to imitate some of the tutorial manifests, I get what I described above.

Thank you,

Jindra


Paul Kinlan

unread,
Jul 27, 2012, 9:43:52 AM7/27/12
to Jindřich Vavruška, chromi...@chromium.org
Hi,

chrome.experimental.app.onLaunched is only available when using manifest_version: 2, likewise with the "background" section.

http://developer.chrome.com/apps is your source of information for manifest_version 2 apps.

P




--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-apps/-/R6nEY9FzAZEJ.
To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.



--
Paul Kinlan
Developer Advocate @ Google for Chrome and HTML5
Skype: paul.kinlan

Andy Sylvester

unread,
Sep 27, 2012, 3:50:01 PM9/27/12
to chromi...@chromium.org, radio.m...@gmail.com
Jindra,

It is still possible to create packaged apps without using manifest version 2, although you may not be able to upload packaged apps to the Google App Store without using version 2 in your manifest file. Here are some examples:

http://www.buildbrowserapps.com/chromeappbook/chapter02.html (Hello World example)

http://www.buildbrowserapps.com/chromeappbook/chapter06.html (number guessing game)

These examples also allow you to execute inline Javascript code.

Andy Sylvester
http://buildbrowserapps.com
@BuildBrowserApp

Mihai Parparita

unread,
Sep 27, 2012, 4:32:08 PM9/27/12
to Andy Sylvester, chromi...@chromium.org, radio.m...@gmail.com
These are legacy packaged apps. New-style packaged apps (as announced at I/O 2012, see http://developer.chrome.com/apps) must use manifest_version 2.

Mihai

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
Reply all
Reply to author
Forward
0 new messages