
In this example, the content script needs some data from the extension's background script in order to initialize its UI. Instead, the extension can use message passing to coordinate across these different contexts. Much like two browser windows opened to the same web page, these two contexts cannot directly access each other's values. Its common for an extension's content scripts to need data managed by another part of the extension, like the extension's background script. # Getting background data into a content script This example shows how a content script can add an image in the extension's package to the page that the content script has been injected into. The two main differences here are that the extension's assets must be exposed as web accessible resources and that typically content scripts are responsible for injecting extension assets. The same is true for when a web page wants to include assets included in an extension. In order for a web page to access an asset hosted on another domain, it must specify the resource's full URL (e.g. # Examples # Use getURL to add an extension image to a page However, sendNativeMessage and connectNative require the nativeMessaging permission to be declared in your manifest. Most methods on the runtime API do not require any permission to use. Helper utilities These methods provide utility such as the conversion of internal resource representations to external formats. Methods in this category include restart and restartAfterDelay. Device restart support These methods are available only on Chrome OS, and exist mainly to support kiosk implementations. Methods in this category include reload, requestUpdateCheck, setUninstallURL, and openOptionsPage.


Managing extension lifecycle and options These methods let you perform some meta-operations on the extension, and display the options page to the extension user. Methods in this category include getBackgroundPage, getManifest, getPackageDirectoryEntry, and getPlatformInfo. Accessing extension and platform metadata These methods let you retrieve several specific pieces of metadata about the extension and the platform. Methods in this category include connect, connectNative, sendMessage, and sendNativeMessage.

See Message Passing for an overview of the subject. The runtime API provides methods to support a number of areas of functionality that your extensions can use: Message passing These methods support message passing so that you can communicate with different parts of your extension (such as an extension popup and background scripts), other extensions, or native applications on the user's device.
