1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 [ 6 { 7 "namespace": "pageAction", 8 "description": "Use the <code>chrome.pageAction</code> 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.", 9 "types": [ 10 { 11 "id": "ImageDataType", 12 "type": "object", 13 "isInstanceOf": "ImageData", 14 "additionalProperties": { "type": "any" }, 15 "description": "Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element)." 16 } 17 ], 18 "functions": [ 19 { 20 "name": "show", 21 "type": "function", 22 "description": "Shows the page action. The page action is shown whenever the tab is selected.", 23 "parameters": [ 24 {"type": "integer", "name": "tabId", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."} 25 ] 26 }, 27 { 28 "name": "hide", 29 "type": "function", 30 "description": "Hides the page action.", 31 "parameters": [ 32 {"type": "integer", "name": "tabId", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."} 33 ] 34 }, 35 { 36 "name": "setTitle", 37 "type": "function", 38 "description": "Sets the title of the page action. This is displayed in a tooltip over the page action.", 39 "parameters": [ 40 { 41 "name": "details", 42 "type": "object", 43 "properties": { 44 "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."}, 45 "title": {"type": "string", "description": "The tooltip string."} 46 } 47 } 48 ] 49 }, 50 { 51 "name": "getTitle", 52 "type": "function", 53 "description": "Gets the title of the page action.", 54 "parameters": [ 55 { 56 "name": "details", 57 "type": "object", 58 "properties": { 59 "tabId": { 60 "type": "integer", 61 "description": "Specify the tab to get the title from." 62 } 63 } 64 }, 65 { 66 "type": "function", 67 "name": "callback", 68 "parameters": [ 69 { 70 "name": "result", 71 "type": "string" 72 } 73 ] 74 } 75 ] 76 }, 77 { 78 "name": "setIcon", 79 "type": "function", 80 "description": "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 <b>path</b> or the <b>imageData</b> property must be specified.", 81 "parameters": [ 82 { 83 "name": "details", 84 "type": "object", 85 "properties": { 86 "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."}, 87 "imageData": { 88 "choices": [ 89 { "$ref": "ImageDataType" }, 90 { 91 "type": "object", 92 "properties": { 93 "19": {"$ref": "ImageDataType", "optional": true}, 94 "38": {"$ref": "ImageDataType", "optional": true} 95 } 96 } 97 ], 98 "optional": true, 99 "description": "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 <code>scale</code>, then image with size <code>scale</code> * 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}'" 100 }, 101 "path": { 102 "choices": [ 103 { "type": "string" }, 104 { 105 "type": "object", 106 "properties": { 107 "19": {"type": "string", "optional": true}, 108 "38": {"type": "string", "optional": true} 109 } 110 } 111 ], 112 "optional": true, 113 "description": "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 <code>scale</code>, then image with size <code>scale</code> * 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}'" 114 }, 115 "iconIndex": { 116 "type": "integer", 117 "minimum": 0, 118 "description": "<b>Deprecated.</b> This argument is ignored.", 119 "optional": true 120 } 121 } 122 }, 123 { 124 "type": "function", 125 "name": "callback", 126 "optional": true, 127 "parameters": [] 128 } 129 ] 130 }, 131 { 132 "name": "setPopup", 133 "type": "function", 134 "description": "Sets the html document to be opened as a popup when the user clicks on the page action's icon.", 135 "parameters": [ 136 { 137 "name": "details", 138 "type": "object", 139 "properties": { 140 "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."}, 141 "popup": { 142 "type": "string", 143 "description": "The html file to show in a popup. If set to the empty string (''), no popup is shown." 144 } 145 } 146 } 147 ] 148 }, 149 { 150 "name": "getPopup", 151 "type": "function", 152 "description": "Gets the html document set as the popup for this page action.", 153 "parameters": [ 154 { 155 "name": "details", 156 "type": "object", 157 "properties": { 158 "tabId": { 159 "type": "integer", 160 "description": "Specify the tab to get the popup from." 161 } 162 } 163 }, 164 { 165 "type": "function", 166 "name": "callback", 167 "parameters": [ 168 { 169 "name": "result", 170 "type": "string" 171 } 172 ] 173 } 174 ] 175 } 176 ], 177 "events": [ 178 { 179 "name": "onClicked", 180 "type": "function", 181 "description": "Fired when a page action icon is clicked. This event will not fire if the page action has a popup.", 182 "parameters": [ 183 { 184 "name": "tab", 185 "$ref": "tabs.Tab" 186 } 187 ] 188 } 189 ] 190 } 191 ] 192