| OLD | NEW |
| 1 <meta name="doc-family" content="apps"> | 1 <meta name="doc-family" content="apps"> |
| 2 <div id="pageData-name" class="pageData">Manage App Lifecycle</div> | 2 <div id="pageData-name" class="pageData">Manage App Lifecycle</div> |
| 3 <div id="pageData-showTOC" class="pageData">true</div> | 3 <div id="pageData-showTOC" class="pageData">true</div> |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 </pre> | 69 </pre> |
| 70 | 70 |
| 71 <p> | 71 <p> |
| 72 Your event page must include the <code>onLaunched()</code> function. | 72 Your event page must include the <code>onLaunched()</code> function. |
| 73 This function is called | 73 This function is called |
| 74 when your application is launched in any way: | 74 when your application is launched in any way: |
| 75 </p> | 75 </p> |
| 76 | 76 |
| 77 <pre> | 77 <pre> |
| 78 chrome.experimental.app.onLaunched.addListener(function() { | 78 chrome.app.runtime.onLaunched.addListener(function() { |
| 79 // Tell your app what to launch and how. | 79 // Tell your app what to launch and how. |
| 80 }); | 80 }); |
| 81 </pre> | 81 </pre> |
| 82 | 82 |
| 83 <h3>Create windows</h3> | 83 <h3>Create windows</h3> |
| 84 | 84 |
| 85 <p> | 85 <p> |
| 86 An event page may create one or more windows at its discretion. | 86 An event page may create one or more windows at its discretion. |
| 87 By default, these windows are created with a script connection | 87 By default, these windows are created with a script connection |
| 88 to the event page and are directly scriptable by the event page. | 88 to the event page and are directly scriptable by the event page. |
| 89 </p> | 89 </p> |
| 90 | 90 |
| 91 <p> | 91 <p> |
| 92 Windows can either be shells or panels. | 92 Windows can either be shells or panels. |
| 93 Shell windows have no browser chrome. | 93 Shell windows have no browser chrome. |
| 94 Panel windows are the same as shell windows, | 94 Panel windows are the same as shell windows, |
| 95 except they have different size and position restrictions, | 95 except they have different size and position restrictions, |
| 96 for example, a chat panel. | 96 for example, a chat panel. |
| 97 </p> | 97 </p> |
| 98 | 98 |
| 99 <p>Here's a sample <code>background.js</code> | 99 <p>Here's a sample <code>background.js</code> |
| 100 with a 'shell' window:</p> | 100 with a 'shell' window:</p> |
| 101 | 101 |
| 102 <pre> | 102 <pre> |
| 103 chrome.experimental.app.onLaunched.addListener(function() { | 103 chrome.app.runtime.onLaunched.addListener(function() { |
| 104 chrome.app.window.create('main.html', { | 104 chrome.app.window.create('main.html', { |
| 105 width: 800, | 105 width: 800, |
| 106 height: 600, | 106 height: 600, |
| 107 minWidth: 800, | 107 minWidth: 800, |
| 108 minHeight: 600, | 108 minHeight: 600, |
| 109 left: 100, | 109 left: 100, |
| 110 top: 100, | 110 top: 100, |
| 111 type: 'shell' | 111 type: 'shell' |
| 112 }); | 112 }); |
| 113 }); | 113 }); |
| 114 </pre> | 114 </pre> |
| 115 | 115 |
| 116 <p>Here's a sample <code>background.js</code> | 116 <p>Here's a sample <code>background.js</code> |
| 117 with a 'panel' window: | 117 with a 'panel' window: |
| 118 </p> | 118 </p> |
| 119 | 119 |
| 120 <pre> | 120 <pre> |
| 121 chrome.experimental.app.onLaunched.addListener(function() { | 121 chrome.app.runtime.onLaunched.addListener(function() { |
| 122 chrome.app.window.create('index.html', { | 122 chrome.app.window.create('index.html', { |
| 123 width: 400, | 123 width: 400, |
| 124 height: 200, | 124 height: 200, |
| 125 type: 'panel' | 125 type: 'panel' |
| 126 }); | 126 }); |
| 127 }); | 127 }); |
| 128 </pre> | 128 </pre> |
| 129 | 129 |
| 130 <h3>Including Launch Data</h3> | 130 <h3>Including Launch Data</h3> |
| 131 | 131 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 Keep the clean-up tasks synchronous and simple. | 221 Keep the clean-up tasks synchronous and simple. |
| 222 </p> | 222 </p> |
| 223 | 223 |
| 224 <pre> | 224 <pre> |
| 225 chrome.runtime.onSuspend.addListener(function() { | 225 chrome.runtime.onSuspend.addListener(function() { |
| 226 // Do some simple clean-up tasks. | 226 // Do some simple clean-up tasks. |
| 227 }); | 227 }); |
| 228 </pre> | 228 </pre> |
| 229 | 229 |
| 230 <p class="backtotop"><a href="#top">Back to top</a></p> | 230 <p class="backtotop"><a href="#top">Back to top</a></p> |
| OLD | NEW |