| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 this._subscriptionStopHandlers = {}; | 42 this._subscriptionStopHandlers = {}; |
| 43 this._extraHeaders = {}; | 43 this._extraHeaders = {}; |
| 44 this._requests = {}; | 44 this._requests = {}; |
| 45 this._lastRequestId = 0; | 45 this._lastRequestId = 0; |
| 46 this._registeredExtensions = {}; | 46 this._registeredExtensions = {}; |
| 47 this._status = new WebInspector.ExtensionStatus(); | 47 this._status = new WebInspector.ExtensionStatus(); |
| 48 /** @type {!Array.<!WebInspector.ExtensionSidebarPane>} */ | 48 /** @type {!Array.<!WebInspector.ExtensionSidebarPane>} */ |
| 49 this._sidebarPanes = []; | 49 this._sidebarPanes = []; |
| 50 /** @type {!Array.<!WebInspector.ExtensionAuditCategory>} */ | 50 /** @type {!Array.<!WebInspector.ExtensionAuditCategory>} */ |
| 51 this._auditCategories = []; | 51 this._auditCategories = []; |
| 52 /** @type {!Array.<!WebInspector.ExtensionTraceProvider>} */ |
| 53 this._traceProviders = []; |
| 52 | 54 |
| 53 var commands = WebInspector.extensionAPI.Commands; | 55 var commands = WebInspector.extensionAPI.Commands; |
| 54 | 56 |
| 55 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi
nd(this)); | 57 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi
nd(this)); |
| 56 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t
his)); | 58 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t
his)); |
| 57 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders.
bind(this)); | 59 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders.
bind(this)); |
| 60 this._registerHandler(commands.AddTraceProvider, this._onAddTraceProvider.bi
nd(this)); |
| 58 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind
(this)); | 61 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind
(this)); |
| 59 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this)); | 62 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this)); |
| 60 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane.
bind(this)); | 63 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane.
bind(this)); |
| 61 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut
ton.bind(this)); | 64 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut
ton.bind(this)); |
| 62 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn
spectedPage.bind(this)); | 65 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn
spectedPage.bind(this)); |
| 63 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard
Event.bind(this)); | 66 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard
Event.bind(this)); |
| 64 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); | 67 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); |
| 65 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi
nd(this)); | 68 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi
nd(this)); |
| 66 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent.
bind(this)); | 69 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent.
bind(this)); |
| 67 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten
t.bind(this)); | 70 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten
t.bind(this)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 window.addEventListener("message", this._onWindowMessage.bind(this), false);
// Only for main window. | 84 window.addEventListener("message", this._onWindowMessage.bind(this), false);
// Only for main window. |
| 82 | 85 |
| 83 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.AddExtensions, this._addExtensions, this); | 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.AddExtensions, this._addExtensions, this); |
| 84 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetInspectedTabId, this._setInspectedTabId, this); | 87 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetInspectedTabId, this._setInspectedTabId, this); |
| 85 | 88 |
| 86 this._initExtensions(); | 89 this._initExtensions(); |
| 87 } | 90 } |
| 88 | 91 |
| 89 WebInspector.ExtensionServer.Events = { | 92 WebInspector.ExtensionServer.Events = { |
| 90 SidebarPaneAdded: "SidebarPaneAdded", | 93 SidebarPaneAdded: "SidebarPaneAdded", |
| 91 AuditCategoryAdded: "AuditCategoryAdded" | 94 AuditCategoryAdded: "AuditCategoryAdded", |
| 92 } | 95 } |
| 93 | 96 |
| 94 WebInspector.ExtensionServer.prototype = { | 97 WebInspector.ExtensionServer.prototype = { |
| 95 initializeExtensions: function() | 98 initializeExtensions: function() |
| 96 { | 99 { |
| 97 this._initializeCommandIssued = true; | 100 this._initializeCommandIssued = true; |
| 98 if (this._pendingExtensionInfos) { | 101 if (this._pendingExtensionInfos) { |
| 99 this._pendingExtensionInfos.forEach(this._addExtension, this); | 102 this._pendingExtensionInfos.forEach(this._addExtension, this); |
| 100 delete this._pendingExtensionInfos; | 103 delete this._pendingExtensionInfos; |
| 101 } | 104 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked +
identifier); | 147 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked +
identifier); |
| 145 }, | 148 }, |
| 146 | 149 |
| 147 _inspectedURLChanged: function(event) | 150 _inspectedURLChanged: function(event) |
| 148 { | 151 { |
| 149 this._requests = {}; | 152 this._requests = {}; |
| 150 var url = event.data; | 153 var url = event.data; |
| 151 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan
ged, url); | 154 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan
ged, url); |
| 152 }, | 155 }, |
| 153 | 156 |
| 154 | |
| 155 /** | 157 /** |
| 156 * @param {string} categoryId | 158 * @param {string} categoryId |
| 157 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 159 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
| 158 */ | 160 */ |
| 159 startAuditRun: function(categoryId, auditResults) | 161 startAuditRun: function(categoryId, auditResults) |
| 160 { | 162 { |
| 161 this._clientObjects[auditResults.id()] = auditResults; | 163 this._clientObjects[auditResults.id()] = auditResults; |
| 162 this._postNotification("audit-started-" + categoryId, auditResults.id())
; | 164 this._postNotification("audit-started-" + categoryId, auditResults.id())
; |
| 163 }, | 165 }, |
| 164 | 166 |
| 165 /** | 167 /** |
| 166 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 168 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
| 167 */ | 169 */ |
| 168 stopAuditRun: function(auditResults) | 170 stopAuditRun: function(auditResults) |
| 169 { | 171 { |
| 170 delete this._clientObjects[auditResults.id()]; | 172 delete this._clientObjects[auditResults.id()]; |
| 171 }, | 173 }, |
| 172 | 174 |
| 173 /** | 175 /** |
| 176 * @param {string} traceProviderId |
| 177 */ |
| 178 startTraceRecording: function(traceProviderId) |
| 179 { |
| 180 this._postNotification("trace-recording-started-" + traceProviderId); |
| 181 }, |
| 182 |
| 183 /** |
| 184 * @param {string} traceProviderId |
| 185 */ |
| 186 stopTraceRecording: function(traceProviderId) |
| 187 { |
| 188 this._postNotification("trace-recording-stopped-" + traceProviderId); |
| 189 }, |
| 190 |
| 191 /** |
| 174 * @param {string} type | 192 * @param {string} type |
| 175 * @return {boolean} | 193 * @return {boolean} |
| 176 */ | 194 */ |
| 177 hasSubscribers: function(type) | 195 hasSubscribers: function(type) |
| 178 { | 196 { |
| 179 return !!this._subscribers[type]; | 197 return !!this._subscribers[type]; |
| 180 }, | 198 }, |
| 181 | 199 |
| 182 /** | 200 /** |
| 183 * @param {string} type | 201 * @param {string} type |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 605 |
| 588 _onAddAuditCategory: function(message, port) | 606 _onAddAuditCategory: function(message, port) |
| 589 { | 607 { |
| 590 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr
igin, message.id, message.displayName, message.resultCount); | 608 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr
igin, message.id, message.displayName, message.resultCount); |
| 591 this._clientObjects[message.id] = category; | 609 this._clientObjects[message.id] = category; |
| 592 this._auditCategories.push(category); | 610 this._auditCategories.push(category); |
| 593 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC
ategoryAdded, category); | 611 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC
ategoryAdded, category); |
| 594 }, | 612 }, |
| 595 | 613 |
| 596 /** | 614 /** |
| 615 * @param {!Object} message |
| 616 * @param {!MessagePort} port |
| 617 */ |
| 618 _onAddTraceProvider: function(message, port) |
| 619 { |
| 620 var provider = new WebInspector.ExtensionTraceProvider(port._extensionOr
igin, message.id, message.categoryName, message.categoryTooltip); |
| 621 this._clientObjects[message.id] = provider; |
| 622 this._traceProviders.push(provider); |
| 623 }, |
| 624 |
| 625 /** |
| 626 * @return {!Array<!WebInspector.ExtensionTraceProvider>} |
| 627 */ |
| 628 traceProviders: function() |
| 629 { |
| 630 return this._traceProviders; |
| 631 }, |
| 632 |
| 633 /** |
| 597 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} | 634 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} |
| 598 */ | 635 */ |
| 599 auditCategories: function() | 636 auditCategories: function() |
| 600 { | 637 { |
| 601 return this._auditCategories; | 638 return this._auditCategories; |
| 602 }, | 639 }, |
| 603 | 640 |
| 604 _onAddAuditResult: function(message) | 641 _onAddAuditResult: function(message) |
| 605 { | 642 { |
| 606 var auditResult = /** {!WebInspector.ExtensionAuditCategoryResults} */ (
this._clientObjects[message.resultId]); | 643 var auditResult = /** {!WebInspector.ExtensionAuditCategoryResults} */ (
this._clientObjects[message.resultId]); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 /** | 1119 /** |
| 1083 * @typedef {{code: string, description: string, details: !Array.<*>}} | 1120 * @typedef {{code: string, description: string, details: !Array.<*>}} |
| 1084 */ | 1121 */ |
| 1085 WebInspector.ExtensionStatus.Record; | 1122 WebInspector.ExtensionStatus.Record; |
| 1086 | 1123 |
| 1087 WebInspector.extensionAPI = {}; | 1124 WebInspector.extensionAPI = {}; |
| 1088 defineCommonExtensionSymbols(WebInspector.extensionAPI); | 1125 defineCommonExtensionSymbols(WebInspector.extensionAPI); |
| 1089 | 1126 |
| 1090 /** @type {!WebInspector.ExtensionServer} */ | 1127 /** @type {!WebInspector.ExtensionServer} */ |
| 1091 WebInspector.extensionServer; | 1128 WebInspector.extensionServer; |
| OLD | NEW |