| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Bridge that sends Braille messages from content scripts or | 6 * @fileoverview Bridge that sends Braille messages from content scripts or |
| 7 * other pages to the main background page. | 7 * other pages to the main background page. |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 }, this)); | 56 }, this)); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 | 59 |
| 60 /** @override */ | 60 /** @override */ |
| 61 cvox.ChromeBraille.prototype.write = function(params) { | 61 cvox.ChromeBraille.prototype.write = function(params) { |
| 62 this.lastContent_ = params; | 62 this.lastContent_ = params; |
| 63 this.updateLastContentId_(); | 63 this.updateLastContentId_(); |
| 64 var outParams = params.toJson(); | 64 var outParams = params.toJson(); |
| 65 | 65 |
| 66 var message = {'target': 'BRAILLE', | 66 var message = { |
| 67 'action': 'write', | 67 'target': 'BRAILLE', |
| 68 'params': outParams, | 68 'action': 'write', |
| 69 'contentId' : this.lastContentId_}; | 69 'params': outParams, |
| 70 'contentId': this.lastContentId_ |
| 71 }; |
| 70 | 72 |
| 71 cvox.ExtensionBridge.send(message); | 73 cvox.ExtensionBridge.send(message); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 | 76 |
| 75 /** @override */ | 77 /** @override */ |
| 76 cvox.ChromeBraille.prototype.writeRawImage = function(imageDataUrl) { | 78 cvox.ChromeBraille.prototype.writeRawImage = function(imageDataUrl) { |
| 77 // Do Nothing. | 79 // Do Nothing. |
| 78 }; | 80 }; |
| 79 | 81 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 | 93 |
| 92 | 94 |
| 93 /** @override */ | 95 /** @override */ |
| 94 cvox.ChromeBraille.prototype.getDisplayState = function() { | 96 cvox.ChromeBraille.prototype.getDisplayState = function() { |
| 95 return {available: false, textRowCount: 0, textColumnCount: 0}; | 97 return {available: false, textRowCount: 0, textColumnCount: 0}; |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 | 100 |
| 99 /** @private */ | 101 /** @private */ |
| 100 cvox.ChromeBraille.prototype.updateLastContentId_ = function() { | 102 cvox.ChromeBraille.prototype.updateLastContentId_ = function() { |
| 101 this.lastContentId_ = cvox.ExtensionBridge.uniqueId() + '.' + | 103 this.lastContentId_ = |
| 102 this.nextLocalId_++; | 104 cvox.ExtensionBridge.uniqueId() + '.' + this.nextLocalId_++; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 | 107 |
| 106 /** | 108 /** |
| 107 * Dispatches braille input commands. | 109 * Dispatches braille input commands. |
| 108 * @param {!cvox.BrailleKeyEvent} brailleEvt The braille key event. | 110 * @param {!cvox.BrailleKeyEvent} brailleEvt The braille key event. |
| 109 * @param {cvox.NavBraille} content display content when command was issued, | 111 * @param {cvox.NavBraille} content display content when command was issued, |
| 110 * if available. | 112 * if available. |
| 111 * @private | 113 * @private |
| 112 */ | 114 */ |
| 113 cvox.ChromeBraille.prototype.onKeyEvent_ = function(brailleEvt, | 115 cvox.ChromeBraille.prototype.onKeyEvent_ = function(brailleEvt, content) { |
| 114 content) { | |
| 115 var command = cvox.ChromeVoxUserCommands.commands[brailleEvt.command]; | 116 var command = cvox.ChromeVoxUserCommands.commands[brailleEvt.command]; |
| 116 if (command) { | 117 if (command) { |
| 117 command({event: brailleEvt, content: content}); | 118 command({event: brailleEvt, content: content}); |
| 118 } else { | 119 } else { |
| 119 console.error('Unknown braille command: ' + JSON.stringify(brailleEvt)); | 120 console.error('Unknown braille command: ' + JSON.stringify(brailleEvt)); |
| 120 } | 121 } |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 | 124 |
| 124 /** | 125 /** |
| 125 * Overrides the key event handler | 126 * Overrides the key event handler |
| 126 * @param {function(!cvox.BrailleKeyEvent, cvox.NavBraille):void} listener | 127 * @param {function(!cvox.BrailleKeyEvent, cvox.NavBraille):void} listener |
| 127 */ | 128 */ |
| 128 cvox.ChromeBraille.prototype.setKeyEventHandlerForTest = function(listener) { | 129 cvox.ChromeBraille.prototype.setKeyEventHandlerForTest = function(listener) { |
| 129 this.onKeyEvent_ = listener; | 130 this.onKeyEvent_ = listener; |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 | 133 |
| 133 /** Export platform constructor. */ | 134 /** Export platform constructor. */ |
| 134 cvox.HostFactory.brailleConstructor = cvox.ChromeBraille; | 135 cvox.HostFactory.brailleConstructor = cvox.ChromeBraille; |
| OLD | NEW |