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

Side by Side Diff: Source/devtools/front_end/sdk/NetworkUISourceCodeProvider.js

Issue 356033002: DevTools: Get rid of WebInspector.debuggerModel in NetworkUISourceCodeProvider (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comments Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 */ 59 */
60 targetRemoved: function(target) 60 targetRemoved: function(target)
61 { 61 {
62 // FIXME: add workspace cleanup here. 62 // FIXME: add workspace cleanup here.
63 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this); 63 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this);
64 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); 64 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
65 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even ts.ParsedScriptSource, this._parsedScriptSource, this); 65 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even ts.ParsedScriptSource, this._parsedScriptSource, this);
66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St yleSheetAdded, this._styleSheetAdded, this); 66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St yleSheetAdded, this._styleSheetAdded, this);
67 }, 67 },
68 68
69 _populate: function() 69 /**
70 * @param {!WebInspector.Target} target
71 */
72 _populate: function(target)
70 { 73 {
71 /** 74 /**
72 * @param {!WebInspector.ResourceTreeFrame} frame 75 * @param {!WebInspector.ResourceTreeFrame} frame
73 * @this {WebInspector.NetworkUISourceCodeProvider} 76 * @this {WebInspector.NetworkUISourceCodeProvider}
74 */ 77 */
75 function populateFrame(frame) 78 function populateFrame(frame)
76 { 79 {
77 for (var i = 0; i < frame.childFrames.length; ++i) 80 for (var i = 0; i < frame.childFrames.length; ++i)
78 populateFrame.call(this, frame.childFrames[i]); 81 populateFrame.call(this, frame.childFrames[i]);
79 82
80 var resources = frame.resources(); 83 var resources = frame.resources();
81 for (var i = 0; i < resources.length; ++i) 84 for (var i = 0; i < resources.length; ++i)
82 this._resourceAdded({data:resources[i]}); 85 this._addFile(resources[i].url, new WebInspector.NetworkUISource CodeProvider.FallbackResource(resources[i]));
83 } 86 }
84 87
85 populateFrame.call(this, WebInspector.resourceTreeModel.mainFrame); 88 var mainFrame = target.resourceTreeModel.mainFrame;
89 if (mainFrame)
90 populateFrame.call(this, mainFrame);
86 }, 91 },
87 92
88 /** 93 /**
89 * @param {!WebInspector.Event} event 94 * @param {!WebInspector.Event} event
90 */ 95 */
91 _parsedScriptSource: function(event) 96 _parsedScriptSource: function(event)
92 { 97 {
93 var script = /** @type {!WebInspector.Script} */ (event.data); 98 var script = /** @type {!WebInspector.Script} */ (event.data);
94 if (!script.sourceURL || script.isInlineScript() || script.isSnippet()) 99 if (!script.sourceURL || script.isInlineScript() || script.isSnippet())
95 return; 100 return;
(...skipping 12 matching lines...) Expand all
108 _styleSheetAdded: function(event) 113 _styleSheetAdded: function(event)
109 { 114 {
110 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); 115 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a);
111 if ((!header.hasSourceURL || header.isInline) && header.origin !== "insp ector") 116 if ((!header.hasSourceURL || header.isInline) && header.origin !== "insp ector")
112 return; 117 return;
113 118
114 this._addFile(header.resourceURL(), header, false); 119 this._addFile(header.resourceURL(), header, false);
115 }, 120 },
116 121
117 /** 122 /**
118 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event 123 * @param {!WebInspector.Event} event
119 */ 124 */
120 _resourceAdded: function(event) 125 _resourceAdded: function(event)
121 { 126 {
122 var resource = /** @type {!WebInspector.Resource} */ (event.data); 127 var resource = /** @type {!WebInspector.Resource} */ (event.data);
123 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider .FallbackResource(resource)); 128 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider .FallbackResource(resource));
124 }, 129 },
125 130
126 /** 131 /**
127 * @param {!WebInspector.Event} event 132 * @param {!WebInspector.Event} event
128 */ 133 */
129 _mainFrameNavigated: function(event) 134 _mainFrameNavigated: function(event)
130 { 135 {
131 this._reset(); 136 var resourceTreeModel = /** @type {!WebInspector.ResourceTreeModel} */ ( event.target);
137 //We assume that mainFrameNavigated could be fired only in one main targ et
138 this._reset(resourceTreeModel.target());
132 }, 139 },
133 140
134 /** 141 /**
135 * @param {string} url 142 * @param {string} url
136 * @param {!WebInspector.ContentProvider} contentProvider 143 * @param {!WebInspector.ContentProvider} contentProvider
137 * @param {boolean=} isContentScript 144 * @param {boolean=} isContentScript
138 */ 145 */
139 _addFile: function(url, contentProvider, isContentScript) 146 _addFile: function(url, contentProvider, isContentScript)
140 { 147 {
141 if (this._workspace.hasMappingForURL(url)) 148 if (this._workspace.hasMappingForURL(url))
142 return; 149 return;
143 150
144 var type = contentProvider.contentType(); 151 var type = contentProvider.contentType();
145 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) 152 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script)
146 return; 153 return;
147 if (this._processedURLs[url]) 154 if (this._processedURLs[url])
148 return; 155 return;
149 this._processedURLs[url] = true; 156 this._processedURLs[url] = true;
150 this._networkWorkspaceBinding.addFileForURL(url, contentProvider, isCont entScript); 157 this._networkWorkspaceBinding.addFileForURL(url, contentProvider, isCont entScript);
151 }, 158 },
152 159
153 _reset: function() 160 /**
161 * @param {!WebInspector.Target} target
162 */
163 _reset: function(target)
154 { 164 {
155 this._processedURLs = {}; 165 this._processedURLs = {};
156 this._networkWorkspaceBinding.reset(); 166 this._networkWorkspaceBinding.reset();
157 this._populate(); 167 this._populate(target);
158 } 168 }
159 } 169 }
160 170
161 /** 171 /**
162 * @constructor 172 * @constructor
163 * @implements {WebInspector.ContentProvider} 173 * @implements {WebInspector.ContentProvider}
164 * @param {!WebInspector.Resource} resource 174 * @param {!WebInspector.Resource} resource
165 */ 175 */
166 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(resource) 176 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(resource)
167 { 177 {
(...skipping 21 matching lines...) Expand all
189 /** 199 /**
190 * @param {function(?string)} callback 200 * @param {function(?string)} callback
191 */ 201 */
192 requestContent: function(callback) 202 requestContent: function(callback)
193 { 203 {
194 /** 204 /**
195 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} 205 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource}
196 */ 206 */
197 function loadFallbackContent() 207 function loadFallbackContent()
198 { 208 {
199 var scripts = WebInspector.debuggerModel.scriptsForSourceURL(this._r esource.url); 209 var scripts = this._resource.target().debuggerModel.scriptsForSource URL(this._resource.url);
200 if (!scripts.length) { 210 if (!scripts.length) {
201 callback(null); 211 callback(null);
202 return; 212 return;
203 } 213 }
204 214
205 var contentProvider; 215 var contentProvider;
206 if (this._resource.type === WebInspector.resourceTypes.Document) 216 if (this._resource.type === WebInspector.resourceTypes.Document)
207 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts); 217 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts);
208 else if (this._resource.type === WebInspector.resourceTypes.Script) 218 else if (this._resource.type === WebInspector.resourceTypes.Script)
209 contentProvider = scripts[0]; 219 contentProvider = scripts[0];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 266 }
257 267
258 this._resource.searchInContent(query, caseSensitive, isRegex, callback); 268 this._resource.searchInContent(query, caseSensitive, isRegex, callback);
259 } 269 }
260 } 270 }
261 271
262 /** 272 /**
263 * @type {!WebInspector.NetworkWorkspaceBinding} 273 * @type {!WebInspector.NetworkWorkspaceBinding}
264 */ 274 */
265 WebInspector.networkWorkspaceBinding; 275 WebInspector.networkWorkspaceBinding;
OLDNEW
« no previous file with comments | « LayoutTests/inspector/sources/debugger/network-uisourcecode-provider.html ('k') | Source/devtools/front_end/sdk/Resource.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698