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

Side by Side Diff: chrome/browser/resources/file_manager/foreground/js/file_grid.js

Issue 130533003: Remove fullPaths from the file_grid.js and file_table.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/foreground/js/file_manager.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * FileGrid constructor. 8 * FileGrid constructor.
9 * 9 *
10 * Represents grid for the Grid Vew in the File Manager. 10 * Represents grid for the Grid Vew in the File Manager.
(...skipping 17 matching lines...) Expand all
28 /** 28 /**
29 * Inherits from cr.ui.Grid. 29 * Inherits from cr.ui.Grid.
30 */ 30 */
31 FileGrid.prototype.__proto__ = cr.ui.Grid.prototype; 31 FileGrid.prototype.__proto__ = cr.ui.Grid.prototype;
32 32
33 /** 33 /**
34 * Decorates an HTML element to be a FileGrid. 34 * Decorates an HTML element to be a FileGrid.
35 * @param {HTMLElement} self The grid to decorate. 35 * @param {HTMLElement} self The grid to decorate.
36 * @param {MetadataCache} metadataCache Metadata cache to find entries 36 * @param {MetadataCache} metadataCache Metadata cache to find entries
37 * metadata. 37 * metadata.
38 * @param {VolumeManagerWrapper} volumeManager Volume manager instance.
38 */ 39 */
39 FileGrid.decorate = function(self, metadataCache) { 40 FileGrid.decorate = function(self, metadataCache, volumeManager) {
40 cr.ui.Grid.decorate(self); 41 cr.ui.Grid.decorate(self);
41 self.__proto__ = FileGrid.prototype; 42 self.__proto__ = FileGrid.prototype;
42 self.metadataCache_ = metadataCache; 43 self.metadataCache_ = metadataCache;
44 self.volumeManager_ = volumeManager;
43 45
44 self.scrollBar_ = new MainPanelScrollBar(); 46 self.scrollBar_ = new MainPanelScrollBar();
45 self.scrollBar_.initialize(self.parentNode, self); 47 self.scrollBar_.initialize(self.parentNode, self);
46 self.setBottomMarginForPanel(0); 48 self.setBottomMarginForPanel(0);
47 49
48 self.itemConstructor = function(entry) { 50 self.itemConstructor = function(entry) {
49 var item = self.ownerDocument.createElement('LI'); 51 var item = self.ownerDocument.createElement('LI');
50 FileGrid.Item.decorate(item, entry, self); 52 FileGrid.Item.decorate(item, entry, self);
51 return item; 53 return item;
52 }; 54 };
(...skipping 11 matching lines...) Expand all
64 var boxes = this.querySelectorAll('.img-container'); 66 var boxes = this.querySelectorAll('.img-container');
65 for (var i = 0; i < boxes.length; i++) { 67 for (var i = 0; i < boxes.length; i++) {
66 var box = boxes[i]; 68 var box = boxes[i];
67 var entry = this.dataModel.item(this.getListItemAncestor(box)); 69 var entry = this.dataModel.item(this.getListItemAncestor(box));
68 if (!entry || !(entry.toURL() in props)) 70 if (!entry || !(entry.toURL() in props))
69 continue; 71 continue;
70 72
71 FileGrid.decorateThumbnailBox(box, 73 FileGrid.decorateThumbnailBox(box,
72 entry, 74 entry,
73 this.metadataCache_, 75 this.metadataCache_,
76 this.volumeManager_,
74 ThumbnailLoader.FillMode.FIT, 77 ThumbnailLoader.FillMode.FIT,
75 FileGrid.ThumbnailQuality.HIGH); 78 FileGrid.ThumbnailQuality.HIGH);
76 } 79 }
77 }; 80 };
78 81
79 /** 82 /**
80 * Redraws the UI. Skips multiple consecutive calls. 83 * Redraws the UI. Skips multiple consecutive calls.
81 */ 84 */
82 FileGrid.prototype.relayout = function() { 85 FileGrid.prototype.relayout = function() {
83 this.relayoutAggregation_.run(); 86 this.relayoutAggregation_.run();
84 }; 87 };
85 88
86 /** 89 /**
87 * Redraws the UI immediately. 90 * Redraws the UI immediately.
88 * @private 91 * @private
89 */ 92 */
90 FileGrid.prototype.relayoutImmediately_ = function() { 93 FileGrid.prototype.relayoutImmediately_ = function() {
91 this.startBatchUpdates(); 94 this.startBatchUpdates();
92 this.columns = 0; 95 this.columns = 0;
93 this.redraw(); 96 this.redraw();
94 this.endBatchUpdates(); 97 this.endBatchUpdates();
95 cr.dispatchSimpleEvent(this, 'relayout'); 98 cr.dispatchSimpleEvent(this, 'relayout');
96 }; 99 };
97 100
98 /** 101 /**
99 * Decorates thumbnail. 102 * Decorates thumbnail.
100 * @param {HTMLElement} li List item. 103 * @param {HTMLElement} li List item.
101 * @param {Entry} entry Entry to render a thumbnail for. 104 * @param {Entry} entry Entry to render a thumbnail for.
102 * @param {MetadataCache} metadataCache To retrieve metadata. 105 * @param {MetadataCache} metadataCache To retrieve metadata.
106 * @param {VolumeManagerWrapper} volumeManager Volume manager instance.
103 */ 107 */
104 FileGrid.decorateThumbnail = function(li, entry, metadataCache) { 108 FileGrid.decorateThumbnail = function(li, entry, metadataCache, volumeManager) {
105 li.className = 'thumbnail-item'; 109 li.className = 'thumbnail-item';
106 if (entry) 110 if (entry)
107 filelist.decorateListItem(li, entry, metadataCache); 111 filelist.decorateListItem(li, entry, metadataCache);
108 112
109 var frame = li.ownerDocument.createElement('div'); 113 var frame = li.ownerDocument.createElement('div');
110 frame.className = 'thumbnail-frame'; 114 frame.className = 'thumbnail-frame';
111 li.appendChild(frame); 115 li.appendChild(frame);
112 116
113 var box = li.ownerDocument.createElement('div'); 117 var box = li.ownerDocument.createElement('div');
114 if (entry) { 118 if (entry) {
115 FileGrid.decorateThumbnailBox(box, 119 FileGrid.decorateThumbnailBox(box,
116 entry, 120 entry,
117 metadataCache, 121 metadataCache,
122 volumeManager,
118 ThumbnailLoader.FillMode.AUTO, 123 ThumbnailLoader.FillMode.AUTO,
119 FileGrid.ThumbnailQuality.HIGH); 124 FileGrid.ThumbnailQuality.HIGH);
120 } 125 }
121 frame.appendChild(box); 126 frame.appendChild(box);
122 127
123 var bottom = li.ownerDocument.createElement('div'); 128 var bottom = li.ownerDocument.createElement('div');
124 bottom.className = 'thumbnail-bottom'; 129 bottom.className = 'thumbnail-bottom';
125 bottom.appendChild(filelist.renderFileNameLabel(li.ownerDocument, entry)); 130 bottom.appendChild(filelist.renderFileNameLabel(li.ownerDocument, entry));
126 frame.appendChild(bottom); 131 frame.appendChild(bottom);
127 }; 132 };
128 133
129 /** 134 /**
130 * Decorates the box containing a centered thumbnail image. 135 * Decorates the box containing a centered thumbnail image.
131 * 136 *
132 * @param {HTMLDivElement} box Box to decorate. 137 * @param {HTMLDivElement} box Box to decorate.
133 * @param {Entry} entry Entry which thumbnail is generating for. 138 * @param {Entry} entry Entry which thumbnail is generating for.
134 * @param {MetadataCache} metadataCache To retrieve metadata. 139 * @param {MetadataCache} metadataCache To retrieve metadata.
140 * @param {VolumeManagerWrapper} volumeManager Volume manager instance.
135 * @param {ThumbnailLoader.FillMode} fillMode Fill mode. 141 * @param {ThumbnailLoader.FillMode} fillMode Fill mode.
136 * @param {FileGrid.ThumbnailQuality} quality Thumbnail quality. 142 * @param {FileGrid.ThumbnailQuality} quality Thumbnail quality.
137 * @param {function(HTMLElement)=} opt_imageLoadCallback Callback called when 143 * @param {function(HTMLElement)=} opt_imageLoadCallback Callback called when
138 * the image has been loaded before inserting it into the DOM. 144 * the image has been loaded before inserting it into the DOM.
139 */ 145 */
140 FileGrid.decorateThumbnailBox = function( 146 FileGrid.decorateThumbnailBox = function(
141 box, entry, metadataCache, fillMode, quality, opt_imageLoadCallback) { 147 box, entry, metadataCache, volumeManager, fillMode, quality,
148 opt_imageLoadCallback) {
142 box.className = 'img-container'; 149 box.className = 'img-container';
143 if (entry.isDirectory) { 150 if (entry.isDirectory) {
144 box.setAttribute('generic-thumbnail', 'folder'); 151 box.setAttribute('generic-thumbnail', 'folder');
145 if (opt_imageLoadCallback) 152 if (opt_imageLoadCallback)
146 setTimeout(opt_imageLoadCallback, 0, null /* callback parameter */); 153 setTimeout(opt_imageLoadCallback, 0, null /* callback parameter */);
147 return; 154 return;
148 } 155 }
149 156
150 var metadataTypes = 'thumbnail|filesystem'; 157 var metadataTypes = 'thumbnail|filesystem';
151 158
152 // TODO(mtomasz): Use Entry instead of paths. 159 var locationInfo = volumeManager.getLocationInfo(entry);
153 if (PathUtil.isDriveBasedPath(entry.fullPath)) { 160 if (locationInfo && locationInfo.isDriveBased) {
154 metadataTypes += '|drive'; 161 metadataTypes += '|drive';
155 } else { 162 } else {
156 // TODO(dgozman): If we ask for 'media' for a Drive file we fall into an 163 // TODO(dgozman): If we ask for 'media' for a Drive file we fall into an
157 // infinite loop. 164 // infinite loop.
158 metadataTypes += '|media'; 165 metadataTypes += '|media';
159 } 166 }
160 167
161 // Drive provides high quality thumbnails via USE_EMBEDDED, however local 168 // Drive provides high quality thumbnails via USE_EMBEDDED, however local
162 // images usually provide very tiny thumbnails, therefore USE_EMBEDDE can't 169 // images usually provide very tiny thumbnails, therefore USE_EMBEDDE can't
163 // be used to obtain high quality output. 170 // be used to obtain high quality output.
164 var useEmbedded; 171 var useEmbedded;
165 switch (quality) { 172 switch (quality) {
166 case FileGrid.ThumbnailQuality.LOW: 173 case FileGrid.ThumbnailQuality.LOW:
167 useEmbedded = ThumbnailLoader.UseEmbedded.USE_EMBEDDED; 174 useEmbedded = ThumbnailLoader.UseEmbedded.USE_EMBEDDED;
168 break; 175 break;
169 case FileGrid.ThumbnailQuality.HIGH: 176 case FileGrid.ThumbnailQuality.HIGH:
170 // TODO(mtomasz): Use Entry instead of paths. 177 // TODO(mtomasz): Use Entry instead of paths.
171 useEmbedded = PathUtil.isDriveBasedPath(entry.fullPath) ? 178 useEmbedded = (locationInfo && locationInfo.isDriveBased) ?
172 ThumbnailLoader.UseEmbedded.USE_EMBEDDED : 179 ThumbnailLoader.UseEmbedded.USE_EMBEDDED :
173 ThumbnailLoader.UseEmbedded.NO_EMBEDDED; 180 ThumbnailLoader.UseEmbedded.NO_EMBEDDED;
174 break; 181 break;
175 } 182 }
176 183
177 metadataCache.get(entry, metadataTypes, 184 metadataCache.get(entry, metadataTypes,
178 function(metadata) { 185 function(metadata) {
179 new ThumbnailLoader(entry, 186 new ThumbnailLoader(entry,
180 ThumbnailLoader.LoaderType.IMAGE, 187 ThumbnailLoader.LoaderType.IMAGE,
181 metadata, 188 metadata,
(...skipping 29 matching lines...) Expand all
211 } 218 }
212 }); 219 });
213 220
214 /** 221 /**
215 * @param {Element} li List item element. 222 * @param {Element} li List item element.
216 * @param {Entry} entry File entry. 223 * @param {Entry} entry File entry.
217 * @param {FileGrid} grid Owner. 224 * @param {FileGrid} grid Owner.
218 */ 225 */
219 FileGrid.Item.decorate = function(li, entry, grid) { 226 FileGrid.Item.decorate = function(li, entry, grid) {
220 li.__proto__ = FileGrid.Item.prototype; 227 li.__proto__ = FileGrid.Item.prototype;
221 FileGrid.decorateThumbnail(li, entry, grid.metadataCache_, true); 228 // TODO(mtomasz): Pass the metadata cache and the volume manager directly
229 // instead of accessing private members of grid.
230 FileGrid.decorateThumbnail(
231 li, entry, grid.metadataCache_, grid.volumeManager_, true);
222 232
223 // Override the default role 'listitem' to 'option' to match the parent's 233 // Override the default role 'listitem' to 'option' to match the parent's
224 // role (listbox). 234 // role (listbox).
225 li.setAttribute('role', 'option'); 235 li.setAttribute('role', 'option');
226 }; 236 };
227 237
228 /** 238 /**
229 * Sets the margin height for the transparent preview panel at the bottom. 239 * Sets the margin height for the transparent preview panel at the bottom.
230 * @param {number} margin Margin to be set in px. 240 * @param {number} margin Margin to be set in px.
231 */ 241 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 for (var horizontalIndex = horizontalStartIndex; 305 for (var horizontalIndex = horizontalStartIndex;
296 horizontalIndex < horizontalEndIndex; 306 horizontalIndex < horizontalEndIndex;
297 horizontalIndex++) { 307 horizontalIndex++) {
298 var index = indexBase + horizontalIndex; 308 var index = indexBase + horizontalIndex;
299 if (0 <= index && index < this.dataModel.length) 309 if (0 <= index && index < this.dataModel.length)
300 currentSelection.push(index); 310 currentSelection.push(index);
301 } 311 }
302 } 312 }
303 return currentSelection; 313 return currentSelection;
304 }; 314 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/foreground/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698