Commit 1e409852 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

Revert "Remove --disable-infobars."

This reverts commit d869ab33.

Reason for revert: this breaks automation scenarios in the field, see crbug.com/820555.

Original change's description:
> 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}

TBR=pasko@chromium.org,pkasting@chromium.org,pfeldman@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: none
Change-Id: I865b1ee1db7d795cf88d2b65cff404c8936b22ce
Reviewed-on: https://chromium-review.googlesource.com/957602
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542669}
parent 0d2f4351
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobars_switches.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
namespace { namespace {
...@@ -54,6 +55,22 @@ class GlobalConfirmInfoBarTest : public InProcessBrowserTest { ...@@ -54,6 +55,22 @@ class GlobalConfirmInfoBarTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBarTest); 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 } // namespace
// Creates a global confirm info bar on a browser with 2 tabs and closes it. // Creates a global confirm info bar on a browser with 2 tabs and closes it.
...@@ -129,3 +146,17 @@ IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarTest, UserInteraction) { ...@@ -129,3 +146,17 @@ IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarTest, UserInteraction) {
for (int i = 0; i < tab_strip_model->count(); i++) for (int i = 0; i < tab_strip_model->count(); i++)
EXPECT_EQ(0u, GetInfoBarServiceFromTabIndex(i)->infobar_count()); EXPECT_EQ(0u, GetInfoBarServiceFromTabIndex(i)->infobar_count());
} }
IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarWithInfoBarDisabledTest,
InfoBarsDisabled) {
ASSERT_EQ(1, browser()->tab_strip_model()->count());
auto delegate = std::make_unique<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);
}
...@@ -21,6 +21,8 @@ static_library("core") { ...@@ -21,6 +21,8 @@ static_library("core") {
"infobar_delegate.h", "infobar_delegate.h",
"infobar_manager.cc", "infobar_manager.cc",
"infobar_manager.h", "infobar_manager.h",
"infobars_switches.cc",
"infobars_switches.h",
"simple_alert_infobar_delegate.cc", "simple_alert_infobar_delegate.cc",
"simple_alert_infobar_delegate.h", "simple_alert_infobar_delegate.h",
] ]
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobars_switches.h"
namespace infobars { namespace infobars {
...@@ -37,6 +38,9 @@ void InfoBarManager::Observer::OnManagerShuttingDown(InfoBarManager* manager) { ...@@ -37,6 +38,9 @@ void InfoBarManager::Observer::OnManagerShuttingDown(InfoBarManager* manager) {
InfoBar* InfoBarManager::AddInfoBar(std::unique_ptr<InfoBar> infobar, InfoBar* InfoBarManager::AddInfoBar(std::unique_ptr<InfoBar> infobar,
bool replace_existing) { bool replace_existing) {
DCHECK(infobar); DCHECK(infobar);
if (!infobars_enabled_)
return nullptr;
for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end(); for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end();
++i) { ++i) {
if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) { if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) {
...@@ -67,6 +71,8 @@ void InfoBarManager::RemoveAllInfoBars(bool animate) { ...@@ -67,6 +71,8 @@ void InfoBarManager::RemoveAllInfoBars(bool animate) {
InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar, InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar,
std::unique_ptr<InfoBar> new_infobar) { std::unique_ptr<InfoBar> new_infobar) {
DCHECK(old_infobar); DCHECK(old_infobar);
if (!infobars_enabled_)
return AddInfoBar(std::move(new_infobar)); // Deletes the infobar.
DCHECK(new_infobar); DCHECK(new_infobar);
InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(),
...@@ -97,6 +103,9 @@ void InfoBarManager::RemoveObserver(Observer* obs) { ...@@ -97,6 +103,9 @@ void InfoBarManager::RemoveObserver(Observer* obs) {
} }
InfoBarManager::InfoBarManager() { InfoBarManager::InfoBarManager() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInfoBars))
infobars_enabled_ = false;
} }
InfoBarManager::~InfoBarManager() {} InfoBarManager::~InfoBarManager() {}
...@@ -133,6 +142,11 @@ void InfoBarManager::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) { ...@@ -133,6 +142,11 @@ void InfoBarManager::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) {
void InfoBarManager::RemoveInfoBarInternal(InfoBar* infobar, bool animate) { void InfoBarManager::RemoveInfoBarInternal(InfoBar* infobar, bool animate) {
DCHECK(infobar); DCHECK(infobar);
if (!infobars_enabled_) {
DCHECK(infobars_.empty());
return;
}
InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), infobar)); InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), infobar));
DCHECK(i != infobars_.end()); DCHECK(i != infobars_.end());
......
...@@ -132,6 +132,7 @@ class InfoBarManager { ...@@ -132,6 +132,7 @@ class InfoBarManager {
void RemoveInfoBarInternal(InfoBar* infobar, bool animate); void RemoveInfoBarInternal(InfoBar* infobar, bool animate);
InfoBars infobars_; InfoBars infobars_;
bool infobars_enabled_ = true;
bool animations_enabled_ = true; bool animations_enabled_ = true;
base::ObserverList<Observer, true> observer_list_; base::ObserverList<Observer, true> observer_list_;
......
// 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
// 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_
...@@ -360,6 +360,11 @@ def _RemoteVideoRecorder(device, local_output_path, megabits_per_second): ...@@ -360,6 +360,11 @@ def _RemoteVideoRecorder(device, local_output_path, megabits_per_second):
def RemoteSpeedIndexRecorder(device, connection, local_output_path): def RemoteSpeedIndexRecorder(device, connection, local_output_path):
"""Records on a device a video compatible for speed-index computation. """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: Args:
device: (device_utils.DeviceUtils) Android device to connect to. device: (device_utils.DeviceUtils) Android device to connect to.
connection: devtools connection. connection: devtools connection.
......
...@@ -331,6 +331,7 @@ class SandwichRunner(object): ...@@ -331,6 +331,7 @@ class SandwichRunner(object):
self._chrome_ctl = controller.RemoteChromeController(self.android_device) self._chrome_ctl = controller.RemoteChromeController(self.android_device)
else: else:
self._chrome_ctl = controller.LocalChromeController() self._chrome_ctl = controller.LocalChromeController()
self._chrome_ctl.AddChromeArguments(['--disable-infobars'])
self._chrome_ctl.AddChromeArguments(self.chrome_args) self._chrome_ctl.AddChromeArguments(self.chrome_args)
if self.cache_operation == CacheOperation.SAVE: if self.cache_operation == CacheOperation.SAVE:
self._chrome_ctl.SetSlowDeath() self._chrome_ctl.SetSlowDeath()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment