1 // Copyright (c) 2011 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.
6 * @fileoverview Implements a shim so that the CFInstall scripts can be compiled
7 * with or without Closure. In particular, chromeframe.js is used by the stub,
8 * the implementation, and the download site, so we need to provide an
9 * implementation of goog.provide.
16 * From closure/base.js:goog.exportPath_ .
17 * @param {string} name
18 * @param {Object=} opt_object
20 goog.provide = function(name, opt_object) {
21 var parts = name.split('.');
22 var cur = goog.global;
24 // Internet Explorer exhibits strange behavior when throwing errors from
25 // methods externed in this manner. See the testExportSymbolExceptions in
26 // base_test.html for an example.
27 if (!(parts[0] in cur) && cur.execScript)
28 cur.execScript('var ' + parts[0]);
30 // Certain browsers cannot parse code in the form for((a in b); c;);
31 // This pattern is produced by the JSCompiler when it collapses the
32 // statement above into the conditional loop below. To prevent this from
33 // happening, use a for-loop and reserve the init logic as below.
35 // Parentheses added to eliminate strict JS warning in Firefox.
36 for (var part; parts.length && (part = parts.shift());) {
37 if (!parts.length && opt_object !== undefined) {
38 // last part and we have an object; use it
39 cur[part] = opt_object;
40 } else if (cur[part]) {
48 // The following line causes the closureBuilder script to recognize this as
53 * From closure/base.js:goog.exportPath_ .
54 * @param {string} name
55 * @param {Object=} opt_object
57 goog.exportSymbol = goog.provide;
61 * @param {string} name
63 goog.require = function(name) {};
66 * A simple form that supports only bound 'this', not arguments.
67 * @param {Function} fn A function to partially apply.
68 * @param {Object|undefined} selfObj Specifies the object which |this| should
69 * point to when the function is run.
70 * @return {!Function} A partially-applied form of the function bind() was
71 * invoked as a method of.
73 goog.bind = function(fn, selfObj) {
75 return fn.apply(selfObj, arguments);