| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.BreakpointsSidebarPaneBase} | 7 * @extends {WebInspector.BreakpointsSidebarPaneBase} |
| 8 * @implements {WebInspector.ContextFlavorListener} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 9 * @implements {WebInspector.TargetManager.Observer} |
| 9 * @implements {WebInspector.ToolbarItem.ItemsProvider} | 10 * @implements {WebInspector.ToolbarItem.ItemsProvider} |
| 10 */ | 11 */ |
| 11 WebInspector.XHRBreakpointsSidebarPane = function() | 12 WebInspector.XHRBreakpointsSidebarPane = function() |
| 12 { | 13 { |
| 13 WebInspector.BreakpointsSidebarPaneBase.call(this); | 14 WebInspector.BreakpointsSidebarPaneBase.call(this); |
| 14 this._xhrBreakpointsSetting = WebInspector.settings.createLocalSetting("xhrB
reakpoints", []); | 15 this._xhrBreakpointsSetting = WebInspector.settings.createLocalSetting("xhrB
reakpoints", []); |
| 15 | 16 |
| 16 /** @type {!Map.<string, !Element>} */ | 17 /** @type {!Map.<string, !Element>} */ |
| 17 this._breakpointElements = new Map(); | 18 this._breakpointElements = new Map(); |
| 18 | 19 |
| 19 this._addButton = new WebInspector.ToolbarButton(WebInspector.UIString("Add
breakpoint"), "add-toolbar-item"); | 20 this._addButton = new WebInspector.ToolbarButton(WebInspector.UIString("Add
breakpoint"), "add-toolbar-item"); |
| 20 this._addButton.addEventListener("click", this._addButtonClicked.bind(this))
; | 21 this._addButton.addEventListener("click", this._addButtonClicked.bind(this))
; |
| 21 | 22 |
| 22 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); | 23 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); |
| 23 | |
| 24 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); | 24 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 25 this._update(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 WebInspector.XHRBreakpointsSidebarPane.prototype = { | 28 WebInspector.XHRBreakpointsSidebarPane.prototype = { |
| 28 /** | 29 /** |
| 29 * @override | 30 * @override |
| 30 * @param {!WebInspector.Target} target | 31 * @param {!WebInspector.Target} target |
| 31 */ | 32 */ |
| 32 targetAdded: function(target) | 33 targetAdded: function(target) |
| 33 { | 34 { |
| 34 this._restoreBreakpoints(target); | 35 this._restoreBreakpoints(target); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 var contextMenu = new WebInspector.ContextMenu(event); | 55 var contextMenu = new WebInspector.ContextMenu(event); |
| 55 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint
"), this._addButtonClicked.bind(this)); | 56 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint
"), this._addButtonClicked.bind(this)); |
| 56 contextMenu.show(); | 57 contextMenu.show(); |
| 57 }, | 58 }, |
| 58 | 59 |
| 59 _addButtonClicked: function(event) | 60 _addButtonClicked: function(event) |
| 60 { | 61 { |
| 61 if (event) | 62 if (event) |
| 62 event.consume(); | 63 event.consume(); |
| 63 | 64 |
| 64 WebInspector.viewManager.revealViewWithWidget(this); | 65 WebInspector.viewManager.showView("sources.xhrBreakpoints"); |
| 65 | 66 |
| 66 var inputElementContainer = createElementWithClass("p", "breakpoint-cond
ition"); | 67 var inputElementContainer = createElementWithClass("p", "breakpoint-cond
ition"); |
| 67 inputElementContainer.textContent = WebInspector.UIString("Break when UR
L contains:"); | 68 inputElementContainer.textContent = WebInspector.UIString("Break when UR
L contains:"); |
| 68 | 69 |
| 69 var inputElement = inputElementContainer.createChild("span", "editing"); | 70 var inputElement = inputElementContainer.createChild("span", "editing"); |
| 70 inputElement.id = "breakpoint-condition-input"; | 71 inputElement.id = "breakpoint-condition-input"; |
| 71 this.addListElement(inputElementContainer, /** @type {?Element} */ (this
.listElement.firstChild)); | 72 this.addListElement(inputElementContainer, /** @type {?Element} */ (this
.listElement.firstChild)); |
| 72 | 73 |
| 73 /** | 74 /** |
| 74 * @param {boolean} accept | 75 * @param {boolean} accept |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 this._saveBreakpoints(); | 217 this._saveBreakpoints(); |
| 217 } else | 218 } else |
| 218 element.classList.remove("hidden"); | 219 element.classList.remove("hidden"); |
| 219 } | 220 } |
| 220 | 221 |
| 221 WebInspector.InplaceEditor.startEditing(inputElement, new WebInspector.I
nplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, fal
se))); | 222 WebInspector.InplaceEditor.startEditing(inputElement, new WebInspector.I
nplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, fal
se))); |
| 222 }, | 223 }, |
| 223 | 224 |
| 224 /** | 225 /** |
| 225 * @override | 226 * @override |
| 226 * @param {?WebInspector.DebuggerPausedDetails} details | 227 * @param {?Object} object |
| 227 */ | 228 */ |
| 228 highlightDetails: function(details) | 229 flavorChanged: function(object) |
| 229 { | 230 { |
| 231 this._update(); |
| 232 }, |
| 233 |
| 234 _update: function() |
| 235 { |
| 236 var details = WebInspector.context.flavor(WebInspector.DebuggerPausedDet
ails); |
| 230 if (!details || details.reason !== WebInspector.DebuggerModel.BreakReaso
n.XHR) { | 237 if (!details || details.reason !== WebInspector.DebuggerModel.BreakReaso
n.XHR) { |
| 231 if (this._highlightedElement) { | 238 if (this._highlightedElement) { |
| 232 this._highlightedElement.classList.remove("breakpoint-hit"); | 239 this._highlightedElement.classList.remove("breakpoint-hit"); |
| 233 delete this._highlightedElement; | 240 delete this._highlightedElement; |
| 234 } | 241 } |
| 235 return; | 242 return; |
| 236 } | 243 } |
| 237 var url = details.auxData["breakpointURL"]; | 244 var url = details.auxData["breakpointURL"]; |
| 238 var element = this._breakpointElements.get(url); | 245 var element = this._breakpointElements.get(url); |
| 239 if (!element) | 246 if (!element) |
| 240 return; | 247 return; |
| 241 WebInspector.viewManager.revealViewWithWidget(this); | 248 WebInspector.viewManager.showView("sources.xhrBreakpoints"); |
| 242 element.classList.add("breakpoint-hit"); | 249 element.classList.add("breakpoint-hit"); |
| 243 this._highlightedElement = element; | 250 this._highlightedElement = element; |
| 244 }, | 251 }, |
| 245 | 252 |
| 246 _saveBreakpoints: function() | 253 _saveBreakpoints: function() |
| 247 { | 254 { |
| 248 var breakpoints = []; | 255 var breakpoints = []; |
| 249 for (var url of this._breakpointElements.keys()) | 256 for (var url of this._breakpointElements.keys()) |
| 250 breakpoints.push({ url: url, enabled: this._breakpointElements.get(u
rl)._checkboxElement.checked }); | 257 breakpoints.push({ url: url, enabled: this._breakpointElements.get(u
rl)._checkboxElement.checked }); |
| 251 this._xhrBreakpointsSetting.set(breakpoints); | 258 this._xhrBreakpointsSetting.set(breakpoints); |
| 252 }, | 259 }, |
| 253 | 260 |
| 254 /** | 261 /** |
| 255 * @param {!WebInspector.Target} target | 262 * @param {!WebInspector.Target} target |
| 256 */ | 263 */ |
| 257 _restoreBreakpoints: function(target) | 264 _restoreBreakpoints: function(target) |
| 258 { | 265 { |
| 259 var breakpoints = this._xhrBreakpointsSetting.get(); | 266 var breakpoints = this._xhrBreakpointsSetting.get(); |
| 260 for (var i = 0; i < breakpoints.length; ++i) { | 267 for (var i = 0; i < breakpoints.length; ++i) { |
| 261 var breakpoint = breakpoints[i]; | 268 var breakpoint = breakpoints[i]; |
| 262 if (breakpoint && typeof breakpoint.url === "string") | 269 if (breakpoint && typeof breakpoint.url === "string") |
| 263 this._setBreakpoint(breakpoint.url, breakpoint.enabled, target); | 270 this._setBreakpoint(breakpoint.url, breakpoint.enabled, target); |
| 264 } | 271 } |
| 265 }, | 272 }, |
| 266 | 273 |
| 267 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype | 274 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype |
| 268 } | 275 } |
| OLD | NEW |