OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 var WallpaperUtil = { | 5 var WallpaperUtil = { |
6 strings: null, // Object that contains all the flags | 6 strings: null, // Object that contains all the flags |
7 syncFs: null, // syncFileSystem handler | 7 syncFs: null, // syncFileSystem handler |
8 webkitFs: null // webkitFileSystem handler | 8 webkitFs: null // webkitFileSystem handler |
9 }; | 9 }; |
10 | 10 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 xhr = new XMLHttpRequest(); | 316 xhr = new XMLHttpRequest(); |
317 | 317 |
318 try { | 318 try { |
319 // Do not use loadend here to handle both success and failure case. It gets | 319 // Do not use loadend here to handle both success and failure case. It gets |
320 // complicated with abortion. Unexpected error message may show up. See | 320 // complicated with abortion. Unexpected error message may show up. See |
321 // http://crbug.com/242581. | 321 // http://crbug.com/242581. |
322 xhr.addEventListener('load', function(e) { | 322 xhr.addEventListener('load', function(e) { |
323 if (this.status == 200) { | 323 if (this.status == 200) { |
324 onSuccess(this); | 324 onSuccess(this); |
325 } else { | 325 } else { |
326 onFailure(); | 326 onFailure(this.status); |
327 } | 327 } |
328 }); | 328 }); |
329 xhr.addEventListener('error', onFailure); | 329 xhr.addEventListener('error', onFailure); |
330 xhr.open('GET', url, true); | 330 xhr.open('GET', url, true); |
331 xhr.responseType = type; | 331 xhr.responseType = type; |
332 xhr.send(null); | 332 xhr.send(null); |
333 } catch (e) { | 333 } catch (e) { |
334 onFailure(); | 334 onFailure(); |
335 } | 335 } |
336 }; | 336 }; |
(...skipping 30 matching lines...) Expand all Loading... |
367 * Runs chrome.test.sendMessage in test environment. Does nothing if running | 367 * Runs chrome.test.sendMessage in test environment. Does nothing if running |
368 * in production environment. | 368 * in production environment. |
369 * | 369 * |
370 * @param {string} message Test message to send. | 370 * @param {string} message Test message to send. |
371 */ | 371 */ |
372 WallpaperUtil.testSendMessage = function(message) { | 372 WallpaperUtil.testSendMessage = function(message) { |
373 var test = chrome.test || window.top.chrome.test; | 373 var test = chrome.test || window.top.chrome.test; |
374 if (test) | 374 if (test) |
375 test.sendMessage(message); | 375 test.sendMessage(message); |
376 }; | 376 }; |
OLD | NEW |