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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 FileMappingRemoved: "FileMappingRemoved" | 46 FileMappingRemoved: "FileMappingRemoved" |
47 } | 47 } |
48 | 48 |
49 WebInspector.FileSystemMapping.prototype = { | 49 WebInspector.FileSystemMapping.prototype = { |
50 _loadFromSettings: function() | 50 _loadFromSettings: function() |
51 { | 51 { |
52 var savedMapping = this._fileSystemMappingSetting.get(); | 52 var savedMapping = this._fileSystemMappingSetting.get(); |
53 this._fileSystemMappings = {}; | 53 this._fileSystemMappings = {}; |
54 for (var fileSystemPath in savedMapping) { | 54 for (var fileSystemPath in savedMapping) { |
55 var savedFileSystemMappings = savedMapping[fileSystemPath]; | 55 var savedFileSystemMappings = savedMapping[fileSystemPath]; |
56 | |
57 this._fileSystemMappings[fileSystemPath] = []; | 56 this._fileSystemMappings[fileSystemPath] = []; |
58 var fileSystemMappings = this._fileSystemMappings[fileSystemPath]; | 57 var fileSystemMappings = this._fileSystemMappings[fileSystemPath]; |
59 | 58 |
60 for (var i = 0; i < savedFileSystemMappings.length; ++i) { | 59 for (var i = 0; i < savedFileSystemMappings.length; ++i) { |
61 var savedEntry = savedFileSystemMappings[i]; | 60 var savedEntry = savedFileSystemMappings[i]; |
62 var entry = new WebInspector.FileSystemMapping.Entry(savedEntry.
fileSystemPath, savedEntry.urlPrefix, savedEntry.pathPrefix, true); | 61 var entry = new WebInspector.FileSystemMapping.Entry(savedEntry.
fileSystemPath, savedEntry.urlPrefix, savedEntry.pathPrefix, true); |
63 fileSystemMappings.push(entry); | 62 fileSystemMappings.push(entry); |
64 } | 63 } |
65 } | 64 } |
66 | 65 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 this._saveToSettings(); | 124 this._saveToSettings(); |
126 }, | 125 }, |
127 | 126 |
128 /** | 127 /** |
129 * @param {string} fileSystemPath | 128 * @param {string} fileSystemPath |
130 * @param {string} urlPrefix | 129 * @param {string} urlPrefix |
131 * @param {string} pathPrefix | 130 * @param {string} pathPrefix |
132 */ | 131 */ |
133 addFileMapping: function(fileSystemPath, urlPrefix, pathPrefix) | 132 addFileMapping: function(fileSystemPath, urlPrefix, pathPrefix) |
134 { | 133 { |
| 134 if (!urlPrefix.endsWith("/")) |
| 135 urlPrefix += "/"; |
| 136 if (!pathPrefix.endsWith("/")) |
| 137 pathPrefix += "/"; |
| 138 if (!pathPrefix.startsWith("/")) |
| 139 pathPrefix = "/" + pathPrefix; |
135 this._innerAddFileMapping(fileSystemPath, urlPrefix, pathPrefix, true); | 140 this._innerAddFileMapping(fileSystemPath, urlPrefix, pathPrefix, true); |
136 this._saveToSettings(); | 141 this._saveToSettings(); |
137 }, | 142 }, |
138 | 143 |
139 /** | 144 /** |
140 * @param {string} fileSystemPath | 145 * @param {string} fileSystemPath |
141 * @param {string} urlPrefix | 146 * @param {string} urlPrefix |
142 * @param {string} pathPrefix | 147 * @param {string} pathPrefix |
143 */ | 148 */ |
144 addNonConfigurableFileMapping: function(fileSystemPath, urlPrefix, pathPrefi
x) | 149 addNonConfigurableFileMapping: function(fileSystemPath, urlPrefix, pathPrefi
x) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return null; | 207 return null; |
203 | 208 |
204 var entry = null; | 209 var entry = null; |
205 for (var i = 0; i < entries.length; ++i) { | 210 for (var i = 0; i < entries.length; ++i) { |
206 var pathPrefix = entries[i].pathPrefix; | 211 var pathPrefix = entries[i].pathPrefix; |
207 if (entry && entry.configurable && !entries[i].configurable) | 212 if (entry && entry.configurable && !entries[i].configurable) |
208 continue; | 213 continue; |
209 // We are looking for the longest pathPrefix match. | 214 // We are looking for the longest pathPrefix match. |
210 if (entry && entry.pathPrefix.length > pathPrefix.length) | 215 if (entry && entry.pathPrefix.length > pathPrefix.length) |
211 continue; | 216 continue; |
212 if (filePath.startsWith(pathPrefix.substr(1))) | 217 if (filePath.startsWith(pathPrefix)) |
213 entry = entries[i]; | 218 entry = entries[i]; |
214 } | 219 } |
215 return entry; | 220 return entry; |
216 }, | 221 }, |
217 | 222 |
218 /** | 223 /** |
219 * @param {string} fileSystemPath | 224 * @param {string} fileSystemPath |
220 * @param {string} pathPrefix | 225 * @param {string} pathPrefix |
221 * @return {?WebInspector.FileSystemMapping.Entry} | 226 * @return {?WebInspector.FileSystemMapping.Entry} |
222 */ | 227 */ |
(...skipping 20 matching lines...) Expand all Loading... |
243 * @param {string} url | 248 * @param {string} url |
244 * @return {boolean} | 249 * @return {boolean} |
245 */ | 250 */ |
246 hasMappingForURL: function(url) | 251 hasMappingForURL: function(url) |
247 { | 252 { |
248 return !!this._mappingEntryForURL(url); | 253 return !!this._mappingEntryForURL(url); |
249 }, | 254 }, |
250 | 255 |
251 /** | 256 /** |
252 * @param {string} url | 257 * @param {string} url |
253 * @return {?{fileSystemPath: string, filePath: string}} | 258 * @return {?{fileSystemPath: string, fileURL: string}} |
254 */ | 259 */ |
255 fileForURL: function(url) | 260 fileForURL: function(url) |
256 { | 261 { |
257 var entry = this._mappingEntryForURL(url); | 262 var entry = this._mappingEntryForURL(url); |
258 if (!entry) | 263 if (!entry) |
259 return null; | 264 return null; |
260 var file = {}; | 265 var file = {}; |
261 file.fileSystemPath = entry.fileSystemPath; | 266 file.fileSystemPath = entry.fileSystemPath; |
262 file.filePath = entry.pathPrefix.substr(1) + url.substr(entry.urlPrefix.
length); | 267 file.fileURL = "file://" + entry.fileSystemPath + entry.pathPrefix + url
.substr(entry.urlPrefix.length); |
263 return file; | 268 return file; |
264 }, | 269 }, |
265 | 270 |
266 /** | 271 /** |
267 * @param {string} fileSystemPath | 272 * @param {string} fileSystemPath |
268 * @param {string} filePath | 273 * @param {string} filePath |
269 * @return {string} | 274 * @return {string} |
270 */ | 275 */ |
271 urlForPath: function(fileSystemPath, filePath) | 276 urlForPath: function(fileSystemPath, filePath) |
272 { | 277 { |
273 var entry = this._mappingEntryForPath(fileSystemPath, filePath); | 278 var relativePath = filePath.substring("file://".length + fileSystemPath.
length); |
| 279 var entry = this._mappingEntryForPath(fileSystemPath, relativePath); |
274 if (!entry) | 280 if (!entry) |
275 return ""; | 281 return ""; |
276 return entry.urlPrefix + filePath.substring(entry.pathPrefix.length - 1)
; | 282 return entry.urlPrefix + relativePath.substring(entry.pathPrefix.length)
; |
277 }, | 283 }, |
278 | 284 |
279 /** | 285 /** |
280 * @param {string} url | 286 * @param {string} url |
281 */ | 287 */ |
282 removeMappingForURL: function(url) | 288 removeMappingForURL: function(url) |
283 { | 289 { |
284 var entry = this._mappingEntryForURL(url); | 290 var entry = this._mappingEntryForURL(url); |
285 if (!entry || !entry.configurable) | 291 if (!entry || !entry.configurable) |
286 return; | 292 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 this.fileSystemPath = fileSystemPath; | 336 this.fileSystemPath = fileSystemPath; |
331 this.urlPrefix = urlPrefix; | 337 this.urlPrefix = urlPrefix; |
332 this.pathPrefix = pathPrefix; | 338 this.pathPrefix = pathPrefix; |
333 this.configurable = configurable; | 339 this.configurable = configurable; |
334 } | 340 } |
335 | 341 |
336 /** | 342 /** |
337 * @type {!WebInspector.FileSystemMapping} | 343 * @type {!WebInspector.FileSystemMapping} |
338 */ | 344 */ |
339 WebInspector.fileSystemMapping; | 345 WebInspector.fileSystemMapping; |
OLD | NEW |