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 Abstract interface to methods that differ depending on the | 6 * @fileoverview Abstract interface to methods that differ depending on the |
7 * host platform. | 7 * host platform. |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
11 goog.provide('cvox.AbstractHost'); | 11 goog.provide('cvox.AbstractHost'); |
12 | 12 |
13 goog.require('cvox.ChromeVoxEventWatcher'); | 13 goog.require('cvox.ChromeVoxEventWatcher'); |
14 | 14 |
15 /** | 15 /** |
16 * @constructor | 16 * @constructor |
17 */ | 17 */ |
18 cvox.AbstractHost = function() { | 18 cvox.AbstractHost = function() {}; |
19 }; | |
20 | 19 |
21 | 20 |
22 /** | 21 /** |
23 * @enum {number} | 22 * @enum {number} |
24 */ | 23 */ |
25 cvox.AbstractHost.State = { | 24 cvox.AbstractHost.State = { |
26 ACTIVE: 0, | 25 ACTIVE: 0, |
27 INACTIVE: 1, | 26 INACTIVE: 1, |
28 KILLED: 2 | 27 KILLED: 2 |
29 }; | 28 }; |
30 | 29 |
31 | 30 |
32 /** | 31 /** |
33 * Do all host-platform-specific initialization. | 32 * Do all host-platform-specific initialization. |
34 */ | 33 */ |
35 cvox.AbstractHost.prototype.init = function() { | 34 cvox.AbstractHost.prototype.init = function() {}; |
36 }; | |
37 | 35 |
38 | 36 |
39 /** | 37 /** |
40 * Used to reinitialize ChromeVox if initialization fails. | 38 * Used to reinitialize ChromeVox if initialization fails. |
41 */ | 39 */ |
42 cvox.AbstractHost.prototype.reinit = function() { | 40 cvox.AbstractHost.prototype.reinit = function() {}; |
43 }; | |
44 | 41 |
45 | 42 |
46 /** | 43 /** |
47 * Executed on page load. | 44 * Executed on page load. |
48 */ | 45 */ |
49 cvox.AbstractHost.prototype.onPageLoad = function() { | 46 cvox.AbstractHost.prototype.onPageLoad = function() {}; |
50 }; | |
51 | 47 |
52 | 48 |
53 /** | 49 /** |
54 * Sends a message to the background page (if it exists) for this host. | 50 * Sends a message to the background page (if it exists) for this host. |
55 * @param {Object} message The message to pass to the background page. | 51 * @param {Object} message The message to pass to the background page. |
56 */ | 52 */ |
57 cvox.AbstractHost.prototype.sendToBackgroundPage = function(message) { | 53 cvox.AbstractHost.prototype.sendToBackgroundPage = function(message) {}; |
58 }; | |
59 | 54 |
60 | 55 |
61 /** | 56 /** |
62 * Returns the absolute URL to the API source. | 57 * Returns the absolute URL to the API source. |
63 * @return {string} The URL. | 58 * @return {string} The URL. |
64 */ | 59 */ |
65 cvox.AbstractHost.prototype.getApiSrc = function() { | 60 cvox.AbstractHost.prototype.getApiSrc = function() { |
66 return ''; | 61 return ''; |
67 }; | 62 }; |
68 | 63 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 cvox.AbstractHost.prototype.mustRedispatchClickEvent = function() { | 99 cvox.AbstractHost.prototype.mustRedispatchClickEvent = function() { |
105 return false; | 100 return false; |
106 }; | 101 }; |
107 | 102 |
108 /** | 103 /** |
109 * Activate or deactivate ChromeVox on this host. | 104 * Activate or deactivate ChromeVox on this host. |
110 * @param {boolean} active The desired state; true for active, false for | 105 * @param {boolean} active The desired state; true for active, false for |
111 * inactive. | 106 * inactive. |
112 */ | 107 */ |
113 cvox.AbstractHost.prototype.activateOrDeactivateChromeVox = function(active) { | 108 cvox.AbstractHost.prototype.activateOrDeactivateChromeVox = function(active) { |
114 this.onStateChanged_(active ? cvox.AbstractHost.State.ACTIVE : | 109 this.onStateChanged_( |
115 cvox.AbstractHost.State.INACTIVE); | 110 active ? cvox.AbstractHost.State.ACTIVE : |
| 111 cvox.AbstractHost.State.INACTIVE); |
116 }; | 112 }; |
117 | 113 |
118 | 114 |
119 /** | 115 /** |
120 * Kills ChromeVox on this host. | 116 * Kills ChromeVox on this host. |
121 */ | 117 */ |
122 cvox.AbstractHost.prototype.killChromeVox = function() { | 118 cvox.AbstractHost.prototype.killChromeVox = function() { |
123 this.onStateChanged_(cvox.AbstractHost.State.KILLED); | 119 this.onStateChanged_(cvox.AbstractHost.State.KILLED); |
124 }; | 120 }; |
125 | 121 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // If ChromeVox is inactive, the event watcher will only listen for key | 153 // If ChromeVox is inactive, the event watcher will only listen for key |
158 // down events. | 154 // down events. |
159 cvox.ChromeVoxEventWatcher.init(window); | 155 cvox.ChromeVoxEventWatcher.init(window); |
160 break; | 156 break; |
161 case cvox.AbstractHost.State.KILLED: | 157 case cvox.AbstractHost.State.KILLED: |
162 cvox.ChromeVox.isActive = false; | 158 cvox.ChromeVox.isActive = false; |
163 cvox.ChromeVox.navigationManager.showOrHideIndicator(false); | 159 cvox.ChromeVox.navigationManager.showOrHideIndicator(false); |
164 break; | 160 break; |
165 } | 161 } |
166 }; | 162 }; |
OLD | NEW |