* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+importScript("ExtensionRegistryStub.js");
+importScript("ExtensionAPI.js");
+importScript("ExtensionAuditCategory.js");
+
/**
* @constructor
+ * @implements {WebInspector.ExtensionServerAPI}
*/
WebInspector.ExtensionServer = function()
{
this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this));
this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this));
this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgress.bind(this));
-
window.addEventListener("message", this._onWindowMessage.bind(this), false);
+
+ this._initExtensions();
}
WebInspector.ExtensionServer.prototype = {
_onOpenResource: function(message)
{
- var a = document.createElement("a");
- a.href = message.url;
- a.lineNumber = message.lineNumber;
- return WebInspector.showAnchorLocation(a) ? this._status.OK() : this._status.E_NOTFOUND(message.url);
+ var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(message.url);
+ if (uiSourceCode) {
+ WebInspector.Revealer.reveal(new WebInspector.UILocation(uiSourceCode, message.lineNumber, 0));
+ return this._status.OK();
+ }
+
+ var resource = WebInspector.resourceForURL(message.url);
+ if (resource) {
+ WebInspector.Revealer.reveal(resource, message.lineNumber);
+ return this._status.OK();
+ }
+
+ var request = WebInspector.networkLog.requestForURL(message.url);
+ if (request) {
+ WebInspector.Revealer.reveal(request);
+ return this._status.OK();
+ }
+
+ return this._status.E_NOTFOUND(message.url);
},
_onSetOpenResourceHandler: function(message, port)
port.postMessage({ command: "callback", requestId: requestId, result: result });
},
- initExtensions: function()
+ _initExtensions: function()
{
this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ConsoleMessageAdded,
WebInspector.console, WebInspector.ConsoleModel.Events.MessageAdded, this._notifyConsoleMessageAdded);
*/
function onElementsSubscriptionStarted()
{
- WebInspector.moduleManager.loadModule("elements");
- WebInspector.notifications.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
+ WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
}
/**
*/
function onElementsSubscriptionStopped()
{
- WebInspector.notifications.removeEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
+ WebInspector.notifications.removeEventListener(WebInspector.NotificationService.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
}
this._registerSubscriptionHandler(WebInspector.extensionAPI.Events.PanelObjectSelected + "elements",
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,
this._inspectedURLChanged, this);
- this._initDone = true;
- if (this._pendingExtensions) {
- this._pendingExtensions.forEach(this._innerAddExtension, this);
- delete this._pendingExtensions;
- }
InspectorExtensionRegistry.getExtensionsAsync();
},
},
/**
- * @param {!Array.<!ExtensionDescriptor>} extensions
+ * @param {!Array.<!ExtensionDescriptor>} extensionInfos
*/
- _addExtensions: function(extensions)
+ addExtensions: function(extensionInfos)
{
- extensions.forEach(this._addExtension, this);
+ extensionInfos.forEach(this._addExtension, this);
},
/**
*/
_addExtension: function(extensionInfo)
{
- if (this._initDone) {
- this._innerAddExtension(extensionInfo);
- return;
- }
- if (this._pendingExtensions)
- this._pendingExtensions.push(extensionInfo);
- else
- this._pendingExtensions = [extensionInfo];
- },
-
- /**
- * @param {!ExtensionDescriptor} extensionInfo
- */
- _innerAddExtension: function(extensionInfo)
- {
const urlOriginRegExp = new RegExp("([^:]+:\/\/[^/]*)\/"); // Can't use regexp literal here, MinJS chokes on it.
var startPage = extensionInfo.startPage;
var name = extensionInfo.name;
}
var extensionOrigin = originMatch[1];
if (!this._registeredExtensions[extensionOrigin]) {
- // See ExtensionAPI.js and ExtensionCommon.js for details.
+ // See ExtensionAPI.js for details.
InspectorFrontendHost.setInjectedScriptForOrigin(extensionOrigin, buildExtensionAPIInjectedScript(extensionInfo));
this._registeredExtensions[extensionOrigin] = { name: name };
}
return true;
},
- _onWindowMessage: function(event)
- {
- if (event.data === "registerExtension")
- this._registerExtension(event.origin, event.ports[0]);
- },
-
_registerExtension: function(origin, port)
{
if (!this._registeredExtensions.hasOwnProperty(origin)) {
port.start();
},
+ _onWindowMessage: function(event)
+ {
+ if (event.data === "registerExtension")
+ this._registerExtension(event.origin, event.ports[0]);
+ },
+
_onmessage: function(event)
{
var message = event.data;
*/
WebInspector.ExtensionStatus.Record;
-WebInspector.addExtensions = function(extensions)
-{
- WebInspector.extensionServer._addExtensions(extensions);
-}
-
WebInspector.extensionAPI = {};
defineCommonExtensionSymbols(WebInspector.extensionAPI);
-WebInspector.extensionServer = new WebInspector.ExtensionServer();
-
-window.addExtension = function(page, name)
-{
- WebInspector.extensionServer._addExtension({
- startPage: page,
- name: name,
- });
-}
+importScript("ExtensionPanel.js");
+importScript("ExtensionView.js");