Skip to content

Commit

Permalink
Revert "Remove --disable-infobars."
Browse files Browse the repository at this point in the history
This reverts commit d869ab3.

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: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542669}
  • Loading branch information
pavelfeldman authored and Commit Bot committed Mar 13, 2018
1 parent 0d2f435 commit 1e40985
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 0 deletions.
31 changes: 31 additions & 0 deletions chrome/browser/devtools/global_confirm_info_bar_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#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 {
Expand Down Expand Up @@ -54,6 +55,22 @@ class GlobalConfirmInfoBarTest : public InProcessBrowserTest {
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.
Expand Down Expand Up @@ -129,3 +146,17 @@ IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarTest, UserInteraction) {
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 = 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);
}
2 changes: 2 additions & 0 deletions components/infobars/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static_library("core") {
"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",
]
Expand Down
14 changes: 14 additions & 0 deletions components/infobars/core/infobar_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "base/command_line.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobars_switches.h"

namespace infobars {

Expand Down Expand Up @@ -37,6 +38,9 @@ void InfoBarManager::Observer::OnManagerShuttingDown(InfoBarManager* manager) {
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())) {
Expand Down Expand Up @@ -67,6 +71,8 @@ void InfoBarManager::RemoveAllInfoBars(bool animate) {
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(),
Expand Down Expand Up @@ -97,6 +103,9 @@ void InfoBarManager::RemoveObserver(Observer* obs) {
}

InfoBarManager::InfoBarManager() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInfoBars))
infobars_enabled_ = false;
}

InfoBarManager::~InfoBarManager() {}
Expand Down Expand Up @@ -133,6 +142,11 @@ void InfoBarManager::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) {

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());

Expand Down
1 change: 1 addition & 0 deletions components/infobars/core/infobar_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class InfoBarManager {
void RemoveInfoBarInternal(InfoBar* infobar, bool animate);

InfoBars infobars_;
bool infobars_enabled_ = true;
bool animations_enabled_ = true;

base::ObserverList<Observer, true> observer_list_;
Expand Down
14 changes: 14 additions & 0 deletions components/infobars/core/infobars_switches.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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
16 changes: 16 additions & 0 deletions components/infobars/core/infobars_switches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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_
5 changes: 5 additions & 0 deletions tools/android/loading/device_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ def _RemoteVideoRecorder(device, local_output_path, megabits_per_second):
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.
Expand Down
1 change: 1 addition & 0 deletions tools/android/loading/sandwich_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def Run(self):
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()
Expand Down

0 comments on commit 1e40985

Please sign in to comment.