Index: chrome/browser/resources/file_manager/foreground/js/image_editor/image_util.js |
diff --git a/chrome/browser/resources/file_manager/foreground/js/image_editor/image_util.js b/chrome/browser/resources/file_manager/foreground/js/image_editor/image_util.js |
index 40b5b70cdf03fe4808adca6ad23058517c1ef0ce..fb1ceb170439112371cada160ccc5754fedc6bfa 100644 |
--- a/chrome/browser/resources/file_manager/foreground/js/image_editor/image_util.js |
+++ b/chrome/browser/resources/file_manager/foreground/js/image_editor/image_util.js |
@@ -398,7 +398,7 @@ ImageUtil.setClass = function(element, className, on) { |
}; |
/** |
- * ImageLoader loads an image from a given URL into a canvas in two steps: |
+ * ImageLoader loads an image from a given Entry into a canvas in two steps: |
* 1. Loads the image into an HTMLImageElement. |
* 2. Copies pixels from HTMLImageElement to HTMLCanvasElement. This is done |
* stripe-by-stripe to avoid freezing up the UI. The transform is taken into |
@@ -435,7 +435,7 @@ ImageUtil.ImageLoader.isTooLarge = function(width, height) { |
* TODO(mtomasz): Simplify, or even get rid of this class and merge with the |
* ThumbnaiLoader class. |
* |
- * @param {string} url Image URL. |
+ * @param {FileEntry} entry Image entry to be loaded. |
* @param {function(function(object))} transformFetcher function to get |
* the image transform (which we need for the image orientation). |
* @param {function(HTMLCanvasElement, string=)} callback Callback to be |
@@ -444,10 +444,10 @@ ImageUtil.ImageLoader.isTooLarge = function(width, height) { |
* animations play out before the computation heavy image loading starts. |
*/ |
ImageUtil.ImageLoader.prototype.load = function( |
- url, transformFetcher, callback, opt_delay) { |
+ entry, transformFetcher, callback, opt_delay) { |
this.cancel(); |
- this.url_ = url; |
+ this.entry_ = entry; |
this.callback_ = callback; |
// The transform fetcher is not cancellable so we need a generation counter. |
@@ -482,7 +482,7 @@ ImageUtil.ImageLoader.prototype.load = function( |
onError('GALLERY_IMAGE_TOO_BIG_ERROR'); |
return; |
} |
- transformFetcher(url, onTransform.bind(this, e.target)); |
+ transformFetcher(entry, onTransform.bind(this, e.target)); |
}.bind(this); |
// The error callback has an optional error argument, which in case of a |
@@ -496,14 +496,14 @@ ImageUtil.ImageLoader.prototype.load = function( |
opt_metadata.modificationTime.getTime(); |
// Load the image directly. |
- this.image_.src = url; |
+ this.image_.src = entry.toURL(); |
}.bind(this); |
// Loads the image. If already loaded, then forces a reload. |
var startLoad = this.resetImage_.bind(this, function() { |
// Fetch metadata to detect last modification time for the caching purpose. |
if (this.metadataCache_) |
- this.metadataCache_.get(url, 'filesystem', loadImage); |
+ this.metadataCache_.get(entry, 'filesystem', loadImage); |
else |
loadImage(); |
}.bind(this), onError); |
@@ -553,11 +553,11 @@ ImageUtil.ImageLoader.prototype.isBusy = function() { |
}; |
/** |
- * @param {string} url Image url. |
+ * @param {Entry} entry Image entry. |
* @return {boolean} True if loader loads this image. |
*/ |
-ImageUtil.ImageLoader.prototype.isLoading = function(url) { |
- return this.isBusy() && (this.url_ == url); |
+ImageUtil.ImageLoader.prototype.isLoading = function(entry) { |
+ return this.isBusy() && (this.entry_.toURL() == entry.toURL()); |
hirono
2013/12/09 06:53:50
nit: util.isSameEntry?
mtomasz
2013/12/10 02:37:34
Done.
mtomasz
2013/12/10 02:37:34
Done.
|
}; |
/** |
@@ -631,7 +631,7 @@ ImageUtil.ImageLoader.prototype.copyStrip_ = function( |
if (lastRow == image.height) { |
context.restore(); |
- if (this.url_.substr(0, 5) != 'data:') { // Ignore data urls. |
+ if (this.entry_.toURL().substr(0, 5) != 'data:') { // Ignore data urls. |
ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('LoadTime')); |
} |
try { |
@@ -658,22 +658,10 @@ ImageUtil.removeChildren = function(element) { |
}; |
/** |
- * @param {string} url "filesystem:" URL. |
- * @return {string} File name. |
- */ |
-ImageUtil.getFullNameFromUrl = function(url) { |
- url = decodeURIComponent(url); |
- if (url.indexOf('/') != -1) |
- return url.substr(url.lastIndexOf('/') + 1); |
- else |
- return url; |
-}; |
- |
-/** |
* @param {string} name File name (with extension). |
* @return {string} File name without extension. |
*/ |
-ImageUtil.getFileNameFromFullName = function(name) { |
+ImageUtil.getDisplayNameFromName = function(name) { |
var index = name.lastIndexOf('.'); |
if (index != -1) |
return name.substr(0, index); |
@@ -682,28 +670,6 @@ ImageUtil.getFileNameFromFullName = function(name) { |
}; |
/** |
- * @param {string} url "filesystem:" URL. |
- * @return {string} File name. |
- */ |
-ImageUtil.getFileNameFromUrl = function(url) { |
- return ImageUtil.getFileNameFromFullName(ImageUtil.getFullNameFromUrl(url)); |
-}; |
- |
-/** |
- * @param {string} fullName Original file name. |
- * @param {string} name New file name without extension. |
- * @return {string} New file name with base of |name| and extension of |
- * |fullName|. |
- */ |
-ImageUtil.replaceFileNameInFullName = function(fullName, name) { |
- var index = fullName.lastIndexOf('.'); |
- if (index != -1) |
- return name + fullName.substr(index); |
- else |
- return name; |
-}; |
- |
-/** |
* @param {string} name File name. |
* @return {string} File extension. |
*/ |