From f08a247c471a213f294e6d368030ac7d11e34c28 Mon Sep 17 00:00:00 2001
From: "aa@chromium.org" <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 28 Jan 2009 09:22:44 +0000
Subject: 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.

Review URL: http://codereview.chromium.org/18401

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8800 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/browser/browser_init.cc                          |  6 ++++--
 .../renderer_host/browser_render_process_host.cc        | 16 +---------------
 chrome/renderer/render_view.cc                          | 17 ++++++-----------
 chrome/renderer/render_view.h                           |  3 ---
 4 files changed, 11 insertions(+), 31 deletions(-)

diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 637f129..ce4febe 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -222,8 +222,6 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
     }
   }
 
-  profile->InitExtensions();
-
   return true;
 }
 
@@ -385,6 +383,10 @@ bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
     CreateAutomationProvider<AutomationProvider>(automation_channel_id,
                                                  profile, expected_tabs);
   }
+
+  // Start up the extensions service.
+  profile->InitExtensions();
+
   // If we don't want to launch a new browser window or tab (in the case
   // of an automation request), we are done here.
   if (!silent_launch) {
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index c8b8e6e..1e1db05 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -267,7 +267,6 @@ bool BrowserRenderProcessHost::Init() {
     switches::kDisablePopupBlocking,
     switches::kUseLowFragHeapCrt,
     switches::kGearsInRenderer,
-    switches::kEnableUserScripts,
     switches::kEnableVideo,
   };
 
@@ -515,21 +514,8 @@ 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();
-  if (!user_script_master) {
-    return;
-  }
+  DCHECK(user_script_master);
 
   if (!user_script_master->ScriptsReady()) {
     // No scripts ready.  :(
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 1544198..0eb16ee 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -172,7 +172,6 @@ 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),
@@ -317,8 +316,6 @@ 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_);
@@ -1491,14 +1488,12 @@ void RenderView::DidFinishDocumentLoadForFrame(WebView* webview,
 
   // Inject any user scripts. Do not inject into chrome UI pages, but do inject
   // into any other document.
-  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);
-    }
+  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 49b0be1..5aff4bd 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -702,9 +702,6 @@ 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_;
-- 
cgit v1.1