summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/user_script_slave.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 09:47:35 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 09:47:35 +0000
commit912256b3517241047095dac6946de191029dda27 (patch)
tree7799ca1544916d7e1f44b06bd0dd43e080b61996 /chrome/renderer/user_script_slave.cc
parent50c4e907cf41e395a5edecd1ae122b9a2b35410d (diff)
downloadchromium_src-912256b3517241047095dac6946de191029dda27.zip
chromium_src-912256b3517241047095dac6946de191029dda27.tar.gz
chromium_src-912256b3517241047095dac6946de191029dda27.tar.bz2
Try again to land "Implement script API:executeScript"
http://codereview.chromium.org/173556 TBR=mpcomplete@chromium.org Patch from Jerry Tang <tangjie@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/user_script_slave.cc')
-rw-r--r--chrome/renderer/user_script_slave.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc
index 7f7ad31..c120c6b 100644
--- a/chrome/renderer/user_script_slave.cc
+++ b/chrome/renderer/user_script_slave.cc
@@ -14,12 +14,10 @@
#include "chrome/renderer/extension_groups.h"
#include "googleurl/src/gurl.h"
#include "webkit/api/public/WebFrame.h"
-#include "webkit/api/public/WebScriptSource.h"
#include "grit/renderer_resources.h"
using WebKit::WebFrame;
-using WebKit::WebScriptSource;
using WebKit::WebString;
// These two strings are injected before and after the Greasemonkey API and
@@ -109,6 +107,15 @@ bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) {
return true;
}
+// static
+void UserScriptSlave::InsertInitExtensionCode(
+ std::vector<WebScriptSource>* sources, const std::string& extension_id) {
+ DCHECK(sources);
+ sources->insert(sources->begin(),
+ WebScriptSource(WebString::fromUTF8(
+ StringPrintf(kInitExtension, extension_id.c_str()))));
+}
+
bool UserScriptSlave::InjectScripts(WebFrame* frame,
UserScript::RunLocation location) {
// Don't bother if this is not a URL we inject script into.
@@ -157,9 +164,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame,
} else {
// Setup chrome.self to contain an Extension object with the correct
// ID.
- sources.insert(sources.begin(),
- WebScriptSource(WebString::fromUTF8(
- StringPrintf(kInitExtension, script->extension_id().c_str()))));
+ InsertInitExtensionCode(&sources, script->extension_id());
}
frame->executeScriptInNewWorld(&sources.front(), sources.size(),