Commit 9ef2a2e3 authored by yawano's avatar yawano Committed by Commit bot

Gallery.app : shows an error message when it fails to save an image.

BUG=463837
TEST=manually tested with chaning the code to throw an error in a promise.

Review URL: https://codereview.chromium.org/1006833002

Cr-Commit-Position: refs/heads/master@{#320854}
parent cd5d2b8b
...@@ -355,6 +355,9 @@ Press any key to continue exploring. ...@@ -355,6 +355,9 @@ Press any key to continue exploring.
<message name="IDS_FILE_BROWSER_GALLERY_SAVED" desc="In the Gallery, the message informing that editing saved successfully."> <message name="IDS_FILE_BROWSER_GALLERY_SAVED" desc="In the Gallery, the message informing that editing saved successfully.">
Saved Saved
</message> </message>
<message name="IDS_FILE_BROWSER_GALLERY_SAVE_FAILED" desc="In the Gallery, the message informing that it failed to save editing image.">
Failed to save image.
</message>
<message name="IDS_FILE_BROWSER_GALLERY_OVERWRITE_ORIGINAL" desc="In the Gallery, text on the button to overwrite original file along with the edited copy."> <message name="IDS_FILE_BROWSER_GALLERY_OVERWRITE_ORIGINAL" desc="In the Gallery, text on the button to overwrite original file along with the edited copy.">
Overwrite original Overwrite original
</message> </message>
......
...@@ -200,6 +200,7 @@ void AddStringsForGallery(base::DictionaryValue* dict) { ...@@ -200,6 +200,7 @@ void AddStringsForGallery(base::DictionaryValue* dict) {
SET_STRING("GALLERY_ROTATE_LEFT", IDS_FILE_BROWSER_GALLERY_ROTATE_LEFT); SET_STRING("GALLERY_ROTATE_LEFT", IDS_FILE_BROWSER_GALLERY_ROTATE_LEFT);
SET_STRING("GALLERY_ROTATE_RIGHT", IDS_FILE_BROWSER_GALLERY_ROTATE_RIGHT); SET_STRING("GALLERY_ROTATE_RIGHT", IDS_FILE_BROWSER_GALLERY_ROTATE_RIGHT);
SET_STRING("GALLERY_SAVED", IDS_FILE_BROWSER_GALLERY_SAVED); SET_STRING("GALLERY_SAVED", IDS_FILE_BROWSER_GALLERY_SAVED);
SET_STRING("GALLERY_SAVE_FAILED", IDS_FILE_BROWSER_GALLERY_SAVE_FAILED);
SET_STRING("GALLERY_SHARE", IDS_FILE_BROWSER_GALLERY_SHARE); SET_STRING("GALLERY_SHARE", IDS_FILE_BROWSER_GALLERY_SHARE);
SET_STRING("GALLERY_SLIDE", IDS_FILE_BROWSER_GALLERY_SLIDE); SET_STRING("GALLERY_SLIDE", IDS_FILE_BROWSER_GALLERY_SLIDE);
SET_STRING("GALLERY_SLIDESHOW", IDS_FILE_BROWSER_GALLERY_SLIDESHOW); SET_STRING("GALLERY_SLIDESHOW", IDS_FILE_BROWSER_GALLERY_SLIDESHOW);
......
...@@ -172,9 +172,6 @@ function Gallery(volumeManager) { ...@@ -172,9 +172,6 @@ function Gallery(volumeManager) {
this.slideMode_.addEventListener('image-displayed', function() { this.slideMode_.addEventListener('image-displayed', function() {
cr.dispatchSimpleEvent(this, 'image-displayed'); cr.dispatchSimpleEvent(this, 'image-displayed');
}.bind(this)); }.bind(this));
this.slideMode_.addEventListener('image-saved', function() {
cr.dispatchSimpleEvent(this, 'image-saved');
}.bind(this));
this.deleteButton_ = this.initToolbarButton_('delete', 'GALLERY_DELETE'); this.deleteButton_ = this.initToolbarButton_('delete', 'GALLERY_DELETE');
this.deleteButton_.addEventListener('click', this.delete_.bind(this)); this.deleteButton_.addEventListener('click', this.delete_.bind(this));
......
...@@ -306,9 +306,11 @@ Gallery.Item.prototype.saveToFile = function( ...@@ -306,9 +306,11 @@ Gallery.Item.prototype.saveToFile = function(
}).then(onSuccess.bind(null, fileEntry)) }).then(onSuccess.bind(null, fileEntry))
.catch(function(error) { .catch(function(error) {
onError(error); onError(error);
// Disable all callbacks on the first error. if (fileWriter) {
fileWriter.onerror = null; // Disable all callbacks on the first error.
fileWriter.onwriteend = null; fileWriter.onerror = null;
fileWriter.onwriteend = null;
}
}); });
}.bind(this); }.bind(this);
......
...@@ -1266,11 +1266,7 @@ SlideMode.prototype.saveCurrentImage_ = function(item, callback) { ...@@ -1266,11 +1266,7 @@ SlideMode.prototype.saveCurrentImage_ = function(item, callback) {
this.imageView_.getCanvas(), this.imageView_.getCanvas(),
this.shouldOverwriteOriginal_()); this.shouldOverwriteOriginal_());
savedPromise.catch(function(error) { savedPromise.then(function() {
// TODO(hirono): Implement write error handling.
// Until then pretend that the save succeeded.
console.error(error.stack || error);
}).then(function() {
this.showSpinner_(false); this.showSpinner_(false);
this.flashSavedLabel_(); this.flashSavedLabel_();
...@@ -1285,10 +1281,14 @@ SlideMode.prototype.saveCurrentImage_ = function(item, callback) { ...@@ -1285,10 +1281,14 @@ SlideMode.prototype.saveCurrentImage_ = function(item, callback) {
ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit')); ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit'));
callback(); callback();
cr.dispatchSimpleEvent(this, 'image-saved');
}.bind(this)).catch(function(error) { }.bind(this)).catch(function(error) {
console.error(error.stack || error); console.error(error.stack || error);
});
this.showSpinner_(false);
this.errorBanner_.show('GALLERY_SAVE_FAILED');
callback();
}.bind(this));
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment