summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormal@chromium.org <mal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 04:25:58 +0000
committermal@chromium.org <mal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 04:25:58 +0000
commit31d9a1aedd6b5ee288face8603e6ab91d334c5e3 (patch)
tree034092192c9430f04e5c32f7327bde4c8224d1a5
parente000c4e2867b398739908e915266ac204a09dca1 (diff)
downloadchromium_src-31d9a1aedd6b5ee288face8603e6ab91d334c5e3.zip
chromium_src-31d9a1aedd6b5ee288face8603e6ab91d334c5e3.tar.gz
chromium_src-31d9a1aedd6b5ee288face8603e6ab91d334c5e3.tar.bz2
Rolback r8793: Remove extraneous uses of the --enable-user-script
switch. It's better to check this at one chokepoint (initialization) and let the rest of the code work the same, but end up as no-ops. This seems to break ui_tests. Review URL: http://codereview.chromium.org/19418 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8794 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc16
-rw-r--r--chrome/renderer/render_view.cc17
-rw-r--r--chrome/renderer/render_view.h3
3 files changed, 29 insertions, 7 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 1e1db05..c8b8e6e 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -267,6 +267,7 @@ bool BrowserRenderProcessHost::Init() {
switches::kDisablePopupBlocking,
switches::kUseLowFragHeapCrt,
switches::kGearsInRenderer,
+ switches::kEnableUserScripts,
switches::kEnableVideo,
};
@@ -514,8 +515,21 @@ void BrowserRenderProcessHost::InitVisitedLinks() {
}
void BrowserRenderProcessHost::InitUserScripts() {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableUserScripts)) {
+ return;
+ }
+
+ // TODO(aa): Figure out lifetime and ownership of this object
+ // - VisitedLinkMaster is owned by Profile, but there has been talk of
+ // having scripts live elsewhere besides the profile.
+ // - File IO should be asynchronous (see VisitedLinkMaster), but how do we
+ // get scripts to the first renderer without blocking startup? Should we
+ // cache some information across restarts?
UserScriptMaster* user_script_master = profile()->GetUserScriptMaster();
- DCHECK(user_script_master);
+ if (!user_script_master) {
+ return;
+ }
if (!user_script_master->ScriptsReady()) {
// No scripts ready. :(
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 0eb16ee..1544198 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -172,6 +172,7 @@ RenderView::RenderView(RenderThreadBase* render_thread)
disable_popup_blocking_(false),
has_unload_listener_(false),
decrement_shared_popup_at_destruction_(false),
+ user_scripts_enabled_(false),
waiting_for_create_window_ack_(false),
form_field_autofill_request_id_(0),
popup_notification_visible_(false),
@@ -316,6 +317,8 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
command_line.HasSwitch(switches::kDomAutomationController);
disable_popup_blocking_ =
command_line.HasSwitch(switches::kDisablePopupBlocking);
+ user_scripts_enabled_ =
+ command_line.HasSwitch(switches::kEnableUserScripts);
debug_message_handler_ = new DebugMessageHandler(this);
render_thread_->AddFilter(debug_message_handler_);
@@ -1488,12 +1491,14 @@ void RenderView::DidFinishDocumentLoadForFrame(WebView* webview,
// 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 (user_scripts_enabled_) {
+ 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);
+ }
}
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 5aff4bd..49b0be1 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -702,6 +702,9 @@ class RenderView : public RenderWidget,
// maintains the cache and other features of the accessibility tree.
scoped_ptr<GlueAccessibility> glue_accessibility_;
+ // True if user scripts are enabled in this process.
+ bool user_scripts_enabled_;
+
// Resource message queue. Used to queue up resource IPCs if we need
// to wait for an ACK from the browser before proceeding.
std::queue<IPC::Message*> queued_resource_messages_;