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

Side by Side Diff: Source/devtools/front_end/Resource.js

Issue 144283012: DevTools: Move the fallback for not loaded resources to NetworkUISourceCodeProvider.js (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: console.error was removed Created 6 years, 10 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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 /** 260 /**
261 * @param {?Protocol.Error} error 261 * @param {?Protocol.Error} error
262 * @param {!Array.<!PageAgent.SearchMatch>} searchMatches 262 * @param {!Array.<!PageAgent.SearchMatch>} searchMatches
263 */ 263 */
264 function callbackWrapper(error, searchMatches) 264 function callbackWrapper(error, searchMatches)
265 { 265 {
266 callback(searchMatches || []); 266 callback(searchMatches || []);
267 } 267 }
268 268
269 if (this.type === WebInspector.resourceTypes.Document) { 269 if (this.type === WebInspector.resourceTypes.Document) {
270 this.requestContent(documentContentLoaded); 270 callback([]);
271 return; 271 return;
272 } 272 }
273 273
274 /**
275 * @param {?string} content
276 */
277 function documentContentLoaded(content)
278 {
279 if (content === null) {
280 callback([]);
281 return;
282 }
283
284 var result = WebInspector.ContentProvider.performSearchInContent(con tent, query, caseSensitive, isRegex);
285 callback(result);
286 }
287
288 if (this.frameId) 274 if (this.frameId)
289 PageAgent.searchInResource(this.frameId, this.url, query, caseSensit ive, isRegex, callbackWrapper); 275 PageAgent.searchInResource(this.frameId, this.url, query, caseSensit ive, isRegex, callbackWrapper);
290 else 276 else
291 callback([]); 277 callback([]);
292 }, 278 },
293 279
294 /** 280 /**
295 * @param {!Element} image 281 * @param {!Element} image
296 */ 282 */
297 populateImageSource: function(image) 283 populateImageSource: function(image)
(...skipping 29 matching lines...) Expand all
327 313
328 /** 314 /**
329 * @param {?Protocol.Error} error 315 * @param {?Protocol.Error} error
330 * @param {?string} content 316 * @param {?string} content
331 * @param {boolean} contentEncoded 317 * @param {boolean} contentEncoded
332 * @this {WebInspector.Resource} 318 * @this {WebInspector.Resource}
333 */ 319 */
334 function contentLoaded(error, content, contentEncoded) 320 function contentLoaded(error, content, contentEncoded)
335 { 321 {
336 if (error || content === null) { 322 if (error || content === null) {
337 loadFallbackContent.call(this, error); 323 replyWithContent.call(this, null, false);
338 return; 324 return;
339 } 325 }
340 replyWithContent.call(this, content, contentEncoded); 326 replyWithContent.call(this, content, contentEncoded);
341 } 327 }
342 328
343 /** 329 /**
344 * @param {?string} content 330 * @param {?string} content
345 * @param {boolean} contentEncoded 331 * @param {boolean} contentEncoded
346 * @this {WebInspector.Resource} 332 * @this {WebInspector.Resource}
347 */ 333 */
(...skipping 11 matching lines...) Expand all
359 /** 345 /**
360 * @param {?Protocol.Error} error 346 * @param {?Protocol.Error} error
361 * @param {string} content 347 * @param {string} content
362 * @param {boolean} contentEncoded 348 * @param {boolean} contentEncoded
363 * @this {WebInspector.Resource} 349 * @this {WebInspector.Resource}
364 */ 350 */
365 function resourceContentLoaded(error, content, contentEncoded) 351 function resourceContentLoaded(error, content, contentEncoded)
366 { 352 {
367 contentLoaded.call(this, error, content, contentEncoded); 353 contentLoaded.call(this, error, content, contentEncoded);
368 } 354 }
369
370 /**
371 * @param {?Protocol.Error} error
372 * @this {WebInspector.Resource}
373 */
374 function loadFallbackContent(error)
375 {
376 var scripts = WebInspector.debuggerModel.scriptsForSourceURL(this.ur l);
377 if (!scripts.length) {
378 console.error("Resource content request failed: " + error);
379 replyWithContent.call(this, null, false);
380 return;
381 }
382
383 var contentProvider;
384 if (this.type === WebInspector.resourceTypes.Document)
385 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts);
386 else if (this.type === WebInspector.resourceTypes.Script)
387 contentProvider = scripts[0];
388
389 if (!contentProvider) {
390 console.error("Resource content request failed: " + error);
391 replyWithContent.call(this, null, false);
392 return;
393 }
394
395 contentProvider.requestContent(fallbackContentLoaded.bind(this));
396 }
397
398 /**
399 * @param {?string} content
400 * @this {WebInspector.Resource}
401 */
402 function fallbackContentLoaded(content)
403 {
404 replyWithContent.call(this, content, false);
405 }
406 355
407 if (this.request) { 356 if (this.request) {
408 this.request.requestContent(requestContentLoaded.bind(this)); 357 this.request.requestContent(requestContentLoaded.bind(this));
409 return; 358 return;
410 } 359 }
411 360
412 /** 361 /**
413 * @param {?string} content 362 * @param {?string} content
414 * @this {WebInspector.Resource} 363 * @this {WebInspector.Resource}
415 */ 364 */
416 function requestContentLoaded(content) 365 function requestContentLoaded(content)
417 { 366 {
418 contentLoaded.call(this, null, content, this.request.contentEncoded) ; 367 contentLoaded.call(this, null, content, this.request.contentEncoded) ;
419 } 368 }
420 369
421 PageAgent.getResourceContent(this.frameId, this.url, resourceContentLoad ed.bind(this)); 370 PageAgent.getResourceContent(this.frameId, this.url, resourceContentLoad ed.bind(this));
422 }, 371 },
423 372
424 /** 373 /**
425 * @return {boolean} 374 * @return {boolean}
426 */ 375 */
427 isHidden: function() 376 isHidden: function()
428 { 377 {
429 return !!this._isHidden; 378 return !!this._isHidden;
430 }, 379 },
431 380
432 __proto__: WebInspector.Object.prototype 381 __proto__: WebInspector.Object.prototype
433 } 382 }
434 383
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698