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

Unified Diff: chrome/renderer/render_view.cc

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/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index fdafb53db192173537874aa8bf375e1c33fa5e03..0a412de10db8cba50a87b20e7184efec6bbc653b 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1459,15 +1459,9 @@ void RenderView::DidFinishDocumentLoadForFrame(WebView* webview,
// Check whether we have new encoding name.
UpdateEncoding(frame, webview->GetMainFrameEncodingName());
- // Inject any user scripts. Do not inject into chrome UI pages, but do inject
- // into any other document.
- const GURL &gurl = frame->GetURL();
- if (g_render_thread && // Will be NULL when testing.
- (gurl.SchemeIs("file") ||
- gurl.SchemeIs("http") ||
- gurl.SchemeIs("https"))) {
- g_render_thread->user_script_slave()->InjectScripts(frame);
- }
+ if (g_render_thread) // Will be NULL when testing.
+ g_render_thread->user_script_slave()->InjectScripts(
+ frame, UserScript::DOCUMENT_END);
}
void RenderView::DidHandleOnloadEventsForFrame(WebView* webview,
@@ -1535,6 +1529,12 @@ void RenderView::WindowObjectCleared(WebFrame* webframe) {
#endif
}
+void RenderView::DocumentElementAvailable(WebFrame* frame) {
+ if (g_render_thread) // Will be NULL when testing.
+ g_render_thread->user_script_slave()->InjectScripts(
+ frame, UserScript::DOCUMENT_START);
+}
+
WindowOpenDisposition RenderView::DispositionForNavigationAction(
WebView* webview,
WebFrame* frame,

Powered by Google App Engine
This is Rietveld 408576698