OLD | NEW |
(Empty) | |
| 1 <meta name="doc-family" content="apps"> |
| 2 <h1 class="page_title">Understand the Architecture</h1> |
| 3 <p> |
| 4 Packaged apps integrate closely with a user’s operating system. |
| 5 They are designed to be run outside of a browser tab, |
| 6 to run robustly in offline and poor connectivity scenarios and |
| 7 to have far more powerful capabilities than are available |
| 8 in a typical web browsing environment. |
| 9 The app container, programming, and security models |
| 10 support these packaged app requirements. |
| 11 </p> |
| 12 <h2 id="container">App container model</h2> |
| 13 <p> |
| 14 The app container describes the visual appearance |
| 15 and loading behavior of packaged apps. |
| 16 Packaged apps look different than traditional web apps |
| 17 because the app container does not show any traditional web page UI controls; |
| 18 it simply contains a blank rectangular area. |
| 19 This allows an app to blend with “native” apps on the system, |
| 20 and it prevents the user from “messing” with the app logic |
| 21 by manually changing the URL. |
| 22 </p> |
| 23 <p> |
| 24 Packaged apps are loaded differently than web apps. |
| 25 Both load the same type of content: |
| 26 HTML documents with CSS and JavaScript; |
| 27 however, a packaged app is loaded in the app container, |
| 28 not in the browser tab. |
| 29 Also, the app container must load the main document |
| 30 of the packaged app from a local source. |
| 31 This forces all packaged apps to be at least minimally functional |
| 32 when offline and it provides a place |
| 33 to enforce stricter security measures. |
| 34 </p> |
| 35 <img src="{{static}}/images/container.png" |
| 36 width="671" |
| 37 height="172" |
| 38 alt="how app container model works"> |
| 39 <h2 id="programming">Programming model</h2> |
| 40 <p> |
| 41 The programming model describes the lifecycle |
| 42 and window behavior of packaged apps. |
| 43 Similar to native apps, |
| 44 the goal of this programming model is to give users |
| 45 and their systems full control over the app lifecycle. |
| 46 The packaged app lifecycle should be independent |
| 47 of browser window behavior or a network connection. |
| 48 </p> |
| 49 <p> |
| 50 The “event page” manages the packaged app lifecycle |
| 51 by responding to user gestures and system events. |
| 52 This page is invisible, only exists in the background, |
| 53 and can be closed automatically by the system runtime. |
| 54 It controls how windows open and close and |
| 55 when the app is started or terminated. |
| 56 There can only be one “event page” for a packaged app. |
| 57 <p> |
| 58 <p> |
| 59 <iframe title="YouTube video player" width="610" height="380" src="http://www.yo
utube.com/embed/yr1jgREbH8U" frameborder="0" allowfullscreen></iframe> |
| 60 </p> |
| 61 <h3>App lifecycle at a glance</h3> |
| 62 <p> |
| 63 For detailed instructions on how to use the programming model, |
| 64 see <a href="app_lifecycle.html">Manage App Lifecycle</a>. |
| 65 Here's a brief summary of the packaged app lifecyle |
| 66 to get you started: |
| 67 </p> |
| 68 <br> |
| 69 <table border="0"> |
| 70 <tr> |
| 71 <th scope="col"> Stage </th> |
| 72 <th scope="col"> Summary </th> |
| 73 </tr> |
| 74 <tr> |
| 75 <td>Installation</td> |
| 76 <td>User chooses to install the app and explicitly accepts the |
| 77 <a href="manifest.html#permissions">permissions</a>. |
| 78 </td> |
| 79 </tr> |
| 80 <tr> |
| 81 <td>Startup</td> |
| 82 <td>The event page is loaded, |
| 83 the 'launch' event fires, |
| 84 and app pages open in windows. |
| 85 You |
| 86 <a href="app_lifecycle.html#eventpage">create the windows</a> |
| 87 that your app requires, |
| 88 how they look, and how they communicate |
| 89 with the event page and with other windows. |
| 90 </td> |
| 91 </tr> |
| 92 <tr> |
| 93 <td>Termination</td> |
| 94 <td>User can terminate apps at any time |
| 95 and app can be quickly restored to previous state. |
| 96 <a href="app_lifecycle.html#H3-7">Stashing data</a> |
| 97 protects against data loss.</td> |
| 98 </tr> |
| 99 <tr> |
| 100 <td>Update</td> |
| 101 <td>Apps can be updated at any time; |
| 102 however, the code that a packaged app is running |
| 103 cannot change during a startup/termination cycle.</td> |
| 104 </tr> |
| 105 <tr> |
| 106 <td>Uninstallation</td> |
| 107 <td>User can actively uninstall apps. |
| 108 When uninstalled, no executing code or |
| 109 private data is left behind.</td> |
| 110 </tr> |
| 111 </table> |
| 112 <h2 id="security">Security model</h2> |
| 113 <p> |
| 114 The packaged apps security model protects users |
| 115 by ensuring their information is managed |
| 116 in a safe and secure manner. |
| 117 <a href="app_csp.html">Comply with CSP</a> |
| 118 includes detailed information on how to comply with content security policy. |
| 119 This policy blocks dangerous scripting |
| 120 reducing cross-site scripting bugs |
| 121 and protecting users against man-in-the-middle attacks. |
| 122 </p> |
| 123 <p> |
| 124 Loading the packaged app main page locally provides a place |
| 125 to enforce stricter security than the web. |
| 126 Like Chrome extensions, |
| 127 users must explicitly agree to trust the packaged app on install; |
| 128 they grant the app permission to access and use their data. |
| 129 Each API that your app uses will have its own permission. |
| 130 The packaged apps security model also provides the ability |
| 131 to set up privilege separation on a per window basis. |
| 132 This allows you to minimize the code in your app |
| 133 that has access to dangerous APIs, |
| 134 while still getting to use them. |
| 135 </p> |
| 136 <p> |
| 137 Packaged apps reuse Chrome extension process isolation, |
| 138 and take this a step further by isolating storage and external content. |
| 139 Each app has its own private storage area |
| 140 and can’t access the storage of another app |
| 141 or personal data (such as cookies) for websites that you use in your browser. |
| 142 All external processes are isolated from the app. |
| 143 Since iframes run in the same process as the surrounding page, |
| 144 they can only be used to load other app pages. |
| 145 You can use the <code>object</code> tag to |
| 146 <a href="app_external.html">embed external content</a>; |
| 147 this content runs in a separate process from the app. |
| 148 </p> |
| 149 <p> |
| 150 <iframe title="YouTube video player" width="610" height="380" src="http://www.yo
utube.com/embed/EDtiWN42lHs" frameborder="0" allowfullscreen></iframe> |
| 151 </p> |
| 152 <p class="backtotop"><a href="#top">Back to top</a></p> |
OLD | NEW |