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

Unified Diff: chrome/common/extensions/user_script.h

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/common/extensions/user_script.h
diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h
index 6453c8ec4680bcebc6a052600ce7149f4819f742..671f158285a57b55e7e803ce110e030f6ead0d98 100644
--- a/chrome/common/extensions/user_script.h
+++ b/chrome/common/extensions/user_script.h
@@ -17,7 +17,19 @@
// extension.
class UserScript {
public:
- UserScript(){}
+ // Locations that user scripts can be run inside the document.
+ enum RunLocation {
+ DOCUMENT_START, // After the documentElemnet is created, but before
+ // anything else happens.
+ DOCUMENT_END, // After the entire document is parsed. Same as
+ // DOMContentLoaded.
+
+ RUN_LOCATION_LAST // Leave this as the last item.
+ };
+
+ // Constructor. Default the run location to document end, which is like
+ // Greasemonkey and probably more useful for typical scripts.
+ UserScript() : run_location_(DOCUMENT_END) {}
// The URL to retrieve the content of this script at.
const GURL& url() const { return url_; }
@@ -27,6 +39,10 @@ class UserScript {
const FilePath& path() const { return path_; }
void set_path(const FilePath& path) { path_ = path; }
+ // The place in the document to run the script.
+ RunLocation run_location() const { return run_location_; }
+ void set_run_location(RunLocation location) { run_location_ = location; }
+
// The globs, if any, that determine which pages this script runs against.
// These are only used with "standalone" Greasemonkey-like user scripts.
const std::vector<std::string>& globs() const { return globs_; }
@@ -60,6 +76,9 @@ class UserScript {
// The path to the content of the script.
FilePath path_;
+ // The location to run the script inside the document.
+ RunLocation run_location_;
+
// Greasemonkey-style globs that determine pages to inject the script into.
// These are only used with standalone scripts.
std::vector<std::string> globs_;

Powered by Google App Engine
This is Rietveld 408576698