| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 * @param {!WebInspector.QueryParamHandler} handler | 245 * @param {!WebInspector.QueryParamHandler} handler |
| 246 */ | 246 */ |
| 247 function handleQueryParam(value, handler) | 247 function handleQueryParam(value, handler) |
| 248 { | 248 { |
| 249 handler.handleQueryParam(value); | 249 handler.handleQueryParam(value); |
| 250 } | 250 } |
| 251 | 251 |
| 252 this._appUIShown = true; | 252 this._appUIShown = true; |
| 253 if (this._fileSystemManagerInitialized) { | 253 if (this._fileSystemManagerInitialized) { |
| 254 // Allow UI cycles to repaint prior to creating connection. | 254 // Allow UI cycles to repaint prior to creating connection. |
| 255 setTimeout(this._connectAndCreateTarget.bind(this), 0); | 255 setTimeout(this._initializeTarget.bind(this), 0); |
| 256 } | 256 } |
| 257 console.timeEnd("Main._showAppUI"); | 257 console.timeEnd("Main._showAppUI"); |
| 258 }, | 258 }, |
| 259 | 259 |
| 260 _didInitializeFileSystemManager: function() | 260 _didInitializeFileSystemManager: function() |
| 261 { | 261 { |
| 262 this._fileSystemManagerInitialized = true; | 262 this._fileSystemManagerInitialized = true; |
| 263 if (this._appUIShown) | 263 if (this._appUIShown) |
| 264 this._connectAndCreateTarget(); | 264 this._initializeTarget(); |
| 265 }, |
| 266 |
| 267 _initializeTarget: function() |
| 268 { |
| 269 this._connectAndCreateTarget(); |
| 270 InspectorFrontendHost.readyForTest(); |
| 271 WebInspector.targetManager.setMainConnectionInterceptor(this._interceptM
ainConnection.bind(this)); |
| 272 // Asynchronously run the extensions. |
| 273 setTimeout(this._lateInitialization.bind(this), 100); |
| 265 }, | 274 }, |
| 266 | 275 |
| 267 _connectAndCreateTarget: function() | 276 _connectAndCreateTarget: function() |
| 268 { | 277 { |
| 269 console.time("Main._connectAndCreateTarget"); | 278 console.time("Main._connectAndCreateTarget"); |
| 270 this._createConnection().then(connection => { | |
| 271 this._createMainTarget(connection); | |
| 272 InspectorFrontendHost.readyForTest(); | |
| 273 WebInspector.targetManager.setMainTargetFactory(this._recreateMainTa
rget.bind(this)); | |
| 274 // Asynchronously run the extensions. | |
| 275 console.timeEnd("Main._connectAndCreateTarget"); | |
| 276 setTimeout(this._lateInitialization.bind(this), 100); | |
| 277 }); | |
| 278 }, | |
| 279 | 279 |
| 280 _recreateMainTarget: function() | |
| 281 { | |
| 282 this._createConnection().then(this._createMainTarget.bind(this)); | |
| 283 }, | |
| 284 | |
| 285 /** | |
| 286 * @return {!Promise<!InspectorBackendClass.Connection>} | |
| 287 */ | |
| 288 _createConnection: function() | |
| 289 { | |
| 290 if (Runtime.queryParam("ws")) { | |
| 291 var ws = "ws://" + Runtime.queryParam("ws"); | |
| 292 return WebInspector.WebSocketConnection.Create(ws).then(connection =
> { | |
| 293 connection.addEventListener(InspectorBackendClass.Connection.Eve
nts.Disconnected, onDisconnected); | |
| 294 return connection; | |
| 295 }); | |
| 296 } | |
| 297 | |
| 298 return /** @type {!Promise<!InspectorBackendClass.Connection>} */ (Promi
se.resolve(InspectorFrontendHost.isHostedMode() ? | |
| 299 new WebInspector.StubConnection() : new WebInspector.MainConnection(
))); | |
| 300 | |
| 301 /** | |
| 302 * @param {!WebInspector.Event} event | |
| 303 */ | |
| 304 function onDisconnected(event) | |
| 305 { | |
| 306 if (WebInspector._disconnectedScreenWithReasonWasShown) | |
| 307 return; | |
| 308 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason)
; | |
| 309 } | |
| 310 }, | |
| 311 | |
| 312 /** | |
| 313 * @param {!InspectorBackendClass.Connection} connection | |
| 314 */ | |
| 315 _createMainTarget: function(connection) | |
| 316 { | |
| 317 console.time("Main._createMainTarget"); | |
| 318 var capabilities = | 280 var capabilities = |
| 319 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil
ity.DOM | | 281 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil
ity.DOM | |
| 320 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L
og | | 282 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L
og | |
| 321 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil
ity.Worker; | 283 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil
ity.Worker; |
| 322 if (Runtime.queryParam("isSharedWorker")) { | 284 if (Runtime.queryParam("isSharedWorker")) { |
| 323 capabilities = | 285 capabilities = |
| 324 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap
ability.Log | | 286 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap
ability.Log | |
| 325 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Worker; | 287 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Worker; |
| 326 } else if (Runtime.queryParam("v8only")) { | 288 } else if (Runtime.queryParam("v8only")) { |
| 327 capabilities = WebInspector.Target.Capability.JS; | 289 capabilities = WebInspector.Target.Capability.JS; |
| 328 } | 290 } |
| 329 | 291 |
| 330 var target = WebInspector.targetManager.createTarget(WebInspector.UIStri
ng("Main"), capabilities, connection, null); | 292 var target = WebInspector.targetManager.createTarget(WebInspector.UIStri
ng("Main"), capabilities, this._createMainConnection.bind(this), null); |
| 331 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain
Dispatcher(target)); | 293 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain
Dispatcher(target)); |
| 332 target.runtimeAgent().runIfWaitingForDebugger(); | 294 target.runtimeAgent().runIfWaitingForDebugger(); |
| 333 if (target.hasBrowserCapability()) | 295 if (target.hasBrowserCapability()) |
| 334 target.inspectorAgent().enable(); | 296 target.inspectorAgent().enable(); |
| 335 console.timeEnd("Main._createMainTarget"); | 297 |
| 298 console.timeEnd("Main._connectAndCreateTarget"); |
| 299 }, |
| 300 |
| 301 /** |
| 302 * @param {function(string)} onMessage |
| 303 * @return {!Promise<!InspectorBackendClass.Connection>} |
| 304 */ |
| 305 _interceptMainConnection: function(onMessage) |
| 306 { |
| 307 var params = { |
| 308 onMessage: onMessage, |
| 309 onDisconnect: this._connectAndCreateTarget.bind(this) |
| 310 }; |
| 311 return this._connection.disconnect().then(this._createMainConnection.bin
d(this, params)); |
| 312 }, |
| 313 |
| 314 /** |
| 315 * @param {!InspectorBackendClass.Connection.Params} params |
| 316 * @return {!InspectorBackendClass.Connection} |
| 317 */ |
| 318 _createMainConnection: function(params) |
| 319 { |
| 320 if (Runtime.queryParam("ws")) { |
| 321 var ws = "ws://" + Runtime.queryParam("ws"); |
| 322 params.onDisconnect = onDisconnect.bind(null, params.onDisconnect); |
| 323 this._connection = new WebInspector.WebSocketConnection(ws, params); |
| 324 } else if (InspectorFrontendHost.isHostedMode()) { |
| 325 this._connection = new WebInspector.StubConnection(params); |
| 326 } else { |
| 327 this._connection = new WebInspector.MainConnection(params); |
| 328 } |
| 329 return this._connection; |
| 330 |
| 331 /** |
| 332 * @param {function(string)} callback |
| 333 * @param {string} reason |
| 334 */ |
| 335 function onDisconnect(callback, reason) |
| 336 { |
| 337 if (!WebInspector._disconnectedScreenWithReasonWasShown) |
| 338 WebInspector.RemoteDebuggingTerminatedScreen.show(reason); |
| 339 callback(reason); |
| 340 } |
| 336 }, | 341 }, |
| 337 | 342 |
| 338 _lateInitialization: function() | 343 _lateInitialization: function() |
| 339 { | 344 { |
| 340 console.timeStamp("Main._lateInitialization"); | 345 console.timeStamp("Main._lateInitialization"); |
| 341 this._registerShortcuts(); | 346 this._registerShortcuts(); |
| 342 WebInspector.extensionServer.initializeExtensions(); | 347 WebInspector.extensionServer.initializeExtensions(); |
| 343 }, | 348 }, |
| 344 | 349 |
| 345 _registerForwardedShortcuts: function() | 350 _registerForwardedShortcuts: function() |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 } | 951 } |
| 947 }; | 952 }; |
| 948 | 953 |
| 949 /** | 954 /** |
| 950 * @param {string} method | 955 * @param {string} method |
| 951 * @param {?Object} params | 956 * @param {?Object} params |
| 952 * @return {!Promise} | 957 * @return {!Promise} |
| 953 */ | 958 */ |
| 954 WebInspector.sendOverProtocol = function(method, params) | 959 WebInspector.sendOverProtocol = function(method, params) |
| 955 { | 960 { |
| 956 var connection = WebInspector.targetManager.mainTarget().connection(); | |
| 957 return new Promise((resolve, reject) => { | 961 return new Promise((resolve, reject) => { |
| 958 connection.sendRawMessageForTesting(method, params, (err, result) => { | 962 InspectorBackendClass.sendRawMessageForTesting(method, params, (err, res
ult) => { |
| 959 if (err) | 963 if (err) |
| 960 return reject(err); | 964 return reject(err); |
| 961 return resolve(result); | 965 return resolve(result); |
| 962 }); | 966 }); |
| 963 }); | 967 }); |
| 964 }; | 968 }; |
| 965 | 969 |
| 966 /** | 970 /** |
| 967 * @constructor | 971 * @constructor |
| 968 * @extends {WebInspector.VBox} | 972 * @extends {WebInspector.VBox} |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 * @override | 1112 * @override |
| 1109 * @return {?Element} | 1113 * @return {?Element} |
| 1110 */ | 1114 */ |
| 1111 settingElement: function() | 1115 settingElement: function() |
| 1112 { | 1116 { |
| 1113 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri
ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); | 1117 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri
ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); |
| 1114 } | 1118 } |
| 1115 }; | 1119 }; |
| 1116 | 1120 |
| 1117 new WebInspector.Main(); | 1121 new WebInspector.Main(); |
| OLD | NEW |