OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 apiPrivate.panels = {}; | 44 apiPrivate.panels = {}; |
45 apiPrivate.panels.SearchAction = { | 45 apiPrivate.panels.SearchAction = { |
46 CancelSearch: "cancelSearch", | 46 CancelSearch: "cancelSearch", |
47 PerformSearch: "performSearch", | 47 PerformSearch: "performSearch", |
48 NextSearchResult: "nextSearchResult", | 48 NextSearchResult: "nextSearchResult", |
49 PreviousSearchResult: "previousSearchResult" | 49 PreviousSearchResult: "previousSearchResult" |
50 }; | 50 }; |
51 | 51 |
52 apiPrivate.Events = { | 52 apiPrivate.Events = { |
53 AuditStarted: "audit-started-", | 53 AuditStarted: "audit-started-", |
| 54 RecordingStarted: "trace-recording-started-", |
| 55 RecordingStopped: "trace-recording-stopped-", |
54 ButtonClicked: "button-clicked-", | 56 ButtonClicked: "button-clicked-", |
55 PanelObjectSelected: "panel-objectSelected-", | 57 PanelObjectSelected: "panel-objectSelected-", |
56 NetworkRequestFinished: "network-request-finished", | 58 NetworkRequestFinished: "network-request-finished", |
57 OpenResource: "open-resource", | 59 OpenResource: "open-resource", |
58 PanelSearch: "panel-search-", | 60 PanelSearch: "panel-search-", |
59 ResourceAdded: "resource-added", | 61 ResourceAdded: "resource-added", |
60 ResourceContentCommitted: "resource-content-committed", | 62 ResourceContentCommitted: "resource-content-committed", |
61 ViewShown: "view-shown-", | 63 ViewShown: "view-shown-", |
62 ViewHidden: "view-hidden-" | 64 ViewHidden: "view-hidden-" |
63 }; | 65 }; |
64 | 66 |
65 apiPrivate.Commands = { | 67 apiPrivate.Commands = { |
66 AddAuditCategory: "addAuditCategory", | 68 AddAuditCategory: "addAuditCategory", |
67 AddAuditResult: "addAuditResult", | 69 AddAuditResult: "addAuditResult", |
68 AddRequestHeaders: "addRequestHeaders", | 70 AddRequestHeaders: "addRequestHeaders", |
| 71 AddTraceProvider: "addTraceProvider", |
| 72 AddTraceData: "addTraceData", |
69 ApplyStyleSheet: "applyStyleSheet", | 73 ApplyStyleSheet: "applyStyleSheet", |
70 CreatePanel: "createPanel", | 74 CreatePanel: "createPanel", |
71 CreateSidebarPane: "createSidebarPane", | 75 CreateSidebarPane: "createSidebarPane", |
72 CreateToolbarButton: "createToolbarButton", | 76 CreateToolbarButton: "createToolbarButton", |
73 EvaluateOnInspectedPage: "evaluateOnInspectedPage", | 77 EvaluateOnInspectedPage: "evaluateOnInspectedPage", |
74 ForwardKeyboardEvent: "_forwardKeyboardEvent", | 78 ForwardKeyboardEvent: "_forwardKeyboardEvent", |
75 GetHAR: "getHAR", | 79 GetHAR: "getHAR", |
76 GetPageResources: "getPageResources", | 80 GetPageResources: "getPageResources", |
77 GetRequestContent: "getRequestContent", | 81 GetRequestContent: "getRequestContent", |
78 GetResourceContent: "getResourceContent", | 82 GetResourceContent: "getResourceContent", |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 this._fire.apply(this, request.arguments); | 171 this._fire.apply(this, request.arguments); |
168 } | 172 } |
169 } | 173 } |
170 | 174 |
171 /** | 175 /** |
172 * @constructor | 176 * @constructor |
173 */ | 177 */ |
174 function InspectorExtensionAPI() | 178 function InspectorExtensionAPI() |
175 { | 179 { |
176 this.audits = new Audits(); | 180 this.audits = new Audits(); |
| 181 this.timeline = new Timeline(); |
177 this.inspectedWindow = new InspectedWindow(); | 182 this.inspectedWindow = new InspectedWindow(); |
178 this.panels = new Panels(); | 183 this.panels = new Panels(); |
179 this.network = new Network(); | 184 this.network = new Network(); |
180 defineDeprecatedProperty(this, "webInspector", "resources", "network"); | 185 defineDeprecatedProperty(this, "webInspector", "resources", "network"); |
181 } | 186 } |
182 | 187 |
183 /** | 188 /** |
184 * @constructor | 189 * @constructor |
185 */ | 190 */ |
186 function Network() | 191 function Network() |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 409 } |
405 | 410 |
406 function extractCallbackArgument(args) | 411 function extractCallbackArgument(args) |
407 { | 412 { |
408 var lastArgument = args[args.length - 1]; | 413 var lastArgument = args[args.length - 1]; |
409 return typeof lastArgument === "function" ? lastArgument : undefined; | 414 return typeof lastArgument === "function" ? lastArgument : undefined; |
410 } | 415 } |
411 | 416 |
412 var AuditCategory = declareInterfaceClass(AuditCategoryImpl); | 417 var AuditCategory = declareInterfaceClass(AuditCategoryImpl); |
413 var AuditResult = declareInterfaceClass(AuditResultImpl); | 418 var AuditResult = declareInterfaceClass(AuditResultImpl); |
| 419 var TraceData = declareInterfaceClass(TraceDataImpl); |
414 var Button = declareInterfaceClass(ButtonImpl); | 420 var Button = declareInterfaceClass(ButtonImpl); |
415 var EventSink = declareInterfaceClass(EventSinkImpl); | 421 var EventSink = declareInterfaceClass(EventSinkImpl); |
416 var ExtensionPanel = declareInterfaceClass(ExtensionPanelImpl); | 422 var ExtensionPanel = declareInterfaceClass(ExtensionPanelImpl); |
417 var ExtensionSidebarPane = declareInterfaceClass(ExtensionSidebarPaneImpl); | 423 var ExtensionSidebarPane = declareInterfaceClass(ExtensionSidebarPaneImpl); |
418 var PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl); | 424 var PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl); |
419 var Request = declareInterfaceClass(RequestImpl); | 425 var Request = declareInterfaceClass(RequestImpl); |
420 var Resource = declareInterfaceClass(ResourceImpl); | 426 var Resource = declareInterfaceClass(ResourceImpl); |
421 | 427 |
422 /** | 428 /** |
423 * @constructor | 429 * @constructor |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 tooltip: tooltipText, | 552 tooltip: tooltipText, |
547 disabled: !!disabled | 553 disabled: !!disabled |
548 }; | 554 }; |
549 extensionServer.sendRequest(request); | 555 extensionServer.sendRequest(request); |
550 } | 556 } |
551 }; | 557 }; |
552 | 558 |
553 /** | 559 /** |
554 * @constructor | 560 * @constructor |
555 */ | 561 */ |
| 562 function Timeline() |
| 563 { |
| 564 } |
| 565 |
| 566 Timeline.prototype = { |
| 567 /** |
| 568 * @param {string} categoryName |
| 569 * @param {string} categoryTooltip |
| 570 * @return {!TraceProvider} |
| 571 */ |
| 572 addTraceProvider: function(categoryName, categoryTooltip) |
| 573 { |
| 574 var id = "extension-timeline-category-" + extensionServer.nextObjectId()
; |
| 575 extensionServer.sendRequest({ command: commands.AddTraceProvider, id: id
, categoryName: categoryName, categoryTooltip: categoryTooltip}); |
| 576 return new TraceProvider(id); |
| 577 } |
| 578 } |
| 579 |
| 580 /** |
| 581 * @constructor |
| 582 */ |
| 583 function TraceProvider(id) |
| 584 { |
| 585 /** |
| 586 * @this {EventSinkImpl} |
| 587 */ |
| 588 function dispatchRecordingStoppedEvent(request) |
| 589 { |
| 590 var traceData = new TraceData(request.arguments[0], id); |
| 591 try { |
| 592 this._fire(traceData); |
| 593 } catch (e) { |
| 594 console.error("Uncaught exception in extension recording stopped eve
nt handler: " + e); |
| 595 } |
| 596 } |
| 597 this.onRecordingStarted = new EventSink(events.RecordingStarted + id); |
| 598 this.onRecordingStopped = new EventSink(events.RecordingStopped + id, dispat
chRecordingStoppedEvent); |
| 599 } |
| 600 |
| 601 /** |
| 602 * @constructor |
| 603 */ |
| 604 function TraceDataImpl(id, traceProviderId) |
| 605 { |
| 606 this._id = id; |
| 607 this._traceProviderId = traceProviderId; |
| 608 } |
| 609 |
| 610 TraceDataImpl.prototype = { |
| 611 addTraceData: function(threadName, events) |
| 612 { |
| 613 var request = { |
| 614 command: commands.AddTraceData, |
| 615 dataId: this._id, |
| 616 threadName: threadName, |
| 617 events: events, |
| 618 traceProviderId: this._traceProviderId, |
| 619 }; |
| 620 extensionServer.sendRequest(request); |
| 621 } |
| 622 } |
| 623 |
| 624 /** |
| 625 * @constructor |
| 626 */ |
556 function Audits() | 627 function Audits() |
557 { | 628 { |
558 } | 629 } |
559 | 630 |
560 Audits.prototype = { | 631 Audits.prototype = { |
561 /** | 632 /** |
562 * @return {!AuditCategory} | 633 * @return {!AuditCategory} |
563 */ | 634 */ |
564 addCategory: function(displayName, resultCount) | 635 addCategory: function(displayName, resultCount) |
565 { | 636 { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 { | 1086 { |
1016 return "(function(injectedScriptId){ " + | 1087 return "(function(injectedScriptId){ " + |
1017 "var extensionServer;" + | 1088 "var extensionServer;" + |
1018 defineCommonExtensionSymbols.toString() + ";" + | 1089 defineCommonExtensionSymbols.toString() + ";" + |
1019 injectedExtensionAPI.toString() + ";" + | 1090 injectedExtensionAPI.toString() + ";" + |
1020 buildPlatformExtensionAPI(extensionInfo, inspectedTabId) + ";" + | 1091 buildPlatformExtensionAPI(extensionInfo, inspectedTabId) + ";" + |
1021 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + | 1092 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + |
1022 "return {};" + | 1093 "return {};" + |
1023 "})"; | 1094 "})"; |
1024 } | 1095 } |
OLD | NEW |