OLD | NEW |
(Empty) | |
| 1 Distributing Your Application (NaCl) |
| 2 ==================================== |
| 3 |
| 4 .. {% setvar pepperversion %}pepper28{% endsetvar %} |
| 5 .. {% include "native-client/_local_variables.html" %} |
| 6 |
| 7 .. contents:: Table Of Contents |
| 8 :local: |
| 9 :backlinks: none |
| 10 :depth: 3 |
| 11 |
| 12 This document describes how to distribute Portable Native Client applications |
| 13 on the web, and Native Client applications through the |
| 14 `Chrome Web Store </chrome/web-store/docs/>`_ (CWS). |
| 15 |
| 16 |
| 17 Introduction |
| 18 ------------ |
| 19 |
| 20 Portable Native Client |
| 21 ...................... |
| 22 |
| 23 Portable Native Client is enabled by default for web pages. The only constraint |
| 24 is that the .html file, .nmf file (Portable Native Client manifest file), and |
| 25 .pexe file (Portable Native Client module) must be served from the same domain. |
| 26 Portable Native Client applications may also be distributed through the Chrome |
| 27 Web Store. |
| 28 |
| 29 Chrome Web Store |
| 30 ................ |
| 31 |
| 32 Native Client is only enabled by default for applications distributed through |
| 33 the Chrome Web Store (CWS). That means that Native Client applications must be |
| 34 distributed through the Chrome Web Store. The CWS requirement is in place to |
| 35 prevent the proliferation of Native Client executables (.nexe files) compiled |
| 36 for specific architecures (e.g., x86-32, x86-64, or ARM). |
| 37 |
| 38 The Chrome Web Store provides a number of |
| 39 `benefits |
| 40 <http://www.google.com/intl/en/landing/chrome/webstore/create/why-build-apps.htm
l>`_, |
| 41 such as reaching a large number of potential customers, making it easy for |
| 42 users to discover your applications, and providing a way to earn revenue from |
| 43 your applications. You can upload your applications to the CWS for free, and |
| 44 distribute them for free or for payment. |
| 45 |
| 46 CWS application types |
| 47 ..................... |
| 48 |
| 49 Before you upload an application to the Chrome Web Store, you must choose how |
| 50 you want to distribute the application. The CWS can be used to distribute |
| 51 three types of applications: hosted applications, packaged applications, and ext
ensions. |
| 52 |
| 53 * A **packaged application** is an application that is bundled into one |
| 54 file, hosted in the Chrome Web Store, and downloaded to the user's machine. |
| 55 * An **extension** is similar to a packaged application—the |
| 56 application is bundled into one file, hosted in the Chrome Web Store, |
| 57 and downloaded to the user's machine—but the application is |
| 58 specifically designed to extend the functionality of the Chrome browser. |
| 59 * A **hosted application** is an application that is hosted somewhere |
| 60 other than the Chrome Web Store (such as your own web server or |
| 61 Google App Engine). The CWS only contains metadata that points to the |
| 62 hosted application. |
| 63 |
| 64 The main factors to consider in choosing between these application types are: |
| 65 |
| 66 hosting |
| 67 You must make your own arrangements to host a hosted application (and |
| 68 pay for hosting services). Packaged applications |
| 69 and extensions are hosted in the Chrome Web Store. |
| 70 |
| 71 size |
| 72 Hosted applications do not have a size limit; packaged applications and |
| 73 extensions are limited to 2 GB in size. |
| 74 |
| 75 behavior |
| 76 Hosted applications and packaged applications are like normal web |
| 77 applications (they present their main functionality using |
| 78 an HTML page); extensions can add functionality to the Chrome browser. |
| 79 |
| 80 For help choosing how to distribute your application, refer to |
| 81 `Choosing an App Type </chrome/web-store/docs/choosing>`_. |
| 82 |
| 83 The next section of this document provides details about how to distribute each
type of application. |
| 84 |
| 85 Distribution details |
| 86 -------------------- |
| 87 |
| 88 .. _packaged: |
| 89 |
| 90 Packaged application |
| 91 .................... |
| 92 |
| 93 A packaged application is a special zip file (with a .crx extension) hosted in |
| 94 the Chrome Web Store. This file contains all of the application parts: A Chrome |
| 95 Web Store manifest file (manifest.json), an icon, and all of the regular Native |
| 96 Client application files. Refer to |
| 97 `Packaged Apps <https://developer.chrome.com/apps/about_apps.html>`_ |
| 98 for more information about creating a packaged application. |
| 99 |
| 100 Once you have a CWS manifest file and an icon for your application, you can zip
up all the files for your packaged application into |
| 101 one zip file for upload to the Chrome Web Store. Refer to |
| 102 `Step 5 </chrome/web-store/docs/get_started_simple#step5>`_ |
| 103 of the CWS Getting Started Tutorial to learn how to zip up your packaged |
| 104 application and upload it to the Chrome Web Store. |
| 105 |
| 106 .. _multi-platform-zip: |
| 107 |
| 108 Reducing the size of the user download package |
| 109 ++++++++++++++++++++++++++++++++++++++++++++++ |
| 110 |
| 111 .. Note:: |
| 112 :class: note |
| 113 |
| 114 **Tip:** |
| 115 Packaging an app in a multi-platform zip file can significantly reduce the |
| 116 download and storage requirements for the app. |
| 117 |
| 118 As described above, to upload a packaged app to the Chrome Web Store (CWS) you |
| 119 have to create a zip file with all the resources that your app needs, including |
| 120 .nexe files for multiple architectures (x86-64, x86-32, and ARM). Prior to |
| 121 Chrome 28, when users installed your app they had to download a .crx file from |
| 122 the CWS with all the included .nexe files. |
| 123 |
| 124 Starting with Chrome 28, the Chrome Web Store includes a feature called |
| 125 **multi-platform zip files.** |
| 126 This feature lets you structure your application directory and zip file in a |
| 127 way that reduces the size of the user download package. Here's how this |
| 128 feature works: |
| 129 |
| 130 * You still include all the .nexe files in the zip file that you upload to |
| 131 the CWS, but you designate specific .nexe files (and other files if |
| 132 appropriate) for specific architectures. |
| 133 * The Chrome Web Store re-packages your app, so that users only download |
| 134 the files that they need for their specific architecture. |
| 135 |
| 136 Here is how to use this feature: |
| 137 |
| 138 1. Create a directory called ``_platform_specific``. |
| 139 Put this directory at the same level where your CWS manifest file, |
| 140 ``manifest.json``, is located. |
| 141 |
| 142 2. Create a subdirectory for each specific architecture that you support, |
| 143 and add the files for each architecture in the relevant subdirectory. |
| 144 |
| 145 Here is a sample app directory structure: |
| 146 |
| 147 .. naclcode:: |
| 148 :prettyprint: 0 |
| 149 |
| 150 |-- my_app_directory/ |
| 151 | |-- manifest.json |
| 152 | |-- my_app.html |
| 153 | |-- my_module.nmf |
| 154 | +-- css/ |
| 155 | +-- images/ |
| 156 | +-- scripts/ |
| 157 | |-- **_platform_specific/** |
| 158 | | |-- x86-64/ |
| 159 | | | |-- my_module_x86_64.nexe |
| 160 | | |-- x86-32/ |
| 161 | | | |-- my_module_x86_32.nexe |
| 162 | | |-- arm/ |
| 163 | | | |-- my_module_arm.nexe |
| 164 | | |-- all/ |
| 165 | | | |-- my_module_x86_64.nexe |
| 166 | | | |-- my_module_x86_64.nexe |
| 167 | | | |-- my_module_x86_32.nexe |
| 168 |
| 169 Please note a few important points about the app directory structure: |
| 170 |
| 171 * The architecture-specific subdirectories: |
| 172 |
| 173 * can have arbitrary names; |
| 174 * must be directly under the ``_platform_specific`` directory; and |
| 175 * must be listed in the CWS manifest file (see step 3 below). |
| 176 |
| 177 * You can include a fallback subdirectory that provides a download package |
| 178 with all the architecture-specific files. (In the example above this |
| 179 is the ``all/`` subdirectory.) This folder is used if the user has an |
| 180 earlier version of Chrome (prior to Chrome 28) that does not support |
| 181 multi-platform zip files. |
| 182 |
| 183 * You cannot include any files directly in the folder |
| 184 ``_platform_specific``. All architecture-specific files |
| 185 must be under one of the architecture-specific subdirectories. |
| 186 |
| 187 * Files that are not under the ``_platform_specific`` directory are |
| 188 included in all download packages. (In the example above, that |
| 189 includes ``my_app.html``, ``my_module.nmf``, |
| 190 and the ``css/``, ``images/``, and ``scripts/`` directories.) |
| 191 |
| 192 |
| 193 3. Modify the CWS manifest file, ``manifest.json``, so that it specifies which |
| 194 subdirectory under ``_platform_specific`` corresponds to which architecture. |
| 195 |
| 196 The CWS manifest file must include a new name/value pair, where the name |
| 197 is ``platforms`` and the value is an array. The array has an object for |
| 198 each Native Client architecture with two name/value pairs: |
| 199 |
| 200 +----------------------+---------------------------------------+ |
| 201 | Name | Value | |
| 202 +======================+=======================================+ |
| 203 | ``nacl_arch`` | ``x86-64``, ``x86-32``, or ``arm`` | |
| 204 +----------------------+---------------------------------------+ |
| 205 | ``sub_package_path`` | the path of the directory (starting | |
| 206 | | with ``_platform_specific``) that | |
| 207 | | contains the files for the designated | |
| 208 | | NaCl architecture | |
| 209 +----------------------+---------------------------------------+ |
| 210 |
| 211 Here is a sample ``manifest.json`` file: |
| 212 |
| 213 .. naclcode:: |
| 214 :prettyprint: 0 |
| 215 |
| 216 { |
| 217 "name": "My Reminder App", |
| 218 "description": "A reminder app that syncs across Chrome browsers.", |
| 219 "manifest_version": 2, |
| 220 "minimum_chrome_version": "28", |
| 221 "offline_enabled": true, |
| 222 "version": "0.3", |
| 223 "permissions": [ |
| 224 {"fileSystem": ["write"]}, |
| 225 "alarms", |
| 226 "storage" |
| 227 ], |
| 228 "app": { |
| 229 "background": { |
| 230 "scripts": ["scripts/background.js"] |
| 231 } |
| 232 }, |
| 233 "icons": { |
| 234 "16": "images/icon-16x16.png", |
| 235 "128": "images/icon-128x128.png" |
| 236 }, |
| 237 **"platforms": [ |
| 238 { |
| 239 "nacl_arch": "x86-64", |
| 240 "sub_package_path": "_platform_specific/x86-64/" |
| 241 }, |
| 242 { |
| 243 "nacl_arch": "x86-32", |
| 244 "sub_package_path": "_platform_specific/x86-32/" |
| 245 }, |
| 246 { |
| 247 "nacl_arch": "arm", |
| 248 "sub_package_path": "_platform_specific/arm/" |
| 249 }, |
| 250 { |
| 251 "sub_package_path": "_platform_specific/all/" |
| 252 } |
| 253 ]** |
| 254 } |
| 255 |
| 256 Note the last entry in the CWS manifest file above, which specifies a |
| 257 ``sub_package_path`` without a corresponding ``nacl_arch``. This entry |
| 258 identifies the fallback directory, which is included in the download |
| 259 package if the user architecture does not match any of the listed NaCl |
| 260 architectures, or if the user is using an older version of Chrome that |
| 261 does not support multi-platform zip files. |
| 262 |
| 263 4. Modify your application as necessary so that it uses the files for the |
| 264 correct user architecture. |
| 265 |
| 266 To reference architecture-specific files, use the JavaScript API |
| 267 `chrome.runtime.getPlatformInfo() <http://developer.chrome.com/trunk/exten
sions/runtime.html#method-getPlatformInfo>`_. |
| 268 As an example, if you have architecture-specific files in the directories |
| 269 ``x86-64``, ``x86-32``, and ``arm``, you can use the following JavaScript |
| 270 code to create a path for the files: |
| 271 |
| 272 .. naclcode:: |
| 273 |
| 274 function getPath(name) { |
| 275 return '_platform_specific/' + |
| 276 chrome.runtime.getPlatformInfo().nacl_arch + |
| 277 '/' + name; |
| 278 } |
| 279 |
| 280 5. Test your app, create a zip file, and upload the app to the CWS as before. |
| 281 |
| 282 Additional considerations for a packaged application |
| 283 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 284 |
| 285 * In the description of your application in the CWS, make sure to mention that |
| 286 your application is a Native Client application that only works with the |
| 287 Chrome browser. Also make sure to identify the minimum version of Chrome |
| 288 that your application requires. |
| 289 * Hosted and packaged applications have a "launch" parameter in the CWS |
| 290 manifest. This parameter is present only in apps (not extensions), and it |
| 291 tells Google Chrome what to show when a user starts an installed app. For |
| 292 example: |
| 293 |
| 294 .. naclcode:: |
| 295 |
| 296 "launch": { |
| 297 "web_url": "http://mail.google.com/mail/" |
| 298 } |
| 299 |
| 300 * If you want to write local data using the Pepper |
| 301 `FileIO </native-client/peppercpp/classpp_1_1_file_i_o>`_ |
| 302 API, you must set the 'unlimitedStorage' permission in your Chrome Web |
| 303 Store manifest file, just as you would for a JavaScript application that |
| 304 uses the HTML5 File API. |
| 305 * For packaged applications, you can only use in-app purchases. |
| 306 * You can place your application in the Google Web Store with access only to |
| 307 certain people for testing. See |
| 308 `Publishing to test accounts </chrome/web-store/docs/publish#testaccounts>`_ |
| 309 for more information. |
| 310 |
| 311 Extension |
| 312 ......... |
| 313 |
| 314 An extension consists of a special zip file (with a .crx extension) hosted in |
| 315 the Chrome Web Store containing all of the application parts: A Chrome Web |
| 316 Store manifest file (manifest.json), an icon, and all of the regular Native |
| 317 Client application files. Refer to the |
| 318 `Google Chrome Extensions Overview <http://code.google.com/chrome/extensions/ove
rview.html>`_ |
| 319 to learn how to create an extension. |
| 320 |
| 321 Once you have a CWS manifest file and an icon for your application, you can zip |
| 322 up all the files for your packaged application into one zip file for upload to |
| 323 the Chrome Web Store. Refer to |
| 324 `Step 5 </chrome/web-store/docs/get_started_simple#step5>`_ |
| 325 of the CWS Getting Started Tutorial to learn how to zip up your extension and |
| 326 upload it to the Chrome Web Store. |
| 327 |
| 328 .. Note:: |
| 329 :class: note |
| 330 |
| 331 **Tip:** Use a :ref:`multi-platform zip file <multi-platform-zip>` to reduce |
| 332 the download and storage requirements for your extension. |
| 333 |
| 334 Hosted application |
| 335 .................. |
| 336 |
| 337 A hosted application is a normal web application with some extra metadata for |
| 338 the Chrome Web Store. Specifically, a hosted application consists of three |
| 339 parts: |
| 340 |
| 341 1. A Chrome Web Store manifest file (manifest.json) and an icon uploaded to the |
| 342 Chrome Web Store. The manifest file points to the Native Client application, |
| 343 essentially a web site, hosted on your web server. You must put the CWS |
| 344 manifest file and the icon into a zip file for upload to the Chrome Web |
| 345 store, and then convert that file to a special zip file with a .crx |
| 346 extension. Refer to the Chrome Web Store |
| 347 `Tutorial: Getting Started </chrome/web-store/docs/get_started_simple>`_ |
| 348 or to the |
| 349 `Hosted Apps </chrome/apps/docs/developers_guide>`_ |
| 350 documentation for information about how to create and upload this metadata |
| 351 to the CWS. |
| 352 |
| 353 2. All the regular Native Client application files. These files are hosted on |
| 354 your web server or Google App Engine at a location pointed to by the CWS |
| 355 manifest file. |
| 356 |
| 357 3. Binary assets. These files are hosted on your web server, Google App Engine, |
| 358 or Data Storage for Developers. |
| 359 |
| 360 Hosting options |
| 361 +++++++++++++++ |
| 362 |
| 363 Google offers a couple of hosting options you might consider instead of your |
| 364 own: |
| 365 |
| 366 * Google App Engine allows developers to release their applications on the same |
| 367 platform that Google uses for applications such Gmail. Refer to |
| 368 `Google App Engine - Pricing and Features <http://www.google.com/enterprise/cl
oud/appengine/pricing.html>`_ |
| 369 for pricing information. |
| 370 |
| 371 * Google Storage for Developers allows developers to store application data |
| 372 using Google's cloud services and is available on a fee-per-usage basis. |
| 373 Refer to `Pricing and Support </storage/docs/pricingandterms>`_ |
| 374 for pricing information. |
| 375 |
| 376 Additional considerations for a hosted application |
| 377 ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 378 |
| 379 * The .html file, .nmf file (Native Client manifest file), and .nexe files |
| 380 (compiled Native Client modules) must be served from the same domain, and the |
| 381 Chrome Web Store manifest file must specify the correct, verified domain. |
| 382 Other files can be served from the same or another domain. |
| 383 |
| 384 * In the description of your application in the CWS, make sure to mention that |
| 385 your application is a Native Client application that only works with the |
| 386 Chrome browser. Also make sure to identify the version of Chrome that your |
| 387 application requires. |
| 388 |
| 389 * Hosted and packaged applications have a "launch" parameter in the CWS |
| 390 manifest. This parameter is present only in apps (not extensions), and it |
| 391 tells Google Chrome what to show when a user starts an installed app. For |
| 392 example: |
| 393 |
| 394 .. naclcode:: |
| 395 :prettyprint: 0 |
| 396 |
| 397 "launch": { |
| 398 "web_url": "http://mail.google.com/mail/" |
| 399 } |
| 400 |
| 401 * If you want to write local data using the Pepper |
| 402 `FileIO </native-client/peppercpp/classpp_1_1_file_i_o>`_ |
| 403 API, you must set the 'unlimitedStorage' permission in your Chrome Web |
| 404 Store manifest file, just as you would for a JavaScript application that uses |
| 405 the HTML5 File API. |
| 406 |
| 407 * You can place your application in the Google Web Store with access only to |
| 408 certain people for testing. See |
| 409 `Publishing to test accounts </chrome/web-store/docs/publish#testaccounts>`_ |
| 410 for more information. |
| 411 |
| 412 Additional considerations |
| 413 ========================= |
| 414 |
| 415 Registering Native Client modules to handle MIME types |
| 416 ------------------------------------------------------ |
| 417 |
| 418 If you want Chrome to use a Native Client module to display a particular type |
| 419 of content, you can associate the MIME type of that content with the Native |
| 420 Client module. Use the ``nacl_modules`` attribute in the Chrome Web Store |
| 421 manifest file to register a Native Client module as the handler for one or more |
| 422 specific MIME types. For example, the bold code in the snippet below registers |
| 423 a Native Client module as the content handler for the OpenOffice spreadsheet |
| 424 MIME type: |
| 425 |
| 426 .. naclcode:: |
| 427 :prettyprint: 0 |
| 428 |
| 429 { |
| 430 "name": "My Native Client Spreadsheet Viewer", |
| 431 "version": "0.1", |
| 432 "description": "Open spreadsheets right in your browser.", |
| 433 **"nacl_modules": [{ |
| 434 "path": "SpreadsheetViewer.nmf", |
| 435 "mime_type": "application/vnd.oasis.opendocument.spreadsheet" |
| 436 }]** |
| 437 } |
| 438 |
| 439 The value of "path" is the location of a Native Client manifest file (.nmf) |
| 440 within the application directory. For more information on Native Client |
| 441 manifest files, see |
| 442 `Files in a Native Client application </native-client/overview#application-files
>`_. |
| 443 |
| 444 The value of "mime_type" is a specific MIME type that you want the Native |
| 445 Client module to handle. Each MIME type can be associated with only one .nmf |
| 446 file, but a single .nmf file might handle multiple MIME types. The following |
| 447 example shows an extension with two .nmf files that handle three MIME types. |
| 448 |
| 449 .. naclcode:: |
| 450 :prettyprint: 0 |
| 451 |
| 452 { |
| 453 "name": "My Native Client Spreadsheet and Document Viewer", |
| 454 "version": "0.1", |
| 455 "description": "Open spreadsheets and documents right in your browser.", |
| 456 "nacl_modules": [{ |
| 457 "path": "SpreadsheetViewer.nmf", |
| 458 "mime_type": "application/vnd.oasis.opendocument.spreadsheet" |
| 459 }, |
| 460 { |
| 461 "path": "SpreadsheetViewer.nmf", |
| 462 "mime_type": "application/vnd.oasis.opendocument.spreadsheet-template" |
| 463 }, |
| 464 { |
| 465 "path": "DocumentViewer.nmf", |
| 466 "mime_type": "application/vnd.oasis.opendocument.text" |
| 467 }] |
| 468 } |
| 469 |
| 470 The ``nacl_modules`` attribute is optional—specify this attribute only if |
| 471 you want Chrome to use a Native Client module to display a particular type of |
| 472 content. |
| 473 |
| 474 Using CWS inline install |
| 475 ------------------------ |
| 476 |
| 477 Once you've published an application, you may be wondering how users will find |
| 478 and install the application. For users who browse the Chrome Web Store and find |
| 479 your application, installing the application is a simple one-click process. |
| 480 However, if a user is already on your site, it can be cumbersome for them to |
| 481 complete the installation—they would need to navigate away from your site |
| 482 to the CWS, complete the installation process, and then return to your site. To |
| 483 address this issue, you can initiate installation of applications "inline" from |
| 484 your site—the applications are still hosted in the Chrome Web Store, but |
| 485 users no longer have to leave your site to install them. See |
| 486 `Using Inline Installation </chrome/web-store/docs/inline_installation>`_ |
| 487 for information on how to use this feature. |
| 488 |
| 489 Monetizing applications and extensions |
| 490 -------------------------------------- |
| 491 |
| 492 Google provides three primary monetization options for Native Client |
| 493 applications: in-app payments, one-time charges, and subscriptions. Refer to |
| 494 `Monetizing Your App </chrome/web-store/docs/money>`_ |
| 495 to learn about these options. The |
| 496 `Chrome Web Store Overview </chrome/web-store/docs/>`_ |
| 497 also has information on different approaches to charging for your application. |
OLD | NEW |