Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This code is used in conjunction with the Google Translate Element script. | 5 // This code is used in conjunction with the Google Translate Element script. |
| 6 // It is executed in an isolated world of a page to translate it from one | 6 // It is executed in an isolated world of a page to translate it from one |
| 7 // language to another. | 7 // language to another. |
| 8 // It should be included in the page before the Translate Element script. | 8 // It should be included in the page before the Translate Element script. |
| 9 | 9 |
| 10 var cr = cr || {}; | 10 var cr = cr || {}; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 * Entry point called by the Translate Element once it has been injected in | 252 * Entry point called by the Translate Element once it has been injected in |
| 253 * the page. | 253 * the page. |
| 254 */ | 254 */ |
| 255 onTranslateElementLoad: function() { | 255 onTranslateElementLoad: function() { |
| 256 loadedTime = performance.now(); | 256 loadedTime = performance.now(); |
| 257 try { | 257 try { |
| 258 lib = google.translate.TranslateService({ | 258 lib = google.translate.TranslateService({ |
| 259 // translateApiKey is predefined by translate_script.cc. | 259 // translateApiKey is predefined by translate_script.cc. |
| 260 'key': translateApiKey, | 260 'key': translateApiKey, |
| 261 'serverParams': serverParams, | 261 'serverParams': serverParams, |
| 262 'timeInfo': gtTimeInfo, | |
|
groby-ooo-7-16
2016/08/18 22:35:04
key is 'timeInfo' here, 'gtTimeInfo' in test - may
ftang
2016/08/18 23:01:39
the JavaScript variable in the test is gtTimeInfo.
groby-ooo-7-16
2016/08/19 18:20:59
Ah, I see - thank you for the explanation.
ftang
2016/08/19 20:33:23
Acknowledged.
| |
| 262 'useSecureConnection': true | 263 'useSecureConnection': true |
| 263 }); | 264 }); |
| 264 translateApiKey = undefined; | 265 translateApiKey = undefined; |
| 265 serverParams = undefined; | 266 serverParams = undefined; |
| 267 gtTimeInfo = undefined; | |
| 266 } catch (err) { | 268 } catch (err) { |
| 267 errorCode = ERROR['INITIALIZATION_ERROR']; | 269 errorCode = ERROR['INITIALIZATION_ERROR']; |
| 268 translateApiKey = undefined; | 270 translateApiKey = undefined; |
| 269 serverParams = undefined; | 271 serverParams = undefined; |
| 272 gtTimeInfo = undefined; | |
| 270 return; | 273 return; |
| 271 } | 274 } |
| 272 // The TranslateService is not available immediately as it needs to start | 275 // The TranslateService is not available immediately as it needs to start |
| 273 // Flash. Let's wait until it is ready. | 276 // Flash. Let's wait until it is ready. |
| 274 checkLibReady(); | 277 checkLibReady(); |
| 275 }, | 278 }, |
| 276 | 279 |
| 277 /** | 280 /** |
| 278 * Entry point called by the Translate Element when it want to load an | 281 * Entry point called by the Translate Element when it want to load an |
| 279 * external CSS resource into the page. | 282 * external CSS resource into the page. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 308 if (this.status != 200) { | 311 if (this.status != 200) { |
| 309 errorCode = ERROR['SCRIPT_LOAD_ERROR']; | 312 errorCode = ERROR['SCRIPT_LOAD_ERROR']; |
| 310 return; | 313 return; |
| 311 } | 314 } |
| 312 eval(this.responseText); | 315 eval(this.responseText); |
| 313 } | 316 } |
| 314 xhr.send(); | 317 xhr.send(); |
| 315 } | 318 } |
| 316 }; | 319 }; |
| 317 })(); | 320 })(); |
| OLD | NEW |