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

Unified Diff: chrome/renderer/user_script_slave.cc

Issue 173556: Implement script API:executeScript (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/user_script_slave.h ('k') | chrome/test/data/extensions/api_test/executescript/1.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/user_script_slave.cc
===================================================================
--- chrome/renderer/user_script_slave.cc (revision 26435)
+++ chrome/renderer/user_script_slave.cc (working copy)
@@ -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 @@
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 @@
} 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(),
« no previous file with comments | « chrome/renderer/user_script_slave.h ('k') | chrome/test/data/extensions/api_test/executescript/1.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698