Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Side by Side Diff: ceee/ie/plugin/scripting/content_script_manager.cc

Issue 4997002: IE CEEE: Explicitly assign window properties/methods into the script host glo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return ScriptHost::CreateInitializedIID(IID_IScriptHost, script_host); 150 return ScriptHost::CreateInitializedIID(IID_IScriptHost, script_host);
151 } 151 }
152 152
153 HRESULT ContentScriptManager::InitializeScriptHost( 153 HRESULT ContentScriptManager::InitializeScriptHost(
154 IHTMLDocument2* document, IScriptHost* script_host) { 154 IHTMLDocument2* document, IScriptHost* script_host) {
155 DCHECK(document != NULL); 155 DCHECK(document != NULL);
156 DCHECK(script_host != NULL); 156 DCHECK(script_host != NULL);
157 157
158 CComPtr<IExtensionPortMessagingProvider> messaging_provider; 158 CComPtr<IExtensionPortMessagingProvider> messaging_provider;
159 HRESULT hr = host_->GetExtensionPortMessagingProvider(&messaging_provider); 159 HRESULT hr = host_->GetExtensionPortMessagingProvider(&messaging_provider);
160 if (FAILED(hr))
Sigurður Ásgeirsson 2010/11/15 16:33:30 thanks... Can you see whether the caller logs erro
Eric Dingle 2010/11/15 16:37:51 This method is private and only called internally.
161 return hr;
160 hr = ContentScriptNativeApi::CreateInitialized(messaging_provider, 162 hr = ContentScriptNativeApi::CreateInitialized(messaging_provider,
161 &native_api_); 163 &native_api_);
162 if (FAILED(hr)) 164 if (FAILED(hr))
163 return hr; 165 return hr;
164 166
165 std::wstring extension_id; 167 std::wstring extension_id;
166 host_->GetExtensionId(&extension_id); 168 host_->GetExtensionId(&extension_id);
167 DCHECK(extension_id.size()) << 169 DCHECK(extension_id.size()) <<
168 "Need to revisit async loading of enabled extension list."; 170 "Need to revisit async loading of enabled extension list.";
169 171
170 // Execute the bootstrap scripts. 172 // Execute the bootstrap scripts.
171 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))
175 return hr;
172 176
177 // Register the window object and manually make its members global.
173 CComPtr<IHTMLWindow2> window; 178 CComPtr<IHTMLWindow2> window;
174 hr = document->get_parentWindow(&window); 179 hr = document->get_parentWindow(&window);
175 if (FAILED(hr)) 180 if (FAILED(hr))
176 return hr; 181 return hr;
177 182 hr = script_host->RegisterScriptObject(L"window", window, false);
178 // Register the window object and make its members global. 183 if (FAILED(hr))
179 hr = script_host->RegisterScriptObject(L"window", window, true); 184 return hr;
185 hr = InvokeNamedFunction(script_host, L"ceee.initGlobals_", NULL, 0);
180 186
181 return hr; 187 return hr;
182 } 188 }
183 189
184 HRESULT ContentScriptManager::BootstrapScriptHost(IScriptHost* script_host, 190 HRESULT ContentScriptManager::BootstrapScriptHost(IScriptHost* script_host,
185 IDispatch* native_api, 191 IDispatch* native_api,
186 const wchar_t* extension_id) { 192 const wchar_t* extension_id) {
187 bool loaded = EnsureBoostrapScriptsLoaded(); 193 bool loaded = EnsureBoostrapScriptsLoaded();
188 if (!loaded) { 194 if (!loaded) {
189 NOTREACHED() << "Unable to load bootstrap scripts"; 195 NOTREACHED() << "Unable to load bootstrap scripts";
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 hr = script_host_with_site->SetSite(NULL); 381 hr = script_host_with_site->SetSite(NULL);
376 DCHECK(SUCCEEDED(hr)); 382 DCHECK(SUCCEEDED(hr));
377 } 383 }
378 384
379 // TODO(siggi@chromium.org): Kill off open extension ports. 385 // TODO(siggi@chromium.org): Kill off open extension ports.
380 386
381 script_host_.Release(); 387 script_host_.Release();
382 388
383 return hr; 389 return hr;
384 } 390 }
OLDNEW
« no previous file with comments | « ceee/ie/plugin/scripting/ceee_bootstrap.js ('k') | ceee/ie/plugin/scripting/content_script_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698