Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/ResourceUtils.js

Issue 2186753002: [DevTools] Track URL through the target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return ""; 63 return "";
64 64
65 var resource = WebInspector.resourceForURL(url); 65 var resource = WebInspector.resourceForURL(url);
66 if (resource) 66 if (resource)
67 return resource.displayName; 67 return resource.displayName;
68 68
69 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarge t(url); 69 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarge t(url);
70 if (uiSourceCode) 70 if (uiSourceCode)
71 return uiSourceCode.displayName(); 71 return uiSourceCode.displayName();
72 72
73 if (!WebInspector.targetManager.inspectedPageURL()) 73 var mainTarget = WebInspector.targetManager.mainTarget();
74 var inspectedURL = mainTarget && mainTarget.inspectedURL();
75 if (!inspectedURL)
74 return url.trimURL(""); 76 return url.trimURL("");
75 77
76 var parsedURL = WebInspector.targetManager.inspectedPageURL().asParsedURL(); 78 var parsedURL = inspectedURL.asParsedURL();
77 var lastPathComponent = parsedURL ? parsedURL.lastPathComponent : parsedURL; 79 var lastPathComponent = parsedURL ? parsedURL.lastPathComponent : parsedURL;
78 var index = WebInspector.targetManager.inspectedPageURL().indexOf(lastPathCo mponent); 80 var index = inspectedURL.indexOf(lastPathComponent);
79 if (index !== -1 && index + lastPathComponent.length === WebInspector.target Manager.inspectedPageURL().length) { 81 if (index !== -1 && index + lastPathComponent.length === inspectedURL.length ) {
80 var baseURL = WebInspector.targetManager.inspectedPageURL().substring(0, index); 82 var baseURL = inspectedURL.substring(0, index);
81 if (url.startsWith(baseURL)) 83 if (url.startsWith(baseURL))
82 return url.substring(index); 84 return url.substring(index);
83 } 85 }
84 86
85 if (!parsedURL) 87 if (!parsedURL)
86 return url; 88 return url;
87 89
88 var displayName = url.trimURL(parsedURL.host); 90 var displayName = url.trimURL(parsedURL.host);
89 return displayName === "/" ? parsedURL.host + "/" : displayName; 91 return displayName === "/" ? parsedURL.host + "/" : displayName;
90 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698