Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: Source/devtools/front_end/main/Main.js

Issue 392603002: DevTools: refactoring connection creation, removing a couple of dead code branches. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 _debuggerPaused: function() 184 _debuggerPaused: function()
185 { 185 {
186 WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerMode l.Events.DebuggerPaused, this._debuggerPaused, this); 186 WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerMode l.Events.DebuggerPaused, this._debuggerPaused, this);
187 WebInspector.inspectorView.showPanel("sources"); 187 WebInspector.inspectorView.showPanel("sources");
188 }, 188 },
189 189
190 _loaded: function() 190 _loaded: function()
191 { 191 {
192 console.timeStamp("Main._loaded"); 192 console.timeStamp("Main._loaded");
193 WebInspector.moduleManager = new WebInspector.ModuleManager(allDescripto rs); 193 WebInspector.moduleManager = new WebInspector.ModuleManager(allDescripto rs);
194
195 // FIXME: Make toolbox a real app.
194 if (WebInspector.queryParam("toolbox")) { 196 if (WebInspector.queryParam("toolbox")) {
195 new WebInspector.Toolbox(); 197 new WebInspector.Toolbox();
196 return; 198 return;
197 } 199 }
198 200
201 this._createSettings();
202 this._createConnection();
203 },
204
205 _createSettings: function()
206 {
199 WebInspector.settings = new WebInspector.Settings(); 207 WebInspector.settings = new WebInspector.Settings();
200 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings( WebInspector.queryParam("experiments") !== null); 208 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings( WebInspector.queryParam("experiments") !== null);
201 // This setting is needed for backwards compatibility with Devtools Code School extension. DO NOT REMOVE 209 // This setting is needed for backwards compatibility with Devtools Code School extension. DO NOT REMOVE
202 WebInspector.settings.pauseOnExceptionStateString = new WebInspector.Pau seOnExceptionStateSetting(); 210 WebInspector.settings.pauseOnExceptionStateString = new WebInspector.Pau seOnExceptionStateSetting();
211 new WebInspector.VersionController().updateVersion();
212 },
203 213
204 if (!InspectorFrontendHost.sendMessageToEmbedder) { 214 _createConnection: function()
205 var helpScreen = new WebInspector.HelpScreen(WebInspector.UIString(" Incompatible Chrome version")); 215 {
206 var p = helpScreen.contentElement.createChild("p", "help-section"); 216 InspectorBackend.loadFromJSONIfNeeded("../protocol.json");
207 p.textContent = WebInspector.UIString("Please upgrade to a newer Chr ome version (you might need a Dev or Canary build)."); 217
208 helpScreen.showModal(); 218 var workerId = WebInspector.queryParam("dedicatedWorkerId");
219 if (workerId) {
220 this._connectionEstablished(new WebInspector.ExternalWorkerConnectio n(workerId));
209 return; 221 return;
210 } 222 }
211 223
212 InspectorBackend.loadFromJSONIfNeeded("../protocol.json");
213
214 var onConnectionReady = this._doLoadedDone.bind(this);
215
216 var workerId = WebInspector.queryParam("dedicatedWorkerId");
217 if (workerId) {
218 new WebInspector.ExternalWorkerConnection(workerId, onConnectionRead y);
219 return;
220 }
221
222 var ws;
223 if (WebInspector.queryParam("ws")) { 224 if (WebInspector.queryParam("ws")) {
224 ws = "ws://" + WebInspector.queryParam("ws"); 225 var ws = "ws://" + WebInspector.queryParam("ws");
225 } else if (WebInspector.queryParam("page")) {
226 var page = WebInspector.queryParam("page");
227 var host = WebInspector.queryParam("host") || window.location.host;
228 ws = "ws://" + host + "/devtools/page/" + page;
229 }
230
231 if (ws) {
232 document.body.classList.add("remote"); 226 document.body.classList.add("remote");
233 new InspectorBackendClass.WebSocketConnection(ws, onConnectionReady) ; 227 InspectorBackendClass.WebSocketConnection.Create(ws, this._connectio nEstablished.bind(this));
234 return; 228 return;
235 } 229 }
236 230
237 if (!InspectorFrontendHost.isStub()) { 231 if (!InspectorFrontendHost.isStub()) {
238 new InspectorBackendClass.MainConnection(onConnectionReady); 232 this._connectionEstablished(new InspectorBackendClass.MainConnection ());
239 return; 233 return;
240 } 234 }
241 235
242 new InspectorBackendClass.StubConnection(onConnectionReady); 236 this._connectionEstablished(new InspectorBackendClass.StubConnection());
243 }, 237 },
244 238
245 /** 239 /**
246 * @param {!InspectorBackendClass.Connection} connection 240 * @param {!InspectorBackendClass.Connection} connection
247 */ 241 */
248 _doLoadedDone: function(connection) 242 _connectionEstablished: function(connection)
249 { 243 {
250 console.timeStamp("Main._doLoadedDone"); 244 console.timeStamp("Main._connectionEstablished");
251 connection.addEventListener(InspectorBackendClass.Connection.Events.Disc onnected, onDisconnected); 245 connection.addEventListener(InspectorBackendClass.Connection.Events.Disc onnected, onDisconnected);
252 246
253 /** 247 /**
254 * @param {!WebInspector.Event} event 248 * @param {!WebInspector.Event} event
255 */ 249 */
256 function onDisconnected(event) 250 function onDisconnected(event)
257 { 251 {
258 if (WebInspector._disconnectedScreenWithReasonWasShown) 252 if (WebInspector._disconnectedScreenWithReasonWasShown)
259 return; 253 return;
260 new WebInspector.RemoteDebuggingTerminatedScreen(event.data.reason). showModal(); 254 new WebInspector.RemoteDebuggingTerminatedScreen(event.data.reason). showModal();
261 } 255 }
262 256
263 InspectorBackend.setConnection(connection); 257 InspectorBackend.setConnection(connection);
264 258
265 // Install styles and themes 259 // Install styles and themes
266 WebInspector.installPortStyles(); 260 WebInspector.installPortStyles();
267 261
268 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam(" textColor")) 262 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam(" textColor"))
269 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor" ), WebInspector.queryParam("textColor")); 263 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor" ), WebInspector.queryParam("textColor"));
270 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.SetToolbarColors, updateToolbarColors); 264 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.SetToolbarColors, updateToolbarColors);
271 /** 265 /**
272 * @param {!WebInspector.Event} event 266 * @param {!WebInspector.Event} event
273 */ 267 */
274 function updateToolbarColors(event) 268 function updateToolbarColors(event)
275 { 269 {
276 WebInspector.setToolbarColors(/** @type {string} */ (event.data["bac kgroundColor"]), /** @type {string} */ (event.data["color"])); 270 WebInspector.setToolbarColors(/** @type {string} */ (event.data["bac kgroundColor"]), /** @type {string} */ (event.data["color"]));
277 } 271 }
278 WebInspector.ContextMenu.initialize(); 272 WebInspector.ContextMenu.initialize();
279 273
280 WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), c onnection, this._doLoadedDoneWithCapabilities.bind(this)); 274 WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), c onnection, this._mainTargetCreated.bind(this));
281 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSy stemManager(); 275 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSy stemManager();
282 WebInspector.workspace = new WebInspector.Workspace(WebInspector.isolate dFileSystemManager.mapping()); 276 WebInspector.workspace = new WebInspector.Workspace(WebInspector.isolate dFileSystemManager.mapping());
283 WebInspector.networkWorkspaceBinding = new WebInspector.NetworkWorkspace Binding(WebInspector.workspace); 277 WebInspector.networkWorkspaceBinding = new WebInspector.NetworkWorkspace Binding(WebInspector.workspace);
284 new WebInspector.NetworkUISourceCodeProvider(WebInspector.networkWorkspa ceBinding, WebInspector.workspace); 278 new WebInspector.NetworkUISourceCodeProvider(WebInspector.networkWorkspa ceBinding, WebInspector.workspace);
285 new WebInspector.PresentationConsoleMessageHelper(WebInspector.workspace ); 279 new WebInspector.PresentationConsoleMessageHelper(WebInspector.workspace );
286 WebInspector.fileSystemWorkspaceBinding = new WebInspector.FileSystemWor kspaceBinding(WebInspector.isolatedFileSystemManager, WebInspector.workspace); 280 WebInspector.fileSystemWorkspaceBinding = new WebInspector.FileSystemWor kspaceBinding(WebInspector.isolatedFileSystemManager, WebInspector.workspace);
287 WebInspector.breakpointManager = new WebInspector.BreakpointManager(WebI nspector.settings.breakpoints, WebInspector.workspace, WebInspector.targetManage r); 281 WebInspector.breakpointManager = new WebInspector.BreakpointManager(WebI nspector.settings.breakpoints, WebInspector.workspace, WebInspector.targetManage r);
288 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(We bInspector.workspace); 282 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(We bInspector.workspace);
289 this._executionContextSelector = new WebInspector.ExecutionContextSelect or(); 283 this._executionContextSelector = new WebInspector.ExecutionContextSelect or();
290 }, 284 },
291 285
292 _doLoadedDoneWithCapabilities: function(mainTarget) 286 /**
287 * @param {!WebInspector.Target} mainTarget
288 */
289 _mainTargetCreated: function(mainTarget)
293 { 290 {
294 console.timeStamp("Main._doLoadedDoneWithCapabilities"); 291 console.timeStamp("Main._mainTargetCreated");
295 WebInspector.dockController = new WebInspector.DockController(!!WebInspe ctor.queryParam("can_dock")); 292 WebInspector.dockController = new WebInspector.DockController(!!WebInspe ctor.queryParam("can_dock"));
296 WebInspector.overridesSupport = new WebInspector.OverridesSupport(WebIns pector.dockController.canDock()); 293 WebInspector.overridesSupport = new WebInspector.OverridesSupport(WebIns pector.dockController.canDock());
297 294
298 if (mainTarget.canScreencast) 295 if (mainTarget.canScreencast)
299 WebInspector.app = new WebInspector.ScreencastApp(); 296 WebInspector.app = new WebInspector.ScreencastApp();
300 else if (WebInspector.dockController.canDock()) 297 else if (WebInspector.dockController.canDock())
301 WebInspector.app = new WebInspector.AdvancedApp(); 298 WebInspector.app = new WebInspector.AdvancedApp();
302 else 299 else
303 WebInspector.app = new WebInspector.SimpleApp(); 300 WebInspector.app = new WebInspector.SimpleApp();
304 301
305 WebInspector.dockController.initialize(); 302 WebInspector.dockController.initialize();
306 303
307 new WebInspector.VersionController().updateVersion();
308 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen(); 304 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
309 this._registerShortcuts(); 305 this._registerShortcuts();
310 306
311 // set order of some sections explicitly 307 // set order of some sections explicitly
312 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console")); 308 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console"));
313 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Pan el")); 309 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Pan el"));
314 310
315 if (WebInspector.experimentsSettings.workersInMainWindow.isEnabled()) 311 if (WebInspector.experimentsSettings.workersInMainWindow.isEnabled())
316 WebInspector.workerTargetManager = new WebInspector.WorkerTargetMana ger(mainTarget, WebInspector.targetManager); 312 WebInspector.workerTargetManager = new WebInspector.WorkerTargetMana ger(mainTarget, WebInspector.targetManager);
317 313
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 }); 828 });
833 829
834 /** 830 /**
835 * @param {string} name 831 * @param {string} name
836 * @return {?WebInspector.Panel} 832 * @return {?WebInspector.Panel}
837 */ 833 */
838 WebInspector.panel = function(name) 834 WebInspector.panel = function(name)
839 { 835 {
840 return WebInspector.inspectorView.panel(name); 836 return WebInspector.inspectorView.panel(name);
841 } 837 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/AdvancedApp.js ('k') | Source/devtools/front_end/sdk/InspectorBackend.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698