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

Side by Side Diff: ui/file_manager/gallery/js/gallery_data_model.js

Issue 971173002: Gallery: Start to use new metadata model in Gallery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/gallery_item.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * Data model for gallery. 6 * Data model for gallery.
7 * 7 *
8 * @param {!MetadataCache} metadataCache Metadata cache. 8 * @param {!MetadataCache} metadataCache Metadata cache.
9 * @param {!MetadataModel} metadataModel 9 * @param {!MetadataModel} metadataModel
10 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. 10 * @param {!EntryListWatcher=} opt_watcher Entry list watcher.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 * @param {!VolumeManager} volumeManager Volume manager instance. 66 * @param {!VolumeManager} volumeManager Volume manager instance.
67 * @param {!Gallery.Item} item Original gallery item. 67 * @param {!Gallery.Item} item Original gallery item.
68 * @param {!HTMLCanvasElement} canvas Canvas containing new image. 68 * @param {!HTMLCanvasElement} canvas Canvas containing new image.
69 * @param {boolean} overwrite Whether to overwrite the image to the item or not. 69 * @param {boolean} overwrite Whether to overwrite the image to the item or not.
70 * @return {!Promise} Promise to be fulfilled with when the operation completes. 70 * @return {!Promise} Promise to be fulfilled with when the operation completes.
71 */ 71 */
72 GalleryDataModel.prototype.saveItem = function( 72 GalleryDataModel.prototype.saveItem = function(
73 volumeManager, item, canvas, overwrite) { 73 volumeManager, item, canvas, overwrite) {
74 var oldEntry = item.getEntry(); 74 var oldEntry = item.getEntry();
75 var oldMetadata = item.getMetadata(); 75 var oldMetadata = item.getMetadata();
76 var oldMetadataItem = item.getMetadataItem();
76 var oldLocationInfo = item.getLocationInfo(); 77 var oldLocationInfo = item.getLocationInfo();
77 return new Promise(function(fulfill, reject) { 78 return new Promise(function(fulfill, reject) {
78 item.saveToFile( 79 item.saveToFile(
79 volumeManager, 80 volumeManager,
80 this.fallbackSaveDirectory, 81 this.fallbackSaveDirectory,
81 overwrite, 82 overwrite,
82 canvas, 83 canvas,
83 function(success) { 84 function(success) {
84 if (!success) { 85 if (!success) {
85 reject('Failed to save the image.'); 86 reject('Failed to save the image.');
86 return; 87 return;
87 } 88 }
88 89
89 // Current entry is updated. 90 // Current entry is updated.
90 // Dispatch an event. 91 // Dispatch an event.
91 var event = new Event('content'); 92 var event = new Event('content');
92 event.item = item; 93 event.item = item;
93 event.oldEntry = oldEntry; 94 event.oldEntry = oldEntry;
94 event.metadata = item.getMetadata(); 95 event.metadata = item.getMetadata();
95 this.dispatchEvent(event); 96 this.dispatchEvent(event);
96 97
97 if (!util.isSameEntry(oldEntry, item.getEntry())) { 98 if (!util.isSameEntry(oldEntry, item.getEntry())) {
98 // New entry is added and the item now tracks it. 99 // New entry is added and the item now tracks it.
99 // Add another item for the old entry. 100 // Add another item for the old entry.
100 var anotherItem = new Gallery.Item( 101 var anotherItem = new Gallery.Item(
101 oldEntry, 102 oldEntry,
102 oldLocationInfo, 103 oldLocationInfo,
103 oldMetadata, 104 oldMetadata,
105 oldMetadataItem,
104 this.metadataCache_, 106 this.metadataCache_,
105 this.metadataModel_, 107 this.metadataModel_,
106 item.isOriginal()); 108 item.isOriginal());
107 // The item must be added behind the existing item so that it does 109 // The item must be added behind the existing item so that it does
108 // not change the index of the existing item. 110 // not change the index of the existing item.
109 // TODO(hirono): Update the item index of the selection model 111 // TODO(hirono): Update the item index of the selection model
110 // correctly. 112 // correctly.
111 this.splice(this.indexOf(item) + 1, 0, anotherItem); 113 this.splice(this.indexOf(item) + 1, 0, anotherItem);
112 } 114 }
113 115
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } else { 150 } else {
149 // Force to free the buffer of the canvas by assigning zero size. 151 // Force to free the buffer of the canvas by assigning zero size.
150 sorted[i].screenImage.width = 0; 152 sorted[i].screenImage.width = 0;
151 sorted[i].screenImage.height = 0; 153 sorted[i].screenImage.height = 0;
152 sorted[i].screenImage = null; 154 sorted[i].screenImage = null;
153 } 155 }
154 } 156 }
155 } 157 }
156 } 158 }
157 }; 159 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/gallery_item.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698