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", |
94 TraceProviderAdded: "TraceProviderAdded" | |
91 } | 95 } |
92 | 96 |
93 WebInspector.ExtensionServer.prototype = { | 97 WebInspector.ExtensionServer.prototype = { |
94 initializeExtensions: function() | 98 initializeExtensions: function() |
95 { | 99 { |
96 this._initializeCommandIssued = true; | 100 this._initializeCommandIssued = true; |
97 if (this._pendingExtensionInfos) { | 101 if (this._pendingExtensionInfos) { |
98 this._pendingExtensionInfos.forEach(this._addExtension, this); | 102 this._pendingExtensionInfos.forEach(this._addExtension, this); |
99 delete this._pendingExtensionInfos; | 103 delete this._pendingExtensionInfos; |
100 } | 104 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked + identifier); | 147 this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked + identifier); |
144 }, | 148 }, |
145 | 149 |
146 _inspectedURLChanged: function(event) | 150 _inspectedURLChanged: function(event) |
147 { | 151 { |
148 this._requests = {}; | 152 this._requests = {}; |
149 var url = event.data; | 153 var url = event.data; |
150 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url); | 154 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url); |
151 }, | 155 }, |
152 | 156 |
153 | |
154 /** | 157 /** |
155 * @param {string} categoryId | 158 * @param {string} categoryId |
156 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 159 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
157 */ | 160 */ |
158 startAuditRun: function(categoryId, auditResults) | 161 startAuditRun: function(categoryId, auditResults) |
159 { | 162 { |
160 this._clientObjects[auditResults.id()] = auditResults; | 163 this._clientObjects[auditResults.id()] = auditResults; |
161 this._postNotification("audit-started-" + categoryId, auditResults.id()) ; | 164 this._postNotification("audit-started-" + categoryId, auditResults.id()) ; |
162 }, | 165 }, |
163 | 166 |
164 /** | 167 /** |
168 * @param {string} traceProviderId | |
169 */ | |
170 startTraceRecording: function(traceProviderId) | |
171 { | |
172 this._postNotification("trace-recording-started-" + traceProviderId); | |
173 }, | |
174 | |
175 /** | |
165 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults | 176 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults |
166 */ | 177 */ |
167 stopAuditRun: function(auditResults) | 178 stopAuditRun: function(auditResults) |
168 { | 179 { |
169 delete this._clientObjects[auditResults.id()]; | 180 delete this._clientObjects[auditResults.id()]; |
170 }, | 181 }, |
171 | 182 |
172 /** | 183 /** |
184 * @param {string} traceProviderId | |
185 */ | |
186 stopTraceRecording: function(traceProviderId) | |
caseq
2016/07/19 22:01:16
nit: please group together with startTraceRecordin
| |
187 { | |
188 this._postNotification("trace-recording-stopped-" + traceProviderId); | |
189 }, | |
190 | |
191 /** | |
173 * @param {string} type | 192 * @param {string} type |
174 * @return {boolean} | 193 * @return {boolean} |
175 */ | 194 */ |
176 hasSubscribers: function(type) | 195 hasSubscribers: function(type) |
177 { | 196 { |
178 return !!this._subscribers[type]; | 197 return !!this._subscribers[type]; |
179 }, | 198 }, |
180 | 199 |
181 /** | 200 /** |
182 * @param {string} type | 201 * @param {string} type |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 }, | 594 }, |
576 | 595 |
577 _onAddAuditCategory: function(message, port) | 596 _onAddAuditCategory: function(message, port) |
578 { | 597 { |
579 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); | 598 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); |
580 this._clientObjects[message.id] = category; | 599 this._clientObjects[message.id] = category; |
581 this._auditCategories.push(category); | 600 this._auditCategories.push(category); |
582 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); | 601 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); |
583 }, | 602 }, |
584 | 603 |
604 _onAddTraceProvider: function(message, port) | |
605 { | |
606 var provider = new WebInspector.ExtensionTraceProvider(port._extensionOr igin, message.id, message.categoryName, message.categoryTooltip); | |
607 this._clientObjects[message.id] = provider; | |
608 this._traceProviders.push(provider); | |
609 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.TraceP roviderAdded, provider); | |
caseq
2016/07/19 22:01:16
is this used?
| |
610 }, | |
611 | |
612 /** | |
613 * @return {!Array.<!WebInspector.ExtensionTraceProvider>} | |
614 */ | |
615 traceProviders: function() | |
616 { | |
617 return this._traceProviders; | |
618 }, | |
619 | |
585 /** | 620 /** |
586 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} | 621 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} |
587 */ | 622 */ |
588 auditCategories: function() | 623 auditCategories: function() |
589 { | 624 { |
590 return this._auditCategories; | 625 return this._auditCategories; |
591 }, | 626 }, |
592 | 627 |
593 _onAddAuditResult: function(message) | 628 _onAddAuditResult: function(message) |
594 { | 629 { |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 /** | 1108 /** |
1074 * @typedef {{code: string, description: string, details: !Array.<*>}} | 1109 * @typedef {{code: string, description: string, details: !Array.<*>}} |
1075 */ | 1110 */ |
1076 WebInspector.ExtensionStatus.Record; | 1111 WebInspector.ExtensionStatus.Record; |
1077 | 1112 |
1078 WebInspector.extensionAPI = {}; | 1113 WebInspector.extensionAPI = {}; |
1079 defineCommonExtensionSymbols(WebInspector.extensionAPI); | 1114 defineCommonExtensionSymbols(WebInspector.extensionAPI); |
1080 | 1115 |
1081 /** @type {!WebInspector.ExtensionServer} */ | 1116 /** @type {!WebInspector.ExtensionServer} */ |
1082 WebInspector.extensionServer; | 1117 WebInspector.extensionServer; |
OLD | NEW |