| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Tools is a main class that wires all components of the | 6 * @fileoverview Tools is a main class that wires all components of the |
| 7 * DevTools frontend together. It is also responsible for overriding existing | 7 * DevTools frontend together. It is also responsible for overriding existing |
| 8 * WebInspector functionality while it is getting upstreamed into WebCore. | 8 * WebInspector functionality while it is getting upstreamed into WebCore. |
| 9 */ | 9 */ |
| 10 goog.provide('devtools.Tools'); | 10 goog.provide('devtools.Tools'); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 * @type {devtools.ToolsAgent} | 146 * @type {devtools.ToolsAgent} |
| 147 */ | 147 */ |
| 148 devtools.tools = null; | 148 devtools.tools = null; |
| 149 | 149 |
| 150 | 150 |
| 151 var context = {}; // Used by WebCore's inspector routines. | 151 var context = {}; // Used by WebCore's inspector routines. |
| 152 | 152 |
| 153 /////////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////////// |
| 154 // Here and below are overrides to existing WebInspector methods only. | 154 // Here and below are overrides to existing WebInspector methods only. |
| 155 // TODO(pfeldman): Patch WebCore and upstream changes. | 155 // TODO(pfeldman): Patch WebCore and upstream changes. |
| 156 (function () { | |
| 157 | |
| 158 var oldLoaded = WebInspector.loaded; | 156 var oldLoaded = WebInspector.loaded; |
| 159 | 157 WebInspector.loaded = function() { |
| 160 function loadDevToolsStrings() { | |
| 161 var locale = DevToolsHost.getApplicationLocale(); | |
| 162 locale = locale.replace('_', '-'); | |
| 163 | |
| 164 var devtoolsStringsScriptElement = document.createElement('script'); | |
| 165 devtoolsStringsScriptElement.addEventListener( | |
| 166 "load", | |
| 167 devToolsHandleLoaded.bind(WebInspector), | |
| 168 false); | |
| 169 devtoolsStringsScriptElement.type = 'text/javascript'; | |
| 170 devtoolsStringsScriptElement.src = 'l10n/devtoolsStrings_' + locale + '.js'; | |
| 171 document.getElementsByTagName("head").item(0).appendChild( | |
| 172 devtoolsStringsScriptElement); | |
| 173 }; | |
| 174 | |
| 175 function devToolsHandleLoaded() { | |
| 176 devtools.tools = new devtools.ToolsAgent(); | 158 devtools.tools = new devtools.ToolsAgent(); |
| 177 devtools.tools.reset(); | 159 devtools.tools.reset(); |
| 178 | 160 |
| 179 Preferences.ignoreWhitespace = false; | 161 Preferences.ignoreWhitespace = false; |
| 180 oldLoaded.call(this); | 162 oldLoaded.call(this); |
| 181 | 163 |
| 182 // Hide dock button on Mac OS. | 164 // Hide dock button on Mac OS. |
| 183 // TODO(pfeldman): remove once Mac OS docking is implemented. | 165 // TODO(pfeldman): remove once Mac OS docking is implemented. |
| 184 if (InspectorController.platform().indexOf('mac') == 0) { | 166 if (InspectorController.platform().indexOf('mac') == 0) { |
| 185 document.getElementById('dock-status-bar-item').addStyleClass('hidden'); | 167 document.getElementById('dock-status-bar-item').addStyleClass('hidden'); |
| 186 } | 168 } |
| 187 | 169 |
| 188 // Mute refresh action. | 170 // Mute refresh action. |
| 189 document.addEventListener("keydown", function(event) { | 171 document.addEventListener("keydown", function(event) { |
| 190 if (event.keyIdentifier == 'F5') { | 172 if (event.keyIdentifier == 'F5') { |
| 191 event.preventDefault(); | 173 event.preventDefault(); |
| 192 } else if (event.keyIdentifier == 'U+0052' /* 'R' */ && | 174 } else if (event.keyIdentifier == 'U+0052' /* 'R' */ && |
| 193 (event.ctrlKey || event.metaKey)) { | 175 (event.ctrlKey || event.metaKey)) { |
| 194 event.preventDefault(); | 176 event.preventDefault(); |
| 195 } | 177 } |
| 196 }, true); | 178 }, true); |
| 197 | 179 |
| 198 DevToolsHost.loaded(); | 180 DevToolsHost.loaded(); |
| 199 }; | 181 }; |
| 200 | 182 |
| 201 | 183 |
| 202 // l10n is turned off in tests mode because delayed loading of strings | |
| 203 // causes test failures. | |
| 204 if (!window.___interactiveUiTestsMode) { | |
| 205 window.localizedStrings = {}; | |
| 206 WebInspector.loaded = loadDevToolsStrings; | |
| 207 } else { | |
| 208 WebInspector.loaded = devToolsHandleLoaded; | |
| 209 } | |
| 210 | |
| 211 })(); | |
| 212 | |
| 213 | |
| 214 /** | 184 /** |
| 215 * This override is necessary for adding script source asynchronously. | 185 * This override is necessary for adding script source asynchronously. |
| 216 * @override | 186 * @override |
| 217 */ | 187 */ |
| 218 WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function() { | 188 WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function() { |
| 219 if (!this._frameNeedsSetup) { | 189 if (!this._frameNeedsSetup) { |
| 220 return; | 190 return; |
| 221 } | 191 } |
| 222 | 192 |
| 223 this.attach(); | 193 this.attach(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 devtools.tools.getDebuggerAgent().initializeProfiling(); | 316 devtools.tools.getDebuggerAgent().initializeProfiling(); |
| 347 this.enableToggleButton.visible = false; | 317 this.enableToggleButton.visible = false; |
| 348 oldShow.call(this); | 318 oldShow.call(this); |
| 349 // Show is called on every show event of a panel, so | 319 // Show is called on every show event of a panel, so |
| 350 // we only need to intercept it once. | 320 // we only need to intercept it once. |
| 351 WebInspector.ProfilesPanel.prototype.show = oldShow; | 321 WebInspector.ProfilesPanel.prototype.show = oldShow; |
| 352 }; | 322 }; |
| 353 })(); | 323 })(); |
| 354 | 324 |
| 355 | 325 |
| 326 /* |
| 327 * @override |
| 328 * TODO(mnaganov): Restore l10n when it will be agreed that it is needed. |
| 329 */ |
| 330 WebInspector.UIString = function(string) { |
| 331 return String.vsprintf(string, Array.prototype.slice.call(arguments, 1)); |
| 332 }; |
| 333 |
| 334 |
| 356 // There is no clear way of setting frame title yet. So sniffing main resource | 335 // There is no clear way of setting frame title yet. So sniffing main resource |
| 357 // load. | 336 // load. |
| 358 (function OverrideUpdateResource() { | 337 (function OverrideUpdateResource() { |
| 359 var originalUpdateResource = WebInspector.updateResource; | 338 var originalUpdateResource = WebInspector.updateResource; |
| 360 WebInspector.updateResource = function(identifier, payload) { | 339 WebInspector.updateResource = function(identifier, payload) { |
| 361 originalUpdateResource.call(this, identifier, payload); | 340 originalUpdateResource.call(this, identifier, payload); |
| 362 var resource = this.resources[identifier]; | 341 var resource = this.resources[identifier]; |
| 363 if (resource && resource.mainResource && resource.finished) { | 342 if (resource && resource.mainResource && resource.finished) { |
| 364 document.title = | 343 document.title = |
| 365 WebInspector.UIString('Developer Tools - %s', resource.url); | 344 WebInspector.UIString('Developer Tools - %s', resource.url); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 { | 399 { |
| 421 InspectorController.resourceTrackingEnabled_ = true; | 400 InspectorController.resourceTrackingEnabled_ = true; |
| 422 this.panels.resources.resourceTrackingWasEnabled(); | 401 this.panels.resources.resourceTrackingWasEnabled(); |
| 423 } | 402 } |
| 424 | 403 |
| 425 WebInspector.resourceTrackingWasDisabled = function() | 404 WebInspector.resourceTrackingWasDisabled = function() |
| 426 { | 405 { |
| 427 InspectorController.resourceTrackingEnabled_ = false; | 406 InspectorController.resourceTrackingEnabled_ = false; |
| 428 this.panels.resources.resourceTrackingWasDisabled(); | 407 this.panels.resources.resourceTrackingWasDisabled(); |
| 429 } | 408 } |
| OLD | NEW |