Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * WallpaperManager constructor. | 6 * WallpaperManager constructor. |
| 7 * | 7 * |
| 8 * WallpaperManager objects encapsulate the functionality of the wallpaper | 8 * WallpaperManager objects encapsulate the functionality of the wallpaper |
| 9 * manager extension. | 9 * manager extension. |
| 10 * | 10 * |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 } | 77 } |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Requests wallpaper manifest file from server. | 81 * Requests wallpaper manifest file from server. |
| 82 */ | 82 */ |
| 83 WallpaperManager.prototype.fetchManifest_ = function() { | 83 WallpaperManager.prototype.fetchManifest_ = function() { |
| 84 var xhr = new XMLHttpRequest(); | 84 var xhr = new XMLHttpRequest(); |
| 85 var locale = navigator.language; | 85 var locale = navigator.language; |
| 86 xhr.open('GET', ManifestBaseURL + locale + '.json', false); | 86 xhr.open('GET', ManifestBaseURL + locale + '.json', false); |
| 87 xhr.send(null); | 87 try { |
| 88 // TODO(bshe): We should save the downloaded manifest to local disk. Other | |
| 89 // components may want to use it (i.e. screen saver). | |
| 90 if (xhr.status === 200) { | |
| 91 this.parseManifest_(xhr.responseText); | |
| 92 } else { | |
| 93 // Fall back to en locale if current locale is not supported. | |
| 94 xhr.open('GET', ManifestBaseURL + 'en.json', false); | |
| 95 xhr.send(null); | 88 xhr.send(null); |
| 89 // TODO(bshe): We should save the downloaded manifest to local disk. Other | |
| 90 // components may want to use it (i.e. screen saver). | |
| 96 if (xhr.status === 200) { | 91 if (xhr.status === 200) { |
| 97 this.parseManifest_(xhr.responseText); | 92 this.parseManifest_(xhr.responseText); |
| 98 } else { | 93 } else { |
| 99 this.manifest_ = {}; | 94 // Fall back to en locale if current locale is not supported. |
| 100 this.butterBar_.showError_(str('connectionFailed')); | 95 xhr.open('GET', ManifestBaseURL + 'en.json', false); |
| 96 xhr.send(null); | |
| 97 if (xhr.status === 200) { | |
| 98 this.parseManifest_(xhr.responseText); | |
|
flackr
2012/10/16 15:29:48
This nested structure which does the same thing to
bshe
2012/10/16 16:01:48
Done.
On 2012/10/16 15:29:48, flackr wrote:
| |
| 99 } else { | |
| 100 this.manifest_ = {}; | |
| 101 this.butterBar_.showError_(str('connectionFailed')); | |
| 102 } | |
| 101 } | 103 } |
| 104 } catch (e) { | |
| 105 this.manifest_ = {}; | |
| 106 this.butterBar_.showError_(str('connectionFailed')); | |
| 102 } | 107 } |
| 103 | 108 |
| 104 // TODO(bshe): Fall back to saved manifest if there is a problem fetching | 109 // TODO(bshe): Fall back to saved manifest if there is a problem fetching |
| 105 // manifest from server. | 110 // manifest from server. |
| 106 }; | 111 }; |
| 107 | 112 |
| 108 /** | 113 /** |
| 109 * One-time initialization of various DOM nodes. | 114 * One-time initialization of various DOM nodes. |
| 110 */ | 115 */ |
| 111 WallpaperManager.prototype.initDom_ = function() { | 116 WallpaperManager.prototype.initDom_ = function() { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 selectedItem = wallpaperInfo; | 382 selectedItem = wallpaperInfo; |
| 378 } | 383 } |
| 379 } | 384 } |
| 380 } | 385 } |
| 381 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 386 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
| 382 this.wallpaperGrid_.selectedItem = selectedItem; | 387 this.wallpaperGrid_.selectedItem = selectedItem; |
| 383 } | 388 } |
| 384 }; | 389 }; |
| 385 | 390 |
| 386 })(); | 391 })(); |
| OLD | NEW |