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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * @private | 42 * @private |
43 */ | 43 */ |
44 this.nextLocalId_ = 1; | 44 this.nextLocalId_ = 1; |
45 cvox.ExtensionBridge.addMessageListener(goog.bind(function(msg, port) { | 45 cvox.ExtensionBridge.addMessageListener(goog.bind(function(msg, port) { |
46 // Since ChromeVox gets injected into multiple iframes on a page, check to | 46 // Since ChromeVox gets injected into multiple iframes on a page, check to |
47 // ensure that this is the "active" iframe via its focused state. | 47 // ensure that this is the "active" iframe via its focused state. |
48 // Furthermore, if the active element is itself an iframe, the focus is | 48 // Furthermore, if the active element is itself an iframe, the focus is |
49 // within the iframe even though the containing document also has focus. | 49 // within the iframe even though the containing document also has focus. |
50 // Don't process the event if this document isn't focused or focus lies in | 50 // Don't process the event if this document isn't focused or focus lies in |
51 // a descendant. | 51 // a descendant. |
52 if (!document.hasFocus() || document.activeElement.tagName == 'IFRAME') { | 52 if (!cvox.ChromeVox.documentHasFocus()) { |
53 return; | 53 return; |
54 } | 54 } |
55 if (msg['message'] == 'BRAILLE' && msg['args']) { | 55 if (msg['message'] == 'BRAILLE' && msg['args']) { |
56 var content = null; | 56 var content = null; |
57 if (msg['contentId'] == this.lastContentId_) { | 57 if (msg['contentId'] == this.lastContentId_) { |
58 content = this.lastContent_; | 58 content = this.lastContent_; |
59 } | 59 } |
60 this.commandListener_(msg['args'], content); | 60 this.commandListener_(msg['args'], content); |
61 } | 61 } |
62 }, this)); | 62 }, this)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (command) { | 105 if (command) { |
106 command({event: brailleEvt, content: content}); | 106 command({event: brailleEvt, content: content}); |
107 } else { | 107 } else { |
108 console.error('Unknown braille command: ' + JSON.stringify(brailleEvt)); | 108 console.error('Unknown braille command: ' + JSON.stringify(brailleEvt)); |
109 } | 109 } |
110 }; | 110 }; |
111 | 111 |
112 | 112 |
113 /** Export platform constructor. */ | 113 /** Export platform constructor. */ |
114 cvox.HostFactory.brailleConstructor = cvox.ChromeBraille; | 114 cvox.HostFactory.brailleConstructor = cvox.ChromeBraille; |
OLD | NEW |