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 // @file | 5 // @file |
6 // Content script manager implementation. | 6 // Content script manager implementation. |
7 #include "ceee/ie/plugin/scripting/content_script_manager.h" | 7 #include "ceee/ie/plugin/scripting/content_script_manager.h" |
8 | 8 |
9 #include "ceee/ie/common/ceee_module_util.h" | 9 #include "ceee/ie/common/ceee_module_util.h" |
10 #include "ceee/ie/plugin/bho/dom_utils.h" | 10 #include "ceee/ie/plugin/bho/dom_utils.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 std::wstring extension_id; | 167 std::wstring extension_id; |
168 host_->GetExtensionId(&extension_id); | 168 host_->GetExtensionId(&extension_id); |
169 DCHECK(extension_id.size()) << | 169 DCHECK(extension_id.size()) << |
170 "Need to revisit async loading of enabled extension list."; | 170 "Need to revisit async loading of enabled extension list."; |
171 | 171 |
172 // Execute the bootstrap scripts. | 172 // Execute the bootstrap scripts. |
173 hr = BootstrapScriptHost(script_host, native_api_, extension_id.c_str()); | 173 hr = BootstrapScriptHost(script_host, native_api_, extension_id.c_str()); |
174 if (FAILED(hr)) | 174 if (FAILED(hr)) |
175 return hr; | 175 return hr; |
176 | 176 |
177 // Register the window object and manually make its members global. | 177 // Register the window object and initialize the global namespace of the |
| 178 // script host. |
178 CComPtr<IHTMLWindow2> window; | 179 CComPtr<IHTMLWindow2> window; |
179 hr = document->get_parentWindow(&window); | 180 hr = document->get_parentWindow(&window); |
180 if (FAILED(hr)) | 181 if (FAILED(hr)) |
181 return hr; | 182 return hr; |
182 hr = script_host->RegisterScriptObject(L"window", window, false); | 183 hr = script_host->RegisterScriptObject(L"unsafeWindow", window, false); |
183 if (FAILED(hr)) | 184 if (FAILED(hr)) |
184 return hr; | 185 return hr; |
185 hr = InvokeNamedFunction(script_host, L"ceee.initGlobals_", NULL, 0); | 186 hr = InvokeNamedFunction(script_host, L"ceee.initGlobals_", NULL, 0); |
186 | 187 |
187 return hr; | 188 return hr; |
188 } | 189 } |
189 | 190 |
190 HRESULT ContentScriptManager::BootstrapScriptHost(IScriptHost* script_host, | 191 HRESULT ContentScriptManager::BootstrapScriptHost(IScriptHost* script_host, |
191 IDispatch* native_api, | 192 IDispatch* native_api, |
192 const wchar_t* extension_id) { | 193 const wchar_t* extension_id) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 hr = script_host_with_site->SetSite(NULL); | 382 hr = script_host_with_site->SetSite(NULL); |
382 DCHECK(SUCCEEDED(hr)); | 383 DCHECK(SUCCEEDED(hr)); |
383 } | 384 } |
384 | 385 |
385 // TODO(siggi@chromium.org): Kill off open extension ports. | 386 // TODO(siggi@chromium.org): Kill off open extension ports. |
386 | 387 |
387 script_host_.Release(); | 388 script_host_.Release(); |
388 | 389 |
389 return hr; | 390 return hr; |
390 } | 391 } |
OLD | NEW |