Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: ui/file_manager/gallery/js/gallery_item.js

Issue 465333005: Gallery.app: Handles readonly volumes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/gallery_item.js
diff --git a/ui/file_manager/gallery/js/gallery_item.js b/ui/file_manager/gallery/js/gallery_item.js
index 995a7d85255a4611b73592034d568de056644871..e6114653d6870db297ef753150a3b6298b8c82d6 100644
--- a/ui/file_manager/gallery/js/gallery_item.js
+++ b/ui/file_manager/gallery/js/gallery_item.js
@@ -10,9 +10,12 @@
* @param {FileEntry} entry Image entry.
* @param {function():Promise} fethcedMediaProvider Function to provide the
* fetchedMedia metadata.
+ * @param {boolean} original Whether the entry is original or edited.
+ * @param {boolean} readonly Whether the entry is located at readonly directory
+ * or not.
* @constructor
*/
-Gallery.Item = function(entry, metadata, metadataCache, original) {
+Gallery.Item = function(entry, metadata, metadataCache, original, readonly) {
/**
* @type {FileEntry}
* @private
@@ -58,6 +61,12 @@ Gallery.Item = function(entry, metadata, metadataCache, original) {
* @type {boolean}
* @private
*/
+ this.isReadOnly_ = readonly;
+
+ /**
+ * @type {boolean}
+ * @private
+ */
this.original_ = original;
Object.seal(this);
@@ -115,6 +124,13 @@ Gallery.Item.prototype.getFileName = function() {
Gallery.Item.prototype.isOriginal = function() { return this.original_; };
/**
+ * @return {boolean} Whther the item is located at a readonly directory.
+ */
+Gallery.Item.prototype.isReadOnly = function() {
+ return this.isReadOnly_;
+};
+
+/**
* Obtains the item is on the drive volume or not.
* @return {boolean} True if the item is on the drive volume.
*/
@@ -219,15 +235,15 @@ Gallery.Item.prototype.createCopyName_ = function(dirEntry, callback) {
/**
* Writes the new item content to the file.
*
- * @param {Entry} overrideDir Directory to save to. If null, save to the same
- * directory as the original.
+ * @param {DirectoryEntry} fallbackDir If the entry is readonly, the edited
+ * image is saved to the directory.
* @param {boolean} overwrite True if overwrite, false if copy.
* @param {HTMLCanvasElement} canvas Source canvas.
* @param {ImageEncoder.MetadataEncoder} metadataEncoder MetadataEncoder.
* @param {function(boolean)=} opt_callback Callback accepting true for success.
*/
Gallery.Item.prototype.saveToFile = function(
- overrideDir, overwrite, canvas, metadataEncoder, opt_callback) {
+ fallbackDir, overwrite, canvas, metadataEncoder, opt_callback) {
ImageUtil.metrics.startInterval(ImageUtil.getMetricName('SaveTime'));
var name = this.getFileName();
@@ -236,6 +252,7 @@ Gallery.Item.prototype.saveToFile = function(
ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('SaveResult'), 1, 2);
ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('SaveTime'));
this.entry_ = entry;
+ this.isReadOnly_ = false;
this.metadataCache_.clear([this.entry_], 'fetchedMedia');
if (opt_callback)
opt_callback(true);
@@ -281,7 +298,7 @@ Gallery.Item.prototype.saveToFile = function(
}
var saveToDir = function(dir) {
- if (overwrite) {
+ if (overwrite && !this.isReadOnly_) {
checkExistence(dir);
} else {
this.createCopyName_(dir, function(copyName) {
@@ -292,8 +309,8 @@ Gallery.Item.prototype.saveToFile = function(
}
}.bind(this);
- if (overrideDir) {
- saveToDir(overrideDir);
+ if (this.isReadOnly_) {
+ saveToDir(fallbackDir);
} else {
this.entry_.getParent(saveToDir, onError);
}
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698