OLD | NEW |
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 {!MetadataModel} metadataModel | 8 * @param {!MetadataModel} metadataModel |
9 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. | 9 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. |
10 * @constructor | 10 * @constructor |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 */ | 65 */ |
66 GalleryDataModel.prototype.saveItem = function( | 66 GalleryDataModel.prototype.saveItem = function( |
67 volumeManager, item, canvas, overwrite) { | 67 volumeManager, item, canvas, overwrite) { |
68 var oldEntry = item.getEntry(); | 68 var oldEntry = item.getEntry(); |
69 var oldLocationInfo = item.getLocationInfo(); | 69 var oldLocationInfo = item.getLocationInfo(); |
70 var oldIsOriginal = item.isOriginal(); | 70 var oldIsOriginal = item.isOriginal(); |
71 return new Promise(function(fulfill, reject) { | 71 return new Promise(function(fulfill, reject) { |
72 item.saveToFile( | 72 item.saveToFile( |
73 volumeManager, | 73 volumeManager, |
74 this.metadataModel_, | 74 this.metadataModel_, |
75 this.fallbackSaveDirectory, | 75 assert(this.fallbackSaveDirectory), |
76 canvas, | 76 canvas, |
77 overwrite, | 77 overwrite, |
78 function(success) { | 78 function(success) { |
79 if (!success) { | 79 if (!success) { |
80 reject('Failed to save the image.'); | 80 reject('Failed to save the image.'); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 // Current entry is updated. | 84 // Current entry is updated. |
85 // Dispatch an event. | 85 // Dispatch an event. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 * @private | 162 * @private |
163 */ | 163 */ |
164 GalleryDataModel.prototype.onSplice_ = function(event) { | 164 GalleryDataModel.prototype.onSplice_ = function(event) { |
165 if (!event.removed || !event.removed.length) | 165 if (!event.removed || !event.removed.length) |
166 return; | 166 return; |
167 var removedURLs = event.removed.map(function(item) { | 167 var removedURLs = event.removed.map(function(item) { |
168 return item.getEntry().toURL(); | 168 return item.getEntry().toURL(); |
169 }); | 169 }); |
170 this.metadataModel_.notifyEntriesRemoved(removedURLs); | 170 this.metadataModel_.notifyEntriesRemoved(removedURLs); |
171 }; | 171 }; |
OLD | NEW |