summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 15:39:37 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 15:39:37 +0000
commit8f358834ef3678b8673160b2611a8fec4361f445 (patch)
tree323ac970976d8e15417a150ebb59f2b3688b1526
parent1866ac1840b783a3376d3132b4bfbe934b8b23e8 (diff)
downloadchromium_src-8f358834ef3678b8673160b2611a8fec4361f445.zip
chromium_src-8f358834ef3678b8673160b2611a8fec4361f445.tar.gz
chromium_src-8f358834ef3678b8673160b2611a8fec4361f445.tar.bz2
Dont show thumbnail and display an error message if user chooses non jpeg image
BUG=151576 Review URL: https://chromiumcodereview.appspot.com/11081012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161119 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/chromeos/extensions/wallpaper_private_api.cc2
-rw-r--r--chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js9
3 files changed, 16 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index f852fed..84c4e0e 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -11534,6 +11534,12 @@ Some features may be unavailable. Please check that the profile exists and you
<message name="IDS_WALLPAPER_MANAGER_DOWNLOAD_CANCEL" desc="The string displayed to user when downloading the wallpaper canceled.">
Download was canceled.
</message>
+ <message name="IDS_WALLPAPER_MANAGER_ACCESS_FILE_FAILURE" desc="The string displayed to user when accessing custom wallpaper on disk failed.">
+ Chrome cannot access the image.
+ </message>
+ <message name="IDS_WALLPAPER_MANAGER_INVALID_FORMAT" desc="The string displayed to user when the format of custom wallpaper is not supported.">
+ Chrome does not support this format yet.
+ </message>
<!-- File Browser -->
<message name="IDS_FILE_BROWSER_ROOT_DIRECTORY_LABEL" desc="Root directory label.">
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
index 7c7e361..7d44c40 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -60,6 +60,8 @@ bool WallpaperStringsFunction::RunImpl() {
SET_STRING("downloadCanceled", IDS_WALLPAPER_MANAGER_DOWNLOAD_CANCEL);
SET_STRING("customWallpaperWarning",
IDS_WALLPAPER_MANAGER_SHOW_CUSTOM_WALLPAPER_ON_START_WARNING);
+ SET_STRING("accessFileFailure", IDS_WALLPAPER_MANAGER_ACCESS_FILE_FAILURE);
+ SET_STRING("invalidFormat", IDS_WALLPAPER_MANAGER_INVALID_FORMAT);
#undef SET_STRING
ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict);
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
index 7c2040c..47976c4 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
@@ -288,10 +288,17 @@ function WallpaperManager(dialogDom) {
var files = $('file-selector').files;
if (files.length != 1)
console.error('More than one files are selected or no file selected');
+ var file = files[0];
+ if (!file.type.match('image/jpeg')) {
+ this.butterBar_.showError_(str('invalidFormat'));
+ return;
+ }
var reader = new FileReader();
reader.readAsArrayBuffer(files[0]);
var self = this;
- // TODO(bshe): Handle file error.
+ reader.addEventListener('error', function(e) {
+ this.butterBar_.showError_(str('accessFileFailure'));
+ });
reader.addEventListener('load', function(e) {
self.customWallpaperData_ = e.target.result;
self.refreshWallpaper_(self.customWallpaperData_);