Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the BSD License.
?2013 Google
このページは大阪弁化フィルタによって翻訳生成されたんですわ。 |
Description: |
Use the chrome.runtime API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.
|
Availability: |
Stable since Chrome 22.
|
Learn More: |
Manage App Lifecycle
Event Pages |
Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.
The callback parameter should specify a function that looks like this:
function(window backgroundPage) {...};
Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file.
Reloads the app or extension.
Requests an update check for this app/extension.
The callback parameter should specify a function that looks like this:
function(enum of"throttled"
,"no_update"
, or"update_available"
status, object details) {...};
Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op.
Attempts to connect to other listeners within the extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect.
Sends a single message to onMessage event listeners within the extension (or another extension/app). Similar to chrome.runtime.connect, but only sends a single message with an optional response. The onMessage event is fired in each extension page of the extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
If you specify the responseCallback parameter, it should specify a function that looks like this:
function(any response) {...};
Send a single message to a native application.
If you specify the responseCallback parameter, it should specify a function that looks like this:
function(any response) {...};
Returns information about the current platform.
The callback parameter should specify a function that looks like this:
function(object platformInfo) {...};
Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode.
Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version.
The callback parameter should specify a function that looks like this:
function(object details) {...};
Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded.
Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload().
onBrowserUpdateAvailable is deprecated. Please use onRestartRequired.
Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.
Fired when a message is sent from either an extension process or a content script.
The callback parameter should specify a function that looks like this:
function(any message, MessageSender sender, function sendResponse) {...};
onMessage
listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse
is called).
Fired when a message is sent from another extension/app. Cannot be used in a content script.
The callback parameter should specify a function that looks like this:
function(any message, MessageSender sender, function sendResponse) {...};
onMessage
listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse
is called).
Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps.
The callback parameter should specify a function that looks like this:
function(enum of"app_update"
,"os_update"
, or"periodic"
reason) {...};
"app_update"
, "os_update"
, or "periodic"
)