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": "declarativeContent", 8 "description": "Use the <code>chrome.declarativeContent</code> API to take actions depending on the content of a page, without requiring permission to read the page's content.", 9 "types": [ 10 { 11 "id": "ImageDataType", 12 "type": "binary", 13 "isInstanceOf": "ImageData", 14 "additionalProperties": { "type": "any" }, 15 "description": "See <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ImageData\">https://developer.mozilla.org/en-US/docs/Web/API/ImageData</a>.", 16 "inline_doc": true 17 }, 18 { 19 "id": "PageStateMatcher", 20 "type": "object", 21 "description": "Matches the state of a web page by various criteria.", 22 "properties": { 23 "pageUrl": { 24 "$ref": "events.UrlFilter", 25 "description": "Matches if the condition of the UrlFilter are fulfilled for the top-level URL of the page.", 26 "optional": true 27 }, 28 "css": { 29 "type": "array", 30 "optional": true, 31 "description": "Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be <a href=\"http://www.w3.org/TR/selectors4/#compound\">compound selectors</a> to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites.", 32 // TODO(jyasskin): Figure out if we want to require all 33 // the selectors to match in the same frame, or allow several 34 // frames to contribute to a match. 35 "items": { "type": "string" } 36 // }, 37 // TODO: "text": { 38 // "type": "array", 39 // "optional": true, 40 // "description": "Matches if all of the regular expressions in the array match text in the page. The regular expressions use the <a href=\"http://code.google.com/p/re2/wiki/Syntax\">RE2 syntax</a>.", 41 // "items": { "type": "string" } 42 }, 43 "instanceType": { 44 "type": "string", "enum": ["declarativeContent.PageStateMatcher"], 45 "nodoc": true 46 } 47 } 48 }, 49 { 50 "id": "ShowPageAction", 51 "description": "Declarative event action that shows the extension's $(ref:pageAction page action) while the corresponding conditions are met. This action can be used without <a href=\"declare_permissions#host-permissions\">host permissions</a>, but the extension must have a page action. If the extension takes the <a href=\"activeTab.html\">activeTab</a> permission, a click on the page action will grant access to the active tab.", 52 "type": "object", 53 "properties": { 54 "instanceType": { 55 "type": "string", "enum": ["declarativeContent.ShowPageAction"], 56 "nodoc": true 57 } 58 } 59 }, 60 { 61 "id": "SetIcon", 62 "description": "Declarative event action that sets the 19-<abbr title=\"device-independent pixel\">dip</abbr> square icon for the extension's $ref:[pageAction page action] or $ref:[browserAction browser action] while the corresponding conditions are met. This action can be used without <a href=\"declare_permissions.html#host-permissions\">host permissions</a>, but the extension must have page or browser action.<p>Exactly one of <code>imageData</code> or <code>path</code> must be specified. Both are dictionaries mapping a number of pixels to an image representation. The image representation in <code>imageData</code> is an<a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ImageData\">ImageData</a> object, for example from a <code><canvas></code> element, while the image representation in <code>path</code> is the path to an image file relative to he extension's manifest. If <code>scale</code> screen pixels fit into a device-independent pixel, the <code>scale * 19</code> icon will be used. If that scale is missing, the other image will be resized to the needed size.", 63 "type": "object", 64 "properties": { 65 "instanceType": { 66 "type": "string", "enum": ["declarativeContent.SetIcon"], 67 "nodoc": true 68 }, 69 "imageData": { 70 "choices": [ 71 { "$ref": "ImageDataType" }, 72 { 73 "type": "object", 74 "properties": { 75 "19": {"$ref": "ImageDataType", "optional": true}, 76 "38": {"$ref": "ImageDataType", "optional": true} 77 } 78 } 79 ], 80 "optional": true, 81 "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}'" 82 } 83 // TODO: "path": { 84 // "choices": [ 85 // { "type": "string" }, 86 // { 87 // "type": "object", 88 // "properties": { 89 // "19": {"type": "string", "optional": true}, 90 // "38": {"type": "string", "optional": true} 91 // } 92 // } 93 // ], 94 // "optional": true, 95 // "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}'" 96 // } 97 } 98 }, 99 { 100 "id": "RequestContentScript", 101 "description": "Declarative event action that injects a content script. <p><b>WARNING:</b> This action is still experimental and is not supported on stable builds of Chrome.</p>", 102 "type": "object", 103 "properties": { 104 "css": { 105 "type": "array", 106 "optional": true, 107 "description": "Names of CSS files to be injected as a part of the content script.", 108 "items": { "type": "string" } 109 }, 110 "js": { 111 "type": "array", 112 "optional": true, 113 "description": "Names of Javascript files to be injected as a part of the content script.", 114 "items": { "type": "string" } 115 }, 116 "allFrames": { 117 "type": "boolean", 118 "optional": true, 119 "description": "Whether the content script runs in all frames of the matching page, or only the top frame. Default is false." 120 }, 121 "matchAboutBlank": { 122 "type": "boolean", 123 "optional": true, 124 "description": "Whether to insert the content script on about:blank and about:srcdoc. Default is false." 125 }, 126 "instanceType": { 127 "type": "string", "enum": ["declarativeContent.RequestContentScript"], 128 "nodoc": true 129 } 130 } 131 } 132 ], 133 "functions": [ 134 ], 135 "events": [ 136 { 137 "name": "onPageChanged", 138 "options": { 139 "supportsListeners": false, 140 "supportsRules": true, 141 "conditions": ["declarativeContent.PageStateMatcher"], 142 "actions": [ 143 "declarativeContent.RequestContentScript", 144 "declarativeContent.SetIcon", 145 "declarativeContent.ShowPageAction" 146 ] 147 } 148 } 149 ] 150 } 151 ] 152