diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-31 18:08:40 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-31 18:08:40 +0000 |
commit | 4f999134a2e270792abc8b5ac6ad70aa500dcef4 (patch) | |
tree | e90d972ee2f29d10d6e22220d54cd142925bb2bb /chrome/renderer/user_script_slave.cc | |
parent | b5cd43eb964e452d7a0245b9e14bd9a9d1e89b4a (diff) | |
download | chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.zip chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.tar.gz chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.tar.bz2 |
Use WebScriptSource and WebFindInPageRequest from the WebKit API.
This change introduces some helper functions in glue_util.cc for efficient
conversion between WebString and WebCore::String when inside the implementation
of webkit/glue. This is a temporary change since eventually all code in glue
that uses WebCore will be moved into the WebKit API implementation.
Instead of making the Chrome automation use WebFindInPageRequest, I decided to
introduce AutomationMsg_Find_Params as a copy of the old FindInPageRequest
structure. That preserves the IPC protocol and avoids making the automation
library depend on WebKit.
R=dglazkov
Review URL: http://codereview.chromium.org/57060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/user_script_slave.cc')
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index 04957ad..9b424f0 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -9,13 +9,17 @@ #include "base/perftimer.h" #include "base/pickle.h" #include "base/shared_memory.h" +#include "base/string_util.h" #include "chrome/common/resource_bundle.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webscriptsource.h" #include "grit/renderer_resources.h" +using WebKit::WebScriptSource; +using WebKit::WebString; + // These two strings are injected before and after the Greasemonkey API and // user script to wrap it in an anonymous scope. static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; @@ -104,7 +108,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, PerfTimer timer; int num_matched = 0; - std::vector<webkit_glue::WebScriptSource> sources; + std::vector<WebScriptSource> sources; for (size_t i = 0; i < scripts_.size(); ++i) { UserScript* script = scripts_[i]; if (!script->MatchesUrl(frame->GetURL())) @@ -121,15 +125,15 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (script->run_location() == location) { for (size_t j = 0; j < script->js_scripts().size(); ++j) { UserScript::File &file = script->js_scripts()[j]; - sources.push_back(webkit_glue::WebScriptSource( - file.GetContent().as_string(), file.url())); + sources.push_back(WebScriptSource( + WebString::fromUTF8(file.GetContent()), file.url())); } } } if (!sources.empty()) { - sources.insert(sources.begin(), - webkit_glue::WebScriptSource(api_js_.as_string())); + sources.insert( + sources.begin(), WebScriptSource(WebString::fromUTF8(api_js_))); frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); } |