Commit fae7e292 authored by Eric Lawrence's avatar Eric Lawrence Committed by Commit Bot

Suppress most startup infobars in Kiosk mode

When the browser is in kiosk mode, the user is unlikely to be able to
act upon or dismiss infobar notifications, so they should be suppressed
when the browser is started in this mode. The only exception is the
Automation info bar, still shown for anti-abuse reasons.

Bug: 445256
Change-Id: Ie49572e5a548e70ce83cd4defafb76510fe384b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095714
Commit-Queue: Eric Lawrence [MSFT] <ericlaw@microsoft.com>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748855}
parent b528fe7d
...@@ -1658,4 +1658,75 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -1658,4 +1658,75 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(CommandLineFlagSecurityWarningsPolicy::kNoPolicy, ::testing::Values(CommandLineFlagSecurityWarningsPolicy::kNoPolicy,
CommandLineFlagSecurityWarningsPolicy::kEnabled, CommandLineFlagSecurityWarningsPolicy::kEnabled,
CommandLineFlagSecurityWarningsPolicy::kDisabled)); CommandLineFlagSecurityWarningsPolicy::kDisabled));
// Verifies that infobars are not displayed in Kiosk mode.
class StartupBrowserCreatorInfobarsKioskTest : public InProcessBrowserTest {
public:
StartupBrowserCreatorInfobarsKioskTest() = default;
protected:
InfoBarService* LaunchKioskBrowserAndGetCreatedInfobarService(
const std::string& extra_switch) {
Profile* profile = browser()->profile();
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(switches::kKioskMode);
command_line.AppendSwitch(extra_switch);
StartupBrowserCreatorImpl launch(base::FilePath(), command_line,
chrome::startup::IS_NOT_FIRST_RUN);
EXPECT_TRUE(launch.Launch(profile, std::vector<GURL>(), true));
// This should have created a new browser window.
Browser* new_browser = FindOneOtherBrowser(browser());
EXPECT_TRUE(new_browser);
if (!new_browser)
return nullptr;
return InfoBarService::FromWebContents(
new_browser->tab_strip_model()->GetActiveWebContents());
}
};
// Verify that the Automation Enabled infobar is still shown in Kiosk mode.
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorInfobarsKioskTest,
CheckInfobarForEnableAutomation) {
InfoBarService* infobar_service =
LaunchKioskBrowserAndGetCreatedInfobarService(
switches::kEnableAutomation);
ASSERT_TRUE(infobar_service);
bool found_automation_infobar = false;
for (size_t i = 0; i < infobar_service->infobar_count(); i++) {
infobars::InfoBar* infobar = infobar_service->infobar_at(i);
if (infobar->delegate()->GetIdentifier() ==
infobars::InfoBarDelegate::AUTOMATION_INFOBAR_DELEGATE) {
found_automation_infobar = true;
}
}
EXPECT_TRUE(found_automation_infobar);
}
// Verify that the Bad Flags infobar is not shown in kiosk mode.
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorInfobarsKioskTest,
CheckInfobarForBadFlag) {
// BadFlagsPrompt::ShowBadFlagsPrompt uses CommandLine::ForCurrentProcess
// instead of the command-line passed to StartupBrowserCreator. In browser
// tests, this references the browser test's instead of the new process.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableWebSecurity);
// Passing the kDisableWebSecurity argument here presently does not do
// anything because of the aforementioned limitation.
// https://crbug.com/1060293
InfoBarService* infobar_service =
LaunchKioskBrowserAndGetCreatedInfobarService(
switches::kDisableWebSecurity);
ASSERT_TRUE(infobar_service);
for (size_t i = 0; i < infobar_service->infobar_count(); i++) {
infobars::InfoBar* infobar = infobar_service->infobar_at(i);
EXPECT_NE(infobars::InfoBarDelegate::BAD_FLAGS_INFOBAR_DELEGATE,
infobar->delegate()->GetIdentifier());
}
}
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
...@@ -864,15 +864,21 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( ...@@ -864,15 +864,21 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary(
if (!browser || !profile_ || browser->tab_strip_model()->count() == 0) if (!browser || !profile_ || browser->tab_strip_model()->count() == 0)
return; return;
if (HasPendingUncleanExit(browser->profile())) // Show the Automation info bar unless it has been disabled by policy.
SessionCrashedBubble::ShowIfNotOffTheRecordProfile(browser);
bool show_bad_flags_security_warnings = ShouldShowBadFlagsSecurityWarnings(); bool show_bad_flags_security_warnings = ShouldShowBadFlagsSecurityWarnings();
if (command_line_.HasSwitch(switches::kEnableAutomation) && if (command_line_.HasSwitch(switches::kEnableAutomation) &&
show_bad_flags_security_warnings) { show_bad_flags_security_warnings) {
AutomationInfoBarDelegate::Create(); AutomationInfoBarDelegate::Create();
} }
// Do not show any other info bars in Kiosk mode, because it's unlikely that
// the viewer can act upon or dismiss them.
if (command_line_.HasSwitch(switches::kKioskMode))
return;
if (HasPendingUncleanExit(browser->profile()))
SessionCrashedBubble::ShowIfNotOffTheRecordProfile(browser);
// The below info bars are only added to the first profile which is launched. // The below info bars are only added to the first profile which is launched.
// Other profiles might be restoring the browsing sessions asynchronously, // Other profiles might be restoring the browsing sessions asynchronously,
// so we cannot add the info bars to the focused tabs here. // so we cannot add the info bars to the focused tabs here.
......
...@@ -170,7 +170,6 @@ class StartupBrowserCreatorImpl { ...@@ -170,7 +170,6 @@ class StartupBrowserCreatorImpl {
SessionRestore::BehaviorBitmask restore_options, bool process_startup, SessionRestore::BehaviorBitmask restore_options, bool process_startup,
bool is_post_crash_launch); bool is_post_crash_launch);
// Adds any startup infobars to the selected tab of the given browser. // Adds any startup infobars to the selected tab of the given browser.
void AddInfoBarsIfNecessary( void AddInfoBarsIfNecessary(
Browser* browser, Browser* browser,
......
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