Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / chromeos / chromevox / chromevox / injected / init_globals.js
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
10 goog.provide('cvox.InitGlobals');
11
12 goog.require('cvox.ApiImplementation');
13 goog.require('cvox.ChromeVox');
14 goog.require('cvox.ChromeVoxEventWatcher');
15 goog.require('cvox.CompositeTts');
16 goog.require('cvox.ConsoleTts');
17 goog.require('cvox.HostFactory');
18 goog.require('cvox.NavigationManager');
19 goog.require('cvox.Serializer');
20 goog.require('cvox.SpokenMessages');
21
22
23
24 /**
25  * @constructor
26  */
27 cvox.InitGlobals = function() { };
28
29
30 /**
31  * Initializes cvox.ChromeVox.
32  */
33 cvox.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 };