diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 01:29:39 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 01:29:39 +0000 |
commit | 5442dafd85700e323fe6c332eeec0f17de6f7891 (patch) | |
tree | 9e065d301222177c4371e0522424deb8f07ba488 /chrome/common/extensions/user_script.h | |
parent | 40fc8b766191d37dbcbcb67894d233da2899821c (diff) | |
download | chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.zip chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.tar.gz chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.tar.bz2 |
Add new user script injection point "document_idle" and make it the default.
Semantically, document-idle means "when the DOM is ready and layout has been idle for awhile", or more loosely, "as soon as we get around to it".
Right now this uses a simple heuristic. It injects scripts 200ms after DOMContentLoaded, or immediately after onload, whichever happens first.
BUG=26126
TEST=Manual. Extensions with content scripts should work.
Review URL: http://codereview.chromium.org/339064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/user_script.h')
-rw-r--r-- | chrome/common/extensions/user_script.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h index 28b3aae..bdd1e54 100644 --- a/chrome/common/extensions/user_script.h +++ b/chrome/common/extensions/user_script.h @@ -28,6 +28,10 @@ class UserScript { // anything else happens. DOCUMENT_END, // After the entire document is parsed. Same as // DOMContentLoaded. + DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document + // is "idle". Currently this uses the simple heuristic of: + // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no + // particular injection point is guaranteed. RUN_LOCATION_LAST // Leave this as the last item. }; @@ -88,9 +92,10 @@ class UserScript { typedef std::vector<File> FileList; - // Constructor. Default the run location to document end, which is like - // Greasemonkey and probably more useful for typical scripts. - UserScript() : run_location_(DOCUMENT_END) {} + // Constructor. Default the run location to document idle, which is similar + // to Greasemonkey but should result in better page load times for fast- + // loading pages. + UserScript() : run_location_(DOCUMENT_IDLE) {} // The place in the document to run the script. RunLocation run_location() const { return run_location_; } |