| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 this._fetchResourceTree(); | 52 this._fetchResourceTree(); |
| 53 | 53 |
| 54 target.registerPageDispatcher(new SDK.PageDispatcher(this)); | 54 target.registerPageDispatcher(new SDK.PageDispatcher(this)); |
| 55 | 55 |
| 56 this._pendingReloadOptions = null; | 56 this._pendingReloadOptions = null; |
| 57 this._reloadSuspensionCount = 0; | 57 this._reloadSuspensionCount = 0; |
| 58 this._isInterstitialShowing = false; | 58 this._isInterstitialShowing = false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @param {!SDK.ResourceTreeFrame} frame |
| 63 * @return {?SDK.ResourceTreeFrame} |
| 64 */ |
| 65 static _parentFrameAcrossTargets(frame) { |
| 66 var parentFrame = frame.parentFrame; |
| 67 if (parentFrame) |
| 68 return parentFrame; |
| 69 var parentTarget = frame.resourceTreeModel().target().parentTarget(); |
| 70 var otherModel = parentTarget && parentTarget.model(SDK.ResourceTreeModel); |
| 71 if (!otherModel) |
| 72 return null; |
| 73 return otherModel.mainFrame; |
| 74 } |
| 75 |
| 76 /** |
| 77 * @param {!SDK.ResourceTreeFrame} frame |
| 78 * @return {!Array<!SDK.ResourceTreeFrame>} |
| 79 */ |
| 80 static framePath(frame) { |
| 81 var path = []; |
| 82 var currentFrame = frame; |
| 83 while (currentFrame) { |
| 84 path.push(currentFrame); |
| 85 currentFrame = SDK.ResourceTreeModel._parentFrameAcrossTargets(currentFram
e); |
| 86 } |
| 87 return path.reverse(); |
| 88 } |
| 89 |
| 90 /** |
| 91 * @param {?SDK.ResourceTreeFrame} a |
| 92 * @param {?SDK.ResourceTreeFrame} b |
| 93 * @return {number} |
| 94 */ |
| 95 static _frameComparator(a, b) { |
| 96 var framesA = a ? SDK.ResourceTreeModel.framePath(a) : []; |
| 97 var framesB = b ? SDK.ResourceTreeModel.framePath(b) : []; |
| 98 var frameA; |
| 99 var frameB; |
| 100 for (var i = 0;; i++) { |
| 101 if (!framesA[i] || !framesB[i] || (framesA[i] !== framesB[i])) { |
| 102 frameA = framesA[i]; |
| 103 frameB = framesB[i]; |
| 104 break; |
| 105 } |
| 106 } |
| 107 if (!frameA && frameB) |
| 108 return -1; |
| 109 |
| 110 if (!frameB && frameA) |
| 111 return 1; |
| 112 |
| 113 if (frameA && frameB) |
| 114 return frameA.id.localeCompare(frameB.id); |
| 115 |
| 116 return 0; |
| 117 } |
| 118 |
| 119 /** |
| 62 * @return {!Array.<!SDK.ResourceTreeFrame>} | 120 * @return {!Array.<!SDK.ResourceTreeFrame>} |
| 63 */ | 121 */ |
| 64 static frames() { | 122 static frames() { |
| 65 var result = []; | 123 var result = []; |
| 66 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel
)) | 124 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel
)) |
| 67 result = result.concat(resourceTreeModel._frames.valuesArray()); | 125 result = result.concat(resourceTreeModel._frames.valuesArray()); |
| 126 result.sort(SDK.ResourceTreeModel._frameComparator); |
| 68 return result; | 127 return result; |
| 69 } | 128 } |
| 70 | 129 |
| 71 /** | 130 /** |
| 72 * @param {string} url | 131 * @param {string} url |
| 73 * @return {?SDK.Resource} | 132 * @return {?SDK.Resource} |
| 74 */ | 133 */ |
| 75 static resourceForURL(url) { | 134 static resourceForURL(url) { |
| 76 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel
)) { | 135 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel
)) { |
| 77 var mainFrame = resourceTreeModel.mainFrame; | 136 var mainFrame = resourceTreeModel.mainFrame; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 * @param {string=} data | 472 * @param {string=} data |
| 414 */ | 473 */ |
| 415 function myCallback(protocolError, url, errors, data) { | 474 function myCallback(protocolError, url, errors, data) { |
| 416 if (protocolError) { | 475 if (protocolError) { |
| 417 callback(url, null, []); | 476 callback(url, null, []); |
| 418 return; | 477 return; |
| 419 } | 478 } |
| 420 callback(url, data || null, errors); | 479 callback(url, data || null, errors); |
| 421 } | 480 } |
| 422 } | 481 } |
| 482 |
| 423 /** | 483 /** |
| 424 * @param {!SDK.ExecutionContext} a | 484 * @param {!SDK.ExecutionContext} a |
| 425 * @param {!SDK.ExecutionContext} b | 485 * @param {!SDK.ExecutionContext} b |
| 426 * @return {number} | 486 * @return {number} |
| 427 */ | 487 */ |
| 428 _executionContextComparator(a, b) { | 488 _executionContextComparator(a, b) { |
| 429 /** | |
| 430 * @param {!SDK.ResourceTreeFrame} frame | |
| 431 */ | |
| 432 function framePath(frame) { | |
| 433 var currentFrame = frame; | |
| 434 var parents = []; | |
| 435 while (currentFrame) { | |
| 436 parents.push(currentFrame); | |
| 437 currentFrame = currentFrame.parentFrame; | |
| 438 } | |
| 439 return parents.reverse(); | |
| 440 } | |
| 441 | |
| 442 if (a.target() !== b.target()) | 489 if (a.target() !== b.target()) |
| 443 return SDK.ExecutionContext.comparator(a, b); | 490 return SDK.ExecutionContext.comparator(a, b); |
| 444 | 491 |
| 445 var framesA = a.frameId ? framePath(this.frameForId(a.frameId)) : []; | 492 var frameA = a.frameId ? this.frameForId(a.frameId) : null; |
| 446 var framesB = b.frameId ? framePath(this.frameForId(b.frameId)) : []; | 493 var frameB = b.frameId ? this.frameForId(b.frameId) : null; |
| 447 var frameA; | |
| 448 var frameB; | |
| 449 for (var i = 0;; i++) { | |
| 450 if (!framesA[i] || !framesB[i] || (framesA[i] !== framesB[i])) { | |
| 451 frameA = framesA[i]; | |
| 452 frameB = framesB[i]; | |
| 453 break; | |
| 454 } | |
| 455 } | |
| 456 if (!frameA && frameB) | |
| 457 return -1; | |
| 458 | 494 |
| 459 if (!frameB && frameA) | 495 if (!frameA && !frameB) |
| 460 return 1; | 496 return SDK.ExecutionContext.comparator(a, b); |
| 461 | 497 |
| 462 if (frameA && frameB) | 498 return SDK.ResourceTreeModel._frameComparator(frameA, frameB); |
| 463 return frameA.id.localeCompare(frameB.id); | |
| 464 | |
| 465 return SDK.ExecutionContext.comparator(a, b); | |
| 466 } | 499 } |
| 467 | 500 |
| 468 _updateSecurityOrigins() { | 501 _updateSecurityOrigins() { |
| 469 var securityOrigins = new Set(); | 502 var securityOrigins = new Set(); |
| 470 var mainSecurityOrigin = null; | 503 var mainSecurityOrigin = null; |
| 471 for (var frame of this._frames.values()) { | 504 for (var frame of this._frames.values()) { |
| 472 var origin = frame.securityOrigin; | 505 var origin = frame.securityOrigin; |
| 473 if (!origin) | 506 if (!origin) |
| 474 continue; | 507 continue; |
| 475 securityOrigins.add(origin); | 508 securityOrigins.add(origin); |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event
s.InterstitialHidden); | 917 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event
s.InterstitialHidden); |
| 885 } | 918 } |
| 886 | 919 |
| 887 /** | 920 /** |
| 888 * @override | 921 * @override |
| 889 */ | 922 */ |
| 890 navigationRequested() { | 923 navigationRequested() { |
| 891 // Frontend is not interested in when navigations are requested. | 924 // Frontend is not interested in when navigations are requested. |
| 892 } | 925 } |
| 893 }; | 926 }; |
| OLD | NEW |