Index: chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js b/chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js |
index 9183a7b12fa12e2a6c775d8e9c52e5eea1f6863e..bea96b5b0061563d188f33f75d08592a333b5994 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js |
+++ b/chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js |
@@ -64,11 +64,7 @@ goog.inherits(cvox.BrailleBackground, cvox.AbstractBraille); |
/** @override */ |
cvox.BrailleBackground.prototype.write = function(params) { |
- this.lastContentId_ = null; |
- this.lastContent_ = null; |
- this.inputHandler_.onDisplayContentChanged(params.text); |
- this.displayManager_.setContent( |
- params, this.inputHandler_.getExpansionType()); |
+ this.setContent_(params, null); |
}; |
@@ -94,16 +90,31 @@ cvox.BrailleBackground.prototype.getTranslatorManager = function() { |
*/ |
cvox.BrailleBackground.prototype.onBrailleMessage = function(msg) { |
if (msg['action'] == 'write') { |
- this.lastContentId_ = msg['contentId']; |
- this.lastContent_ = cvox.NavBraille.fromJson(msg['params']); |
- this.inputHandler_.onDisplayContentChanged(this.lastContent_.text); |
- this.displayManager_.setContent( |
- this.lastContent_, this.inputHandler_.getExpansionType()); |
+ this.setContent_(cvox.NavBraille.fromJson(msg['params']), |
+ msg['contentId']); |
} |
}; |
/** |
+ * @param {!cvox.NavBraille} newContent |
+ * @param {?string} newContentId |
+ * @private |
+ */ |
+cvox.BrailleBackground.prototype.setContent_ = function( |
+ newContent, newContentId) { |
+ var updateContent = function() { |
+ this.lastContent_ = newContentId ? newContent : null; |
+ this.lastContentId_ = newContentId; |
+ this.displayManager_.setContent( |
+ newContent, this.inputHandler_.getExpansionType()); |
+ }.bind(this); |
+ this.inputHandler_.onDisplayContentChanged(newContent.text, updateContent); |
+ updateContent(); |
+}; |
+ |
+ |
+/** |
* Handles braille key events by dispatching either to the input handler or |
* a content script. |
* @param {!cvox.BrailleKeyEvent} brailleEvt The event. |