| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 /** | 297 /** |
| 298 * Forwards public APIs to private implementations. | 298 * Forwards public APIs to private implementations. |
| 299 * @param {Function} ctor Constructor that have private implementations in its | 299 * @param {Function} ctor Constructor that have private implementations in its |
| 300 * prototype. | 300 * prototype. |
| 301 * @param {Array.<string>} methods List of public method names that have their | 301 * @param {Array<string>} methods List of public method names that have their |
| 302 * underscored counterparts in constructor's prototype. | 302 * underscored counterparts in constructor's prototype. |
| 303 * @param {string=} opt_target Selector for target node. | 303 * @param {string=} opt_target Selector for target node. |
| 304 */ | 304 */ |
| 305 function makePublic(ctor, methods, opt_target) { | 305 function makePublic(ctor, methods, opt_target) { |
| 306 methods.forEach(function(method) { | 306 methods.forEach(function(method) { |
| 307 ctor[method] = function() { | 307 ctor[method] = function() { |
| 308 var target = opt_target ? document.getElementById(opt_target) : | 308 var target = opt_target ? document.getElementById(opt_target) : |
| 309 ctor.getInstance(); | 309 ctor.getInstance(); |
| 310 return target[method + '_'].apply(target, arguments); | 310 return target[method + '_'].apply(target, arguments); |
| 311 }; | 311 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return /Linux/.test(navigator.userAgent); | 348 return /Linux/.test(navigator.userAgent); |
| 349 }, | 349 }, |
| 350 | 350 |
| 351 /** Whether this uses the views toolkit or not. */ | 351 /** Whether this uses the views toolkit or not. */ |
| 352 get isViews() { | 352 get isViews() { |
| 353 return typeof chrome.getVariableValue == 'function' && | 353 return typeof chrome.getVariableValue == 'function' && |
| 354 /views/.test(chrome.getVariableValue('toolkit')); | 354 /views/.test(chrome.getVariableValue('toolkit')); |
| 355 }, | 355 }, |
| 356 }; | 356 }; |
| 357 }(); | 357 }(); |
| OLD | NEW |