| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 { | 550 { |
| 551 if (!this._cachedTypeClasses[typeName]) { | 551 if (!this._cachedTypeClasses[typeName]) { |
| 552 var path = typeName.split("."); | 552 var path = typeName.split("."); |
| 553 var object = window; | 553 var object = window; |
| 554 for (var i = 0; object && (i < path.length); ++i) | 554 for (var i = 0; object && (i < path.length); ++i) |
| 555 object = object[path[i]]; | 555 object = object[path[i]]; |
| 556 if (object) | 556 if (object) |
| 557 this._cachedTypeClasses[typeName] = /** @type function(new:Objec
t) */(object); | 557 this._cachedTypeClasses[typeName] = /** @type function(new:Objec
t) */(object); |
| 558 } | 558 } |
| 559 return this._cachedTypeClasses[typeName] || null; | 559 return this._cachedTypeClasses[typeName] || null; |
| 560 }, |
| 561 |
| 562 /** |
| 563 * @param {!Object} object |
| 564 * @return {!Promise<!Array<!Object>>} |
| 565 */ |
| 566 adapt: function(object) |
| 567 { |
| 568 return this.instancesPromise(Runtime.Adapter, object).then(processAdapte
rs); |
| 569 |
| 570 /** |
| 571 * @param {!Array<!Runtime.Adapter>} adapters |
| 572 * @return {!Promise<!Array<!Object>>} |
| 573 */ |
| 574 function processAdapters(adapters) |
| 575 { |
| 576 var promises = []; |
| 577 for (var adapter of adapters) |
| 578 promises.push(adapter.adapt(object)); |
| 579 return /** @type {!Promise<!Array<!Object>>} */ (Runtime._some(promi
ses)); |
| 580 } |
| 560 } | 581 } |
| 561 } | 582 } |
| 562 | 583 |
| 563 /** | 584 /** |
| 564 * @constructor | 585 * @constructor |
| 565 */ | 586 */ |
| 566 Runtime.ModuleDescriptor = function() | 587 Runtime.ModuleDescriptor = function() |
| 567 { | 588 { |
| 568 /** | 589 /** |
| 569 * @type {string} | 590 * @type {string} |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1090 |
| 1070 /** | 1091 /** |
| 1071 * @param {boolean} enabled | 1092 * @param {boolean} enabled |
| 1072 */ | 1093 */ |
| 1073 setEnabled: function(enabled) | 1094 setEnabled: function(enabled) |
| 1074 { | 1095 { |
| 1075 this._experiments.setEnabled(this.name, enabled); | 1096 this._experiments.setEnabled(this.name, enabled); |
| 1076 } | 1097 } |
| 1077 } | 1098 } |
| 1078 | 1099 |
| 1100 /** |
| 1101 * @interface |
| 1102 */ |
| 1103 Runtime.Adapter = function() { } |
| 1104 |
| 1105 Runtime.Adapter.prototype = { |
| 1106 /** |
| 1107 * @param {!Object} from |
| 1108 * @return {!Promise<?Object>} |
| 1109 */ |
| 1110 adapt: function(from) { } |
| 1111 } |
| 1112 |
| 1079 {(function parseQueryParameters() | 1113 {(function parseQueryParameters() |
| 1080 { | 1114 { |
| 1081 var queryParams = location.search; | 1115 var queryParams = location.search; |
| 1082 if (!queryParams) | 1116 if (!queryParams) |
| 1083 return; | 1117 return; |
| 1084 var params = queryParams.substring(1).split("&"); | 1118 var params = queryParams.substring(1).split("&"); |
| 1085 for (var i = 0; i < params.length; ++i) { | 1119 for (var i = 0; i < params.length; ++i) { |
| 1086 var pair = params[i].split("="); | 1120 var pair = params[i].split("="); |
| 1087 var name = pair.shift(); | 1121 var name = pair.shift(); |
| 1088 Runtime._queryParamsObject[name] = pair.join("="); | 1122 Runtime._queryParamsObject[name] = pair.join("="); |
| 1089 } | 1123 } |
| 1090 })();} | 1124 })();} |
| 1091 | 1125 |
| 1092 | 1126 |
| 1093 // This must be constructed after the query parameters have been parsed. | 1127 // This must be constructed after the query parameters have been parsed. |
| 1094 Runtime.experiments = new Runtime.ExperimentsSupport(); | 1128 Runtime.experiments = new Runtime.ExperimentsSupport(); |
| 1095 | 1129 |
| 1096 /** | 1130 /** |
| 1097 * @type {?string} | 1131 * @type {?string} |
| 1098 */ | 1132 */ |
| 1099 Runtime._remoteBase = Runtime.queryParam("remoteBase"); | 1133 Runtime._remoteBase = Runtime.queryParam("remoteBase"); |
| 1100 | 1134 |
| 1101 /** @type {!Runtime} */ | 1135 /** @type {!Runtime} */ |
| 1102 var runtime; | 1136 var runtime; |
| OLD | NEW |