Chrome System API Complete Reference

8 min read

chrome.system API Reference

The chrome.system API provides extensions with access to system hardware and resource information. This API enables extensions to adapt their behavior based on the capabilities and state of the underlying hardware.

Overview

The chrome.system API is organized into several sub-APIs, each providing access to different system resources:

Each sub-API requires its own permission in the extension manifest. Request only the permissions you need to minimize the permissions surface of your extension.

chrome.system.cpu

Permission

"permissions": ["system.cpu"]

Methods

getInfo()

Retrieves information about the CPU on the system.

chrome.system.cpu.getInfo(callback)

Parameters:

Returns: A CpuInfo object containing:

ProcessorInfo

Each processor object contains:

Use Cases

chrome.system.memory

Permission

"permissions": ["system.memory"]

Methods

getInfo()

Retrieves physical memory information.

chrome.system.memory.getInfo(callback)

Parameters:

Returns: A MemoryInfo object containing:

Use Cases

chrome.system.storage

Permission

"permissions": ["system.storage"]

Methods

getInfo()

Retrieves information about storage devices attached to the system.

chrome.system.storage.getInfo(callback)

Returns: An array of StorageUnitInfo objects:

ejectDevice(deviceId)

Ejects a removable storage device.

chrome.system.storage.ejectDevice(deviceId, callback)

Parameters:

getAvailableCapacity(deviceId)

Gets the available capacity for a specific storage device.

chrome.system.storage.getAvailableCapacity(deviceId, callback)

Parameters:

Events

onAttached

Fired when a removable storage device is attached.

chrome.system.storage.onAttached.addListener(callback)

onDetached

Fired when a removable storage device is detached.

chrome.system.storage.onDetached.addListener(callback)

Use Cases

chrome.system.display

Permission

"permissions": ["system.display"]

Methods

getInfo(flags?)

Retrieves information about all displays connected to the system.

chrome.system.display.getInfo(callback)
chrome.system.display.getInfo({ singleUnified: true }, callback)

Parameters:

Returns: An array of DisplayInfo objects:

setDisplayProperties(id, info)

Modifies display properties. Most properties only work on Chrome OS.

chrome.system.display.setDisplayProperties(id, info, callback)

Parameters:

Events

onDisplayChanged

Fired when the display configuration changes.

chrome.system.display.onDisplayChanged.addListener(callback)

Use Cases

Manifest Declaration

To use the chrome.system API, declare the required permissions in your manifest:

{
  "name": "My System Extension",
  "version": "1.0",
  "permissions": [
    "system.cpu",
    "system.memory",
    "system.storage",
    "system.display"
  ]
}

Request only the specific sub-permissions your extension needs. For example, if you only need CPU information:

{
  "permissions": ["system.cpu"]
}

Code Examples

Display System Info Dashboard

async function showSystemInfo() {
  const cpuInfo = await chrome.system.cpu.getInfo();
  const memInfo = await chrome.system.memory.getInfo();
  
  console.log(`CPU: ${cpuInfo.modelName}`);
  console.log(`Processors: ${cpuInfo.numOfProcessors}`);
  console.log(`Total Memory: ${(memInfo.capacity / 1e9).toFixed(2)} GB`);
  console.log(`Available Memory: ${(memInfo.availableCapacity / 1e9).toFixed(2)} GB`);
}

Adaptive Behavior Based on CPU/Memory

async function adaptToSystemCapabilities() {
  const memInfo = await chrome.system.memory.getInfo();
  const memGB = memInfo.capacity / 1e9;
  
  // Adjust caching strategy based on available memory
  if (memGB < 4) {
    setCacheSize(50); // Conservative for low-memory systems
  } else if (memGB < 8) {
    setCacheSize(200);
  } else {
    setCacheSize(1000); // Generous for high-memory systems
  }
}

Monitor Removable Storage Devices

// Listen for removable storage attachment
chrome.system.storage.onAttached.addListener((device) => {
  console.log(`Storage attached: ${device.name} (${device.id})`);
});

chrome.system.storage.onDetached.addListener((deviceId) => {
  console.log(`Storage detached: ${deviceId}`);
});

// Get storage info
const devices = await chrome.system.storage.getInfo();
const removable = devices.filter(d => d.type === 'removable');

Multi-Monitor Aware Extension

async function positionOnSecondMonitor() {
  const displays = await chrome.system.display.getInfo();
  const primary = displays.find(d => d.isPrimary);
  const secondary = displays.find(d => !d.isPrimary);
  
  if (secondary) {
    // Open side panel on secondary display
    await chrome.sidePanel.setOptions({
      path: 'panel.html',
      tabId: activeTab.id
    });
  }
}

Cross-References

Additional Resources

What system information can I access?

chrome.system provides CPU, memory, display, and storage information. Specific capabilities vary by platform.

Is system API available in Chrome Apps?

The system API is available in extensions but some features may differ from deprecated Chrome Apps.


Part of the Chrome Extension Guide by theluckystrike. Built at zovo.one.