There are three core pieces to any Chrome packaged app:
Let's look at each of these components at their simplest level.
Tip: If you use the Sublime Text editor with our plugin, you can create these three files with a click (Chrome -> New App -> Hello World).
In an empty directory (let's call it <myappdir>),
create the manifest file: manifest.json
{
"manifest_version": 2,
"name": "My first app",
"version": "1",
"app": {
"background": {
"scripts": ["main.js"]
}
}
}
In the same directory, create the background script: main.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
bounds: {
width: 500,
height: 309
}
});
});
Create the user interface: index.html
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
chrome://extensions.<myappdir> directory.Tip:
If you have enabled Developer mode in chrome://extensions,
your apps can be inspected and debugged using the Chrome Developer Tools.
Just like any standard web page, right-click on page and select Inspect Element.
For the background page which doesn't have UI,
you can either right-click on any app window and
select Inspect Background Page or
go to chrome://extensions and click on Inspect Views...
Change the text "Hello world" to "My first app" in index.html.
Change the main.js background script to create two windows instead of one. Don't bother to create another html. For now, you can open index.html on both.
After changing code, right-click on your app and select Reload App to reload the changed files. All Developer Tools windows will be reopened when you reload your app.
Launch the app in a new tab page. Move the top window and you will see the second window behind it.
In 3 - Create MVC, you will use either pure JavaScript or AngluarJS to build your app's model, view, and controller.