| 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>} methods List of public method names that have their | |
| 302 * underscored counterparts in constructor's prototype. | |
| 303 * @param {*=} opt_target Target node. | |
| 304 */ | |
| 305 function makePublic(ctor, methods, opt_target) { | |
| 306 methods.forEach(function(method) { | |
| 307 ctor[method] = function() { | |
| 308 var target = opt_target || ctor.getInstance(); | |
| 309 return target[method + '_'].apply(target, arguments); | |
| 310 }; | |
| 311 }); | |
| 312 } | |
| 313 | |
| 314 return { | 297 return { |
| 315 addSingletonGetter: addSingletonGetter, | 298 addSingletonGetter: addSingletonGetter, |
| 316 createUid: createUid, | 299 createUid: createUid, |
| 317 define: define, | 300 define: define, |
| 318 defineProperty: defineProperty, | 301 defineProperty: defineProperty, |
| 319 dispatchPropertyChange: dispatchPropertyChange, | 302 dispatchPropertyChange: dispatchPropertyChange, |
| 320 dispatchSimpleEvent: dispatchSimpleEvent, | 303 dispatchSimpleEvent: dispatchSimpleEvent, |
| 321 exportPath: exportPath, | 304 exportPath: exportPath, |
| 322 getUid: getUid, | 305 getUid: getUid, |
| 323 makePublic: makePublic, | |
| 324 PropertyKind: PropertyKind, | 306 PropertyKind: PropertyKind, |
| 325 | 307 |
| 326 get doc() { | 308 get doc() { |
| 327 return document; | 309 return document; |
| 328 }, | 310 }, |
| 329 | 311 |
| 330 /** Whether we are using a Mac or not. */ | 312 /** Whether we are using a Mac or not. */ |
| 331 get isMac() { | 313 get isMac() { |
| 332 return /Mac/.test(navigator.platform); | 314 return /Mac/.test(navigator.platform); |
| 333 }, | 315 }, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 347 return /Linux/.test(navigator.userAgent); | 329 return /Linux/.test(navigator.userAgent); |
| 348 }, | 330 }, |
| 349 | 331 |
| 350 /** Whether this uses the views toolkit or not. */ | 332 /** Whether this uses the views toolkit or not. */ |
| 351 get isViews() { | 333 get isViews() { |
| 352 return typeof chrome.getVariableValue == 'function' && | 334 return typeof chrome.getVariableValue == 'function' && |
| 353 /views/.test(chrome.getVariableValue('toolkit')); | 335 /views/.test(chrome.getVariableValue('toolkit')); |
| 354 }, | 336 }, |
| 355 }; | 337 }; |
| 356 }(); | 338 }(); |
| OLD | NEW |