Commit 83a34182 authored by Tim Judkins's avatar Tim Judkins Committed by Commit Bot

[Extensions] Enable promise support on the tabs API

This CL changes over the json schema to use the new returns_async format
to define callbacks, enabling promise support on those APIs.

Bug: 328932
Change-Id: Iab033c7cd7174d82be4740bcf1ee4fca5288665f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514807Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Tim Judkins <tjudkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826846}
parent 84869dc2
...@@ -156,33 +156,30 @@ ...@@ -156,33 +156,30 @@
"type": "integer", "type": "integer",
"name": "tabId", "name": "tabId",
"minimum": 0 "minimum": 0
},
{
"type": "function",
"name": "callback",
"parameters": [
{"name": "tab", "$ref": "Tab"}
]
} }
] ],
"returns_async": {
"name": "callback",
"parameters": [
{"name": "tab", "$ref": "Tab"}
]
}
}, },
{ {
"name": "getCurrent", "name": "getCurrent",
"type": "function", "type": "function",
"description": "Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example, a background page or popup view).", "description": "Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example, a background page or popup view).",
"parameters": [ "parameters": [],
{ "returns_async": {
"type": "function", "name": "callback",
"name": "callback", "parameters": [
"parameters": [ {
{ "name": "tab",
"name": "tab", "$ref": "Tab",
"$ref": "Tab", "optional": true
"optional": true }
} ]
] }
}
]
}, },
{ {
"name": "connect", "name": "connect",
...@@ -300,15 +297,14 @@ ...@@ -300,15 +297,14 @@
"minimum": -2, "minimum": -2,
"optional": true, "optional": true,
"description": "Defaults to the <a href='windows#current-window'>current window</a>." "description": "Defaults to the <a href='windows#current-window'>current window</a>."
},
{
"type": "function",
"name": "callback",
"parameters": [
{"name": "tab", "$ref": "Tab"}
]
} }
] ],
"returns_async": {
"name": "callback",
"parameters": [
{"name": "tab", "$ref": "Tab"}
]
}
}, },
{ {
"name": "getAllInWindow", "name": "getAllInWindow",
...@@ -322,15 +318,14 @@ ...@@ -322,15 +318,14 @@
"minimum": -2, "minimum": -2,
"optional": true, "optional": true,
"description": "Defaults to the <a href='windows#current-window'>current window</a>." "description": "Defaults to the <a href='windows#current-window'>current window</a>."
},
{
"type": "function",
"name": "callback",
"parameters": [
{"name": "tabs", "type": "array", "items": { "$ref": "Tab" } }
]
} }
] ],
"returns_async": {
"name": "callback",
"parameters": [
{"name": "tabs", "type": "array", "items": { "$ref": "Tab" } }
]
}
}, },
{ {
"name": "create", "name": "create",
...@@ -540,34 +535,33 @@ ...@@ -540,34 +535,33 @@
"type": "object", "type": "object",
"name": "highlightInfo", "name": "highlightInfo",
"properties": { "properties": {
"windowId": { "windowId": {
"type": "integer", "type": "integer",
"optional": true, "optional": true,
"description": "The window that contains the tabs.", "description": "The window that contains the tabs.",
"minimum": -2 "minimum": -2
}, },
"tabs": { "tabs": {
"description": "One or more tab indices to highlight.", "description": "One or more tab indices to highlight.",
"choices": [ "choices": [
{"type": "array", "items": {"type": "integer", "minimum": 0}}, {"type": "array", "items": {"type": "integer", "minimum": 0}},
{"type": "integer"} {"type": "integer"}
] ]
} }
} }
}, }
{ ],
"type": "function", "returns_async": {
"name": "callback", "name": "callback",
"optional": true, "optional": true,
"parameters": [ "parameters": [
{ {
"name": "window", "name": "window",
"$ref": "windows.Window", "$ref": "windows.Window",
"description": "Contains details about the window whose tabs were highlighted." "description": "Contains details about the window whose tabs were highlighted."
} }
] ]
} }
]
}, },
{ {
"name": "update", "name": "update",
...@@ -628,21 +622,20 @@ ...@@ -628,21 +622,20 @@
"description": "Whether the tab should be discarded automatically by the browser when resources are low." "description": "Whether the tab should be discarded automatically by the browser when resources are low."
} }
} }
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [
{
"name": "tab",
"$ref": "Tab",
"optional": true,
"description": "Details about the updated tab. The $(ref:tabs.Tab) object does not contain <code>url</code>, <code>pendingUrl</code>, <code>title</code>, and <code>favIconUrl</code> if the <code>\"tabs\"</code> permission has not been requested."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"parameters": [
{
"name": "tab",
"$ref": "Tab",
"optional": true,
"description": "Details about the updated tab. The $(ref:tabs.Tab) object does not contain <code>url</code>, <code>pendingUrl</code>, <code>title</code>, and <code>favIconUrl</code> if the <code>\"tabs\"</code> permission has not been requested."
}
]
}
}, },
{ {
"name": "move", "name": "move",
...@@ -673,23 +666,22 @@ ...@@ -673,23 +666,22 @@
"description": "The position to move the window to. Use <code>-1</code> to place the tab at the end of the window." "description": "The position to move the window to. Use <code>-1</code> to place the tab at the end of the window."
} }
} }
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [
{
"name": "tabs",
"description": "Details about the moved tabs.",
"choices": [
{"$ref": "Tab"},
{"type": "array", "items": {"$ref": "Tab"}}
]
}
]
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"parameters": [
{
"name": "tabs",
"description": "Details about the moved tabs.",
"choices": [
{"$ref": "Tab"},
{"type": "array", "items": {"$ref": "Tab"}}
]
}
]
}
}, },
{ {
"name": "reload", "name": "reload",
...@@ -708,9 +700,9 @@ ...@@ -708,9 +700,9 @@
"description": "Whether to bypass local caching. Defaults to <code>false</code>." "description": "Whether to bypass local caching. Defaults to <code>false</code>."
} }
} }
}, }
{"type": "function", "name": "callback", "optional": true, "parameters": []} ],
] "returns_async": {"name": "callback", "optional": true, "parameters": []}
}, },
{ {
"name": "remove", "name": "remove",
...@@ -724,9 +716,9 @@ ...@@ -724,9 +716,9 @@
{"type": "integer", "minimum": 0}, {"type": "integer", "minimum": 0},
{"type": "array", "items": {"type": "integer", "minimum": 0}} {"type": "array", "items": {"type": "integer", "minimum": 0}}
] ]
}, }
{"type": "function", "name": "callback", "optional": true, "parameters": []} ],
] "returns_async": {"name": "callback", "optional": true, "parameters": []}
}, },
{ {
"name": "group", "name": "group",
...@@ -764,21 +756,20 @@ ...@@ -764,21 +756,20 @@
} }
} }
} }
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [
{
"name": "groupId",
"type": "integer",
"minimum": 0,
"description": "The ID of the group that the tabs were added to."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"parameters": [
{
"name": "groupId",
"type": "integer",
"minimum": 0,
"description": "The ID of the group that the tabs were added to."
}
]
}
}, },
{ {
"name": "ungroup", "name": "ungroup",
...@@ -792,9 +783,9 @@ ...@@ -792,9 +783,9 @@
{"type": "integer", "minimum": 0}, {"type": "integer", "minimum": 0},
{"type": "array", "items": {"type": "integer", "minimum": 0}, "minItems": 1} {"type": "array", "items": {"type": "integer", "minimum": 0}, "minItems": 1}
] ]
}, }
{"type": "function", "name": "callback", "optional": true, "parameters": []} ],
] "returns_async": {"name": "callback", "optional": true, "parameters": []}
}, },
{ {
"name": "detectLanguage", "name": "detectLanguage",
...@@ -807,19 +798,18 @@ ...@@ -807,19 +798,18 @@
"minimum": 0, "minimum": 0,
"optional": true, "optional": true,
"description": "Defaults to the active tab of the <a href='windows#current-window'>current window</a>." "description": "Defaults to the active tab of the <a href='windows#current-window'>current window</a>."
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"type": "string",
"name": "language",
"description": "An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>kLanguageInfoTable</a>. The second to fourth columns are checked and the first non-NULL value is returned, except for Simplified Chinese for which <code>zh-CN</code> is returned. For an unknown/undefined language, <code>und</code> is returned."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"parameters": [
{
"type": "string",
"name": "language",
"description": "An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>kLanguageInfoTable</a>. The second to fourth columns are checked and the first non-NULL value is returned, except for Simplified Chinese for which <code>zh-CN</code> is returned. For an unknown/undefined language, <code>und</code> is returned."
}
]
}
}, },
{ {
"name": "captureVisibleTab", "name": "captureVisibleTab",
...@@ -837,13 +827,18 @@ ...@@ -837,13 +827,18 @@
"$ref": "extensionTypes.ImageDetails", "$ref": "extensionTypes.ImageDetails",
"name": "options", "name": "options",
"optional": true "optional": true
},
{
"type": "function", "name": "callback", "parameters": [
{"type": "string", "name": "dataUrl", "description": "A data URL that encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML <code>img</code> element for display."}
]
} }
] ],
"returns_async": {
"name": "callback",
"parameters": [
{
"type": "string",
"name": "dataUrl",
"description": "A data URL that encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML <code>img</code> element for display."
}
]
}
}, },
{ {
"name": "executeScript", "name": "executeScript",
...@@ -855,23 +850,22 @@ ...@@ -855,23 +850,22 @@
"$ref": "extensionTypes.InjectDetails", "$ref": "extensionTypes.InjectDetails",
"name": "details", "name": "details",
"description": "Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time." "description": "Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after all the JavaScript has been executed.",
"parameters": [
{
"name": "result",
"optional": true,
"type": "array",
"items": {"type": "any", "minimum": 0},
"description": "The result of the script in every injected frame."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called after all the JavaScript has been executed.",
"parameters": [
{
"name": "result",
"optional": true,
"type": "array",
"items": {"type": "any", "minimum": 0},
"description": "The result of the script in every injected frame."
}
]
}
}, },
{ {
"name": "insertCSS", "name": "insertCSS",
...@@ -883,15 +877,14 @@ ...@@ -883,15 +877,14 @@
"$ref": "extensionTypes.InjectDetails", "$ref": "extensionTypes.InjectDetails",
"name": "details", "name": "details",
"description": "Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time." "description": "Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called when all the CSS has been inserted.",
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called when all the CSS has been inserted.",
"parameters": []
}
}, },
{ {
"name": "removeCSS", "name": "removeCSS",
...@@ -909,15 +902,14 @@ ...@@ -909,15 +902,14 @@
"$ref": "extensionTypes.DeleteInjectionDetails", "$ref": "extensionTypes.DeleteInjectionDetails",
"name": "details", "name": "details",
"description": "Details of the CSS text to remove. Either the code or the file property must be set, but both may not be set at the same time." "description": "Details of the CSS text to remove. Either the code or the file property must be set, but both may not be set at the same time."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called when all the CSS has been removed.",
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called when all the CSS has been removed.",
"parameters": []
}
}, },
{ {
"name": "setZoom", "name": "setZoom",
...@@ -935,15 +927,14 @@ ...@@ -935,15 +927,14 @@
"type": "number", "type": "number",
"name": "zoomFactor", "name": "zoomFactor",
"description": "The new zoom factor. A value of <code>0</code> sets the tab to its current default zoom factor. Values greater than <code>0</code> specify a (possibly non-default) zoom factor for the tab." "description": "The new zoom factor. A value of <code>0</code> sets the tab to its current default zoom factor. Values greater than <code>0</code> specify a (possibly non-default) zoom factor for the tab."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after the zoom factor has been changed.",
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called after the zoom factor has been changed.",
"parameters": []
}
}, },
{ {
"name": "getZoom", "name": "getZoom",
...@@ -956,20 +947,19 @@ ...@@ -956,20 +947,19 @@
"minimum": 0, "minimum": 0,
"optional": true, "optional": true,
"description": "The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window." "description": "The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window."
},
{
"type": "function",
"name": "callback",
"description": "Called with the tab's current zoom factor after it has been fetched.",
"parameters": [
{
"type": "number",
"name": "zoomFactor",
"description": "The tab's current zoom factor."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"description": "Called with the tab's current zoom factor after it has been fetched.",
"parameters": [
{
"type": "number",
"name": "zoomFactor",
"description": "The tab's current zoom factor."
}
]
}
}, },
{ {
"name": "setZoomSettings", "name": "setZoomSettings",
...@@ -987,15 +977,14 @@ ...@@ -987,15 +977,14 @@
"$ref": "ZoomSettings", "$ref": "ZoomSettings",
"name": "zoomSettings", "name": "zoomSettings",
"description": "Defines how zoom changes are handled and at what scope." "description": "Defines how zoom changes are handled and at what scope."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after the zoom settings are changed.",
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called after the zoom settings are changed.",
"parameters": []
}
}, },
{ {
"name": "getZoomSettings", "name": "getZoomSettings",
...@@ -1008,20 +997,19 @@ ...@@ -1008,20 +997,19 @@
"optional": true, "optional": true,
"minimum": 0, "minimum": 0,
"description": "The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window." "description": "The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window."
},
{
"type": "function",
"name": "callback",
"description": "Called with the tab's current zoom settings.",
"parameters": [
{
"$ref": "ZoomSettings",
"name": "zoomSettings",
"description": "The tab's current zoom settings."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"description": "Called with the tab's current zoom settings.",
"parameters": [
{
"$ref": "ZoomSettings",
"name": "zoomSettings",
"description": "The tab's current zoom settings."
}
]
}
}, },
{ {
"name": "discard", "name": "discard",
...@@ -1034,22 +1022,21 @@ ...@@ -1034,22 +1022,21 @@
"optional": true, "optional": true,
"minimum": 0, "minimum": 0,
"description": "The ID of the tab to be discarded. If specified, the tab is discarded unless it is active or already discarded. If omitted, the browser discards the least important tab. This can fail if no discardable tabs exist." "description": "The ID of the tab to be discarded. If specified, the tab is discarded unless it is active or already discarded. If omitted, the browser discards the least important tab. This can fail if no discardable tabs exist."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after the operation is completed.",
"parameters": [
{
"name": "tab",
"$ref": "Tab",
"optional": true,
"description": "The discarded tab, if it was successfully discarded; undefined otherwise."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"description": "Called after the operation is completed.",
"parameters": [
{
"name": "tab",
"$ref": "Tab",
"optional": true,
"description": "The discarded tab, if it was successfully discarded; undefined otherwise."
}
]
}
}, },
{ {
"name": "goForward", "name": "goForward",
...@@ -1062,14 +1049,13 @@ ...@@ -1062,14 +1049,13 @@
"optional": true, "optional": true,
"minimum": 0, "minimum": 0,
"description": "The ID of the tab to navigate forward; defaults to the selected tab of the current window." "description": "The ID of the tab to navigate forward; defaults to the selected tab of the current window."
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"parameters": []
}
}, },
{ {
"name": "goBack", "name": "goBack",
...@@ -1082,14 +1068,13 @@ ...@@ -1082,14 +1068,13 @@
"optional": true, "optional": true,
"minimum": 0, "minimum": 0,
"description": "The ID of the tab to navigate back; defaults to the selected tab of the current window." "description": "The ID of the tab to navigate back; defaults to the selected tab of the current window."
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": []
} }
] ],
"returns_async": {
"name": "callback",
"optional": true,
"parameters": []
}
} }
], ],
"events": [ "events": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment