Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2669)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/chromevox_state.js

Issue 1457683009: Complete live region support in ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed last feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/chromevox_state.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/chromevox_state.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/chromevox_state.js
new file mode 100644
index 0000000000000000000000000000000000000000..25ba09e007652ff53a5f78901010dbb441695cb8
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/chromevox_state.js
@@ -0,0 +1,93 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview An interface for querying and modifying the global
+ * ChromeVox state, to avoid direct dependencies on the Background
+ * object and to facilitate mocking for tests.
+ */
+
+goog.provide('ChromeVoxMode');
+goog.provide('ChromeVoxState');
+
+goog.require('cursors.Cursor');
+
+/**
+ * All possible modes ChromeVox can run.
+ * @enum {string}
+ */
+ChromeVoxMode = {
+ CLASSIC: 'classic',
+ COMPAT: 'compat',
+ NEXT: 'next',
+ FORCE_NEXT: 'force_next'
+};
+
+/**
+ * ChromeVox2 state object.
+ * @constructor
+ */
+ChromeVoxState = function() {
+ if (ChromeVoxState.instance)
+ throw 'Trying to create two instances of singleton ChromeVoxState.';
+ ChromeVoxState.instance = this;
+};
+
+/**
+ * @type {ChromeVoxState}
+ */
+ChromeVoxState.instance;
+
+ChromeVoxState.prototype = {
+ /** @type {ChromeVoxMode} */
+ get mode() {
+ return this.getMode();
+ },
+
+ /**
+ * @return {ChromeVoxMode} The current mode.
+ * @protected
+ */
+ getMode: function() {
+ return ChromeVoxMode.NEXT;
+ },
+
+ /**
+ * Sets the current ChromeVox mode.
+ * @param {ChromeVoxMode} mode
+ * @param {boolean=} opt_injectClassic Injects ChromeVox classic into tabs;
+ * defaults to false.
+ */
+ setMode: function(mode, opt_injectClassic) {
+ throw new Error('setMode must be implemented by subclass.');
+ },
+
+ /**
+ * Refreshes the current mode based on a url.
+ * @param {string} url
+ */
+ refreshMode: function(url) {
+ throw new Error('refresthMode must be implemented by subclass.');
+ },
+
+ /** @type {cursors.Range} */
+ get currentRange() {
+ return this.getCurrentRange();
+ },
+
+ /**
+ * @return {cursors.Range} The current range.
+ * @protected
+ */
+ getCurrentRange: function() {
+ return null;
+ },
+
+ /**
+ * @param {cursors.Range} newRange The new range.
+ */
+ setCurrentRange: function(newRange) {
+ throw new Error('setCurrentRange must be implemented by subclass.');
+ },
+};

Powered by Google App Engine
This is Rietveld 408576698