OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 Provides bindings to instantiate objects in the automation API. |
| 7 * |
| 8 * Due to restrictions in the extension system, it is not ordinarily possible to |
| 9 * construct an object defined by the extension API. However, given an instance |
| 10 * of that object, we can save its constructor for future use. |
| 11 */ |
| 12 |
| 13 goog.provide('AutomationObjectConstructorInstaller'); |
| 14 |
| 15 /** |
| 16 * Installs the AutomationNode and AutomationEvent classes based on an |
| 17 * AutomationNode instance. |
| 18 * @param {chrome.automation.AutomationNode} node |
| 19 * @param {function()} callback Called when installation finishes. |
| 20 */ |
| 21 AutomationObjectConstructorInstaller.init = function(node, callback) { |
| 22 chrome.automation.AutomationNode = |
| 23 /** @type {function (new:chrome.automation.AutomationNode)} */( |
| 24 node.constructor); |
| 25 node.addEventListener(chrome.automation.EventType.childrenChanged, |
| 26 function installAutomationEvent(e) { |
| 27 chrome.automation.AutomationEvent = |
| 28 /** @type {function (new:chrome.automation.AutomationEvent)} */( |
| 29 e.constructor); |
| 30 node.removeEventListener( |
| 31 chrome.automation.EventType.childrenChanged, |
| 32 installAutomationEvent, |
| 33 true); |
| 34 callback(); |
| 35 }, |
| 36 true); |
| 37 }; |
OLD | NEW |