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 The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
7 * background page. | 7 * background page. |
8 */ | 8 */ |
9 | 9 |
10 goog.provide('Background'); | 10 goog.provide('Background'); |
11 goog.provide('global'); | 11 goog.provide('global'); |
12 | 12 |
13 goog.require('AutomationPredicate'); | 13 goog.require('AutomationPredicate'); |
14 goog.require('AutomationUtil'); | 14 goog.require('AutomationUtil'); |
15 goog.require('ClassicCompatibility'); | 15 goog.require('ClassicCompatibility'); |
16 goog.require('NextEarcons'); | |
16 goog.require('Output'); | 17 goog.require('Output'); |
17 goog.require('Output.EventType'); | 18 goog.require('Output.EventType'); |
18 goog.require('cursors.Cursor'); | 19 goog.require('cursors.Cursor'); |
19 goog.require('cvox.BrailleKeyCommand'); | 20 goog.require('cvox.BrailleKeyCommand'); |
20 goog.require('cvox.ChromeVoxEditableTextBase'); | 21 goog.require('cvox.ChromeVoxEditableTextBase'); |
22 goog.require('cvox.ClassicEarcons'); | |
21 goog.require('cvox.ExtensionBridge'); | 23 goog.require('cvox.ExtensionBridge'); |
22 goog.require('cvox.NavBraille'); | 24 goog.require('cvox.NavBraille'); |
23 | 25 |
24 goog.scope(function() { | 26 goog.scope(function() { |
25 var AutomationNode = chrome.automation.AutomationNode; | 27 var AutomationNode = chrome.automation.AutomationNode; |
26 var Dir = AutomationUtil.Dir; | 28 var Dir = AutomationUtil.Dir; |
27 var EventType = chrome.automation.EventType; | 29 var EventType = chrome.automation.EventType; |
28 var RoleType = chrome.automation.RoleType; | 30 var RoleType = chrome.automation.RoleType; |
29 | 31 |
30 /** | 32 /** |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 var url = msg['url']; | 110 var url = msg['url']; |
109 var isClassicEnabled = this.shouldEnableClassicForUrl_(url); | 111 var isClassicEnabled = this.shouldEnableClassicForUrl_(url); |
110 port.postMessage({ | 112 port.postMessage({ |
111 target: 'next', | 113 target: 'next', |
112 isClassicEnabled: isClassicEnabled | 114 isClassicEnabled: isClassicEnabled |
113 }); | 115 }); |
114 } | 116 } |
115 break; | 117 break; |
116 } | 118 } |
117 }.bind(this)); | 119 }.bind(this)); |
120 | |
121 /** @type {!cvox.AbstractEarcons} @private */ | |
122 this.classicEarcons_ = cvox.ChromeVox.earcons || new cvox.ClassicEarcons(); | |
Peter Lundblad
2015/09/29 09:27:33
This constructor now depends on only being called
dmazzoni
2015/10/13 23:07:03
I believe this isn't an issue anymore. If we const
| |
123 | |
124 /** @type {!cvox.AbstractEarcons} @private */ | |
125 this.nextEarcons_ = new NextEarcons(); | |
126 | |
127 cvox.ChromeVox.earcons = this.classicEarcons_; | |
118 }; | 128 }; |
119 | 129 |
120 Background.prototype = { | 130 Background.prototype = { |
121 /** Forces ChromeVox Next to be active for all tabs. */ | 131 /** Forces ChromeVox Next to be active for all tabs. */ |
122 forceChromeVoxNextActive: function() { | 132 forceChromeVoxNextActive: function() { |
123 this.setChromeVoxMode(ChromeVoxMode.FORCE_NEXT); | 133 this.setChromeVoxMode(ChromeVoxMode.FORCE_NEXT); |
124 }, | 134 }, |
125 | 135 |
126 /** | 136 /** |
127 * Handles all setup once a new automation tree appears. | 137 * Handles all setup once a new automation tree appears. |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 } else { | 738 } else { |
729 // When in compat mode, if the focus is within the desktop tree proper, | 739 // When in compat mode, if the focus is within the desktop tree proper, |
730 // then do not disable content scripts. | 740 // then do not disable content scripts. |
731 if (this.currentRange_.start.node.root.role == 'desktop') | 741 if (this.currentRange_.start.node.root.role == 'desktop') |
732 return; | 742 return; |
733 | 743 |
734 this.disableClassicChromeVox_(); | 744 this.disableClassicChromeVox_(); |
735 } | 745 } |
736 }.bind(this)); | 746 }.bind(this)); |
737 | 747 |
748 // Switch the earcon controller used depending on if we're using | |
749 // ChromeVox Next or Classic, but don't change it if the earcon | |
750 // controller is something else (like for testing). | |
751 if (cvox.ChromeVox.earcons == this.classicEarcons_ || | |
752 cvox.ChromeVox.earcons == this.nextEarcons_) { | |
753 if (mode === ChromeVoxMode.FORCE_NEXT || mode === ChromeVoxMode.NEXT) { | |
754 cvox.ChromeVox.earcons = this.nextEarcons_; | |
755 } else { | |
756 cvox.ChromeVox.earcons = this.classicEarcons_; | |
757 } | |
758 } | |
Peter Lundblad
2015/09/29 09:27:33
I am always cautious when introducing state that i
dmazzoni
2015/10/13 23:07:03
Done, made it a getter.
| |
759 | |
738 this.mode_ = mode; | 760 this.mode_ = mode; |
739 }, | 761 }, |
740 | 762 |
741 /** | 763 /** |
742 * @param {!cvox.Spannable} text | 764 * @param {!cvox.Spannable} text |
743 * @param {number} position | 765 * @param {number} position |
744 * @private | 766 * @private |
745 */ | 767 */ |
746 brailleRoutingCommand_: function(text, position) { | 768 brailleRoutingCommand_: function(text, position) { |
747 var actionNode = null; | 769 var actionNode = null; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 node.state.protected, | 812 node.state.protected, |
791 cvox.ChromeVox.tts); | 813 cvox.ChromeVox.tts); |
792 } | 814 } |
793 } | 815 } |
794 }; | 816 }; |
795 | 817 |
796 /** @type {Background} */ | 818 /** @type {Background} */ |
797 global.backgroundObj = new Background(); | 819 global.backgroundObj = new Background(); |
798 | 820 |
799 }); // goog.scope | 821 }); // goog.scope |
OLD | NEW |