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

Side by Side Diff: Source/devtools/front_end/inspector.js

Issue 185463010: DevTools: Introduce Target class which holds connection & models (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gr-RuntimeAgent
Patch Set: Created 6 years, 9 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
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 286 }
287 WebInspector.socket.onclose = function() { 287 WebInspector.socket.onclose = function() {
288 if (!WebInspector.socket._detachReason) 288 if (!WebInspector.socket._detachReason)
289 (new WebInspector.RemoteDebuggingTerminatedScreen("websocket_clo sed")).showModal(); 289 (new WebInspector.RemoteDebuggingTerminatedScreen("websocket_clo sed")).showModal();
290 } 290 }
291 return; 291 return;
292 } 292 }
293 293
294 WebInspector.doLoadedDone(); 294 WebInspector.doLoadedDone();
295 295
296 // In case of loading as a web page with no bindings / harness, kick off ini tialization manually. 296 if (InspectorFrontendHost.isStub)
297 if (InspectorFrontendHost.isStub) {
298 InspectorFrontendAPI.dispatchQueryParameters(WebInspector.queryParamsObj ect); 297 InspectorFrontendAPI.dispatchQueryParameters(WebInspector.queryParamsObj ect);
299 WebInspector._doLoadedDoneWithCapabilities();
300 }
301 } 298 }
302 299
303 WebInspector.doLoadedDone = function() 300 WebInspector.doLoadedDone = function()
304 { 301 {
305 // Install styles and themes 302 // Install styles and themes
306 WebInspector.installPortStyles(); 303 WebInspector.installPortStyles();
307 if (WebInspector.socket) 304 if (WebInspector.socket)
308 document.body.classList.add("remote"); 305 document.body.classList.add("remote");
309 306
310 if (WebInspector.queryParamsObject.toolbarColor && WebInspector.queryParamsO bject.textColor) 307 if (WebInspector.queryParamsObject.toolbarColor && WebInspector.queryParamsO bject.textColor)
311 WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbarColo r, WebInspector.queryParamsObject.textColor); 308 WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbarColo r, WebInspector.queryParamsObject.textColor);
312 309
313 var workerId = WebInspector.queryParamsObject["dedicatedWorkerId"]; 310 var workerId = WebInspector.queryParamsObject["dedicatedWorkerId"];
314 if (workerId) 311 if (workerId)
315 this._initializeDedicatedWorkerFrontend(workerId); 312 this._initializeDedicatedWorkerFrontend(workerId);
316 313
317 var connection = workerId ? new WebInspector.WorkerConnection(workerId) : ne w InspectorBackendClass.MainConnection(); 314 var connection = workerId ? new WebInspector.WorkerConnection(workerId) : ne w InspectorBackendClass.MainConnection();
318 InspectorBackend.setConnection(connection); 315 InspectorBackend.setConnection(connection);
319 316
320 PageAgent.canScreencast(WebInspector._initializeCapability.bind(WebInspector , "canScreencast", null)); 317 WebInspector.targetManager = new WebInspector.TargetManager();
321 WorkerAgent.canInspectWorkers(WebInspector._initializeCapability.bind(WebIns pector, "canInspectWorkers", WebInspector._doLoadedDoneWithCapabilities.bind(Web Inspector))); 318 var mainTarget = WebInspector.targetManager.newConnectionAvailable(connectio n);
319 mainTarget.addEventListener(WebInspector.Target.Events.TargetIsReady, WebIns pector._doLoadedDoneWithCapabilities.bind(WebInspector, mainTarget));
322 } 320 }
323 321
324 WebInspector._doLoadedDoneWithCapabilities = function() 322 WebInspector._doLoadedDoneWithCapabilities = function(mainTarget)
325 { 323 {
324 // compatibility code
325 Capabilities.canInspectWorkers = mainTarget.canInspectWorkers;
326 this.console = mainTarget.consoleModel;
327 this.networkManager = mainTarget.networkManager;
328 this.resourceTreeModel = mainTarget.resourceTreeModel;
329 this.debuggerModel = mainTarget.debuggerModel;
330 this.runtimeModel = mainTarget.runtimeModel;
331
332 this.domAgent = new WebInspector.DOMAgent();
333 this.workerManager = new WebInspector.WorkerManager(this.canInspectWorkers);
334
326 new WebInspector.VersionController().updateVersion(); 335 new WebInspector.VersionController().updateVersion();
327
328 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen(); 336 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
329 this._registerShortcuts(); 337 this._registerShortcuts();
330 338
331 // set order of some sections explicitly 339 // set order of some sections explicitly
332 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console")); 340 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console"));
333 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Panel") ); 341 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Panel") );
334 WebInspector.ShortcutsScreen.registerShortcuts(); 342 WebInspector.ShortcutsScreen.registerShortcuts();
335 343
336 this.console = new WebInspector.ConsoleModel();
337 this.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleare d, this._resetErrorAndWarningCounts, this); 344 this.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleare d, this._resetErrorAndWarningCounts, this);
338 this.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._updateErrorAndWarningCounts, this); 345 this.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._updateErrorAndWarningCounts, this);
339 this.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUp dated, this._updateErrorAndWarningCounts, this); 346 this.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUp dated, this._updateErrorAndWarningCounts, this);
340 this.networkManager = new WebInspector.NetworkManager(); 347
341 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.networkMana ger, this.console);
342 this.debuggerModel = new WebInspector.DebuggerModel();
343 this.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debugg erPaused, this._debuggerPaused, this); 348 this.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debugg erPaused, this._debuggerPaused, this);
344 this.networkLog = new WebInspector.NetworkLog(); 349 this.networkLog = new WebInspector.NetworkLog();
345 this.domAgent = new WebInspector.DOMAgent();
346 this.domAgent.addEventListener(WebInspector.DOMAgent.Events.InspectNodeReque sted, this._inspectNodeRequested, this); 350 this.domAgent.addEventListener(WebInspector.DOMAgent.Events.InspectNodeReque sted, this._inspectNodeRequested, this);
aandrey 2014/03/04 10:05:16 domAgent is one for many targets? what is "target"
sergeyv 2014/03/04 12:42:38 It is hard to add support of multiple target in al
347 this.workerManager = new WebInspector.WorkerManager(Capabilities.canInspectW orkers);
348 this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel);
349 351
350 this.zoomManager = new WebInspector.ZoomManager(); 352 this.zoomManager = new WebInspector.ZoomManager();
351 353
352 this.advancedSearchController = new WebInspector.AdvancedSearchController(); 354 this.advancedSearchController = new WebInspector.AdvancedSearchController();
353 this.consoleView = new WebInspector.ConsoleView(WebInspector.isWorkerFronten d()); 355 this.consoleView = new WebInspector.ConsoleView(WebInspector.isWorkerFronten d());
354 356
355 InspectorBackend.registerInspectorDispatcher(this); 357 InspectorBackend.registerInspectorDispatcher(this);
356 358
357 this.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager( ); 359 this.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager( );
358 this.isolatedFileSystemDispatcher = new WebInspector.IsolatedFileSystemDispa tcher(this.isolatedFileSystemManager); 360 this.isolatedFileSystemDispatcher = new WebInspector.IsolatedFileSystemDispa tcher(this.isolatedFileSystemManager);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 new WebInspector.PresentationConsoleMessageHelper(this.workspace); 399 new WebInspector.PresentationConsoleMessageHelper(this.workspace);
398 400
399 // Create settings before loading modules. 401 // Create settings before loading modules.
400 WebInspector.settings.initializeBackendSettings(); 402 WebInspector.settings.initializeBackendSettings();
401 403
402 this._registerModules(); 404 this._registerModules();
403 405
404 this.panels = {}; 406 this.panels = {};
405 this.inspectorView = new WebInspector.InspectorView(); 407 this.inspectorView = new WebInspector.InspectorView();
406 // Screencast controller creates a root view itself. 408 // Screencast controller creates a root view itself.
407 if (Capabilities.canScreencast) 409 if (mainTarget.canScreencast)
408 this._screencastController = new WebInspector.ScreencastController(); 410 this._screencastController = new WebInspector.ScreencastController();
409 else 411 else
410 this._createRootView(); 412 this._createRootView();
411 this._createGlobalStatusBarItems(); 413 this._createGlobalStatusBarItems();
412 414
413 this.addMainEventListeners(document); 415 this.addMainEventListeners(document);
414 416
415 window.addEventListener("resize", this.windowResize.bind(this), true); 417 window.addEventListener("resize", this.windowResize.bind(this), true);
416 418
417 var errorWarningCount = document.getElementById("error-warning-count"); 419 var errorWarningCount = document.getElementById("error-warning-count");
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 WebInspector.addMainEventListeners = function(doc) 889 WebInspector.addMainEventListeners = function(doc)
888 { 890 {
889 doc.addEventListener("keydown", this.postDocumentKeyDown.bind(this), false); 891 doc.addEventListener("keydown", this.postDocumentKeyDown.bind(this), false);
890 doc.addEventListener("beforecopy", this.documentCanCopy.bind(this), true); 892 doc.addEventListener("beforecopy", this.documentCanCopy.bind(this), true);
891 doc.addEventListener("copy", this.documentCopy.bind(this), false); 893 doc.addEventListener("copy", this.documentCopy.bind(this), false);
892 doc.addEventListener("contextmenu", this.contextMenuEventFired.bind(this), t rue); 894 doc.addEventListener("contextmenu", this.contextMenuEventFired.bind(this), t rue);
893 doc.addEventListener("click", this.documentClick.bind(this), false); 895 doc.addEventListener("click", this.documentClick.bind(this), false);
894 } 896 }
895 897
896 window.DEBUG = true; 898 window.DEBUG = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698