Commit 2ba9bb88 authored by Greg Thompson's avatar Greg Thompson Committed by Chromium LUCI CQ

[A11Y, Windows] Issue an alert when Chrome is first launched.

With this change, Chrome's installer now includes the --from-installer
switch when launching Chrome. When this switch is present during Chrome
startup and a browser window is active following the
StartupBrowserCreator's job, the text "Welcome to Chrome; new browser
window opened" is announced. This lets users relying on assistive
technologies know that installation has finished and Chrome is ready for
action.

conclusion of installation.

Bug: 1072735
Skip-Translation-Screenshots-Check: true
AX-Relnotes: Chrome will issue a spoken alert when launched at the
Change-Id: I4a493052abe7a0ce30553388ed9801418a86fb17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587050
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840245}
parent 82ca1b70
......@@ -200,6 +200,9 @@ If you update this file, be sure also to update google_chrome_strings.grd. -->
<message name="IDS_PRODUCT_DESCRIPTION" desc="Browser description">
Chromium is a web browser that runs webpages and applications with lightning speed. It's fast, stable, and easy to use. Browse the web more safely with malware and phishing protection built into Chromium.
</message>
<message name="IDS_WELCOME_TO_CHROME" desc="Welcoming text announced via screen readers the first time Chrome is launched at the conclusion of installation.">
Welcome to Chromium; new browser window opened
</message>
</if>
<if expr="chromeos">
<message name="IDS_PRODUCT_OS_NAME" desc="The Chrome OS application name">
......
......@@ -205,6 +205,9 @@ chromium_strings.grd. -->
<message name="IDS_PRODUCT_DESCRIPTION" desc="Browser description">
Google Chrome is a web browser that runs webpages and applications with lightning speed. It's fast, stable, and easy to use. Browse the web more safely with malware and phishing protection built into Google Chrome.
</message>
<message name="IDS_WELCOME_TO_CHROME" desc="Welcoming text announced via screen readers the first time Chrome is launched at the conclusion of installation.">
Welcome to Chrome; new browser window opened
</message>
</if>
<if expr="chromeos">
<message name="IDS_PRODUCT_OS_NAME" desc="The Chrome OS application name">
......
......@@ -53,6 +53,7 @@
#include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config.h"
#include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_util_win.h"
#include "chrome/browser/shell_integration_win.h"
#include "chrome/browser/ui/accessibility_util.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/browser/ui/uninstall_browser_prompt.h"
#include "chrome/browser/web_applications/chrome_pwa_launcher/last_browser_file_util.h"
......@@ -739,6 +740,11 @@ void ChromeBrowserMainPartsWin::PostBrowserStart() {
->PostTask(FROM_HERE,
base::BindOnce(&MigratePinnedTaskBarShortcutsIfNeeded));
// Send an accessibility announcement if this launch originated from the
// installer.
if (parsed_command_line().HasSwitch(switches::kFromInstaller))
AnnounceInActiveBrowser(l10n_util::GetStringUTF16(IDS_WELCOME_TO_CHROME));
base::ImportantFileWriterCleaner::GetInstance().Start();
}
......@@ -907,6 +913,10 @@ base::CommandLine ChromeBrowserMainPartsWin::GetRestartCommandLine(
// Remove flag switches added by about::flags.
about_flags::RemoveFlagsSwitches(&switches);
// Remove switches that should never be conveyed to the restart.
switches.erase(switches::kFromInstaller);
// Add remaining switches, but not non-switch arguments.
for (const auto& it : switches)
restart_command.AppendSwitchNative(it.first, it.second);
......
......@@ -26,6 +26,9 @@ constexpr const char* kSwitchesToRemoveOnAutorestart[] = {
switches::kApp,
switches::kAppId,
switches::kForceFirstRun,
#if defined(OS_WIN)
switches::kFromInstaller,
#endif
switches::kGuest,
switches::kIncognito,
switches::kMakeDefaultBrowser,
......
......@@ -4274,7 +4274,11 @@ static_library("ui") {
}
if (is_win) {
sources += [ "views/chrome_views_delegate_win.cc" ]
sources += [
"accessibility_util.h",
"views/accessibility/accessibility_util.cc",
"views/chrome_views_delegate_win.cc",
]
}
if (is_win || (is_linux || is_chromeos_lacros)) {
......
// Copyright 2020 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 CHROME_BROWSER_UI_ACCESSIBILITY_UTIL_H_
#define CHROME_BROWSER_UI_ACCESSIBILITY_UTIL_H_
#include "base/strings/string16.h"
// Announces |message| as an accessibility alert in the currently active normal
// browser window, if there is one. Otherwise, no announcement is made.
void AnnounceInActiveBrowser(const base::string16& message);
#endif // CHROME_BROWSER_UI_ACCESSIBILITY_UTIL_H_
// Copyright 2020 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 "chrome/browser/ui/accessibility_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "ui/views/accessibility/view_accessibility.h"
void AnnounceInActiveBrowser(const base::string16& message) {
Browser* const browser = BrowserList::GetInstance()->GetLastActive();
if (!browser || !browser->is_type_normal() || !browser->window()->IsActive())
return;
BrowserView::GetBrowserViewForBrowser(browser)
->GetViewAccessibility()
.AnnounceText(message);
}
// Copyright 2020 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 "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "ui/views/accessibility/ax_event_manager.h"
#include "ui/views/test/ax_event_counter.h"
class PostInstallAnnouncementTestBase : public InProcessBrowserTest {
protected:
views::test::AXEventCounter event_counter_{views::AXEventManager::Get()};
};
IN_PROC_BROWSER_TEST_F(PostInstallAnnouncementTestBase, NormalLaunch) {
// Expect no announcement from a normal launch.
EXPECT_EQ(event_counter_.GetCount(ax::mojom::Event::kAlert), 0);
}
class PostInstallAnnouncementTest : public PostInstallAnnouncementTestBase {
protected:
// PostInstallAnnouncementTestBase:
void SetUpCommandLine(base::CommandLine* command_line) override {
// Pretend that the browser was launched by the installer.
command_line->AppendSwitch(switches::kFromInstaller);
}
};
IN_PROC_BROWSER_TEST_F(PostInstallAnnouncementTest, FromInstaller) {
// Expect that the welcome message was announced.
EXPECT_EQ(event_counter_.GetCount(ax::mojom::Event::kAlert), 1);
}
......@@ -742,6 +742,12 @@ const char kDisableWindows10CustomTitlebar[] =
// they use a custom-user-data-dir which disables this.
const char kEnableProfileShortcutManager[] = "enable-profile-shortcut-manager";
// Indicates that this launch of the browser originated from the installer
// (i.e., following a successful new install or over-install). This triggers
// browser behaviors for this specific launch, such as a welcome announcement
// for accessibility software (see https://crbug.com/1072735).
extern const char kFromInstaller[] = "from-installer";
// Makes Windows happy by allowing it to show "Enable access to this program"
// checkbox in Add/Remove Programs->Set Program Access and Defaults. This only
// shows an error box because the only way to hide Chrome is by uninstalling
......
......@@ -233,6 +233,7 @@ extern const char kMakeChromeDefault[];
#if defined(OS_WIN)
extern const char kDisableWindows10CustomTitlebar[];
extern const char kEnableProfileShortcutManager[];
extern const char kFromInstaller[];
extern const char kHideIcons[];
extern const char kNoNetworkProfileWarning[];
extern const char kNotificationInlineReply[];
......
......@@ -9,16 +9,25 @@
#include "base/logging.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/util_constants.h"
namespace installer {
base::CommandLine GetPostInstallLaunchCommand(
const base::FilePath& application_path) {
base::CommandLine cmd(application_path.Append(kChromeExe));
cmd.AppendSwitch(::switches::kFromInstaller);
return cmd;
}
bool LaunchChromeBrowser(const base::FilePath& application_path) {
if (application_path.empty())
return false;
const base::CommandLine cmd(application_path.Append(kChromeExe));
return base::LaunchProcess(cmd, base::LaunchOptions()).IsValid();
return base::LaunchProcess(GetPostInstallLaunchCommand(application_path),
base::LaunchOptions())
.IsValid();
}
bool LaunchChromeAndWait(const base::FilePath& application_path,
......
......@@ -7,14 +7,21 @@
#include <stdint.h>
#include "base/command_line.h"
namespace base {
class CommandLine;
class FilePath;
} // namespace base
namespace installer {
// Launches Chrome without waiting for it to exit.
// Returns a command line to be used to launch the browser in |application_path|
// following a successful install.
base::CommandLine GetPostInstallLaunchCommand(
const base::FilePath& application_path);
// Launches the browser following a successful install without waiting for it to
// exit.
bool LaunchChromeBrowser(const base::FilePath& application_path);
// Launches Chrome with given command line, waits for Chrome indefinitely (until
......
......@@ -1196,7 +1196,9 @@ InstallStatus InstallProductsHelper(InstallationState& original_state,
install_status = OS_ERROR;
} else {
chrome_exe = installer_state.target_path().Append(kChromeExe);
quoted_chrome_exe = L"\"" + chrome_exe.value() + L"\"";
quoted_chrome_exe =
GetPostInstallLaunchCommand(installer_state.target_path())
.GetCommandLineString();
install_msg_base = 0;
}
}
......
......@@ -6717,6 +6717,7 @@ if (!is_android) {
}
if (is_win) {
sources += [
"../browser/ui/views/accessibility/post_install_announcement_browsertest.cc",
"../browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc",
"../browser/ui/views/status_icons/status_tray_state_changer_interactive_uitest_win.cc",
]
......
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