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

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

Issue 339064: Add new user script injection point: document_idle. (Closed)
Patch Set: smaller, cleaner, better Created 11 years, 2 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 28b3aaec1928117c1bcda7f21f49eb41a688ddf0..bdd1e5435fdd7f201eee32617192cf5195af2c22 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_; }

Powered by Google App Engine
This is Rietveld 408576698