| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 An interface for querying and modifying the global | 6 * @fileoverview An interface for querying and modifying the global |
| 7 * ChromeVox state, to avoid direct dependencies on the Background | 7 * ChromeVox state, to avoid direct dependencies on the Background |
| 8 * object and to facilitate mocking for tests. | 8 * object and to facilitate mocking for tests. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 goog.provide('ChromeVoxMode'); | 11 goog.provide('ChromeVoxMode'); |
| 12 goog.provide('ChromeVoxState'); | 12 goog.provide('ChromeVoxState'); |
| 13 goog.provide('ChromeVoxStateObserver'); |
| 13 | 14 |
| 14 goog.require('cursors.Cursor'); | 15 goog.require('cursors.Cursor'); |
| 16 goog.require('cursors.Range'); |
| 15 | 17 |
| 16 /** | 18 /** |
| 17 * All possible modes ChromeVox can run. | 19 * All possible modes ChromeVox can run. |
| 18 * @enum {string} | 20 * @enum {string} |
| 19 */ | 21 */ |
| 20 ChromeVoxMode = { | 22 ChromeVoxMode = { |
| 21 CLASSIC: 'classic', | 23 CLASSIC: 'classic', |
| 22 CLASSIC_COMPAT: 'classic_compat', | 24 CLASSIC_COMPAT: 'classic_compat', |
| 23 NEXT: 'next', | 25 NEXT: 'next', |
| 24 FORCE_NEXT: 'force_next' | 26 FORCE_NEXT: 'force_next' |
| 25 }; | 27 }; |
| 26 | 28 |
| 27 /** | 29 /** |
| 30 * An interface implemented by objects that want to observe ChromeVox state |
| 31 * changes. |
| 32 * @interface |
| 33 */ |
| 34 ChromeVoxStateObserver = function() {}; |
| 35 |
| 36 ChromeVoxStateObserver.prototype = { |
| 37 /** |
| 38 * @param {cursors.Range} range The new range. |
| 39 */ |
| 40 onCurrentRangeChanged: function(range) {} |
| 41 }; |
| 42 |
| 43 /** |
| 28 * ChromeVox2 state object. | 44 * ChromeVox2 state object. |
| 29 * @constructor | 45 * @constructor |
| 30 */ | 46 */ |
| 31 ChromeVoxState = function() { | 47 ChromeVoxState = function() { |
| 32 if (ChromeVoxState.instance) | 48 if (ChromeVoxState.instance) |
| 33 throw 'Trying to create two instances of singleton ChromeVoxState.'; | 49 throw 'Trying to create two instances of singleton ChromeVoxState.'; |
| 34 ChromeVoxState.instance = this; | 50 ChromeVoxState.instance = this; |
| 35 }; | 51 }; |
| 36 | 52 |
| 37 /** | 53 /** |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 * @return {cursors.Range} The current range. | 89 * @return {cursors.Range} The current range. |
| 74 * @protected | 90 * @protected |
| 75 */ | 91 */ |
| 76 getCurrentRange: function() { | 92 getCurrentRange: function() { |
| 77 return null; | 93 return null; |
| 78 }, | 94 }, |
| 79 | 95 |
| 80 /** | 96 /** |
| 81 * @param {cursors.Range} newRange The new range. | 97 * @param {cursors.Range} newRange The new range. |
| 82 */ | 98 */ |
| 83 setCurrentRange: goog.abstractMethod, | 99 setCurrentRange: goog.abstractMethod |
| 84 }; | 100 }; |
| 101 |
| 102 /** @type {!Array<ChromeVoxStateObserver>} */ |
| 103 ChromeVoxState.observers = []; |
| 104 |
| 105 /** |
| 106 * @param {ChromeVoxStateObserver} observer |
| 107 */ |
| 108 ChromeVoxState.addObserver = function(observer) { |
| 109 this.observers.push(observer); |
| 110 }; |
| OLD | NEW |