| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 /** | 302 /** |
| 303 * @param {!WebInspector.Event} event | 303 * @param {!WebInspector.Event} event |
| 304 */ | 304 */ |
| 305 function onDisconnected(event) | 305 function onDisconnected(event) |
| 306 { | 306 { |
| 307 if (WebInspector._disconnectedScreenWithReasonWasShown) | 307 if (WebInspector._disconnectedScreenWithReasonWasShown) |
| 308 return; | 308 return; |
| 309 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason)
; | 309 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason)
; |
| 310 } | 310 } |
| 311 | 311 |
| 312 var targetType = WebInspector.Target.Type.Page; | 312 var capabilities = WebInspector.Target.Capability.Browser | WebInspector
.Target.Capability.JS | WebInspector.Target.Capability.Network | WebInspector.Ta
rget.Capability.Worker; |
| 313 if (Runtime.queryParam("isSharedWorker")) | 313 if (Runtime.queryParam("isSharedWorker")) |
| 314 targetType = WebInspector.Target.Type.ServiceWorker; | 314 capabilities = WebInspector.Target.Capability.Network | WebInspector
.Target.Capability.Worker; |
| 315 else if (Runtime.queryParam("v8only")) | 315 else if (Runtime.queryParam("v8only")) |
| 316 targetType = WebInspector.Target.Type.JSInspector; | 316 capabilities = WebInspector.Target.Capability.JS; |
| 317 | 317 |
| 318 this._mainTarget = WebInspector.targetManager.createTarget(WebInspector.
UIString("Main"), targetType, connection, null); | 318 this._mainTarget = WebInspector.targetManager.createTarget(WebInspector.
UIString("Main"), capabilities, connection, null); |
| 319 console.timeStamp("Main._mainTargetCreated"); | 319 console.timeStamp("Main._mainTargetCreated"); |
| 320 this._registerShortcuts(); | 320 this._registerShortcuts(); |
| 321 | 321 |
| 322 this._mainTarget.registerInspectorDispatcher(this); | 322 this._mainTarget.registerInspectorDispatcher(this); |
| 323 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E
vents.ReloadInspectedPage, this._reloadInspectedPage, this); | 323 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E
vents.ReloadInspectedPage, this._reloadInspectedPage, this); |
| 324 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E
vents.EvaluateForTestInFrontend, this._evaluateForTestInFrontend, this); | 324 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E
vents.EvaluateForTestInFrontend, this._evaluateForTestInFrontend, this); |
| 325 | 325 |
| 326 if (this._mainTarget.isServiceWorker() || this._mainTarget.isPage() || t
his._mainTarget.isJSInspector()) | 326 this._mainTarget.runtimeAgent().run(); |
| 327 this._mainTarget.runtimeAgent().run(); | |
| 328 | 327 |
| 329 this._mainTarget.inspectorAgent().enable(); | 328 this._mainTarget.inspectorAgent().enable(); |
| 330 InspectorFrontendHost.readyForTest(); | 329 InspectorFrontendHost.readyForTest(); |
| 331 | 330 |
| 332 // Asynchronously run the extensions. | 331 // Asynchronously run the extensions. |
| 333 setTimeout(lateInitialization, 0); | 332 setTimeout(lateInitialization, 0); |
| 334 | 333 |
| 335 function lateInitialization() | 334 function lateInitialization() |
| 336 { | 335 { |
| 337 console.timeStamp("Main.lateInitialization"); | 336 console.timeStamp("Main.lateInitialization"); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 686 } |
| 688 return false; | 687 return false; |
| 689 } | 688 } |
| 690 } | 689 } |
| 691 | 690 |
| 692 /** | 691 /** |
| 693 * @param {boolean} hard | 692 * @param {boolean} hard |
| 694 */ | 693 */ |
| 695 WebInspector.Main._reloadPage = function(hard) | 694 WebInspector.Main._reloadPage = function(hard) |
| 696 { | 695 { |
| 697 if (!WebInspector.targetManager.hasTargets()) | 696 var mainTarget = WebInspector.targetManager.mainTarget(); |
| 698 return; | 697 if (mainTarget && mainTarget.hasBrowserCapability()) |
| 699 if (WebInspector.targetManager.mainTarget().isServiceWorker()) | 698 WebInspector.targetManager.reloadPage(hard); |
| 700 return; | |
| 701 WebInspector.targetManager.reloadPage(hard); | |
| 702 } | 699 } |
| 703 | 700 |
| 704 /** | 701 /** |
| 705 * @param {string} ws | |
| 706 */ | |
| 707 WebInspector.Main._addWebSocketTarget = function(ws) | |
| 708 { | |
| 709 /** | |
| 710 * @param {!InspectorBackendClass.Connection} connection | |
| 711 */ | |
| 712 function callback(connection) | |
| 713 { | |
| 714 WebInspector.targetManager.createTarget(ws, WebInspector.Target.Type.Pag
e, connection, null); | |
| 715 } | |
| 716 new WebInspector.WebSocketConnection(ws, callback); | |
| 717 } | |
| 718 | |
| 719 /** | |
| 720 * @constructor | 702 * @constructor |
| 721 * @implements {WebInspector.ToolbarItem.Provider} | 703 * @implements {WebInspector.ToolbarItem.Provider} |
| 722 */ | 704 */ |
| 723 WebInspector.Main.WarningErrorCounter = function() | 705 WebInspector.Main.WarningErrorCounter = function() |
| 724 { | 706 { |
| 725 WebInspector.Main.WarningErrorCounter._instanceForTest = this; | 707 WebInspector.Main.WarningErrorCounter._instanceForTest = this; |
| 726 | 708 |
| 727 this._counter = createElement("div"); | 709 this._counter = createElement("div"); |
| 728 this._counter.addEventListener("click", WebInspector.console.show.bind(WebIn
spector.console), false); | 710 this._counter.addEventListener("click", WebInspector.console.show.bind(WebIn
spector.console), false); |
| 729 this._toolbarItem = new WebInspector.ToolbarItem(this._counter); | 711 this._toolbarItem = new WebInspector.ToolbarItem(this._counter); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 * @implements {WebInspector.TargetManager.Observer} | 1031 * @implements {WebInspector.TargetManager.Observer} |
| 1050 */ | 1032 */ |
| 1051 WebInspector.BackendSettingsSync = function() | 1033 WebInspector.BackendSettingsSync = function() |
| 1052 { | 1034 { |
| 1053 this._autoAttachSetting = WebInspector.settings.moduleSetting("autoAttachToC
reatedPages"); | 1035 this._autoAttachSetting = WebInspector.settings.moduleSetting("autoAttachToC
reatedPages"); |
| 1054 this._autoAttachSetting.addChangeListener(this._update, this); | 1036 this._autoAttachSetting.addChangeListener(this._update, this); |
| 1055 this._disableJavascriptSetting = WebInspector.settings.moduleSetting("javaSc
riptDisabled"); | 1037 this._disableJavascriptSetting = WebInspector.settings.moduleSetting("javaSc
riptDisabled"); |
| 1056 this._disableJavascriptSetting.addChangeListener(this._update, this); | 1038 this._disableJavascriptSetting.addChangeListener(this._update, this); |
| 1057 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting("blo
ckedEventsWarningEnabled"); | 1039 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting("blo
ckedEventsWarningEnabled"); |
| 1058 this._blockedEventsWarningSetting.addChangeListener(this._update, this); | 1040 this._blockedEventsWarningSetting.addChangeListener(this._update, this); |
| 1059 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); | 1041 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 1060 } | 1042 } |
| 1061 | 1043 |
| 1062 WebInspector.BackendSettingsSync.prototype = { | 1044 WebInspector.BackendSettingsSync.prototype = { |
| 1063 /** | 1045 /** |
| 1064 * @param {!WebInspector.Target} target | 1046 * @param {!WebInspector.Target} target |
| 1065 */ | 1047 */ |
| 1066 _updateTarget: function(target) | 1048 _updateTarget: function(target) |
| 1067 { | 1049 { |
| 1068 var blockedEventsWarningThresholdSeconds = 0.1; | 1050 var blockedEventsWarningThresholdSeconds = 0.1; |
| 1069 target.pageAgent().setBlockedEventsWarningThreshold(this._blockedEventsW
arningSetting.get() ? blockedEventsWarningThresholdSeconds : 0); | 1051 target.pageAgent().setBlockedEventsWarningThreshold(this._blockedEventsW
arningSetting.get() ? blockedEventsWarningThresholdSeconds : 0); |
| 1070 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.g
et()); | 1052 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.g
et()); |
| 1071 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascri
ptSetting.get()); | 1053 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascri
ptSetting.get()); |
| 1072 }, | 1054 }, |
| 1073 | 1055 |
| 1074 _update: function() | 1056 _update: function() |
| 1075 { | 1057 { |
| 1076 WebInspector.targetManager.targets(WebInspector.Target.Type.Page).forEac
h(this._updateTarget, this); | 1058 WebInspector.targetManager.targets(WebInspector.Target.Capability.Browse
r).forEach(this._updateTarget, this); |
| 1077 }, | 1059 }, |
| 1078 | 1060 |
| 1079 /** | 1061 /** |
| 1080 * @param {!WebInspector.Target} target | 1062 * @param {!WebInspector.Target} target |
| 1081 * @override | 1063 * @override |
| 1082 */ | 1064 */ |
| 1083 targetAdded: function(target) | 1065 targetAdded: function(target) |
| 1084 { | 1066 { |
| 1085 this._updateTarget(target); | 1067 this._updateTarget(target); |
| 1086 target.renderingAgent().setShowViewportSizeOnResize(true); | 1068 target.renderingAgent().setShowViewportSizeOnResize(true); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1109 * @return {?Element} | 1091 * @return {?Element} |
| 1110 */ | 1092 */ |
| 1111 settingElement: function() | 1093 settingElement: function() |
| 1112 { | 1094 { |
| 1113 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri
ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); | 1095 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri
ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); |
| 1114 } | 1096 } |
| 1115 } | 1097 } |
| 1116 | 1098 |
| 1117 | 1099 |
| 1118 new WebInspector.Main(); | 1100 new WebInspector.Main(); |
| OLD | NEW |