Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_installer.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_installer.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_installer.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7ed7eb7af5e2cddc0f86833132fd9d26328352e4 |
| --- /dev/null |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_installer.js |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2016 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 Provides bindings to instantiate objects in the automation API. |
| + * |
| + * Due to restrictions in the extension system, it is not ordinarily possible to |
| + * construct an object defined by the extension API. However, given an instance |
| + * of that object, we can save its constructor for future use. |
| + */ |
| + |
| +goog.provide('AutomationObjectInstaller'); |
|
dmazzoni
2016/05/02 22:15:48
Nice hack! How about something like AutomationObje
David Tseng
2016/05/03 20:18:27
Done.
|
| + |
| +/** |
| + * installs the AutomationNode and AutomationEvent classes based on an |
|
dmazzoni
2016/05/02 22:15:48
nit: capital I at start of sentence
David Tseng
2016/05/03 20:18:27
Done.
|
| + * AutomationNode instance. |
| + * @param {chrome.automation.AutomationNode} node |
| + */ |
| +AutomationObjectInstaller.init = function(node) { |
| + chrome.automation.AutomationNode = |
| + /** @type {function (new:chrome.automation.AutomationNode)} */( |
| + node.constructor); |
| + node.addEventListener(chrome.automation.EventType.childrenChanged, |
| + function installAutomationEvent(e) { |
| + chrome.automation.AutomationEvent = |
| + /** @type {function (new:chrome.automation.AutomationEvent)} */( |
| + e.constructor); |
| + node.removeEventListener( |
| + chrome.automation.EventType.childrenChanged, |
| + installAutomationEvent, |
| + true); |
| + }, |
| + true); |
| +}; |