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. |