waffles | 5173214 | 2016-07-28 23:48:44 | [diff] [blame] | 1 | # Component Updater |
| 2 | |
| 3 | ## Overview |
| 4 | The Component Updater is a piece of Chrome responsible for updating other pieces |
| 5 | of Chrome. It runs in the browser process and communicates with a set of servers |
| 6 | using the [Omaha](https://github.com/google/omaha) protocol to find the latest |
| 7 | versions of components, download them, and register them with the rest of |
| 8 | Chrome. |
| 9 | |
| 10 | The primary benefit of components is that they can be updated without an update |
| 11 | to Chrome itself, which allows them to have faster (or desynchronized) release |
| 12 | cadences, lower bandwidth consumption, and avoids bloat in the (already sizable) |
| 13 | Chrome installer. The primary drawback is that they require Chrome to tolerate |
| 14 | their absence in a sane way. |
| 15 | |
| 16 | In the normal configuration, the component updater registers all components |
| 17 | during (or close to) browser start-up, and then begins checking for updates six |
| 18 | minutes later, with substantial pauses between successive update application. |
| 19 | |
| 20 | ## Terminology |
| 21 | For the purposes of this document: |
| 22 | |
| 23 | * A `component` is any element of Chrome's core functionality that is sometimes |
| 24 | delivered by the component updater separately from the browser itself, |
| 25 | usually as a dynamically-linked library or data file. |
| 26 | * A `crx file` is any file in the |
| 27 | [CRX package format](https://developer.chrome.com/extensions/crx). |
| 28 | |
| 29 | ## Adding New Components |
| 30 | This document covers the work that must be done on the client side. Additional |
| 31 | work is necessary to integrate with the Omaha servers, and is covered in |
| 32 | [Google-internal documentation](http://go/newchromecomponent). |
| 33 | |
| 34 | This assumes you've already done the hard work of splitting your functionality |
| 35 | out into a dynamically-linked library or data file. |
| 36 | |
| 37 | ### Create a CRX Package Signing Key & Manifest (Non-Google) |
| 38 | All components are delivered as CRX files (signed ZIP archives). You need to |
| 39 | create a signing key. If you are a Googler, follow the instructions at |
David Benjamin | 2c77ed71 | 2019-03-07 18:21:11 | [diff] [blame] | 40 | http://go/newchromecomponent for maximum key security. Otherwise, you can |
waffles | 5173214 | 2016-07-28 23:48:44 | [diff] [blame] | 41 | create an RSA key pair using `openssl` or a similar tool. |
| 42 | |
| 43 | You will additionally need to create a manifest.json file. If nothing else, the |
| 44 | manifest file must specify the component's version and name. If you plan to |
| 45 | release the component using Google infrastructure, this file can be generated |
| 46 | for you automatically. |
| 47 | |
| 48 | ### Writing an Installer |
| 49 | The "installer" is a piece of Chrome code that the component updater will run to |
| 50 | install or update the component. Installers live at |
| 51 | `src/chrome/browser/component_updater`. |
| 52 | |
| 53 | You will need the SHA256 hash of the public key generated in the previous step, |
| 54 | as well as the CRX ID, which consists of the first half (128 bits) of that hash, |
| 55 | rendered as hexadecimal using the characters `a-p` (rather than `0-9a-f`). |
| 56 | |
| 57 | New components should use |
Sorin Jianu | 08f92b3c | 2017-09-25 16:17:12 | [diff] [blame] | 58 | [`component_installer`](component_installer.h) |
waffles | 5173214 | 2016-07-28 23:48:44 | [diff] [blame] | 59 | if possible, as this provides you with transparent differential updates, version |
Sorin Jianu | 08f92b3c | 2017-09-25 16:17:12 | [diff] [blame] | 60 | management, and more. You must provide a `ComponentInstallerPolicy` object to |
| 61 | a new `ComponentInstaller`. |
waffles | 5173214 | 2016-07-28 23:48:44 | [diff] [blame] | 62 | [file\_type\_policies\_component\_installer.cc](../../chrome/browser/component_updater/file_type_policies_component_installer.cc) |
| 63 | is a good example to work from. |
| 64 | |
| 65 | Components need to be registered with the component updater. This is done in |
| 66 | [RegisterComponentsForUpdate](https://cs.chromium.org/chromium/src/chrome/browser/chrome_browser_main.cc). |
| 67 | |
| 68 | ### Bundle with the Chrome Installer (Optional) |
| 69 | If you need the guarantee that some implementation of your component is always |
| 70 | available, you must bundle a component implementation with the browser itself. |
Sorin Jianu | 08f92b3c | 2017-09-25 16:17:12 | [diff] [blame] | 71 | If you are using `ComponentInstaller`, you simply need to make sure that |
waffles | 5173214 | 2016-07-28 23:48:44 | [diff] [blame] | 72 | your component implementation (and a corresponding manifest.json file) are |
| 73 | written to DIR\_COMPONENTS as part of the build. The manifest.json file must |
| 74 | state the version of this component implementation, and the files must be |
| 75 | bitwise identical to the contents of any update CRX with that version for that |
| 76 | platform, as the system will attempt to apply differential updates over these |
| 77 | files. |
| 78 | |
| 79 | ### Implement On-Demand or Just-In-Time Updates (Optional) |
| 80 | Contact the component\_updater OWNERS. |