OLD | NEW |
---|---|
1 <meta name="doc-family" content="apps"> | 1 <meta name="doc-family" content="apps"> |
2 <h1>Chrome App Lifecycle</h1> | 2 <h1>Chrome App Lifecycle</h1> |
3 | 3 |
4 | 4 |
5 <p> | 5 <p> |
6 The app runtime and event page are responsible | 6 The app runtime and event page are responsible |
7 for managing the app lifecycle. | 7 for managing the app lifecycle. |
8 The app runtime manages app installation, | 8 The app runtime manages app installation, |
9 controls the event page, | 9 controls the event page, |
10 and can shutdown the app at anytime. | 10 and can shutdown the app at anytime. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 Windows in Chrome Apps are not associated with any Chrome browser | 92 Windows in Chrome Apps are not associated with any Chrome browser |
93 windows. They have an optional frame with title bar and size controls, | 93 windows. They have an optional frame with title bar and size controls, |
94 and a recommended window ID. | 94 and a recommended window ID. |
95 Windows without IDs will not restore to their size and location after restart. | 95 Windows without IDs will not restore to their size and location after restart. |
96 </p> | 96 </p> |
97 | 97 |
98 <p>Here's a sample window created from <code>background.js</code>:</p> | 98 <p>Here's a sample window created from <code>background.js</code>:</p> |
99 | 99 |
100 <pre data-filename="background.js"> | 100 <pre data-filename="background.js"> |
101 chrome.app.runtime.onLaunched.addListener(function() { | 101 chrome.app.runtime.onLaunched.addListener(function() { |
102 chrome.app.window.create('main.html', { | 102 chrome.app.window.create('main', { |
mkearney1
2014/04/09 19:43:30
Keep .html as it refers to a filename.
| |
103 id: 'MyWindowID', | 103 id: 'MyWindowID', |
104 bounds: { | 104 bounds: { |
105 width: 800, | 105 width: 800, |
106 height: 600, | 106 height: 600, |
107 left: 100, | 107 left: 100, |
108 top: 100 | 108 top: 100 |
109 }, | 109 }, |
110 minWidth: 800, | 110 minWidth: 800, |
111 minHeight: 600 | 111 minHeight: 600 |
112 }); | 112 }); |
(...skipping 27 matching lines...) Expand all Loading... | |
140 | 140 |
141 <h3 id="local_settings">Storing local settings</h3> | 141 <h3 id="local_settings">Storing local settings</h3> |
142 | 142 |
143 <p> | 143 <p> |
144 <code>chrome.runtime.onInstalled()</code> | 144 <code>chrome.runtime.onInstalled()</code> |
145 is called when your app has first been installed, | 145 is called when your app has first been installed, |
146 or when it has been updated. | 146 or when it has been updated. |
147 Any time this function is called, | 147 Any time this function is called, |
148 the <code>onInstalled</code> event is fired. | 148 the <code>onInstalled</code> event is fired. |
149 The event page can listen for this event and use the | 149 The event page can listen for this event and use the |
150 <a href="storage.html">Storage API</a> | 150 <a href="storage">Storage API</a> |
151 to store and update local settings | 151 to store and update local settings |
152 (see also <a href="app_storage.html#options">Storage options</a>). | 152 (see also <a href="app_storage#options">Storage options</a>). |
153 </p> | 153 </p> |
154 | 154 |
155 <pre data-filename="background.js"> | 155 <pre data-filename="background.js"> |
156 chrome.runtime.onInstalled.addListener(function() { | 156 chrome.runtime.onInstalled.addListener(function() { |
157 chrome.storage.local.set(object items, function callback); | 157 chrome.storage.local.set(object items, function callback); |
158 }); | 158 }); |
159 </pre> | 159 </pre> |
160 | 160 |
161 <h3 id="preventing_loss">Preventing data loss</h3> | 161 <h3 id="preventing_loss">Preventing data loss</h3> |
162 | 162 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 Keep the clean-up tasks synchronous and simple. | 200 Keep the clean-up tasks synchronous and simple. |
201 </p> | 201 </p> |
202 | 202 |
203 <pre data-filename="background.js"> | 203 <pre data-filename="background.js"> |
204 chrome.runtime.onSuspend.addListener(function() { | 204 chrome.runtime.onSuspend.addListener(function() { |
205 // Do some simple clean-up tasks. | 205 // Do some simple clean-up tasks. |
206 }); | 206 }); |
207 </pre> | 207 </pre> |
208 | 208 |
209 <p class="backtotop"><a href="#top">Back to top</a></p> | 209 <p class="backtotop"><a href="#top">Back to top</a></p> |
OLD | NEW |