| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 { | 283 { |
| 284 var id = message.id; | 284 var id = message.id; |
| 285 // The ids are generated on the client API side and must be unique, so t
he check below | 285 // The ids are generated on the client API side and must be unique, so t
he check below |
| 286 // shouldn't be hit unless someone is bypassing the API. | 286 // shouldn't be hit unless someone is bypassing the API. |
| 287 if (id in this._clientObjects || WebInspector.inspectorView.hasPanel(id)
) | 287 if (id in this._clientObjects || WebInspector.inspectorView.hasPanel(id)
) |
| 288 return this._status.E_EXISTS(id); | 288 return this._status.E_EXISTS(id); |
| 289 | 289 |
| 290 var page = this._expandResourcePath(port._extensionOrigin, message.page)
; | 290 var page = this._expandResourcePath(port._extensionOrigin, message.page)
; |
| 291 var persistentId = port._extensionOrigin + message.title; | 291 var persistentId = port._extensionOrigin + message.title; |
| 292 persistentId = persistentId.replace(/\s/g, ""); | 292 persistentId = persistentId.replace(/\s/g, ""); |
| 293 var panelDescriptor = new WebInspector.ExtensionServerPanelDescriptor(pe
rsistentId, message.title, new WebInspector.ExtensionPanel(this, persistentId, i
d, page)); | 293 var panelView = new WebInspector.ExtensionServerPanelView(persistentId,
message.title, new WebInspector.ExtensionPanel(this, persistentId, id, page)); |
| 294 this._clientObjects[id] = panelDescriptor; | 294 this._clientObjects[id] = panelView; |
| 295 WebInspector.inspectorView.addPanel(panelDescriptor); | 295 WebInspector.inspectorView.addPanel(panelView); |
| 296 return this._status.OK(); | 296 return this._status.OK(); |
| 297 }, | 297 }, |
| 298 | 298 |
| 299 _onShowPanel: function(message) | 299 _onShowPanel: function(message) |
| 300 { | 300 { |
| 301 var panelName = message.id; | 301 var panelViewId = message.id; |
| 302 var panelDescriptor = this._clientObjects[message.id]; | 302 var panelView = this._clientObjects[message.id]; |
| 303 if (panelDescriptor && panelDescriptor instanceof WebInspector.Extension
ServerPanelDescriptor) | 303 if (panelView && panelView instanceof WebInspector.ExtensionServerPanelV
iew) |
| 304 panelName = panelDescriptor.name(); | 304 panelViewId = panelView.viewId(); |
| 305 WebInspector.inspectorView.showPanel(panelName); | 305 WebInspector.inspectorView.showPanel(panelViewId); |
| 306 }, | 306 }, |
| 307 | 307 |
| 308 _onCreateToolbarButton: function(message, port) | 308 _onCreateToolbarButton: function(message, port) |
| 309 { | 309 { |
| 310 var panelDescriptor = this._clientObjects[message.panel]; | 310 var panelView = this._clientObjects[message.panel]; |
| 311 if (!panelDescriptor || !(panelDescriptor instanceof WebInspector.Extens
ionServerPanelDescriptor)) | 311 if (!panelView || !(panelView instanceof WebInspector.ExtensionServerPan
elView)) |
| 312 return this._status.E_NOTFOUND(message.panel); | 312 return this._status.E_NOTFOUND(message.panel); |
| 313 var button = new WebInspector.ExtensionButton(this, message.id, this._ex
pandResourcePath(port._extensionOrigin, message.icon), message.tooltip, message.
disabled); | 313 var button = new WebInspector.ExtensionButton(this, message.id, this._ex
pandResourcePath(port._extensionOrigin, message.icon), message.tooltip, message.
disabled); |
| 314 this._clientObjects[message.id] = button; | 314 this._clientObjects[message.id] = button; |
| 315 | 315 |
| 316 panelDescriptor.panel().then(appendButton); | 316 panelView.widget().then(appendButton); |
| 317 | 317 |
| 318 /** | 318 /** |
| 319 * @param {!WebInspector.Panel} panel | 319 * @param {!WebInspector.Widget} panel |
| 320 */ | 320 */ |
| 321 function appendButton(panel) | 321 function appendButton(panel) |
| 322 { | 322 { |
| 323 /** @type {!WebInspector.ExtensionPanel} panel*/ (panel).addToolbarI
tem(button.toolbarButton()); | 323 /** @type {!WebInspector.ExtensionPanel} panel*/ (panel).addToolbarI
tem(button.toolbarButton()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 return this._status.OK(); | 326 return this._status.OK(); |
| 327 }, | 327 }, |
| 328 | 328 |
| 329 _onUpdateButton: function(message, port) | 329 _onUpdateButton: function(message, port) |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 }, | 1051 }, |
| 1052 | 1052 |
| 1053 __proto__: WebInspector.Object.prototype | 1053 __proto__: WebInspector.Object.prototype |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 /** | 1056 /** |
| 1057 * @constructor | 1057 * @constructor |
| 1058 * @param {string} name | 1058 * @param {string} name |
| 1059 * @param {string} title | 1059 * @param {string} title |
| 1060 * @param {!WebInspector.Panel} panel | 1060 * @param {!WebInspector.Panel} panel |
| 1061 * @implements {WebInspector.PanelDescriptor} | 1061 * @extends {WebInspector.SimpleView} |
| 1062 */ | 1062 */ |
| 1063 WebInspector.ExtensionServerPanelDescriptor = function(name, title, panel) | 1063 WebInspector.ExtensionServerPanelView = function(name, title, panel) |
| 1064 { | 1064 { |
| 1065 WebInspector.SimpleView.call(this, title); |
| 1065 this._name = name; | 1066 this._name = name; |
| 1066 this._title = title; | |
| 1067 this._panel = panel; | 1067 this._panel = panel; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 WebInspector.ExtensionServerPanelDescriptor.prototype = { | 1070 WebInspector.ExtensionServerPanelView.prototype = { |
| 1071 /** | 1071 /** |
| 1072 * @override | 1072 * @override |
| 1073 * @return {string} | 1073 * @return {string} |
| 1074 */ | 1074 */ |
| 1075 name: function() | 1075 viewId: function() |
| 1076 { | 1076 { |
| 1077 return this._name; | 1077 return this._name; |
| 1078 }, | 1078 }, |
| 1079 | 1079 |
| 1080 /** | 1080 /** |
| 1081 * @override | 1081 * @override |
| 1082 * @return {string} | 1082 * @return {!Promise.<!WebInspector.Widget>} |
| 1083 */ | 1083 */ |
| 1084 title: function() | 1084 widget: function() |
| 1085 { | 1085 { |
| 1086 return this._title; | 1086 return /** @type {!Promise.<!WebInspector.Widget>} */ (Promise.resolve(t
his._panel)); |
| 1087 }, | 1087 }, |
| 1088 | 1088 |
| 1089 /** | 1089 __proto__: WebInspector.SimpleView.prototype |
| 1090 * @override | |
| 1091 * @return {!Promise.<!WebInspector.Panel>} | |
| 1092 */ | |
| 1093 panel: function() | |
| 1094 { | |
| 1095 return Promise.resolve(this._panel); | |
| 1096 } | |
| 1097 } | 1090 } |
| 1098 | 1091 |
| 1099 /** | 1092 /** |
| 1100 * @constructor | 1093 * @constructor |
| 1101 */ | 1094 */ |
| 1102 WebInspector.ExtensionStatus = function() | 1095 WebInspector.ExtensionStatus = function() |
| 1103 { | 1096 { |
| 1104 /** | 1097 /** |
| 1105 * @param {string} code | 1098 * @param {string} code |
| 1106 * @param {string} description | 1099 * @param {string} description |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1130 /** | 1123 /** |
| 1131 * @typedef {{code: string, description: string, details: !Array.<*>}} | 1124 * @typedef {{code: string, description: string, details: !Array.<*>}} |
| 1132 */ | 1125 */ |
| 1133 WebInspector.ExtensionStatus.Record; | 1126 WebInspector.ExtensionStatus.Record; |
| 1134 | 1127 |
| 1135 WebInspector.extensionAPI = {}; | 1128 WebInspector.extensionAPI = {}; |
| 1136 defineCommonExtensionSymbols(WebInspector.extensionAPI); | 1129 defineCommonExtensionSymbols(WebInspector.extensionAPI); |
| 1137 | 1130 |
| 1138 /** @type {!WebInspector.ExtensionServer} */ | 1131 /** @type {!WebInspector.ExtensionServer} */ |
| 1139 WebInspector.extensionServer; | 1132 WebInspector.extensionServer; |
| OLD | NEW |