/**
* Saves new image.
*
+ * @param {VolumeManager} volumeManager Volume manager instance.
* @param {Gallery.Item} item Original gallery item.
* @param {Canvas} canvas Canvas containing new image.
* @param {boolean} overwrite Whether to overwrite the image to the item or not.
* @return {Promise} Promise to be fulfilled with when the operation completes.
*/
-GalleryDataModel.prototype.saveItem = function(item, canvas, overwrite) {
+GalleryDataModel.prototype.saveItem = function(
+ volumeManager, item, canvas, overwrite) {
var oldEntry = item.getEntry();
var oldMetadata = item.getMetadata();
+ var oldLocationInfo = item.getLocationInfo();
var metadataEncoder = ImageEncoder.encodeMetadata(
item.getMetadata(), canvas, 1 /* quality */);
var newMetadata = ContentProvider.ConvertContentMetadata(
MetadataCache.cloneMetadata(item.getMetadata()));
if (newMetadata.filesystem)
newMetadata.filesystem.modificationTime = new Date();
- if (newMetadata.drive)
- newMetadata.drive.present = true;
+ if (newMetadata.external)
+ newMetadata.external.present = true;
return new Promise(function(fulfill, reject) {
item.saveToFile(
+ volumeManager,
this.fallbackSaveDirectory,
overwrite,
canvas,
// Add another item for the old entry.
var anotherItem = new Gallery.Item(
oldEntry,
+ oldLocationInfo,
oldMetadata,
this.metadataCache_,
- item.isOriginal(),
- item.isReadOnly());
+ item.isOriginal());
// The item must be added behind the existing item so that it does
// not change the index of the existing item.
// TODO(hirono): Update the item index of the selection model
this.metadataCacheObserverId_ = null;
this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this);
- this.dataModel_ = new GalleryDataModel(this.context_.metadataCache);
+ this.dataModel_ = new GalleryDataModel(
+ this.context_.metadataCache);
var downloadVolumeInfo = this.volumeManager_.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.DOWNLOADS);
downloadVolumeInfo.resolveDisplayRoot().then(function(entry) {
* @const
* @type {string}
*/
-Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming|drive';
+Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|external';
/**
* Initializes listeners.
this.dataModel_,
this.selectionModel_,
this.context_,
+ this.volumeManager_,
this.toggleMode_.bind(this),
str);
return Promise.reject('Failed to load metadata.');
// Add items to the model.
- var items = chunk.map(function(chunkItem, index) {
- var volumeInfo = self.volumeManager_.getVolumeInfo(chunkItem.entry);
+ var items = [];
+ chunk.forEach(function(chunkItem, index) {
+ var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry);
+ if (!locationInfo) // Skip the item, since gone.
+ return;
var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]);
- return new Gallery.Item(
+ items.push(new Gallery.Item(
chunkItem.entry,
+ locationInfo,
clonedMetadata,
self.metadataCache_,
- /* original */ true,
- /* readonly */ !!(volumeInfo && volumeInfo.isReadOnly));
+ /* original */ true));
});
self.dataModel_.push.apply(self.dataModel_, items);
};
/**
- * @return {Object} File browser private API.
+ * @return {Object} File manager private API.
*/
-Gallery.getFileBrowserPrivate = function() {
- return chrome.fileBrowserPrivate || window.top.chrome.fileBrowserPrivate;
+Gallery.getFileManagerPrivate = function() {
+ return chrome.fileManagerPrivate || window.top.chrome.fileManagerPrivate;
};
/**
// Update the title and the display name.
if (numSelectedItems === 1) {
document.title = this.selectedEntry_.name;
- this.filenameEdit_.disabled = selectedItem.isReadOnly();
+ this.filenameEdit_.disabled = selectedItem.getLocationInfo().isReadOnly;
this.filenameEdit_.value =
ImageUtil.getDisplayNameFromName(this.selectedEntry_.name);
- this.shareButton_.hidden = !selectedItem.isOnDrive();
+ this.shareButton_.hidden = !selectedItem.getLocationInfo().isDriveBased;
} else {
if (this.context_.curDirEntry) {
// If the Gallery was opened on search results the search query will not
* Blur event handler on filename edit box.
*
* @param {Event} event Blur event.
- * @return {boolean} if default action should be prevented.
+ * @return {Promise} Promise fulfilled on renaming completed.
* @private
*/
Gallery.prototype.onFilenameEditBlur_ = function(event) {
this.dataModel_.dispatchEvent(event);
}.bind(this), function(error) {
if (error === 'NOT_CHANGED')
- return;
+ return Promise.resolve();
this.filenameEdit_.value =
ImageUtil.getDisplayNameFromName(item.getEntry().name);
this.filenameEdit_.focus();
ImageUtil.setAttribute(this.filenameSpacer_, 'renaming', false);
this.onUserAction_();
+ return Promise.resolve();
};
/**
/**
* Loads entries.
+ * @param {!Array.<Entry>} entries Array of entries.
+ * @param {!Array.<Entry>} selectedEntries Array of selected entries.
*/
window.loadEntries = function(entries, selectedEntries) {
gallery.load(entries, selectedEntries);