From 0afe827a49501c6801c3c9efbbdb1f64aa010beb Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Sat, 14 Feb 2009 04:15:16 +0000 Subject: Add early-injection capability to user scripts. Review URL: http://codereview.chromium.org/19624 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9822 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/extensions/user_script.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'chrome/common/extensions/user_script.h') diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h index 6453c8e..671f158 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& 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 globs_; -- cgit v1.1