このページは大阪弁化フィルタによって翻訳生成されたんですわ。

翻訳前ページへ


chrome.extension - Google Chrome
The Wayback Machine - http://web.archive.org/web/20130715060353/http://developer.chrome.com:80/extensions/extension.html

chrome.extension

The chrome.extension module has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing.

Support for content scripts

Unlike the other chrome.* APIs, parts of chrome.extension can be used by content scripts:

runtime.sendMessage and runtime.onMessage
Simple communication with extension pages
runtime.connect and runtime.onConnect
Extended communication with extension pages
getURL
Access to extension resources such as image files

For details, see Content Scripts.

chrome.extension reference

Types

MessageSender

An object containing information about the script context that sent a message or request.

properties of MessageSender

tab ( optional tabs.Tab )
This property will only be present when the connection was opened from a tab or content script.
id ( string )
The extension ID of the extension that opened the connection.

Properties

lastError

chrome.extension.lastError
lastError ( )
Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined.

Properties of lastError

message ( string )
Description of the error that has taken place.

inIncognitoContext

chrome.extension.inIncognitoContext
inIncognitoContext ( )
True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior.

Methods

getURL

string chrome.extension.getURL(string path)

Converts a relative path within an extension install directory to a fully-qualified URL.

Parameters

path ( string )
A path to a resource within an extension expressed relative to its install directory.

getViews

array of global chrome.extension.getViews(object fetchProperties)

Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.

Parameters

fetchProperties ( optional object )
type ( optional enum of "tab", "infobar", "notification", or "popup" )
The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'infobar', 'notification', 'popup'.
windowId ( optional integer )
The window to restrict the search to. If omitted, returns all views.

getBackgroundPage

global chrome.extension.getBackgroundPage()

Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page.

Properties of return type

isAllowedIncognitoAccess

chrome.extension.isAllowedIncognitoAccess(function callback)

Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox.

Parameters

callback ( function )

Callback

The callback parameter should specify a function that looks like this:

function(boolean isAllowedAccess) {...};
isAllowedAccess ( boolean )
True if the extension has access to Incognito mode, false otherwise.

isAllowedFileSchemeAccess

chrome.extension.isAllowedFileSchemeAccess(function callback)

Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox.

Parameters

callback ( function )

Callback

The callback parameter should specify a function that looks like this:

function(boolean isAllowedAccess) {...};
isAllowedAccess ( boolean )
True if the extension can access the 'file://' scheme, false otherwise.

setUpdateUrlData

chrome.extension.setUpdateUrlData(string data)

Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery.

Parameters

data ( string )

Sample Extensions that use chrome.extension

  • Context Menus Sample – Shows some of the features of the Context Menus API
  • Context Menus Sample (with Event Page) – Shows some of the features of the Context Menus API using an event page
  • Cookie API Test Extension – Testing Cookie API
  • `extension.isAllowedFileSchemeAccess` and `extension.isAllowedIncognitoAccess` Example – Demonstrates the `extension.isAllowedFileSchemeAccess` and `extesion.isAllowedIncognitoAccess` APIs
  • Idle - Simple Example – Demonstrates the Idle API
  • Block/allow third-party cookies API example extension – Sample extension which demonstrates how to access a preference.
  • Block/allow referrer API example extension – Sample extension which demonstrates how to access a preference.
  • Stylizr – Spruce up your pages with custom CSS.
  • Tab Inspector – Utility for working with the extension tabs api
  • Test Screenshot Extension – Demonstrate screenshot functionality in the chrome.tabs api. Note: only works for code.google.com
  • Console TTS Engine – A "silent" TTS engine that prints text to a small window rather than synthesizing speech.
  • App Launcher
  • Page Benchmarker – Chromium Page Benchmarker.
  • Chromium Buildbot Monitor – Displays the status of the Chromium buildbot in the toolbar. Click to see more detailed status in a popup.
  • Google Calendar Checker (by Google) – Quickly see the time until your next meeting from any of your calendars. Click on the button to be taken to your calendar.
  • Chrome Sounds – Enjoy a more magical and immersive experience when browsing the web using the power of sound.
  • Google Document List Viewer – Demonstrates how to use OAuth to connect the Google Documents List Data API.
  • Mappy – Finds addresses in the web page you're on and pops up a map window.
  • News Reader (by Google) – Displays the latest stories from Google News in a popup.
  • Sample - OAuth Contacts – Uses OAuth to connect to Google's contacts service and display a list of your contacts.
  • Proxy Extension API Sample – Set Chrome-specific proxies; a demonstration of Chrome's Proxy API
  • Speak Selection – Speaks the current selection out loud.