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

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

Issue 7453045: Moved ChromeOS Image Editor into an iframe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 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/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..204fa5be2632218ef88d7a8815f3b78e7bf134e8 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) {
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) {
+ // 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.
};
/**

Powered by Google App Engine
This is Rietveld 408576698