summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/extensions/api/page_action.json
blob: 9f0f461bed50ff2392a3dbe93571bf4c18a63d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace": "pageAction",
    "description": "Use the <code>chrome.pageAction</code> API to put icons in the main Google Chrome toolbar, to the right of the address bar. Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages. Page actions appear grayed out when inactive.",
    "compiler_options": {
      "implemented_in": "chrome/browser/extensions/api/extension_action/extension_action_api.h"
    },
    "types": [
      {
        "id": "ImageDataType",
        "type": "object",
        "isInstanceOf": "ImageData",
        "additionalProperties": { "type": "any" },
        "description": "Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element)."
      },
      {
        "id": "TabDetails",
        "type": "object",
        "properties": {
          "tabId": { "type": "integer", "optional": true, "minimum": 0, "description": "The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned." }
        }
      }
    ],
    "functions": [
      {
        "name": "show",
        "type": "function",
        "description": "Shows the page action. The page action is shown whenever the tab is selected.",
        "parameters": [
          {"type": "integer", "name": "tabId", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."}
        ],
        "returns_async": {"name": "callback", "parameters": [], "optional": true}
      },
      {
        "name": "hide",
        "type": "function",
        "description": "Hides the page action. Hidden page actions still appear in the Chrome toolbar, but are grayed out.",
        "parameters": [
          {"type": "integer", "name": "tabId", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."}
        ],
        "returns_async": {"name": "callback", "parameters": [], "optional": true}
      },
      {
        "name": "setTitle",
        "type": "function",
        "description": "Sets the title of the page action. This is displayed in a tooltip over the page action.",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "properties": {
              "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."},
              "title": {"type": "string", "description": "The tooltip string."}
            }
          }
        ],
        "returns_async": {"name": "callback", "parameters": [], "optional": true}
      },
      {
        "name": "getTitle",
        "type": "function",
        "description": "Gets the title of the page action.",
        "parameters": [
          {
            "name": "details",
            "$ref": "TabDetails"
          }
        ],
        "returns_async": {
          "name": "callback",
          "parameters": [
            {
              "name": "result",
              "type": "string"
            }
          ]
        }
      },
      {
        "name": "setIcon",
        "type": "function",
        "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.",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "properties": {
              "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."},
              "imageData": {
                "choices": [
                  { "$ref": "ImageDataType" },
                  {
                    "type": "object",
                    "additionalProperties": { "type": "any" }
                  }
                ],
                "optional": true,
                "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> * n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'16': foo}'"
              },
              "path": {
                "choices": [
                  { "type": "string" },
                  {
                    "type": "object",
                    "additionalProperties": { "type": "any" }
                  }
                ],
                "optional": true,
                "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> * n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.path = {'16': foo}'"
              },
              "iconIndex": {
                "type": "integer",
                "minimum": 0,
                "description": "<b>Deprecated.</b> This argument is ignored.",
                "optional": true
              }
            }
          }
        ],
        "returns_async": {
          "name": "callback",
          "optional": true,
          "parameters": []
        }
      },
      {
        "name": "setPopup",
        "type": "function",
        "description": "Sets the HTML document to be opened as a popup when the user clicks on the page action's icon.",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "properties": {
              "tabId": {"type": "integer", "minimum": 0, "description": "The id of the tab for which you want to modify the page action."},
              "popup": {
                "type": "string",
                "description": "The relative path to the HTML file to show in a popup. If set to the empty string (<code>''</code>), no popup is shown."
              }
            }
          }
        ],
        "returns_async": {"name": "callback", "parameters": [], "optional": true}
      },
      {
        "name": "getPopup",
        "type": "function",
        "description": "Gets the html document set as the popup for this page action.",
        "parameters": [
          {
            "name": "details",
            "$ref": "TabDetails"
          }
        ],
        "returns_async": {
          "name": "callback",
          "parameters": [
            {
              "name": "result",
              "type": "string"
            }
          ]
        }
      }
    ],
    "events": [
      {
        "name": "onClicked",
        "type": "function",
        "description": "Fired when a page action icon is clicked.  This event will not fire if the page action has a popup.",
        "parameters": [
          {
            "name": "tab",
            "$ref": "tabs.Tab"
          }
        ]
      }
    ]
  }
]