| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 Runtime._console = console; | 449 Runtime._console = console; |
| 450 Runtime._originalAssert = console.assert; | 450 Runtime._originalAssert = console.assert; |
| 451 Runtime._assert = function(value, message) | 451 Runtime._assert = function(value, message) |
| 452 { | 452 { |
| 453 if (value) | 453 if (value) |
| 454 return; | 454 return; |
| 455 Runtime._originalAssert.call(Runtime._console, value, message + " " + new Er
ror().stack); | 455 Runtime._originalAssert.call(Runtime._console, value, message + " " + new Er
ror().stack); |
| 456 } | 456 } |
| 457 | 457 |
| 458 Runtime._platform = ""; |
| 459 |
| 460 /** |
| 461 * @param {string} platform |
| 462 */ |
| 463 Runtime.setPlatform = function(platform) |
| 464 { |
| 465 Runtime._platform = platform; |
| 466 } |
| 467 |
| 458 Runtime.prototype = { | 468 Runtime.prototype = { |
| 459 useTestBase: function() | 469 useTestBase: function() |
| 460 { | 470 { |
| 461 Runtime._remoteBase = "http://localhost:8000/inspector-sources/"; | 471 Runtime._remoteBase = "http://localhost:8000/inspector-sources/"; |
| 462 }, | 472 }, |
| 463 | 473 |
| 464 /** | 474 /** |
| 465 * @param {!Runtime.ModuleDescriptor} descriptor | 475 * @param {!Runtime.ModuleDescriptor} descriptor |
| 466 */ | 476 */ |
| 467 _registerModule: function(descriptor) | 477 _registerModule: function(descriptor) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 */ | 566 */ |
| 557 function isContextTypeKnown(targetType) | 567 function isContextTypeKnown(targetType) |
| 558 { | 568 { |
| 559 return currentContextTypes.has(targetType); | 569 return currentContextTypes.has(targetType); |
| 560 } | 570 } |
| 561 }, | 571 }, |
| 562 | 572 |
| 563 /** | 573 /** |
| 564 * @param {*} type | 574 * @param {*} type |
| 565 * @param {?Object=} context | 575 * @param {?Object=} context |
| 576 * @param {boolean=} sortByTitle |
| 566 * @return {!Array.<!Runtime.Extension>} | 577 * @return {!Array.<!Runtime.Extension>} |
| 567 */ | 578 */ |
| 568 extensions: function(type, context) | 579 extensions: function(type, context, sortByTitle) |
| 569 { | 580 { |
| 570 return this._extensions.filter(filter).sort(orderComparator); | 581 return this._extensions.filter(filter).sort(sortByTitle ? titleComparato
r : orderComparator); |
| 571 | 582 |
| 572 /** | 583 /** |
| 573 * @param {!Runtime.Extension} extension | 584 * @param {!Runtime.Extension} extension |
| 574 * @return {boolean} | 585 * @return {boolean} |
| 575 */ | 586 */ |
| 576 function filter(extension) | 587 function filter(extension) |
| 577 { | 588 { |
| 578 if (extension._type !== type && extension._typeClass() !== type) | 589 if (extension._type !== type && extension._typeClass() !== type) |
| 579 return false; | 590 return false; |
| 580 if (!extension.enabled()) | 591 if (!extension.enabled()) |
| 581 return false; | 592 return false; |
| 582 return !context || extension.isApplicable(context); | 593 return !context || extension.isApplicable(context); |
| 583 } | 594 } |
| 584 | 595 |
| 585 /** | 596 /** |
| 586 * @param {!Runtime.Extension} extension1 | 597 * @param {!Runtime.Extension} extension1 |
| 587 * @param {!Runtime.Extension} extension2 | 598 * @param {!Runtime.Extension} extension2 |
| 588 * @return {number} | 599 * @return {number} |
| 589 */ | 600 */ |
| 590 function orderComparator(extension1, extension2) | 601 function orderComparator(extension1, extension2) |
| 591 { | 602 { |
| 592 var order1 = extension1.descriptor()["order"] || 0; | 603 var order1 = extension1.descriptor()["order"] || 0; |
| 593 var order2 = extension2.descriptor()["order"] || 0; | 604 var order2 = extension2.descriptor()["order"] || 0; |
| 594 return order1 - order2; | 605 return order1 - order2; |
| 595 } | 606 } |
| 607 |
| 608 /** |
| 609 * @param {!Runtime.Extension} extension1 |
| 610 * @param {!Runtime.Extension} extension2 |
| 611 * @return {number} |
| 612 */ |
| 613 function titleComparator(extension1, extension2) |
| 614 { |
| 615 var title1 = extension1.title() || ""; |
| 616 var title2 = extension2.title() || ""; |
| 617 return title1.localeCompare(title2); |
| 618 } |
| 596 }, | 619 }, |
| 597 | 620 |
| 598 /** | 621 /** |
| 599 * @param {*} type | 622 * @param {*} type |
| 600 * @param {?Object=} context | 623 * @param {?Object=} context |
| 601 * @return {?Runtime.Extension} | 624 * @return {?Runtime.Extension} |
| 602 */ | 625 */ |
| 603 extension: function(type, context) | 626 extension: function(type, context) |
| 604 { | 627 { |
| 605 return this.extensions(type, context)[0] || null; | 628 return this.extensions(type, context)[0] || null; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 function constructInstance() | 994 function constructInstance() |
| 972 { | 995 { |
| 973 var result = this._module._instance(className, this); | 996 var result = this._module._instance(className, this); |
| 974 if (!result) | 997 if (!result) |
| 975 return Promise.reject("Could not instantiate: " + className); | 998 return Promise.reject("Could not instantiate: " + className); |
| 976 return result; | 999 return result; |
| 977 } | 1000 } |
| 978 }, | 1001 }, |
| 979 | 1002 |
| 980 /** | 1003 /** |
| 981 * @param {string} platform | |
| 982 * @return {string} | 1004 * @return {string} |
| 983 */ | 1005 */ |
| 984 title: function(platform) | 1006 title: function() |
| 985 { | 1007 { |
| 986 // FIXME: should be WebInspector.UIString() but runtime is not l10n awar
e yet. | 1008 // FIXME: should be WebInspector.UIString() but runtime is not l10n awar
e yet. |
| 987 return this._descriptor["title-" + platform] || this._descriptor["title"
]; | 1009 return this._descriptor["title-" + Runtime._platform] || this._descripto
r["title"]; |
| 988 } | 1010 } |
| 989 } | 1011 } |
| 990 | 1012 |
| 991 /** | 1013 /** |
| 992 * @constructor | 1014 * @constructor |
| 993 */ | 1015 */ |
| 994 Runtime.ExperimentsSupport = function() | 1016 Runtime.ExperimentsSupport = function() |
| 995 { | 1017 { |
| 996 this._supportEnabled = Runtime.queryParam("experiments") !== null; | 1018 this._supportEnabled = Runtime.queryParam("experiments") !== null; |
| 997 this._experiments = []; | 1019 this._experiments = []; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 { | 1211 { |
| 1190 var sourceURL = self.location.href; | 1212 var sourceURL = self.location.href; |
| 1191 if (self.location.search) | 1213 if (self.location.search) |
| 1192 sourceURL = sourceURL.replace(self.location.search, ""); | 1214 sourceURL = sourceURL.replace(self.location.search, ""); |
| 1193 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; | 1215 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; |
| 1194 return "\n/*# sourceURL=" + sourceURL + " */"; | 1216 return "\n/*# sourceURL=" + sourceURL + " */"; |
| 1195 } | 1217 } |
| 1196 | 1218 |
| 1197 /** @type {!Runtime} */ | 1219 /** @type {!Runtime} */ |
| 1198 var runtime; | 1220 var runtime; |
| OLD | NEW |