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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_object_constructor_installer.js

Issue 1942683005: Refactor event handler classes to make it easier to add new event type listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
(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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698