Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 WebInspector.PersistenceUtils = class { | 5 WebInspector.PersistenceUtils = class { |
| 6 /** | 6 /** |
| 7 * @param {!WebInspector.UISourceCode} uiSourceCode | 7 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 8 * @return {string} | 8 * @return {string} |
| 9 */ | 9 */ |
| 10 static tooltipForUISourceCode(uiSourceCode) { | 10 static tooltipForUISourceCode(uiSourceCode) { |
| 11 var binding = WebInspector.persistence.binding(uiSourceCode); | 11 var binding = WebInspector.persistence.binding(uiSourceCode); |
| 12 if (!binding) | 12 if (!binding) |
| 13 return ''; | 13 return ''; |
| 14 if (uiSourceCode === binding.network) | 14 if (uiSourceCode === binding.network) |
| 15 return WebInspector.UIString('Persisted to file system: %s', binding.fileS ystem.url().trimMiddle(150)); | 15 return WebInspector.UIString('Persisted to file system: %s', binding.fileS ystem.url().trimMiddle(150)); |
| 16 if (binding.network.contentType().isFromSourceMap()) | 16 if (binding.network.contentType().isFromSourceMap()) |
| 17 return WebInspector.UIString('Linked to source map: %s', binding.network.u rl().trimMiddle(150)); | 17 return WebInspector.UIString('Linked to source map: %s', binding.network.u rl().trimMiddle(150)); |
| 18 return WebInspector.UIString('Linked to %s', binding.network.url().trimMiddl e(150)); | 18 return WebInspector.UIString('Linked to %s', binding.network.url().trimMiddl e(150)); |
| 19 } | 19 } |
| 20 }; | 20 }; |
| 21 | |
| 22 /** | |
| 23 * @extends {WebInspector.Object} | |
| 24 * @implements {WebInspector.LinkDecorator} | |
| 25 */ | |
| 26 WebInspector.PersistenceUtils.LinkDecorator = class extends WebInspector.Object { | |
| 27 constructor(persistence) { | |
|
dgozman
2016/11/10 01:01:43
JSDoc
lushnikov
2016/11/10 01:13:45
Done.
| |
| 28 super(); | |
| 29 persistence.addEventListener(WebInspector.Persistence.Events.BindingCreated, this._bindingChanged, this); | |
| 30 persistence.addEventListener(WebInspector.Persistence.Events.BindingRemoved, this._bindingChanged, this); | |
| 31 } | |
| 32 | |
| 33 /** | |
| 34 * @param {!WebInspector.Event} event | |
| 35 */ | |
| 36 _bindingChanged(event) { | |
| 37 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data); | |
| 38 this.dispatchEventToListeners(WebInspector.LinkDecorator.Events.LinkIconChan ged, binding.network); | |
| 39 } | |
| 40 | |
| 41 /** | |
| 42 * @override | |
| 43 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 44 * @return {?WebInspector.Icon} | |
| 45 */ | |
| 46 linkIcon(uiSourceCode) { | |
| 47 var binding = WebInspector.persistence.binding(uiSourceCode); | |
| 48 if (!binding) | |
| 49 return null; | |
| 50 var icon = WebInspector.Icon.create('smallicon-green-checkmark'); | |
| 51 icon.title = WebInspector.PersistenceUtils.tooltipForUISourceCode(uiSourceCo de); | |
| 52 return icon; | |
| 53 } | |
| 54 }; | |
| OLD | NEW |