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 {!MetadataCache} metadataCache Metadata cache. | 8 * @param {!MetadataCache} metadataCache Metadata cache. |
9 * @param {!FileSystemMetadata} fileSystemMetadata | 9 * @param {!MetadataModel} metadataModel |
10 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. | 10 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. |
11 * @constructor | 11 * @constructor |
12 * @extends {cr.ui.ArrayDataModel} | 12 * @extends {cr.ui.ArrayDataModel} |
13 */ | 13 */ |
14 function GalleryDataModel(metadataCache, fileSystemMetadata, opt_watcher) { | 14 function GalleryDataModel(metadataCache, metadataModel, opt_watcher) { |
15 cr.ui.ArrayDataModel.call(this, []); | 15 cr.ui.ArrayDataModel.call(this, []); |
16 | 16 |
17 /** | 17 /** |
18 * Metadata cache. | 18 * Metadata cache. |
19 * @private {!MetadataCache} | 19 * @private {!MetadataCache} |
20 * @const | 20 * @const |
21 */ | 21 */ |
22 this.metadataCache_ = metadataCache; | 22 this.metadataCache_ = metadataCache; |
23 | 23 |
24 /** | 24 /** |
25 * File system metadata. | 25 * File system metadata. |
26 * @private {!FileSystemMetadata} | 26 * @private {!MetadataModel} |
27 * @const | 27 * @const |
28 */ | 28 */ |
29 this.fileSystemMetadata_ = fileSystemMetadata; | 29 this.metadataModel_ = metadataModel; |
30 | 30 |
31 /** | 31 /** |
32 * Directory where the image is saved if the image is located in a read-only | 32 * Directory where the image is saved if the image is located in a read-only |
33 * volume. | 33 * volume. |
34 * @public {DirectoryEntry} | 34 * @public {DirectoryEntry} |
35 */ | 35 */ |
36 this.fallbackSaveDirectory = null; | 36 this.fallbackSaveDirectory = null; |
37 | 37 |
38 // Start to watch file system entries. | 38 // Start to watch file system entries. |
39 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); | 39 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 this.dispatchEvent(event); | 95 this.dispatchEvent(event); |
96 | 96 |
97 if (!util.isSameEntry(oldEntry, item.getEntry())) { | 97 if (!util.isSameEntry(oldEntry, item.getEntry())) { |
98 // New entry is added and the item now tracks it. | 98 // New entry is added and the item now tracks it. |
99 // Add another item for the old entry. | 99 // Add another item for the old entry. |
100 var anotherItem = new Gallery.Item( | 100 var anotherItem = new Gallery.Item( |
101 oldEntry, | 101 oldEntry, |
102 oldLocationInfo, | 102 oldLocationInfo, |
103 oldMetadata, | 103 oldMetadata, |
104 this.metadataCache_, | 104 this.metadataCache_, |
105 this.fileSystemMetadata_, | 105 this.metadataModel_, |
106 item.isOriginal()); | 106 item.isOriginal()); |
107 // The item must be added behind the existing item so that it does | 107 // The item must be added behind the existing item so that it does |
108 // not change the index of the existing item. | 108 // not change the index of the existing item. |
109 // TODO(hirono): Update the item index of the selection model | 109 // TODO(hirono): Update the item index of the selection model |
110 // correctly. | 110 // correctly. |
111 this.splice(this.indexOf(item) + 1, 0, anotherItem); | 111 this.splice(this.indexOf(item) + 1, 0, anotherItem); |
112 } | 112 } |
113 | 113 |
114 fulfill(); | 114 fulfill(); |
115 }.bind(this)); | 115 }.bind(this)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } else { | 148 } else { |
149 // Force to free the buffer of the canvas by assigning zero size. | 149 // Force to free the buffer of the canvas by assigning zero size. |
150 sorted[i].screenImage.width = 0; | 150 sorted[i].screenImage.width = 0; |
151 sorted[i].screenImage.height = 0; | 151 sorted[i].screenImage.height = 0; |
152 sorted[i].screenImage = null; | 152 sorted[i].screenImage = null; |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 }; | 157 }; |
OLD | NEW |