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(); |
| 123 |
| 124 /** @type {!cvox.AbstractEarcons} @private */ |
| 125 this.nextEarcons_ = new NextEarcons(); |
| 126 |
| 127 // Turn cvox.ChromeVox.earcons into a getter that returns either the |
| 128 // Next earcons or the Classic earcons depending on the current mode. |
| 129 Object.defineProperty(cvox.ChromeVox, 'earcons', { |
| 130 get: (function() { |
| 131 if (this.mode_ === ChromeVoxMode.FORCE_NEXT || |
| 132 this.mode_ === ChromeVoxMode.NEXT) { |
| 133 return this.nextEarcons_; |
| 134 } else { |
| 135 return this.classicEarcons_; |
| 136 } |
| 137 }).bind(this) |
| 138 }); |
118 }; | 139 }; |
119 | 140 |
120 Background.prototype = { | 141 Background.prototype = { |
121 /** Forces ChromeVox Next to be active for all tabs. */ | 142 /** Forces ChromeVox Next to be active for all tabs. */ |
122 forceChromeVoxNextActive: function() { | 143 forceChromeVoxNextActive: function() { |
123 this.setChromeVoxMode(ChromeVoxMode.FORCE_NEXT); | 144 this.setChromeVoxMode(ChromeVoxMode.FORCE_NEXT); |
124 }, | 145 }, |
125 | 146 |
126 /** | 147 /** |
127 * Handles all setup once a new automation tree appears. | 148 * Handles all setup once a new automation tree appears. |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 node.state.protected, | 827 node.state.protected, |
807 cvox.ChromeVox.tts); | 828 cvox.ChromeVox.tts); |
808 } | 829 } |
809 } | 830 } |
810 }; | 831 }; |
811 | 832 |
812 /** @type {Background} */ | 833 /** @type {Background} */ |
813 global.backgroundObj = new Background(); | 834 global.backgroundObj = new Background(); |
814 | 835 |
815 }); // goog.scope | 836 }); // goog.scope |
OLD | NEW |