Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/common/extensions/docs/server2/templates/articles/first_app.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: everything but svn stuff Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <meta name="doc-family" content="apps">
2 <h1>Create Your First App</h1>
3
4
5 <p>
6 This tutorial walks you through creating your first packaged app.
7 Packaged apps are structured similarly to extensions
8 so current developers will recognize the manifest and packaging methods.
9 When you're done,
10 you'll just need to produce a zip file of your code and assets
11 in order to <a href="publish_app.html">publish</a> your app.
12 </p>
13
14 <p>
15 A packaged app contains these components:
16 </p>
17
18 <ul>
19 <li>The <strong>manifest</strong> tells Chrome about your app, what it is,
20 how to launch it and the extra permissions that it requires.</li>
21 <li>The <strong>background script</strong> is used to create the event page
22 responsible for managing the app life cycle.</li>
23 <li>All code must be included in the package. This includes HTML, JS, CSS
24 and Native Client modules.</li>
25 <li>All <strong>icons</strong> and other assets must be included
26 in the package as well.</li>
27 </ul>
28
29 <p class="note">
30 <b>API Samples: </b>
31 Want to play with the code?
32 Check out the
33 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/hello-wo rld">hello-world</a>
34 sample.
35 </p>
36
37 <h2 id="one">Step 1: Create the manifest</h2>
38
39 <p>
40 First create your <code>manifest.json</code> file
41 (<a href="manifest.html">Formats: Manifest Files</a>
42 describes this manifest in detail):
43 </p>
44
45 <pre>
46 {
47 "name": "Hello World!",
48 "description": "My first packaged app.",
49 "manifest_version": 2,
50 "version": "0.1",
51 "app": {
52 "background": {
53 "scripts": ["background.js"]
54 }
55 },
56 "permissions": ["experimental", "app.window"],
57 "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
58 }
59 </pre>
60
61 <p class="note">
62 <b>Important:</b>
63 Packaged apps <b>must</b> use
64 <a href="manifestVersion.html">manifest version 2</a>.
65 </p>
66
67 <h2 id="two">Step 2: Create the background script</h2>
68
69 <p>
70 Next create a new file called <code>background.js</code>
71 with the following content:
72 </p>
73
74 <pre>
75 chrome.experimental.app.onLaunched.addListener(function() {
76 chrome.app.window.create('window.html', {
77 'width': 400,
78 'height': 500
79 });
80 });
81 </pre>
82
83 <p>
84 In the above sample code,
85 the <a href="app_lifecycle.html#lifecycle">onLaunched event</a>
86 will be fired when the user starts the app.
87 It then immediately opens a window for the app of the specified width and height .
88 Your background script may contain additional listeners,
89 windows, post messages, and launch data,
90 all of which are used by the event page to manage the app.
91 </p>
92
93 <h2 id="three">Step 3: Create a window page</h2>
94
95 <p>
96 Create your <code>window.html</code> file:
97 </p>
98
99 <pre>
100 &lt;!DOCTYPE html>
101 &lt;html>
102 &lt;head>
103 &lt;/head>
104 &lt;body>
105 &lt;div>Hello, world!&lt;/div>
106 &lt;/body>
107 &lt;/html>
108 </pre>
109
110 <h2 id="four">Step 4: Create the icons</h2>
111
112 <p>
113 Copy these icons to your app folder:
114 </p>
115
116 <ul>
117 <li><a href="{{static}}/images/calculator-16.png">calculator-16.png</a></li>
118 <li><a href="{{static}}/images/calculator-128.png">calculator-128.png</a></li>
119 </ul>
120
121 <h2 id="five">Step 5: Launch your app</h2>
122
123 <h3>Enable flags</h3>
124
125 <p>
126 Many of the packaged apps APIs are still experimental,
127 so you should enable experimental APIs
128 so that you can try them out:
129 </p>
130
131 <ul>
132 <li>Go to <b>chrome://flags</b>.</li>
133 <li>Find "Experimental Extension APIs",
134 and click its "Enable" link.</li>
135 <li>Restart Chrome.</li>
136 </ul>
137
138 <h3>Load your app</h3>
139
140 <p>
141 To load your app,
142 bring up the apps and extensions management page
143 by clicking the wrench icon
144 <img src="{{static}}/images/toolsmenu.gif" width="29" height="29" alt=""
145 style="margin-top:0" />
146 and choosing <b>Tools > Extensions</b>.
147 </p>
148
149 <p>
150 Make sure the <b>Developer mode</b>
151 checkbox has been selected.
152 </p>
153
154 <p>
155 Click the <b>Load unpacked extension</b> button,
156 navigate to your app's folder
157 and click <b>OK</b>.
158 </p>
159
160 <h3>Open new tab and launch</h3>
161
162 <p>
163 Once you've loaded your app,
164 open a New Tab page
165 and click on your new app icon.
166 </p>
167
168 <p class="backtotop"><a href="#top">Back to top</a></p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698