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

Side by Side Diff: chrome/browser/resources/file_manager/js/image_editor/image_view.js

Issue 9664045: [File Manager] Use content url for playing media files from a gdata directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Permissions Created 8 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 | Annotate | Revision Log
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 /** 5 /**
6 * The overlay displaying the image. 6 * The overlay displaying the image.
7 */ 7 */
8 function ImageView(container, viewport) { 8 function ImageView(container, viewport) {
9 this.container_ = container; 9 this.container_ = container;
10 this.viewport_ = viewport; 10 this.viewport_ = viewport;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 var self = this; 174 var self = this;
175 175
176 this.contentID_ = id; 176 this.contentID_ = id;
177 177
178 if (FileType.getMediaType(source) == 'video') { 178 if (FileType.getMediaType(source) == 'video') {
179 var video = this.document_.createElement('video'); 179 var video = this.document_.createElement('video');
180 if (metadata.thumbnailURL) { 180 if (metadata.thumbnailURL) {
181 video.setAttribute('poster', metadata.thumbnailURL); 181 video.setAttribute('poster', metadata.thumbnailURL);
182 } 182 }
183 if (!metadata.thumbnailOnly) { 183 video.src = metadata.contentURL || source;
184 video.src = source; 184 video.load();
185 video.load();
186 }
187 displayMainImage(ImageView.LOAD_TYPE_TOTAL, video); 185 displayMainImage(ImageView.LOAD_TYPE_TOTAL, video);
188 return; 186 return;
189 } 187 }
190 var readyContent = this.getReadyContent(id, source); 188 var readyContent = this.getReadyContent(id, source);
191 if (readyContent) { 189 if (readyContent) {
192 displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL, readyContent); 190 displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL, readyContent);
193 } else { 191 } else {
194 var cachedScreen = this.screenCache_.getItem(id); 192 var cachedScreen = this.screenCache_.getItem(id);
195 if (cachedScreen) { 193 if (cachedScreen) {
196 // We have a cached screen-scale canvas, use it instead of a thumbnail. 194 // We have a cached screen-scale canvas, use it instead of a thumbnail.
(...skipping 18 matching lines...) Expand all
215 213
216 var mainImageLoadDelay = ImageView.ANIMATION_WAIT_INTERVAL; 214 var mainImageLoadDelay = ImageView.ANIMATION_WAIT_INTERVAL;
217 215
218 // Do not do slide-in animation when scrolling very fast. 216 // Do not do slide-in animation when scrolling very fast.
219 if (self.lastLoadTime_ && 217 if (self.lastLoadTime_ &&
220 (time - self.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) { 218 (time - self.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) {
221 slide = 0; 219 slide = 0;
222 } 220 }
223 self.lastLoadTime_ = time; 221 self.lastLoadTime_ = time;
224 222
225 if (metadata.thumbnailOnly) { 223 if (metadata.contentURL) {
224 source = metadata.contentURL;
dgozman 2012/03/11 13:17:41 Where is |source| defined and used?
Vladislav Kaznacheev 2012/03/11 14:09:53 This is a parameter, and yes, this is ugly. I refa
226 // We do not know the main image size, but chances are that it is large 225 // We do not know the main image size, but chances are that it is large
227 // enough. Show the thumbnail at the maximum possible scale. 226 // enough. Show the thumbnail at the maximum possible scale.
228 var bounds = self.viewport_.getScreenBounds(); 227 var bounds = self.viewport_.getScreenBounds();
229 var scale = Math.min (bounds.width / canvas.width, 228 var scale = Math.min (bounds.width / canvas.width,
230 bounds.height / canvas.height); 229 bounds.height / canvas.height);
231 self.replace(canvas, slide, canvas.width * scale, canvas.height * scale); 230 self.replace(canvas, slide, canvas.width * scale, canvas.height * scale);
232 if (opt_callback) opt_callback(ImageView.LOAD_TYPE_TOTAL); 231 } else {
233 return; 232 self.replace(canvas, slide, metadata.width, metadata.height);
234 } 233 }
235
236 self.replace(canvas, slide, metadata.width, metadata.height);
237 if (!slide) mainImageLoadDelay = 0; 234 if (!slide) mainImageLoadDelay = 0;
238 slide = 0; 235 slide = 0;
239 loadMainImage(loadType, mainImageLoadDelay); 236 loadMainImage(loadType, mainImageLoadDelay);
240 } 237 }
241 238
242 function loadMainImage(loadType, delay) { 239 function loadMainImage(loadType, delay) {
243 if (self.prefetchLoader_.isLoading(source)) { 240 if (self.prefetchLoader_.isLoading(source)) {
244 // The image we need is already being prefetched. Initiating another load 241 // The image we need is already being prefetched. Initiating another load
245 // would be a waste. Hijack the load instead by overriding the callback. 242 // would be a waste. Hijack the load instead by overriding the callback.
246 self.prefetchLoader_.setCallback(displayMainImage.bind(null, loadType)); 243 self.prefetchLoader_.setCallback(displayMainImage.bind(null, loadType));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (this.order_.length > this.capacity_) 519 if (this.order_.length > this.capacity_)
523 throw new Error('Exceeded cache capacity'); 520 throw new Error('Exceeded cache capacity');
524 }; 521 };
525 522
526 ImageView.Cache.prototype.evictLRU = function() { 523 ImageView.Cache.prototype.evictLRU = function() {
527 if (this.order_.length == this.capacity_) { 524 if (this.order_.length == this.capacity_) {
528 var id = this.order_.shift(); 525 var id = this.order_.shift();
529 delete this.map_[id]; 526 delete this.map_[id];
530 } 527 }
531 }; 528 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698