Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 80 window.addEventListener("message", this._onWindowMessage.bind(this), false); // Only for main window. | 83 window.addEventListener("message", this._onWindowMessage.bind(this), false); // Only for main window. |
| 81 | 84 |
| 82 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.AddExtensions, this._addExtensions, this); | 85 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.AddExtensions, this._addExtensions, this); |
| 83 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.SetInspectedTabId, this._setInspectedTabId, this); | 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.SetInspectedTabId, this._setInspectedTabId, this); |
| 84 | 87 |
| 85 this._initExtensions(); | 88 this._initExtensions(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 WebInspector.ExtensionServer.Events = { | 91 WebInspector.ExtensionServer.Events = { |
| 89 SidebarPaneAdded: "SidebarPaneAdded", | 92 SidebarPaneAdded: "SidebarPaneAdded", |
| 90 AuditCategoryAdded: "AuditCategoryAdded" | 93 AuditCategoryAdded: "AuditCategoryAdded", |
| 91 } | 94 } |
| 92 | 95 |
| 93 WebInspector.ExtensionServer.prototype = { | 96 WebInspector.ExtensionServer.prototype = { |
| 94 initializeExtensions: function() | 97 initializeExtensions: function() |
| 95 { | 98 { |
| 96 this._initializeCommandIssued = true; | 99 this._initializeCommandIssued = true; |
| 97 if (this._pendingExtensionInfos) { | 100 if (this._pendingExtensionInfos) { |
| 98 this._pendingExtensionInfos.forEach(this._addExtension, this); | 101 this._pendingExtensionInfos.forEach(this._addExtension, this); |
| 99 delete this._pendingExtensionInfos; | 102 delete this._pendingExtensionInfos; |
| 100 } | 103 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked + identifier); | 146 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked + identifier); |
| 144 }, | 147 }, |
| 145 | 148 |
| 146 _inspectedURLChanged: function(event) | 149 _inspectedURLChanged: function(event) |
| 147 { | 150 { |
| 148 this._requests = {}; | 151 this._requests = {}; |
| 149 var url = event.data; | 152 var url = event.data; |
| 150 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url); | 153 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url); |
| 151 }, | 154 }, |
| 152 | 155 |
| 153 | |
| 154 /** | 156 /** |
| 155 * @param {string} categoryId | 157 * @param {string} categoryId |
| 156 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 158 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
| 157 */ | 159 */ |
| 158 startAuditRun: function(categoryId, auditResults) | 160 startAuditRun: function(categoryId, auditResults) |
| 159 { | 161 { |
| 160 this._clientObjects[auditResults.id()] = auditResults; | 162 this._clientObjects[auditResults.id()] = auditResults; |
| 161 this._postNotification("audit-started-" + categoryId, auditResults.id()) ; | 163 this._postNotification("audit-started-" + categoryId, auditResults.id()) ; |
| 162 }, | 164 }, |
| 163 | 165 |
| 164 /** | 166 /** |
|
caseq
2016/07/20 22:51:49
revert this one.
| |
| 165 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 167 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
| 166 */ | 168 */ |
| 167 stopAuditRun: function(auditResults) | 169 stopAuditRun: function(auditResults) |
| 168 { | 170 { |
| 169 delete this._clientObjects[auditResults.id()]; | 171 delete this._clientObjects[auditResults.id()]; |
| 170 }, | 172 }, |
| 171 | 173 |
| 172 /** | 174 /** |
| 175 * @param {string} traceProviderId | |
| 176 */ | |
| 177 startTraceRecording: function(traceProviderId) | |
| 178 { | |
| 179 this._postNotification("trace-recording-started-" + traceProviderId); | |
| 180 }, | |
| 181 | |
| 182 /** | |
| 183 * @param {string} traceProviderId | |
| 184 */ | |
| 185 stopTraceRecording: function(traceProviderId) | |
| 186 { | |
| 187 this._postNotification("trace-recording-stopped-" + traceProviderId); | |
| 188 }, | |
| 189 | |
| 190 /** | |
| 173 * @param {string} type | 191 * @param {string} type |
| 174 * @return {boolean} | 192 * @return {boolean} |
| 175 */ | 193 */ |
| 176 hasSubscribers: function(type) | 194 hasSubscribers: function(type) |
| 177 { | 195 { |
| 178 return !!this._subscribers[type]; | 196 return !!this._subscribers[type]; |
| 179 }, | 197 }, |
| 180 | 198 |
| 181 /** | 199 /** |
| 182 * @param {string} type | 200 * @param {string} type |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 }, | 593 }, |
| 576 | 594 |
| 577 _onAddAuditCategory: function(message, port) | 595 _onAddAuditCategory: function(message, port) |
| 578 { | 596 { |
| 579 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); | 597 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); |
| 580 this._clientObjects[message.id] = category; | 598 this._clientObjects[message.id] = category; |
| 581 this._auditCategories.push(category); | 599 this._auditCategories.push(category); |
| 582 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); | 600 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); |
| 583 }, | 601 }, |
| 584 | 602 |
| 603 _onAddTraceProvider: function(message, port) | |
|
alph
2016/07/21 17:06:23
nit: please annotate
| |
| 604 { | |
| 605 var provider = new WebInspector.ExtensionTraceProvider(port._extensionOr igin, message.id, message.categoryName, message.categoryTooltip); | |
| 606 this._clientObjects[message.id] = provider; | |
| 607 this._traceProviders.push(provider); | |
| 608 }, | |
| 609 | |
| 610 /** | |
| 611 * @return {!Array.<!WebInspector.ExtensionTraceProvider>} | |
|
caseq
2016/07/20 22:51:49
nit: drop ., just !Array<!WebInspector.ExtensionTr
| |
| 612 */ | |
| 613 traceProviders: function() | |
| 614 { | |
| 615 return this._traceProviders; | |
| 616 }, | |
| 617 | |
| 585 /** | 618 /** |
| 586 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} | 619 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} |
| 587 */ | 620 */ |
| 588 auditCategories: function() | 621 auditCategories: function() |
| 589 { | 622 { |
| 590 return this._auditCategories; | 623 return this._auditCategories; |
| 591 }, | 624 }, |
| 592 | 625 |
| 593 _onAddAuditResult: function(message) | 626 _onAddAuditResult: function(message) |
| 594 { | 627 { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 /** | 1106 /** |
| 1074 * @typedef {{code: string, description: string, details: !Array.<*>}} | 1107 * @typedef {{code: string, description: string, details: !Array.<*>}} |
| 1075 */ | 1108 */ |
| 1076 WebInspector.ExtensionStatus.Record; | 1109 WebInspector.ExtensionStatus.Record; |
| 1077 | 1110 |
| 1078 WebInspector.extensionAPI = {}; | 1111 WebInspector.extensionAPI = {}; |
| 1079 defineCommonExtensionSymbols(WebInspector.extensionAPI); | 1112 defineCommonExtensionSymbols(WebInspector.extensionAPI); |
| 1080 | 1113 |
| 1081 /** @type {!WebInspector.ExtensionServer} */ | 1114 /** @type {!WebInspector.ExtensionServer} */ |
| 1082 WebInspector.extensionServer; | 1115 WebInspector.extensionServer; |
| OLD | NEW |