Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/image_editor/image_editor.js |
| diff --git a/chrome/browser/resources/file_manager/js/image_editor/image_editor.js b/chrome/browser/resources/file_manager/js/image_editor/image_editor.js |
| index 65120531dc83ca7c941670fcb177871955dcaf80..d5f253ce10a8a010342f25926c84d13b2bd2116f 100644 |
| --- a/chrome/browser/resources/file_manager/js/image_editor/image_editor.js |
| +++ b/chrome/browser/resources/file_manager/js/image_editor/image_editor.js |
| @@ -69,6 +69,11 @@ ImageEditor.prototype.lockUI = function(on) { |
| ImageUtil.setAttribute(this.rootContainer_, 'locked', on); |
| }; |
| +ImageEditor.prototype.recordToolUse = function(name) { |
| + ImageUtil.metrics.recordEnum( |
| + ImageUtil.getMetricName('Tool'), name, this.actionNames_); |
| +}; |
| + |
| ImageEditor.prototype.onContentUpdate_ = function() { |
| for (var i = 0; i != this.modes_.length; i++) { |
| var mode = this.modes_[i]; |
| @@ -88,14 +93,14 @@ ImageEditor.prototype.openSession = function( |
| this.lockUI(true); |
| var self = this; |
| - this.imageView_.load(id, source, metadata, slide, function(loadedInstantly) { |
| + this.imageView_.load(id, source, metadata, slide, function() { |
| self.lockUI(false); |
| self.commandQueue_ = new CommandQueue( |
| self.container_.ownerDocument, self.imageView_.getCanvas()); |
| self.commandQueue_.attachUI( |
| self.getImageView(), self.getPrompt(), self.lockUI.bind(self)); |
| self.updateUndoRedo(); |
| - if (opt_callback) opt_callback(loadedInstantly); |
| + if (opt_callback) opt_callback(arguments); |
| }); |
| }; |
| @@ -140,6 +145,7 @@ ImageEditor.prototype.requestImage = function(callback) { |
| ImageEditor.prototype.undo = function() { |
| if (this.isLocked()) return; |
| + this.recordToolUse('undo'); |
| // First undo click should dismiss the uncommitted modifications. |
| if (this.currentMode_ && this.currentMode_.isUpdated()) { |
| @@ -155,6 +161,7 @@ ImageEditor.prototype.undo = function() { |
| ImageEditor.prototype.redo = function() { |
| if (this.isLocked()) return; |
| + this.recordToolUse('redo'); |
| this.getPrompt().hide(); |
| this.leaveMode(false); |
| this.commandQueue_.redo(); |
| @@ -306,15 +313,21 @@ ImageEditor.Mode.OneClick.prototype.getCommand = function() { |
| ImageEditor.prototype.createToolButtons = function() { |
| this.mainToolbar_.clear(); |
| + this.actionNames_ = []; |
| + |
| + var self = this; |
| + function createButton(name, handler) { |
| + self.actionNames_.push(name); |
| + return self.mainToolbar_.addButton(name, handler, name); |
| + } |
| + |
| for (var i = 0; i != this.modes_.length; i++) { |
| var mode = this.modes_[i]; |
| - mode.bind(this, this.mainToolbar_. |
| - addButton(mode.name, this.enterMode.bind(this, mode), mode.name)); |
| + mode.bind(this, createButton(mode.name, this.enterMode.bind(this, mode))); |
| } |
| - this.undoButton_ = this.mainToolbar_. |
| - addButton('undo', this.undo.bind(this), 'undo'); |
| - this.redoButton_ = this.mainToolbar_. |
| - addButton('redo', this.redo.bind(this), 'redo'); |
| + this.undoButton_ = createButton('undo', this.undo.bind(this)); |
| + this.redoButton_ = createButton('redo', this.redo.bind(this)); |
| + this.actionNames_.push('share'); |
|
dgozman
2011/12/06 15:45:56
Can we push this in ShareMode ?
Vladislav Kaznacheev
2011/12/06 16:07:44
Done.
|
| }; |
| ImageEditor.prototype.getMode = function() { return this.currentMode_ }; |
| @@ -331,6 +344,8 @@ ImageEditor.prototype.enterMode = function(mode, event) { |
| return; |
| } |
| + this.recordToolUse(mode.name); |
| + |
| this.leaveModeGently(); |
| // The above call could have caused a commit which might have initiated |
| // an asynchronous command execution. Wait for it to complete, then proceed |