diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-14 04:15:16 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-14 04:15:16 +0000 |
commit | 0afe827a49501c6801c3c9efbbdb1f64aa010beb (patch) | |
tree | dba6031dd45eb3f0a0435b9750976b1cd432abc1 /chrome/common/extensions/user_script.h | |
parent | 27eef9c8edf84061f4e36a3bd26ff7538092a22b (diff) | |
download | chromium_src-0afe827a49501c6801c3c9efbbdb1f64aa010beb.zip chromium_src-0afe827a49501c6801c3c9efbbdb1f64aa010beb.tar.gz chromium_src-0afe827a49501c6801c3c9efbbdb1f64aa010beb.tar.bz2 |
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
Diffstat (limited to 'chrome/common/extensions/user_script.h')
-rw-r--r-- | chrome/common/extensions/user_script.h | 21 |
1 files changed, 20 insertions, 1 deletions
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<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_; |