diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 10:26:31 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 10:26:31 +0000 |
commit | b9a622b9fe09868974a5af845bc474752b239566 (patch) | |
tree | 939d1e3947e35bbd960a925992bc7f049fe5775f /chrome/renderer/user_script_slave.cc | |
parent | 72cbd32707a2ede460bcc1b3cb199e653282a8ed (diff) | |
download | chromium_src-b9a622b9fe09868974a5af845bc474752b239566.zip chromium_src-b9a622b9fe09868974a5af845bc474752b239566.tar.gz chromium_src-b9a622b9fe09868974a5af845bc474752b239566.tar.bz2 |
Revert "Implement chromium.self in content scripts..."
This reverts commit 61ab30f52667e739602ab2af4fd8f2d8a0a2a2f0.
Still seeing memory errors.
Review URL: http://codereview.chromium.org/63056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/user_script_slave.cc')
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index bd5a988..aedc345 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -25,8 +25,6 @@ using WebKit::WebString; static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; static const char kUserScriptTail[] = "\n})(window);"; -static const char kInitSelf[] = "chromium.self = new chromium.Extension('%s')"; - UserScriptSlave::UserScriptSlave() : shared_memory_(NULL), script_deleter_(&scripts_), @@ -112,8 +110,8 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, PerfTimer timer; int num_matched = 0; + std::vector<WebScriptSource> sources; for (size_t i = 0; i < scripts_.size(); ++i) { - std::vector<WebScriptSource> sources; UserScript* script = scripts_[i]; if (!script->MatchesUrl(frame->GetURL())) continue; // This frame doesn't match the script url pattern, skip it. @@ -129,35 +127,16 @@ 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]; - std::string content = file.GetContent().as_string(); - - // We add this dumb function wrapper for standalone user script to - // emulate what Greasemonkey does. - if (script->is_standalone()) { - content.insert(0, kUserScriptHead); - content += kUserScriptTail; - } sources.push_back(WebScriptSource( - WebString::fromUTF8(content.c_str(), content.length()), - file.url())); + WebString::fromUTF8(file.GetContent()), file.url())); } } + } - if (!sources.empty()) { - if (script->is_standalone()) { - // For standalone scripts, we try to emulate the Greasemonkey API. - sources.insert(sources.begin(), - WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); - } else { - // Setup chromium.self to contain an Extension object with the correct - // ID. - sources.insert(sources.begin(), - WebScriptSource(WebString::fromUTF8( - StringPrintf(kInitSelf, script->extension_id().c_str())))); - } - - frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); - } + if (!sources.empty()) { + sources.insert( + sources.begin(), WebScriptSource(WebString::fromUTF8(api_js_))); + frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); } // Log debug info. |