Getting started with chrome.printing API

Printer extension configuration

Task 2

10 minutes

Your manifest.json now contains the basic information required to build a Chrome extension. But we still need to customize it for your printer extension.

Update manifest.json with:

  • A descriptive name: “Chrome Printing Extension.”
  • A concise, friendly description: “Print to a printer connected to a Chromebook.”

Your updated manifest.json now looks like this:

json
{ 
    "name": "Chrome Printing Extension", 
    "version": "1.0", 
    "manifest_version": 3, 
    "description": "Print to a printer connected to a Chromebook.",
    "background": {
      "service_worker": "background.js"
    },
  "action": {}
}

Open background.js. For the purposes of this tutorial, you will make background.js open a tab in Chrome browser showing a user interface.

Copy the following code into background.js:

chrome.action.onClicked.addListener(() => { chrome.tabs.create({ url: 'printers.html' });});

Your new code will use chrome.tabs.create to create a tab linking to printers.html.

Together with printers.js, printers.html will show a UI that lets users see available printers and manage print jobs.

Your turn