Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Developer Notes on Installing or Updating Extensions

Brian Clifton edited this page Oct 16, 2017 · 8 revisions

Installing or Updating Extensions

Locating Extensions:

Chrome installs extensions in:

Platform Source Path Brave Path (>=0.12.3)
Mac ~/Library/Application\ Support/Google/Chrome/Default/Extensions/<id> ~/Library/Application\ Support/brave/Extensions/<id>
Windows C:\Users\name\AppData\Local\Google\Chrome\User Data\Default\Extensions\<id> C:\Users\name\AppData\Roaming\brave\Extensions\<id>
Linux ~/.config/google-chrome/Default/Extensions/<id> ~/.config/brave/Extensions/<id>
Linux (Chromium) ~/.config/chromium/Profile\ 1/Extensions/<id> ~/.config/brave/Extensions/<id>

As of 0.12.3, Brave shares extensions with each session partition (user tab) so installs into:

It is often easiest to install an extension in Chrome, and inspect the extracted CRX code. Alternatively, you can download the CRX and unzip it (more info on how to download the CRX below). Usually the code will be minified.

Quickly test out an extension

Open <browser-laptop>/app/extension.js and add a block of code after the code for braveExtensionId, similar to this:

// Test the following extension for support
extensionInfo.setState('<extension-id>', extensionStates.REGISTERED)
loadExtension('<extension-id>', getExtensionsPath('<path-to-extension>'))

The getExtensionsPath method attempts to locate the manifest.json file. The Brave Extension has a generated manifest, but Chrome extensions will have their manifest within <extensionID>/<extensionVersion>. Be sure to take this into consideration when providing the <path-to-extension> value.

Restart Brave to find your extension in about:extensions. You can also take the longer path to try out an extension if you want to add it officially.

Dev env setup for adding a new extension

To add more extensions you will need to use a custom build of Muon (our fork of Electron) from GitHub. Please see the following instructions for detailed help about building browser-laptop-bootstrap and Muon:

https://github.com/brave/browser-laptop-bootstrap/wiki

Code changes needed to add new extensions

Edit: <brave-electron>/brave/browser/component_updater/default_extensions.h and add the new extension you’d like to test. In particular you will need to define the public key of the extension, and the extension ID.

The easiest way to get the extension ID is just by going to about:extensions on Chrome. The about:extensions page will list all extensions with their IDs. Brave has a similar page, but ours is read only.
To get the public key you need the CRX. You can download a CRX like this:

1Password: aomjjhallfgjeglblehebfpbcfeobpgk https://clients2.google.com/service/update2/crx?response=redirect&prodversion=52.0.2743.116&x=id%3Daomjjhallfgjeglblehebfpbcfeobpgk%26uc

Then you can use a handy python script to extract the public key:

python ./script/get-extension-public-key-sha256.py <crx-path>

Reference the new extension from ComponentUpdater::RegisterComponent in brave/browser/api/brave_api_component_updater.cc with a new condition like this:

 else if (extension_id == kOnePasswordId) {
    RegisterComponentForUpdate(
        kOnePasswordPublicKeyStr, registered_callback, ready_callback);
  } 

The easiest way to get the extension installed from here (so you don’t need to look into how our update server works) is just to use Chrome’s update server to get the extension instead of our own. That server already knows about the extension you’re adding.

Open browser-laptop-bootstrap/src/electron/component_updater/brave_component_updater_configurator.cc and modify BraveConfigurator::UpdateUrl() to use return configurator_impl_.UpdateUrl(); instead of the laptop-updates.brave.com URL.

From here you should be able to build electron and then npm start from browser-laptop. Open up a developer console with Shift+F8.

Register the component for updates/install with:

require('electron').remote.componentUpdater.registerComponent('aomjjhallfgjeglblehebfpbcfeobpgk')

And force an install now with:

require('electron').remote.componentUpdater.checkNow('aomjjhallfgjeglblehebfpbcfeobpgk')

Server load

  • First install makes the request for PDFJS on first startup right away.
  • There’s an initial delay for update checks / client after 360 seconds === 6 minutes,
    Subsequent checks are every 21600 seconds === 6 hours.
  • If a user turns on a password manager, we do a request to install the extension.
  • If the user has a password manager already turned on from a previous version, their first startup will also do a request for that.
  • Response size is <1kb of text XML.
  • Subsequent non first browser startups do not do an update check at startup time.

Vertical Side Tabs Tab Suspender

Clone this wiki locally