| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 /** | 352 /** |
| 353 * @param {string} name | 353 * @param {string} name |
| 354 * @return {?string} | 354 * @return {?string} |
| 355 */ | 355 */ |
| 356 Runtime.queryParam = function(name) | 356 Runtime.queryParam = function(name) |
| 357 { | 357 { |
| 358 return Runtime._queryParamsObject[name] || null; | 358 return Runtime._queryParamsObject[name] || null; |
| 359 } | 359 } |
| 360 | 360 |
| 361 /** | 361 /** |
| 362 * @param {!Array.<string>} banned | |
| 363 * @return {string} | |
| 364 */ | |
| 365 Runtime.constructQueryParams = function(banned) | |
| 366 { | |
| 367 var params = []; | |
| 368 for (var key in Runtime._queryParamsObject) { | |
| 369 if (!key || banned.indexOf(key) !== -1) | |
| 370 continue; | |
| 371 params.push(key + "=" + Runtime._queryParamsObject[key]); | |
| 372 } | |
| 373 return params.length ? "?" + params.join("&") : ""; | |
| 374 } | |
| 375 | |
| 376 /** | |
| 377 * @return {!Object} | 362 * @return {!Object} |
| 378 */ | 363 */ |
| 379 Runtime._experimentsSetting = function() | 364 Runtime._experimentsSetting = function() |
| 380 { | 365 { |
| 381 try { | 366 try { |
| 382 return /** @type {!Object} */ (JSON.parse(self.localStorage && self.loca
lStorage["experiments"] ? self.localStorage["experiments"] : "{}")); | 367 return /** @type {!Object} */ (JSON.parse(self.localStorage && self.loca
lStorage["experiments"] ? self.localStorage["experiments"] : "{}")); |
| 383 } catch (e) { | 368 } catch (e) { |
| 384 console.error("Failed to parse localStorage['experiments']"); | 369 console.error("Failed to parse localStorage['experiments']"); |
| 385 return {}; | 370 return {}; |
| 386 } | 371 } |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 { | 1094 { |
| 1110 var queryParams = location.search; | 1095 var queryParams = location.search; |
| 1111 if (!queryParams) | 1096 if (!queryParams) |
| 1112 return; | 1097 return; |
| 1113 var params = queryParams.substring(1).split("&"); | 1098 var params = queryParams.substring(1).split("&"); |
| 1114 for (var i = 0; i < params.length; ++i) { | 1099 for (var i = 0; i < params.length; ++i) { |
| 1115 var pair = params[i].split("="); | 1100 var pair = params[i].split("="); |
| 1116 var name = pair.shift(); | 1101 var name = pair.shift(); |
| 1117 Runtime._queryParamsObject[name] = pair.join("="); | 1102 Runtime._queryParamsObject[name] = pair.join("="); |
| 1118 } | 1103 } |
| 1104 var flags = Runtime._queryParamsObject["flags"]; |
| 1105 delete Runtime._queryParamsObject["flags"]; |
| 1106 if (flags) { |
| 1107 try { |
| 1108 var parsedFlags = JSON.parse(window.decodeURIComponent(flags)); |
| 1109 for (var key in parsedFlags) |
| 1110 Runtime._queryParamsObject[key] = parsedFlags[key]; |
| 1111 } catch(e) { |
| 1112 console.error("Invalid startup flag: " + e); |
| 1113 } |
| 1114 } |
| 1119 })();} | 1115 })();} |
| 1120 | 1116 |
| 1121 | 1117 |
| 1122 // This must be constructed after the query parameters have been parsed. | 1118 // This must be constructed after the query parameters have been parsed. |
| 1123 Runtime.experiments = new Runtime.ExperimentsSupport(); | 1119 Runtime.experiments = new Runtime.ExperimentsSupport(); |
| 1124 | 1120 |
| 1125 /** | 1121 /** |
| 1126 * @type {?string} | 1122 * @type {?string} |
| 1127 */ | 1123 */ |
| 1128 Runtime._remoteBase = Runtime.queryParam("remoteBase"); | 1124 Runtime._remoteBase = Runtime.queryParam("remoteBase"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1141 { | 1137 { |
| 1142 var sourceURL = self.location.href; | 1138 var sourceURL = self.location.href; |
| 1143 if (self.location.search) | 1139 if (self.location.search) |
| 1144 sourceURL = sourceURL.replace(self.location.search, ""); | 1140 sourceURL = sourceURL.replace(self.location.search, ""); |
| 1145 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; | 1141 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; |
| 1146 return "\n/*# sourceURL=" + sourceURL + " */"; | 1142 return "\n/*# sourceURL=" + sourceURL + " */"; |
| 1147 } | 1143 } |
| 1148 | 1144 |
| 1149 /** @type {!Runtime} */ | 1145 /** @type {!Runtime} */ |
| 1150 var runtime; | 1146 var runtime; |
| OLD | NEW |