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

Unified Diff: chrome/browser/resources/file_manager/js/media/media_util.js

Issue 10804010: HiDPI assets for Chrome OS Files app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed ID ranges to accommodate new resources Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/file_manager/js/media/media_util.js
diff --git a/chrome/browser/resources/file_manager/js/media/media_util.js b/chrome/browser/resources/file_manager/js/media/media_util.js
index 585a0a7b274886dfd96525fbfbf2896ac2c96cbb..eb4ec0bfb6add01bd2352655c027b8b7347c531b 100644
--- a/chrome/browser/resources/file_manager/js/media/media_util.js
+++ b/chrome/browser/resources/file_manager/js/media/media_util.js
@@ -3,33 +3,38 @@
// found in the LICENSE file.
/**
- * @param {string} imageUrl Image URL
- * @param {Object} opt_metadata Metadata object
+ * @param {string} url File URL.
+ * @param {Object} opt_metadata Metadata object.
+ * @param {string} opt_mediaType Media type.
* @constructor
*/
-function ThumbnailLoader(imageUrl, opt_metadata) {
- var genericIconUrl = FileType.getPreviewArt(FileType.getMediaType(imageUrl));
- if (opt_metadata && opt_metadata.gdata) {
+function ThumbnailLoader(url, opt_metadata, opt_mediaType) {
+ this.mediaType_ = opt_mediaType || FileType.getMediaType(url);
+
+ if (!opt_metadata) {
+ this.thumbnailUrl_ = url; // Use the URL directly.
+ return;
+ }
+
+ if (opt_metadata.gdata) {
var apps = opt_metadata.gdata.driveApps;
if (apps.length > 0 && apps[0].docIcon) {
- genericIconUrl = apps[0].docIcon;
+ this.fallbackUrl_ = apps[0].docIcon;
}
}
- if (!opt_metadata) {
- this.thumbnailUrl_ = imageUrl;
- } else if (opt_metadata.thumbnail && opt_metadata.thumbnail.url) {
+ if (opt_metadata.thumbnail && opt_metadata.thumbnail.url) {
this.thumbnailUrl_ = opt_metadata.thumbnail.url;
- this.fallbackUrl_ = genericIconUrl;
this.transform_ = opt_metadata.thumbnail.transform;
- } else if (FileType.isImage(imageUrl) &&
+ } else if (FileType.isImage(url) &&
ThumbnailLoader.canUseImageUrl_(opt_metadata)) {
- this.thumbnailUrl_ = imageUrl;
- this.fallbackUrl_ = genericIconUrl;
+ this.thumbnailUrl_ = url;
this.transform_ = opt_metadata.media && opt_metadata.media.imageTransform;
- } else {
- this.thumbnailUrl_ = genericIconUrl;
- }
+ } else if (this.fallbackUrl_) {
+ // Use fallback as the primary thumbnail.
+ this.thumbnailUrl_ = this.fallbackUrl_;
+ this.fallbackUrl_ = null;
+ } // else the generic thumbnail based on the media type will be used.
}
/**
@@ -69,6 +74,12 @@ ThumbnailLoader.canUseImageUrl_ = function(metadata) {
*/
ThumbnailLoader.prototype.load = function(
box, fill, opt_onSuccess, opt_onError) {
+ if (!this.thumbnailUrl_) {
+ // Relevant CSS rules are in file_types.css.
+ box.setAttribute('generic-thumbnail', this.mediaType_);
+ return;
+ }
+
var img = box.ownerDocument.createElement('img');
img.onload = function() {
util.applyTransform(box, this.transform_);
@@ -83,7 +94,8 @@ ThumbnailLoader.prototype.load = function(
if (opt_onError)
opt_onError();
if (this.fallbackUrl_)
- new ThumbnailLoader(this.fallbackUrl_).load(box, fill, opt_onSuccess);
+ new ThumbnailLoader(this.fallbackUrl_, null, this.mediaType_).
+ load(box, fill, opt_onSuccess);
}.bind(this);
if (img.src == this.thumbnailUrl_) {

Powered by Google App Engine
This is Rietveld 408576698