| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 WebInspector.SnippetStorage = function(settingPrefix, namePrefix) | 35 WebInspector.SnippetStorage = function(settingPrefix, namePrefix) |
| 36 { | 36 { |
| 37 /** @type {!Map<string,!WebInspector.Snippet>} */ | 37 /** @type {!Map<string,!WebInspector.Snippet>} */ |
| 38 this._snippets = new Map(); | 38 this._snippets = new Map(); |
| 39 | 39 |
| 40 this._lastSnippetIdentifierSetting = WebInspector.settings.createSetting(set
tingPrefix + "Snippets_lastIdentifier", 0); | 40 this._lastSnippetIdentifierSetting = WebInspector.settings.createSetting(set
tingPrefix + "Snippets_lastIdentifier", 0); |
| 41 this._snippetsSetting = WebInspector.settings.createSetting(settingPrefix +
"Snippets", []); | 41 this._snippetsSetting = WebInspector.settings.createSetting(settingPrefix +
"Snippets", []); |
| 42 this._namePrefix = namePrefix; | 42 this._namePrefix = namePrefix; |
| 43 | 43 |
| 44 this._loadSettings(); | 44 this._loadSettings(); |
| 45 } | 45 }; |
| 46 | 46 |
| 47 WebInspector.SnippetStorage.prototype = { | 47 WebInspector.SnippetStorage.prototype = { |
| 48 get namePrefix() | 48 get namePrefix() |
| 49 { | 49 { |
| 50 return this._namePrefix; | 50 return this._namePrefix; |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 _saveSettings: function() | 53 _saveSettings: function() |
| 54 { | 54 { |
| 55 var savedSnippets = []; | 55 var savedSnippets = []; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * @param {!WebInspector.Snippet} snippet | 122 * @param {!WebInspector.Snippet} snippet |
| 123 */ | 123 */ |
| 124 _snippetAdded: function(snippet) | 124 _snippetAdded: function(snippet) |
| 125 { | 125 { |
| 126 this._snippets.set(snippet.id, snippet); | 126 this._snippets.set(snippet.id, snippet); |
| 127 }, | 127 }, |
| 128 | 128 |
| 129 __proto__: WebInspector.Object.prototype | 129 __proto__: WebInspector.Object.prototype |
| 130 } | 130 }; |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * @constructor | 133 * @constructor |
| 134 * @extends {WebInspector.Object} | 134 * @extends {WebInspector.Object} |
| 135 * @param {!WebInspector.SnippetStorage} storage | 135 * @param {!WebInspector.SnippetStorage} storage |
| 136 * @param {string} id | 136 * @param {string} id |
| 137 * @param {string=} name | 137 * @param {string=} name |
| 138 * @param {string=} content | 138 * @param {string=} content |
| 139 */ | 139 */ |
| 140 WebInspector.Snippet = function(storage, id, name, content) | 140 WebInspector.Snippet = function(storage, id, name, content) |
| 141 { | 141 { |
| 142 this._storage = storage; | 142 this._storage = storage; |
| 143 this._id = id; | 143 this._id = id; |
| 144 this._name = name || storage.namePrefix + id; | 144 this._name = name || storage.namePrefix + id; |
| 145 this._content = content || ""; | 145 this._content = content || ""; |
| 146 } | 146 }; |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @param {!WebInspector.SnippetStorage} storage | 149 * @param {!WebInspector.SnippetStorage} storage |
| 150 * @param {!Object} serializedSnippet | 150 * @param {!Object} serializedSnippet |
| 151 * @return {!WebInspector.Snippet} | 151 * @return {!WebInspector.Snippet} |
| 152 */ | 152 */ |
| 153 WebInspector.Snippet.fromObject = function(storage, serializedSnippet) | 153 WebInspector.Snippet.fromObject = function(storage, serializedSnippet) |
| 154 { | 154 { |
| 155 return new WebInspector.Snippet(storage, serializedSnippet.id, serializedSni
ppet.name, serializedSnippet.content); | 155 return new WebInspector.Snippet(storage, serializedSnippet.id, serializedSni
ppet.name, serializedSnippet.content); |
| 156 } | 156 }; |
| 157 | 157 |
| 158 WebInspector.Snippet.prototype = { | 158 WebInspector.Snippet.prototype = { |
| 159 /** | 159 /** |
| 160 * @return {string} | 160 * @return {string} |
| 161 */ | 161 */ |
| 162 get id() | 162 get id() |
| 163 { | 163 { |
| 164 return this._id; | 164 return this._id; |
| 165 }, | 165 }, |
| 166 | 166 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 serializeToObject: function() | 204 serializeToObject: function() |
| 205 { | 205 { |
| 206 var serializedSnippet = {}; | 206 var serializedSnippet = {}; |
| 207 serializedSnippet.id = this.id; | 207 serializedSnippet.id = this.id; |
| 208 serializedSnippet.name = this.name; | 208 serializedSnippet.name = this.name; |
| 209 serializedSnippet.content = this.content; | 209 serializedSnippet.content = this.content; |
| 210 return serializedSnippet; | 210 return serializedSnippet; |
| 211 }, | 211 }, |
| 212 | 212 |
| 213 __proto__: WebInspector.Object.prototype | 213 __proto__: WebInspector.Object.prototype |
| 214 } | 214 }; |
| OLD | NEW |