| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_constructor_installer.js
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_constructor_installer.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_constructor_installer.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cdb5e93ec187fee0a9f273fb3740da6a3672e90a
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_constructor_installer.js
|
| @@ -0,0 +1,37 @@
|
| +// 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('AutomationObjectConstructorInstaller');
|
| +
|
| +/**
|
| + * Installs the AutomationNode and AutomationEvent classes based on an
|
| + * AutomationNode instance.
|
| + * @param {chrome.automation.AutomationNode} node
|
| + * @param {function()} callback Called when installation finishes.
|
| + */
|
| +AutomationObjectConstructorInstaller.init = function(node, callback) {
|
| + 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);
|
| + callback();
|
| + },
|
| + true);
|
| +};
|
|
|