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

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

Issue 2137773002: [DevTools] Replace the target type with capabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing the code review comments Created 4 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
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 /** 301 /**
302 * @param {!WebInspector.Event} event 302 * @param {!WebInspector.Event} event
303 */ 303 */
304 function onDisconnected(event) 304 function onDisconnected(event)
305 { 305 {
306 if (WebInspector._disconnectedScreenWithReasonWasShown) 306 if (WebInspector._disconnectedScreenWithReasonWasShown)
307 return; 307 return;
308 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason) ; 308 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason) ;
309 } 309 }
310 310
311 var targetType = WebInspector.Target.Type.Page; 311 var capabilities = WebInspector.Target.Capability.Browser | WebInspector .Target.Capability.JS | WebInspector.Target.Capability.Network | WebInspector.Ta rget.Capability.Worker;
312 if (Runtime.queryParam("isSharedWorker")) 312 if (Runtime.queryParam("isSharedWorker"))
313 targetType = WebInspector.Target.Type.ServiceWorker; 313 capabilities = WebInspector.Target.Capability.Network | WebInspector .Target.Capability.Worker;
314 else if (Runtime.queryParam("v8only")) 314 else if (Runtime.queryParam("v8only"))
315 targetType = WebInspector.Target.Type.JSInspector; 315 capabilities = WebInspector.Target.Capability.JS;
316 316
317 this._mainTarget = WebInspector.targetManager.createTarget(WebInspector. UIString("Main"), targetType, connection, null); 317 this._mainTarget = WebInspector.targetManager.createTarget(WebInspector. UIString("Main"), capabilities, connection, null);
318 console.timeStamp("Main._mainTargetCreated"); 318 console.timeStamp("Main._mainTargetCreated");
319 this._registerShortcuts(); 319 this._registerShortcuts();
320 320
321 this._mainTarget.registerInspectorDispatcher(this); 321 this._mainTarget.registerInspectorDispatcher(this);
322 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.ReloadInspectedPage, this._reloadInspectedPage, this); 322 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.ReloadInspectedPage, this._reloadInspectedPage, this);
323 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.EvaluateForTestInFrontend, this._evaluateForTestInFrontend, this); 323 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.EvaluateForTestInFrontend, this._evaluateForTestInFrontend, this);
324 324
325 if (this._mainTarget.isServiceWorker() || this._mainTarget.isPage() || t his._mainTarget.isJSInspector()) 325 this._mainTarget.runtimeAgent().run();
326 this._mainTarget.runtimeAgent().run();
327 326
328 this._mainTarget.inspectorAgent().enable(); 327 this._mainTarget.inspectorAgent().enable();
329 InspectorFrontendHost.readyForTest(); 328 InspectorFrontendHost.readyForTest();
330 329
331 // Asynchronously run the extensions. 330 // Asynchronously run the extensions.
332 setTimeout(lateInitialization, 0); 331 setTimeout(lateInitialization, 0);
333 332
334 function lateInitialization() 333 function lateInitialization()
335 { 334 {
336 console.timeStamp("Main.lateInitialization"); 335 console.timeStamp("Main.lateInitialization");
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 703 }
705 } 704 }
706 705
707 /** 706 /**
708 * @param {boolean} hard 707 * @param {boolean} hard
709 */ 708 */
710 WebInspector.Main._reloadPage = function(hard) 709 WebInspector.Main._reloadPage = function(hard)
711 { 710 {
712 if (!WebInspector.targetManager.hasTargets()) 711 if (!WebInspector.targetManager.hasTargets())
713 return; 712 return;
714 if (WebInspector.targetManager.mainTarget().isServiceWorker()) 713 if (WebInspector.targetManager.mainTarget().hasBrowserCapability())
715 return; 714 WebInspector.targetManager.reloadPage(hard);
716 WebInspector.targetManager.reloadPage(hard);
717 } 715 }
718 716
719 /** 717 /**
720 * @param {string} ws 718 * @param {string} ws
721 */ 719 */
722 WebInspector.Main._addWebSocketTarget = function(ws) 720 WebInspector.Main._addWebSocketTarget = function(ws)
dgozman 2016/07/13 00:08:29 Looks like this method is never called. Remove it
eostroukhov-old 2016/07/13 00:36:29 Done.
723 { 721 {
724 /** 722 /**
725 * @param {!InspectorBackendClass.Connection} connection 723 * @param {!InspectorBackendClass.Connection} connection
726 */ 724 */
727 function callback(connection) 725 function callback(connection)
728 { 726 {
729 WebInspector.targetManager.createTarget(ws, WebInspector.Target.Type.Pag e, connection, null); 727 var capabilities = WebInspector.Target.Capability.Browser | WebInspector .Target.Capability.JS | WebInspector.Target.Capability.Network | WebInspector.Ta rget.Capability.Worker;
728 WebInspector.targetManager.createTarget(ws, capabilities, connection, nu ll);
730 } 729 }
731 new WebInspector.WebSocketConnection(ws, callback); 730 new WebInspector.WebSocketConnection(ws, callback);
732 } 731 }
733 732
734 /** 733 /**
735 * @constructor 734 * @constructor
736 * @implements {WebInspector.ToolbarItem.Provider} 735 * @implements {WebInspector.ToolbarItem.Provider}
737 */ 736 */
738 WebInspector.Main.WarningErrorCounter = function() 737 WebInspector.Main.WarningErrorCounter = function()
739 { 738 {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 * @implements {WebInspector.TargetManager.Observer} 1056 * @implements {WebInspector.TargetManager.Observer}
1058 */ 1057 */
1059 WebInspector.BackendSettingsSync = function() 1058 WebInspector.BackendSettingsSync = function()
1060 { 1059 {
1061 this._autoAttachSetting = WebInspector.settings.moduleSetting("autoAttachToC reatedPages"); 1060 this._autoAttachSetting = WebInspector.settings.moduleSetting("autoAttachToC reatedPages");
1062 this._autoAttachSetting.addChangeListener(this._update, this); 1061 this._autoAttachSetting.addChangeListener(this._update, this);
1063 this._disableJavascriptSetting = WebInspector.settings.moduleSetting("javaSc riptDisabled"); 1062 this._disableJavascriptSetting = WebInspector.settings.moduleSetting("javaSc riptDisabled");
1064 this._disableJavascriptSetting.addChangeListener(this._update, this); 1063 this._disableJavascriptSetting.addChangeListener(this._update, this);
1065 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting("blo ckedEventsWarningEnabled"); 1064 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting("blo ckedEventsWarningEnabled");
1066 this._blockedEventsWarningSetting.addChangeListener(this._update, this); 1065 this._blockedEventsWarningSetting.addChangeListener(this._update, this);
1067 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); 1066 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili ty.Browser);
1068 } 1067 }
1069 1068
1070 WebInspector.BackendSettingsSync.prototype = { 1069 WebInspector.BackendSettingsSync.prototype = {
1071 /** 1070 /**
1072 * @param {!WebInspector.Target} target 1071 * @param {!WebInspector.Target} target
1073 */ 1072 */
1074 _updateTarget: function(target) 1073 _updateTarget: function(target)
1075 { 1074 {
1076 var blockedEventsWarningThresholdSeconds = 0.1; 1075 var blockedEventsWarningThresholdSeconds = 0.1;
1077 target.pageAgent().setBlockedEventsWarningThreshold(this._blockedEventsW arningSetting.get() ? blockedEventsWarningThresholdSeconds : 0); 1076 target.pageAgent().setBlockedEventsWarningThreshold(this._blockedEventsW arningSetting.get() ? blockedEventsWarningThresholdSeconds : 0);
1078 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.g et()); 1077 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.g et());
1079 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascri ptSetting.get()); 1078 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascri ptSetting.get());
1080 }, 1079 },
1081 1080
1082 _update: function() 1081 _update: function()
1083 { 1082 {
1084 WebInspector.targetManager.targets(WebInspector.Target.Type.Page).forEac h(this._updateTarget, this); 1083 WebInspector.targetManager.targets(WebInspector.Target.Capability.Browse r).forEach(this._updateTarget, this);
1085 }, 1084 },
1086 1085
1087 /** 1086 /**
1088 * @param {!WebInspector.Target} target 1087 * @param {!WebInspector.Target} target
1089 * @override 1088 * @override
1090 */ 1089 */
1091 targetAdded: function(target) 1090 targetAdded: function(target)
1092 { 1091 {
1093 this._updateTarget(target); 1092 this._updateTarget(target);
1094 target.renderingAgent().setShowViewportSizeOnResize(true); 1093 target.renderingAgent().setShowViewportSizeOnResize(true);
(...skipping 22 matching lines...) Expand all
1117 * @return {?Element} 1116 * @return {?Element}
1118 */ 1117 */
1119 settingElement: function() 1118 settingElement: function()
1120 { 1119 {
1121 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); 1120 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers"));
1122 } 1121 }
1123 } 1122 }
1124 1123
1125 1124
1126 new WebInspector.Main(); 1125 new WebInspector.Main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698