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

Unified Diff: chrome/renderer/render_view.cc

Issue 7254: Initial Greasemonkey support (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/renderer.vcproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 3492)
+++ chrome/renderer/render_view.cc (working copy)
@@ -31,6 +31,7 @@
#include "chrome/renderer/about_handler.h"
#include "chrome/renderer/chrome_plugin_host.h"
#include "chrome/renderer/debug_message_handler.h"
+#include "chrome/renderer/greasemonkey_slave.h"
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/renderer_resources.h"
#include "chrome/renderer/visitedlink_slave.h"
@@ -150,7 +151,8 @@
history_back_list_count_(0),
history_forward_list_count_(0),
disable_popup_blocking_(false),
- has_unload_listener_(false) {
+ has_unload_listener_(false),
+ greasemonkey_enabled_(false) {
resource_dispatcher_ = new ResourceDispatcher(this);
#ifdef CHROME_PERSONALIZATION
personalization_ = Personalization::CreateRendererPersonalization();
@@ -261,6 +263,8 @@
command_line.HasSwitch(switches::kDomAutomationController);
disable_popup_blocking_ =
command_line.HasSwitch(switches::kDisablePopupBlocking);
+ greasemonkey_enabled_ =
+ command_line.HasSwitch(switches::kEnableGreasemonkey);
debug_message_handler_ = new DebugMessageHandler(this);
RenderThread::current()->AddFilter(debug_message_handler_);
@@ -1369,6 +1373,17 @@
WebFrame* frame) {
// Check whether we have new encoding name.
UpdateEncoding(frame, webview->GetMainFrameEncodingName());
+
+ // Inject any Greasemonkey scripts. Do not inject into chrome UI pages, but
+ // do inject into any other document.
+ if (greasemonkey_enabled_) {
+ const GURL &gurl = frame->GetURL();
+ if (gurl.SchemeIs("file") ||
+ gurl.SchemeIs("http") ||
+ gurl.SchemeIs("https")) {
+ RenderThread::current()->greasemonkey_slave()->InjectScripts(frame);
+ }
+ }
}
void RenderView::DidHandleOnloadEventsForFrame(WebView* webview,
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/renderer.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698