mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Added/Updated pageAction /w docs
This commit is contained in:
57
chrome/chrome.d.ts
vendored
57
chrome/chrome.d.ts
vendored
@@ -4910,40 +4910,95 @@ declare module chrome.omnibox {
|
||||
////////////////////
|
||||
// Page Action
|
||||
////////////////////
|
||||
/**
|
||||
* Use the chrome.pageAction API to put icons inside the address bar. Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages.
|
||||
* Manifest: "page_action": {...}
|
||||
* @since Chrome 5.
|
||||
*/
|
||||
declare module chrome.pageAction {
|
||||
interface PageActionClickedEvent extends chrome.events.Event {
|
||||
/**
|
||||
* @param callback The callback parameter should be a function that looks like this:
|
||||
* function( tabs.Tab tab) {...};
|
||||
*/
|
||||
addListener(callback: (tab: chrome.tabs.Tab) => void): void;
|
||||
}
|
||||
|
||||
interface TitleDetails {
|
||||
/** The id of the tab for which you want to modify the page action. */
|
||||
tabId: number;
|
||||
/** The tooltip string. */
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface GetDetails {
|
||||
/** Specify the tab to get the title from. */
|
||||
tabId: number;
|
||||
}
|
||||
|
||||
interface PopupDetails {
|
||||
/** The id of the tab for which you want to modify the page action. */
|
||||
tabId: number;
|
||||
/** The html file to show in a popup. If set to the empty string (''), no popup is shown. */
|
||||
popup: string;
|
||||
}
|
||||
|
||||
interface IconDetails {
|
||||
/** The id of the tab for which you want to modify the page action. */
|
||||
tabId: number;
|
||||
/**
|
||||
* Optional.
|
||||
* @deprecated This argument is ignored.
|
||||
*/
|
||||
iconIndex?: number;
|
||||
/**
|
||||
* Optional.
|
||||
* Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}'
|
||||
*/
|
||||
imageData?: ImageData;
|
||||
/**
|
||||
* Optional.
|
||||
* Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'
|
||||
*/
|
||||
path?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the page action. The page action is shown whenever the tab is selected.
|
||||
* @param tabId The id of the tab for which you want to modify the page action.
|
||||
*/
|
||||
export function hide(tabId: number): void;
|
||||
/**
|
||||
* Shows the page action. The page action is shown whenever the tab is selected.
|
||||
* @param tabId The id of the tab for which you want to modify the page action.
|
||||
*/
|
||||
export function show(tabId: number): void;
|
||||
/** Sets the title of the page action. This is displayed in a tooltip over the page action. */
|
||||
export function setTitle(details: TitleDetails): void;
|
||||
/** Sets the html document to be opened as a popup when the user clicks on the page action's icon. */
|
||||
export function setPopup(details: PopupDetails): void;
|
||||
/**
|
||||
* Gets the title of the page action.
|
||||
* @since Chrome 19.
|
||||
* @param callback The callback parameter should be a function that looks like this:
|
||||
* function(string result) {...};
|
||||
*/
|
||||
export function getTitle(details: GetDetails, callback: (result: string) => void): void;
|
||||
/**
|
||||
* Gets the html document set as the popup for this page action.
|
||||
* @since Chrome 19.
|
||||
* @param callback The callback parameter should be a function that looks like this:
|
||||
* function(string result) {...};
|
||||
*/
|
||||
export function getPopup(details: GetDetails, callback: (result: string) => void): void;
|
||||
export function setIcon(details: IconDetails, callback?: Function): void;
|
||||
/**
|
||||
* Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified.
|
||||
* @param callback If you specify the callback parameter, it should be a function that looks like this:
|
||||
* function() {...};
|
||||
*/
|
||||
export function setIcon(details: IconDetails, callback?: () => void): void;
|
||||
|
||||
/** Fired when a page action icon is clicked. This event will not fire if the page action has a popup. */
|
||||
var onClicked: PageActionClickedEvent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user