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

Unified Diff: chrome/browser/extensions/user_script_master.cc

Issue 19624: Add early-injection capability to user scripts. I haven't yet (Closed)
Patch Set: Use new documentElementAvailable() callback Created 11 years, 10 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
Index: chrome/browser/extensions/user_script_master.cc
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index 7164dc1479494ba09e145006f7ea34144c60a3b2..23ef66fb3d68affefc7f519f0f1efa7ea30c805d 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -45,6 +45,9 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(
static const StringPiece kUserScriptEng("// ==/UserScript==");
static const StringPiece kIncludeDeclaration("// @include ");
static const StringPiece kMatchDeclaration("// @match ");
+ static const StringPiece kRunAtDeclaration("// @run-at ");
+ static const StringPiece kRunAtDocumentStartValue("document-start");
+ static const StringPiece kRunAtDocumentEndValue("document-end");
while (line_start < script_text.length()) {
line_end = script_text.find('\n', line_start);
@@ -76,6 +79,11 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(
if (!pattern.Parse(value))
return false;
script->add_url_pattern(pattern);
+ } else if (GetDeclarationValue(line, kRunAtDeclaration, &value)) {
+ if (value == kRunAtDocumentStartValue)
+ script->set_run_location(UserScript::DOCUMENT_START);
+ else if (value != kRunAtDocumentEndValue)
+ return false;
}
// TODO(aa): Handle more types of metadata.

Powered by Google App Engine
This is Rietveld 408576698