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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 /** | 251 /** |
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 'useSecureConnection': true | 262 'useSecureConnection': true |
262 }); | 263 }); |
263 translateApiKey = undefined; | 264 translateApiKey = undefined; |
| 265 serverParams = undefined; |
264 } catch (err) { | 266 } catch (err) { |
265 errorCode = ERROR['INITIALIZATION_ERROR']; | 267 errorCode = ERROR['INITIALIZATION_ERROR']; |
266 translateApiKey = undefined; | 268 translateApiKey = undefined; |
| 269 serverParams = undefined; |
267 return; | 270 return; |
268 } | 271 } |
269 // The TranslateService is not available immediately as it needs to start | 272 // The TranslateService is not available immediately as it needs to start |
270 // Flash. Let's wait until it is ready. | 273 // Flash. Let's wait until it is ready. |
271 checkLibReady(); | 274 checkLibReady(); |
272 }, | 275 }, |
273 | 276 |
274 /** | 277 /** |
275 * Entry point called by the Translate Element when it want to load an | 278 * Entry point called by the Translate Element when it want to load an |
276 * external CSS resource into the page. | 279 * external CSS resource into the page. |
(...skipping 28 matching lines...) Expand all Loading... |
305 if (this.status != 200) { | 308 if (this.status != 200) { |
306 errorCode = ERROR['SCRIPT_LOAD_ERROR']; | 309 errorCode = ERROR['SCRIPT_LOAD_ERROR']; |
307 return; | 310 return; |
308 } | 311 } |
309 eval(this.responseText); | 312 eval(this.responseText); |
310 } | 313 } |
311 xhr.send(); | 314 xhr.send(); |
312 } | 315 } |
313 }; | 316 }; |
314 })(); | 317 })(); |
OLD | NEW |