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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox_next/chromevox2/background/background.js

Issue 272013002: Provide skeleton for ChromeVox next. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check port name. Created 6 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview The entry point for all ChromeVox2 related code for the
Peter Lundblad 2014/05/12 18:37:32 Please decide on chromevox_next vs. chromevox2. ;)
David Tseng 2014/05/12 20:33:38 ChromeVox2 it is then. Note that I didn't change
7 * background page.
8 */
9
10 /** ChromeVox2 (ChromeVox Next) namespace */
11 var cvox2 = function() {};
12
13 /** Namespace for global objects in the background page. */
14 cvox2.global = function() {};
15
16 /** Classic Chrome accessibility API. */
17 cvox2.global.accessibility =
18 chrome.accessibilityPrivate || chrome.experimental.accessibility;
19
20 /**
21 * ChromeVox2 background page.
22 */
23 cvox2.Background = function() {
24 // Only needed with unmerged ChromeVox classic loaded before.
25 cvox2.global.accessibility.setAccessibilityEnabled(false);
26 chrome.automation.getDesktop(this.onDesktopAvailable);
dmazzoni 2014/05/12 18:18:12 Do you not need to bind this?
David Tseng 2014/05/12 20:33:38 Not using 'this' within the function, but done any
27 };
28
29 cvox2.Background.prototype = {
30 onDesktopAvailable: function(tree) {
Peter Lundblad 2014/05/12 18:37:32 jsdoc?
David Tseng 2014/05/12 20:33:38 We need to decide pretty quickly if we want lots o
31 if (!tree.root) {
32 window.setTimeout(this.onDesktopAvailable, 500);
33 return;
34 }
35 chrome.extension.onConnect.addListener(function(port) {
36 if (port.name != 'chromevox2')
Peter Lundblad 2014/05/12 18:37:32 Make a constant.
David Tseng 2014/05/12 20:33:38 Done.
37 return;
38 var cur = tree.root;
39 port.onMessage.addListener(function(message) {
40 switch (message.keydown) {
41 case 37:
42 cur = cur.previousSibling() || cur;
43 break;
44 case 38:
45 cur = cur.parent() || cur;
46 break;
47 case 39:
48 cur = cur.nextSibling() || cur;
49 break;
50 case 40:
51 cur = cur.firstChild() || cur;
52 break;
53 }
54 var index = 1;
55 if (cur.parent())
56 index = cur.parent().children().indexOf(cur) + 1;
57 var name = '';
58 if (cur.attributes && cur.attributes['ax_attr_name'])
59 name = cur.attributes['ax_attr_name'];
60 var utterance = index + ' ' + name + cur.role;
61 chrome.tts.speak(String(utterance), {lang: 'en-US'});
62 });
63 });
64 }
65 };
66
67 /** @type {cvox2.Background} */
68 cvox2.global.backgroundObj = new cvox2.Background();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698