Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/file_manager.js |
| diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
| index 888cd979abe2211dd7965da74ebe55145fd49bdd..80cf942050382a2ae263fb3d45dc48b15f6c5d54 100644 |
| --- a/chrome/browser/resources/file_manager/js/file_manager.js |
| +++ b/chrome/browser/resources/file_manager/js/file_manager.js |
| @@ -524,11 +524,6 @@ FileManager.prototype = { |
| this.renameInput_ = this.document_.createElement('input'); |
| this.renameInput_.className = 'rename'; |
| - this.imageEditorFrame_ = this.document_.createElement('div'); |
| - this.imageEditorFrame_.className = 'image-editor'; |
| - this.imageEditorFrame_.style.display = 'none'; |
| - this.dialogDom_.appendChild(this.imageEditorFrame_); |
| - |
| this.renameInput_.addEventListener( |
| 'keydown', this.onRenameInputKeyDown_.bind(this)); |
| this.renameInput_.addEventListener( |
| @@ -1364,35 +1359,39 @@ FileManager.prototype = { |
| g_slideshow_data = urls; |
| chrome.tabs.create({url: "slideshow.html"}); |
| } else if (id == 'edit') { |
| - this.imageEditorFrame_.style.display = 'block'; |
| - this.imageEditor_ = new ImageEditor( |
| - this.imageEditorFrame_, |
| - this.onImageEditorSave.bind(this, details.entries[0]), |
| - this.onImageEditorClose.bind(this)); |
| - this.imageEditor_.getBuffer().load(urls[0]); |
| + this.openImageEditor(details.entries[0]); |
| } else if (id == 'play' || id == 'enqueue') { |
| chrome.fileBrowserPrivate.viewFiles(urls, id); |
| } |
| }; |
| - FileManager.prototype.onImageEditorSave = function(entry, canvas) { |
| + FileManager.prototype.openImageEditor = function(entry) { |
|
SeRya
2011/08/02 17:53:57
Shouldn't it be a private method?
Vladislav Kaznacheev
2011/08/03 09:46:41
Done.
|
| var self = this; |
| - this.cacheMetadata_(entry, function(metadata) { |
| - // The code below modifies the metadata parameter. We assume that this is |
| - // the master copy, otherwise other cacheMetadata_ callers would not |
| - // see our changes. |
| - // The mime type is hardcoded as the editor only works with jpeg for now. |
| - var blob = ImageEncoder.getBlob(canvas, 'image/jpeg', metadata) |
| - // TODO(kaznacheev): Notify user properly about write failures. |
| - util.writeBlobToFile(entry, blob, function(){}, |
| - util.flog('Error writing to ' + entry.fullPath)); |
| - self.updatePreview_(); // Metadata may have changed. |
| - }); |
| + |
| + var editorFrame = this.document_.createElement('iframe'); |
| + editorFrame.className = 'overlay-pane'; |
| + editorFrame.scrolling = 'no'; |
| + |
| + editorFrame.onload = function() { |
| + self.cacheMetadata_(entry, function(metadata) { |
| + editorFrame.contentWindow.ImageEditor.open( |
| + self.onImageEditorSave.bind(self, entry), |
| + function () { self.dialogDom_.removeChild(editorFrame) }, |
| + entry.toURL(), |
| + metadata); |
| + }); |
| + }; |
| + |
| + editorFrame.src = 'js/image_editor/image_editor.html'; |
| + |
| + this.dialogDom_.appendChild(editorFrame); |
| }; |
| - FileManager.prototype.onImageEditorClose = function() { |
| - this.imageEditorFrame_.style.display = 'none'; |
| - this.imageEditor_ = null; |
| + FileManager.prototype.onImageEditorSave = function(entry, blob) { |
|
SeRya
2011/08/02 17:53:57
as above
Vladislav Kaznacheev
2011/08/03 09:46:41
Done.
|
| + // TODO(kaznacheev): Notify user properly about write failures. |
| + util.writeBlobToFile(entry, blob, function(){}, |
| + util.flog('Error writing to ' + entry.fullPath)); |
| + this.updatePreview_(); // Metadata may have changed. |
| }; |
| /** |