| Index: ui/webui/resources/js/cr.js
|
| diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js
|
| index ceb1eb9707474fb9d91f9bc6b12ad5b13858569f..a38c59f84732e820c00407287b3ef00c37b41bb2 100644
|
| --- a/ui/webui/resources/js/cr.js
|
| +++ b/ui/webui/resources/js/cr.js
|
| @@ -318,9 +318,9 @@ var cr = function() {
|
| * sent by the browser in response to the chrome.send call. The mapping is
|
| * from ID to callback function; the ID is generated by sendWithCallback and
|
| * is unique across all invocations of said method.
|
| - * @type {!Map<string, Function>}
|
| + * @type {!Object<Function>}
|
| */
|
| - var chromeSendCallbackMap = new Map();
|
| + var chromeSendCallbackMap = Object.create(null);
|
|
|
| /**
|
| * The named method the WebUI handler calls directly in response to a
|
| @@ -335,9 +335,9 @@ var cr = function() {
|
| * response is tied to.
|
| */
|
| function webUIResponse(id) {
|
| - chromeSendCallbackMap.get(id).apply(
|
| + chromeSendCallbackMap[id].apply(
|
| null, Array.prototype.slice.call(arguments, 1));
|
| - chromeSendCallbackMap.delete(id);
|
| + delete chromeSendCallbackMap[id];
|
| }
|
|
|
| /**
|
| @@ -353,16 +353,16 @@ var cr = function() {
|
| */
|
| function sendWithCallback(methodName, args, callback) {
|
| var id = methodName + createUid();
|
| - chromeSendCallbackMap.set(id, callback);
|
| + chromeSendCallbackMap[id] = callback;
|
| chrome.send(methodName, ['cr.webUIResponse', id].concat(args || []));
|
| }
|
|
|
| /**
|
| * A registry of callbacks keyed by event name. Used by addWebUIListener to
|
| * register listeners.
|
| - * @type {!Map<string, Array<Function>>}
|
| + * @type {!Object<Array<Function>>}
|
| */
|
| - var webUIListenerMap = new Map();
|
| + var webUIListenerMap = Object.create(null);
|
|
|
| /**
|
| * The named method the WebUI handler calls directly when an event occurs.
|
| @@ -372,7 +372,7 @@ var cr = function() {
|
| * @param {string} event The name of the event that has occurred.
|
| */
|
| function webUIListenerCallback(event) {
|
| - var listenerCallbacks = webUIListenerMap.get(event);
|
| + var listenerCallbacks = webUIListenerMap[event];
|
| for (var i = 0; i < listenerCallbacks.length; i++) {
|
| var callback = listenerCallbacks[i];
|
| callback.apply(null, Array.prototype.slice.call(arguments, 1));
|
| @@ -386,10 +386,10 @@ var cr = function() {
|
| * @param {Function} callback The callback run when the event is fired.
|
| */
|
| function addWebUIListener(event, callback) {
|
| - if (!webUIListenerMap.has(event))
|
| - webUIListenerMap.set(event, [callback]);
|
| + if (event in webUIListenerMap)
|
| + webUIListenerMap[event].push(callback);
|
| else
|
| - webUIListenerMap.get(event).push(callback);
|
| + webUIListenerMap[event] = [callback];
|
| }
|
|
|
| return {
|
|
|