Chrome Packaged Apps
For a few years now I use Windows, Linux, OS X daily. For years, I've been looking into a language/framework/product that will allow me to build (desktop) applications that can run on all of these OS's. I've looked into QT, PyQT, Java Swing and others. I've looked into the cloud, PaaS, web applications but I couldn't find something that I liked.
Of course, HTML5 has gained a lot of momentum and I've been following it from the very first day, so I was "double" happy when I found out about the Chrome Packaged Apps that look and behave like desktop apps, they can however live perfectly in the cloud and are built purely with web technologies. The fact they can run on my Chromebook too, is the cherry on top.
Hello World!
No time to lose, I jumped into the proverbial Hello World app, which run on my stable Chrome 27.0.1448.0 without a glitch. You have to follow instructions on the previous link to enable the Experimental Extension APIs on chrome://flags/ and ensure you have the Developer mode on in order to be able to load unpacked extensions.
My first real app
Next thought was of course "let's convert an existing app" and not having too much of a choice I decided to convert my Mandelbrot HTML5 experiment. Quickly, I "cut" two icons in Photoshop, and created a manifest file, only to find out that the application didn't work right away... The problem a security exception:
Refused to execute inline event handler because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
I guess everybody who tries to convert their app in 3 seconds blindfolded will have the same outcome, so here how to fix that. A little bit of Googling quickly reveals that the Content Security Policy (CSP) for packaged apps doesn't allow onclick
events, therefore the developer has to either properly rewrite the application to use the APIs provided or sandbox the offending pages. Adding the following to my manifest.json
does the trick:
"sandbox": {
"pages": ["index.html"]
}
The next issue I had, was that my app had a <body onload="...">
handler which didn't fire. Adding a JavaScript onload handler in my application's main .js file worked:
window.onload = function() {
...
};
My first "true" multi-OS desktop app
Well, long way to go still and a lot of things to learn and explore, however I do feel like what I was looking for all these years, has started to materialize courtesy of Chromium and its awesome APIs. I cannot wait until the apps can be added to the chrome web store and be accessible through the upcoming chrome app launcher.
Screenshots
For the observant reader it will look like the Linux app is faster than both the Mac and the Windows version. However, the test is really very small so you can't really read into it. I have not yet benchmarked their speed. I must say though that my 4+ yr old MBP did slightly better than my 2yr old massive Windows rig and Linux went best of all, even though it was running in a virtual machine inside Windows! :-] Not a good test. Definitely not!
Comments