OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 * @fileoverview this file provides the bootstrap interface between the | 6 * @fileoverview this file provides the bootstrap interface between the |
7 * Chrome event and extension bindings JavaScript files, and the CEEE | 7 * Chrome event and extension bindings JavaScript files, and the CEEE |
8 * native IE interface, as well as initialization hooks for the native | 8 * native IE interface, as well as initialization hooks for the native |
9 * interface. | 9 * interface. |
10 */ | 10 */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 nativeContentScriptApi.onPortMessage = | 104 nativeContentScriptApi.onPortMessage = |
105 chromeHidden.Port.dispatchOnMessage; | 105 chromeHidden.Port.dispatchOnMessage; |
106 | 106 |
107 // TODO(siggi@chromium.org): If there is a different global | 107 // TODO(siggi@chromium.org): If there is a different global |
108 // environment at this point (i.e. we have cloned the scripting | 108 // environment at this point (i.e. we have cloned the scripting |
109 // engine for a new window) this is where we can restore goog, | 109 // engine for a new window) this is where we can restore goog, |
110 // JSON and chrome. | 110 // JSON and chrome. |
111 | 111 |
112 // Delete the ceee namespace from globals. | 112 // Delete the ceee namespace from globals. |
113 delete ceee; | 113 delete ceee; |
114 } | 114 }; |
| 115 |
| 116 ceee.initGlobals_ = function() { |
| 117 // We expose a subset of the Window interface defined at |
| 118 // http://www.w3.org/TR/html5/browsers.html#the-window-object |
| 119 // to the global namespace. We purposely skip all event handler |
| 120 // attributes (e.g. onclick). |
| 121 |
| 122 // Browsing context. |
| 123 self = window.self; |
| 124 document = window.document; |
| 125 name = window.name; |
| 126 location = window.location; |
| 127 history = window.history; |
| 128 undoManager = window.undoManager; |
| 129 locationbar = window.locationbar; |
| 130 menubar = window.menubar; |
| 131 scrollbars = window.scrollbars; |
| 132 statusbar = window.statusbar; |
| 133 toolbar = window.toolbar; |
| 134 close = window.close; |
| 135 stop = window.stop; |
| 136 focus = window.focus; |
| 137 blur = window.blur; |
| 138 |
| 139 // Other browsing contexts. |
| 140 frames = window.frames; |
| 141 length = window.length; |
| 142 top = window.top; |
| 143 opener = window.opener; |
| 144 parent = window.parent; |
| 145 frameElement = window.frameElement; |
| 146 open = window.open; |
| 147 |
| 148 // User agent. |
| 149 navigator = window.navigator; |
| 150 applicationCache = window.applicationCache; |
| 151 |
| 152 // User prompts. |
| 153 alert = window.alert; |
| 154 confirm = window.confirm; |
| 155 prompt = window.prompt; |
| 156 print = window.print; |
| 157 showModalDialog = window.showModalDialog; |
| 158 |
| 159 // EventTarget interface. |
| 160 addEventListener = window.addEventListener; |
| 161 removeEventListener = window.removeEventListener; |
| 162 dispatchEvent = window.dispatchEvent; |
| 163 |
| 164 // Old IE event model. |
| 165 attachEvent = window.attachEvent; |
| 166 detachEvent = window.detachEvent; |
| 167 }; |
115 | 168 |
116 console.log = console.log || function (msg) { | 169 console.log = console.log || function (msg) { |
117 if (nativeContentScriptApi) | 170 if (nativeContentScriptApi) |
118 nativeContentScriptApi.Log("info", msg); | 171 nativeContentScriptApi.Log("info", msg); |
119 }; | 172 }; |
120 | 173 |
121 console.error = console.error || function (msg) { | 174 console.error = console.error || function (msg) { |
122 if (nativeContentScriptApi) | 175 if (nativeContentScriptApi) |
123 nativeContentScriptApi.Log("error", msg); | 176 nativeContentScriptApi.Log("error", msg); |
124 } | 177 } |
(...skipping 11 matching lines...) Expand all Loading... |
136 | 189 |
137 for (; from < len; from++) { | 190 for (; from < len; from++) { |
138 if (from in this && this[from] === elt) | 191 if (from in this && this[from] === elt) |
139 return from; | 192 return from; |
140 } | 193 } |
141 return -1; | 194 return -1; |
142 } | 195 } |
143 }; | 196 }; |
144 | 197 |
145 })(); | 198 })(); |
OLD | NEW |