OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * The global object. | 6 * The global object. |
7 * @type {!Object} | 7 * @type {!Object} |
8 * @const | 8 * @const |
9 */ | 9 */ |
10 var global = this; | 10 var global = this; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 * instance object. | 287 * instance object. |
288 * @param {!Function} ctor The constructor for the class to add the static | 288 * @param {!Function} ctor The constructor for the class to add the static |
289 * method to. | 289 * method to. |
290 */ | 290 */ |
291 function addSingletonGetter(ctor) { | 291 function addSingletonGetter(ctor) { |
292 ctor.getInstance = function() { | 292 ctor.getInstance = function() { |
293 return ctor.instance_ || (ctor.instance_ = new ctor()); | 293 return ctor.instance_ || (ctor.instance_ = new ctor()); |
294 }; | 294 }; |
295 } | 295 } |
296 | 296 |
297 /** | |
298 * Forwards public APIs to private implementations. | |
299 * @param {Function} ctor Constructor that have private implementations in its | |
300 * prototype. | |
301 * @param {Array.<string>} publicAPI List of public method names that have | |
302 * their underscored counterparts in constructor's prototype. | |
303 * @param {HTMLElement=} opt_target Target node (used in | |
304 * oobe_screen_user_image.js) | |
305 */ | |
306 function makePublic(ctor, publicAPI, opt_target) { | |
307 publicAPI.forEach(function(name) { | |
308 if (opt_target) { | |
309 ctor[name] = function(value) { | |
310 opt_target[name + '_'](value); | |
311 }; | |
312 } else { | |
313 ctor[name] = function() { | |
314 var instance = ctor.getInstance(); | |
315 return instance[name + '_'].apply(instance, arguments); | |
316 }; | |
317 } | |
318 }); | |
319 } | |
320 | |
297 return { | 321 return { |
298 addSingletonGetter: addSingletonGetter, | 322 addSingletonGetter: addSingletonGetter, |
299 createUid: createUid, | 323 createUid: createUid, |
300 define: define, | 324 define: define, |
301 defineProperty: defineProperty, | 325 defineProperty: defineProperty, |
302 dispatchPropertyChange: dispatchPropertyChange, | 326 dispatchPropertyChange: dispatchPropertyChange, |
303 dispatchSimpleEvent: dispatchSimpleEvent, | 327 dispatchSimpleEvent: dispatchSimpleEvent, |
304 exportPath: exportPath, | 328 exportPath: exportPath, |
305 getUid: getUid, | 329 getUid: getUid, |
330 makePublic: makePublic, | |
Dan Beam
2014/09/10 19:26:27
expose might be a better name if it's apparent eno
Vitaly Pavlenko
2014/09/10 20:25:21
So could you propose the best method name to use?
Dan Beam
2014/09/12 00:57:51
Tyler and I agreed that makePublic is fine
Vitaly Pavlenko
2014/09/12 18:38:07
Acknowledged.
| |
306 PropertyKind: PropertyKind, | 331 PropertyKind: PropertyKind, |
307 | 332 |
308 get doc() { | 333 get doc() { |
309 return document; | 334 return document; |
310 }, | 335 }, |
311 | 336 |
312 /** Whether we are using a Mac or not. */ | 337 /** Whether we are using a Mac or not. */ |
313 get isMac() { | 338 get isMac() { |
314 return /Mac/.test(navigator.platform); | 339 return /Mac/.test(navigator.platform); |
315 }, | 340 }, |
(...skipping 13 matching lines...) Expand all Loading... | |
329 return /Linux/.test(navigator.userAgent); | 354 return /Linux/.test(navigator.userAgent); |
330 }, | 355 }, |
331 | 356 |
332 /** Whether this uses the views toolkit or not. */ | 357 /** Whether this uses the views toolkit or not. */ |
333 get isViews() { | 358 get isViews() { |
334 return typeof chrome.getVariableValue == 'function' && | 359 return typeof chrome.getVariableValue == 'function' && |
335 /views/.test(chrome.getVariableValue('toolkit')); | 360 /views/.test(chrome.getVariableValue('toolkit')); |
336 }, | 361 }, |
337 }; | 362 }; |
338 }(); | 363 }(); |
OLD | NEW |