init_globals.js revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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 Initializes the injected content script.
7 *
8 */
9
10goog.provide('cvox.InitGlobals');
11
12goog.require('cvox.ApiImplementation');
13goog.require('cvox.ChromeVox');
14goog.require('cvox.ChromeVoxEventWatcher');
15goog.require('cvox.CompositeTts');
16goog.require('cvox.ConsoleTts');
17goog.require('cvox.HostFactory');
18goog.require('cvox.NavigationManager');
19goog.require('cvox.Serializer');
20goog.require('cvox.SpokenMessages');
21
22
23
24/**
25 * @constructor
26 */
27cvox.InitGlobals = function() { };
28
29
30/**
31 * Initializes cvox.ChromeVox.
32 */
33cvox.InitGlobals.initGlobals = function() {
34  if (!cvox.ChromeVox.host) {
35    cvox.ChromeVox.host = cvox.HostFactory.getHost();
36  }
37
38  cvox.ChromeVox.tts = new cvox.CompositeTts()
39      .add(cvox.HostFactory.getTts())
40      .add(cvox.History.getInstance())
41      .add(cvox.ConsoleTts.getInstance());
42
43  if (!cvox.ChromeVox.braille) {
44    cvox.ChromeVox.braille = cvox.HostFactory.getBraille();
45  }
46  cvox.ChromeVox.mathJax = cvox.HostFactory.getMathJax();
47
48  cvox.ChromeVox.earcons = cvox.HostFactory.getEarcons();
49  cvox.ChromeVox.msgs = new cvox.Msgs();
50  cvox.ChromeVox.isActive = true;
51  cvox.ChromeVox.navigationManager = new cvox.NavigationManager();
52  cvox.ChromeVox.navigationManager.updateIndicator();
53  cvox.ChromeVox.syncToNode = cvox.ApiImplementation.syncToNode;
54  cvox.ChromeVox.speakNode = cvox.ApiImplementation.speakNode;
55
56  cvox.ChromeVox.serializer = new cvox.Serializer();
57
58  // Do platform specific initialization here.
59  cvox.ChromeVox.host.init();
60
61  // Start the event watchers
62  cvox.ChromeVoxEventWatcher.init(window);
63
64  // Provide a way for modules that can't depend on cvox.ChromeVoxUserCommands
65  // to execute commands.
66  cvox.ChromeVox.executeUserCommand = function(commandName) {
67    cvox.ChromeVoxUserCommands.commands[commandName]();
68  };
69
70  cvox.ChromeVox.host.onPageLoad();
71};
72