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 /** | 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 }; | 702 }; |
703 | 703 |
704 /** | 704 /** |
705 * Handles the custom wallpaper which user selected from file manager. Called | 705 * Handles the custom wallpaper which user selected from file manager. Called |
706 * when users select a file. | 706 * when users select a file. |
707 */ | 707 */ |
708 WallpaperManager.prototype.onFileSelectorChanged_ = function() { | 708 WallpaperManager.prototype.onFileSelectorChanged_ = function() { |
709 var files = $('file-selector').files; | 709 var files = $('file-selector').files; |
710 if (files.length != 1) | 710 if (files.length != 1) |
711 console.error('More than one files are selected or no file selected'); | 711 console.error('More than one files are selected or no file selected'); |
712 if (!files[0].type.match('image/jpeg')) { | 712 if (!files[0].type.match('image/jpeg') && |
| 713 !files[0].type.match('image/png')) { |
713 this.showError_(str('invalidWallpaper')); | 714 this.showError_(str('invalidWallpaper')); |
714 return; | 715 return; |
715 } | 716 } |
716 var layout = getSelectedLayout(); | 717 var layout = getSelectedLayout(); |
717 var self = this; | 718 var self = this; |
718 var errorHandler = this.onFileSystemError_.bind(this); | 719 var errorHandler = this.onFileSystemError_.bind(this); |
719 var setSelectedFile = function(file, layout, fileName) { | 720 var setSelectedFile = function(file, layout, fileName) { |
720 var saveThumbnail = function(thumbnail) { | 721 var saveThumbnail = function(thumbnail) { |
721 var success = function(dirEntry) { | 722 var success = function(dirEntry) { |
722 dirEntry.getFile(fileName, {create: true}, function(fileEntry) { | 723 dirEntry.getFile(fileName, {create: true}, function(fileEntry) { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 983 } |
983 } | 984 } |
984 } | 985 } |
985 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 986 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
986 this.wallpaperGrid_.selectedItem = selectedItem; | 987 this.wallpaperGrid_.selectedItem = selectedItem; |
987 this.wallpaperGrid_.activeItem = selectedItem; | 988 this.wallpaperGrid_.activeItem = selectedItem; |
988 } | 989 } |
989 }; | 990 }; |
990 | 991 |
991 })(); | 992 })(); |
OLD | NEW |