Remove --disable-infobars.

This flag is no longer needed by the perf testing infrastructure and can be
misused for malicious purposes, so remove it.

BUG=none
TEST=none

Change-Id: Iaa875bc887a5a1564ca10ef7d3c2d760a1f7cb11
Reviewed-on: https://chromium-review.googlesource.com/857604
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Egor Pasko <pasko@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528386}
diff --git a/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc b/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc
index 5f27aab..b334f62 100644
--- a/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc
+++ b/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc
@@ -15,7 +15,6 @@
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "components/infobars/core/infobar.h"
-#include "components/infobars/core/infobars_switches.h"
 #include "content/public/test/test_utils.h"
 
 namespace {
@@ -55,22 +54,6 @@
   DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBarTest);
 };
 
-// Subclass for tests that require infobars to be disabled.
-class GlobalConfirmInfoBarWithInfoBarDisabledTest
-    : public GlobalConfirmInfoBarTest {
- public:
-  GlobalConfirmInfoBarWithInfoBarDisabledTest() = default;
-  ~GlobalConfirmInfoBarWithInfoBarDisabledTest() override = default;
-
- protected:
-  void SetUpCommandLine(base::CommandLine* command_line) override {
-    command_line->AppendSwitch(infobars::switches::kDisableInfoBars);
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBarWithInfoBarDisabledTest);
-};
-
 }  // namespace
 
 // Creates a global confirm info bar on a browser with 2 tabs and closes it.
@@ -146,17 +129,3 @@
   for (int i = 0; i < tab_strip_model->count(); i++)
     EXPECT_EQ(0u, GetInfoBarServiceFromTabIndex(i)->infobar_count());
 }
-
-IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarWithInfoBarDisabledTest,
-                       InfoBarsDisabled) {
-  ASSERT_EQ(1, browser()->tab_strip_model()->count());
-
-  auto delegate = base::MakeUnique<TestConfirmInfoBarDelegate>();
-  base::WeakPtr<GlobalConfirmInfoBar> global_confirm_info_bar =
-      GlobalConfirmInfoBar::Show(std::move(delegate));
-
-  // In this case, the deletion is done asynchronously.
-  content::RunAllPendingInMessageLoop();
-
-  ASSERT_FALSE(global_confirm_info_bar);
-}
diff --git a/components/infobars/core/BUILD.gn b/components/infobars/core/BUILD.gn
index 103e359..acb9374 100644
--- a/components/infobars/core/BUILD.gn
+++ b/components/infobars/core/BUILD.gn
@@ -21,8 +21,6 @@
     "infobar_delegate.h",
     "infobar_manager.cc",
     "infobar_manager.h",
-    "infobars_switches.cc",
-    "infobars_switches.h",
     "simple_alert_infobar_delegate.cc",
     "simple_alert_infobar_delegate.h",
   ]
diff --git a/components/infobars/core/infobar_manager.cc b/components/infobars/core/infobar_manager.cc
index 7f6a4c9..7005855 100644
--- a/components/infobars/core/infobar_manager.cc
+++ b/components/infobars/core/infobar_manager.cc
@@ -8,7 +8,6 @@
 
 #include "base/command_line.h"
 #include "components/infobars/core/infobar.h"
-#include "components/infobars/core/infobars_switches.h"
 
 namespace infobars {
 
@@ -38,9 +37,6 @@
 InfoBar* InfoBarManager::AddInfoBar(std::unique_ptr<InfoBar> infobar,
                                     bool replace_existing) {
   DCHECK(infobar);
-  if (!infobars_enabled_)
-    return nullptr;
-
   for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end();
        ++i) {
     if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) {
@@ -71,8 +67,6 @@
 InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar,
                                         std::unique_ptr<InfoBar> new_infobar) {
   DCHECK(old_infobar);
-  if (!infobars_enabled_)
-    return AddInfoBar(std::move(new_infobar));  // Deletes the infobar.
   DCHECK(new_infobar);
 
   InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(),
@@ -103,9 +97,6 @@
 }
 
 InfoBarManager::InfoBarManager() {
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kDisableInfoBars))
-    infobars_enabled_ = false;
 }
 
 InfoBarManager::~InfoBarManager() {}
@@ -142,11 +133,6 @@
 
 void InfoBarManager::RemoveInfoBarInternal(InfoBar* infobar, bool animate) {
   DCHECK(infobar);
-  if (!infobars_enabled_) {
-    DCHECK(infobars_.empty());
-    return;
-  }
-
   InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), infobar));
   DCHECK(i != infobars_.end());
 
diff --git a/components/infobars/core/infobar_manager.h b/components/infobars/core/infobar_manager.h
index 2d44965..9ae6c06 100644
--- a/components/infobars/core/infobar_manager.h
+++ b/components/infobars/core/infobar_manager.h
@@ -132,7 +132,6 @@
   void RemoveInfoBarInternal(InfoBar* infobar, bool animate);
 
   InfoBars infobars_;
-  bool infobars_enabled_ = true;
   bool animations_enabled_ = true;
 
   base::ObserverList<Observer, true> observer_list_;
diff --git a/components/infobars/core/infobars_switches.cc b/components/infobars/core/infobars_switches.cc
deleted file mode 100644
index deb21a76..0000000
--- a/components/infobars/core/infobars_switches.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/infobars/core/infobars_switches.h"
-
-namespace infobars {
-namespace switches {
-
-// Prevent infobars from appearing.
-const char kDisableInfoBars[] = "disable-infobars";
-
-}  // namespace switches
-}  // namespace infobars
diff --git a/components/infobars/core/infobars_switches.h b/components/infobars/core/infobars_switches.h
deleted file mode 100644
index d24a09a4..0000000
--- a/components/infobars/core/infobars_switches.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_
-#define COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_
-
-namespace infobars {
-namespace switches {
-
-extern const char kDisableInfoBars[];
-
-}  // namespace switches
-}  // namespace infobars
-
-#endif  // COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_
diff --git a/tools/android/loading/device_setup.py b/tools/android/loading/device_setup.py
index cfa19bf0..16abfa6 100644
--- a/tools/android/loading/device_setup.py
+++ b/tools/android/loading/device_setup.py
@@ -360,11 +360,6 @@
 def RemoteSpeedIndexRecorder(device, connection, local_output_path):
   """Records on a device a video compatible for speed-index computation.
 
-  Note:
-    Chrome should be opened with the --disable-infobars command line argument to
-    avoid web page viewport size to be changed, that can change speed-index
-    value.
-
   Args:
     device: (device_utils.DeviceUtils) Android device to connect to.
     connection: devtools connection.
diff --git a/tools/android/loading/sandwich_runner.py b/tools/android/loading/sandwich_runner.py
index 5c3bb949..cb2a80d 100644
--- a/tools/android/loading/sandwich_runner.py
+++ b/tools/android/loading/sandwich_runner.py
@@ -331,7 +331,6 @@
       self._chrome_ctl = controller.RemoteChromeController(self.android_device)
     else:
       self._chrome_ctl = controller.LocalChromeController()
-    self._chrome_ctl.AddChromeArguments(['--disable-infobars'])
     self._chrome_ctl.AddChromeArguments(self.chrome_args)
     if self.cache_operation == CacheOperation.SAVE:
       self._chrome_ctl.SetSlowDeath()