| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| 11 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
| 12 * 2. Redistributions in binary form must reproduce the above copyright | 12 * 2. Redistributions in binary form must reproduce the above copyright |
| 13 * notice, this list of conditions and the following disclaimer in the | 13 * notice, this list of conditions and the following disclaimer in the |
| 14 * documentation and/or other materials provided with the distribution. | 14 * documentation and/or other materials provided with the distribution. |
| 15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 16 * its contributors may be used to endorse or promote products derived | 16 * its contributors may be used to endorse or promote products derived |
| 17 * from this software without specific prior written permission. | 17 * from this software without specific prior written permission. |
| 18 * | 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | |
| 31 /** | 30 /** |
| 32 * @param {string} url | 31 * @param {string} url |
| 33 * @return {?WebInspector.Resource} | 32 * @return {?WebInspector.Resource} |
| 34 */ | 33 */ |
| 35 WebInspector.resourceForURL = function(url) | 34 WebInspector.resourceForURL = function(url) { |
| 36 { | 35 var targets = WebInspector.targetManager.targets(WebInspector.Target.Capabilit
y.DOM); |
| 37 var targets = WebInspector.targetManager.targets(WebInspector.Target.Capabil
ity.DOM); | 36 for (var i = 0; i < targets.length; ++i) { |
| 38 for (var i = 0; i < targets.length; ++i) { | 37 var resource = WebInspector.ResourceTreeModel.fromTarget(targets[i]).resourc
eForURL(url); |
| 39 var resource = WebInspector.ResourceTreeModel.fromTarget(targets[i]).res
ourceForURL(url); | 38 if (resource) |
| 40 if (resource) | 39 return resource; |
| 41 return resource; | 40 } |
| 42 } | 41 return null; |
| 43 return null; | |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 /** | 44 /** |
| 47 * @param {function(!WebInspector.Resource)} callback | 45 * @param {function(!WebInspector.Resource)} callback |
| 48 */ | 46 */ |
| 49 WebInspector.forAllResources = function(callback) | 47 WebInspector.forAllResources = function(callback) { |
| 50 { | 48 var targets = WebInspector.targetManager.targets(WebInspector.Target.Capabilit
y.DOM); |
| 51 var targets = WebInspector.targetManager.targets(WebInspector.Target.Capabil
ity.DOM); | 49 for (var i = 0; i < targets.length; ++i) |
| 52 for (var i = 0; i < targets.length; ++i) | 50 WebInspector.ResourceTreeModel.fromTarget(targets[i]).forAllResources(callba
ck); |
| 53 WebInspector.ResourceTreeModel.fromTarget(targets[i]).forAllResources(ca
llback); | |
| 54 }; | 51 }; |
| 55 | 52 |
| 56 /** | 53 /** |
| 57 * @param {string} url | 54 * @param {string} url |
| 58 * @return {string} | 55 * @return {string} |
| 59 */ | 56 */ |
| 60 WebInspector.displayNameForURL = function(url) | 57 WebInspector.displayNameForURL = function(url) { |
| 61 { | 58 if (!url) |
| 62 if (!url) | 59 return ''; |
| 63 return ""; | |
| 64 | 60 |
| 65 var resource = WebInspector.resourceForURL(url); | 61 var resource = WebInspector.resourceForURL(url); |
| 66 if (resource) | 62 if (resource) |
| 67 return resource.displayName; | 63 return resource.displayName; |
| 68 | 64 |
| 69 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarge
t(url); | 65 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarget(
url); |
| 70 if (uiSourceCode) | 66 if (uiSourceCode) |
| 71 return uiSourceCode.displayName(); | 67 return uiSourceCode.displayName(); |
| 72 | 68 |
| 73 var mainTarget = WebInspector.targetManager.mainTarget(); | 69 var mainTarget = WebInspector.targetManager.mainTarget(); |
| 74 var inspectedURL = mainTarget && mainTarget.inspectedURL(); | 70 var inspectedURL = mainTarget && mainTarget.inspectedURL(); |
| 75 if (!inspectedURL) | 71 if (!inspectedURL) |
| 76 return url.trimURL(""); | 72 return url.trimURL(''); |
| 77 | 73 |
| 78 var parsedURL = inspectedURL.asParsedURL(); | 74 var parsedURL = inspectedURL.asParsedURL(); |
| 79 var lastPathComponent = parsedURL ? parsedURL.lastPathComponent : parsedURL; | 75 var lastPathComponent = parsedURL ? parsedURL.lastPathComponent : parsedURL; |
| 80 var index = inspectedURL.indexOf(lastPathComponent); | 76 var index = inspectedURL.indexOf(lastPathComponent); |
| 81 if (index !== -1 && index + lastPathComponent.length === inspectedURL.length
) { | 77 if (index !== -1 && index + lastPathComponent.length === inspectedURL.length)
{ |
| 82 var baseURL = inspectedURL.substring(0, index); | 78 var baseURL = inspectedURL.substring(0, index); |
| 83 if (url.startsWith(baseURL)) | 79 if (url.startsWith(baseURL)) |
| 84 return url.substring(index); | 80 return url.substring(index); |
| 85 } | 81 } |
| 86 | 82 |
| 87 if (!parsedURL) | 83 if (!parsedURL) |
| 88 return url; | 84 return url; |
| 89 | 85 |
| 90 var displayName = url.trimURL(parsedURL.host); | 86 var displayName = url.trimURL(parsedURL.host); |
| 91 return displayName === "/" ? parsedURL.host + "/" : displayName; | 87 return displayName === '/' ? parsedURL.host + '/' : displayName; |
| 92 }; | 88 }; |
| OLD | NEW |