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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js

Issue 2754363003: Do more strict checking when calling into MathJaX (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/injected/loader.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 Public APIs to enable web applications to communicate 6 * @fileoverview Public APIs to enable web applications to communicate
7 * with ChromeVox. 7 * with ChromeVox.
8 */ 8 */
9 if (typeof(goog) != 'undefined' && goog.provide) { 9 if (typeof(goog) != 'undefined' && goog.provide) {
10 goog.provide('cvox.Api'); 10 goog.provide('cvox.Api');
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 */ 121 */
122 function callSpeakAsync_(message, properties) { 122 function callSpeakAsync_(message, properties) {
123 var callback = null; 123 var callback = null;
124 /* Use the user supplied callback as callAsync_'s callback. */ 124 /* Use the user supplied callback as callAsync_'s callback. */
125 if (properties && properties['endCallback']) { 125 if (properties && properties['endCallback']) {
126 callback = properties['endCallback']; 126 callback = properties['endCallback'];
127 } 127 }
128 callAsync_(message, callback); 128 callAsync_(message, callback);
129 }; 129 };
130 130
131 /**
132 * @param {string} path
133 * @return {*}
134 */
135 function getPath(path) {
dmazzoni 2017/03/20 18:16:15 Could you name this something more clear and/or ad
136 var pieces = path.split('.');
137 var resolved = window;
138 for (var i = 0; i < pieces.length; i++) {
139 resolved = resolved[pieces[i]];
140 if (!resolved)
141 return null;
dmazzoni 2017/03/20 18:16:15 nit: indent
142 }
143 return resolved;
144 }
145
131 146
132 /** 147 /**
133 * Maybe enable MathJaX support. 148 * Maybe enable MathJaX support.
134 */ 149 */
135 function maybeEnableMathJaX() { 150 function maybeEnableMathJaX() {
136 if (!MathJax || !MathJax.Hub || !MathJax.Hub.Register || 151 if (!getPath('MathJax.Hub.Register.LoadHook') ||
137 !MathJax.Hub.Register.LoadHook) 152 !getPath('MathJax.Ajax.Require')) {
138 return; 153 return;
154 }
139 155
140 MathJax.Hub.Register.LoadHook( 156 MathJax.Hub.Register.LoadHook('[a11y]/explorer.js', function() {
141 '[a11y]/explorer.js', 157 // |explorer| is an object instance, so we get it to call an instance
142 function() { 158 // |method.
143 MathJax.Extension.explorer.Enable(true, true); 159 var explorer = getPath('MathJax.Extension.explorer');
144 }); 160 if (explorer.Enable) {
161 explorer.Enable(true, true);
162 }
163 });
145 MathJax.Ajax.Require('[a11y]/explorer.js'); 164 MathJax.Ajax.Require('[a11y]/explorer.js');
146 } 165 }
147 166
148 167
149 /* 168 /*
150 * Public API. 169 * Public API.
151 */ 170 */
152 171
153 if (!window['cvox']) { 172 if (!window['cvox']) {
154 window['cvox'] = {}; 173 window['cvox'] = {};
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 /** 252 /**
234 * This method is kept to keep Docs from throwing an error. 253 * This method is kept to keep Docs from throwing an error.
235 * 254 *
236 */ 255 */
237 cvox.Api.stop = function() { 256 cvox.Api.stop = function() {
238 }; 257 };
239 258
240 cvox.Api.internalEnable(); 259 cvox.Api.internalEnable();
241 260
242 })(); 261 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/injected/loader.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698