0

[Lacros] Add dialog for logging out and switching to device guest mode

New confirmation dialog:
https://storage.cloud.google.com/chromium-translation-screenshots/87341af13b830d6ef048d3f15db1ace2721d82f0

Account manager updated link to device guest mode:
https://storage.cloud.google.com/chromium-translation-screenshots/e756cb82d5c6aa35fc36bf4580983560e8025a0c

Version with Guest mode disabled:
https://storage.cloud.google.com/chromium-translation-screenshots/c4a47b5c8d424ef55417bc79b5827ab83a47ba38

Bug: 1411310
Change-Id: Id481ee57d908f2c695095324193d609158b8a5fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4315676
Reviewed-by: Anastasiia N <anastasiian@chromium.org>
Reviewed-by: Andre Le <leandre@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1116271}
This commit is contained in:
David Roger
2023-03-13 08:56:50 +00:00
committed by Chromium LUCI CQ
parent 06e5ebd1af
commit 66f2e1136f
18 changed files with 206 additions and 18 deletions

@ -1804,6 +1804,8 @@ component("ash") {
"system/scheduled_feature/scheduled_feature.h",
"system/screen_layout_observer.cc",
"system/screen_layout_observer.h",
"system/session/guest_session_confirmation_dialog.cc",
"system/session/guest_session_confirmation_dialog.h",
"system/session/logout_button_tray.cc",
"system/session/logout_button_tray.h",
"system/session/logout_confirmation_controller.cc",

@ -6293,6 +6293,20 @@ New install
Update and shut down
</message>
<!-- Guest session confirmation dialog -->
<message name="IDS_GUEST_SESSION_CONFIRMATION_DIALOG_TITLE" desc="Title of the dialog for switching to device guest mode.">
Sign out now?
</message>
<message name="IDS_GUEST_SESSION_CONFIRMATION_DIALOG_TEXT" desc="Content of the dialog for switching to device guest mode.">
To use the device as guest, you need to sign out and then select Browse as Guest at the bottom of the screen.
</message>
<message name="IDS_GUEST_SESSION_CONFIRMATION_DIALOG_SIGN_OUT" desc="Sign out button.">
Sign out
</message>
<message name="IDS_GUEST_SESSION_CONFIRMATION_DIALOG_CANCEL" desc="Cancel button.">
Cancel
</message>
<!-- Glanceables -->
<message name="IDS_GLANCEABLES_WELCOME_LABEL" desc="Personalized greeting / welcome message shown on glanceables surfaces (welcome screen and overview mode).">
Welcome back, <ph name="GIVEN_NAME">$1<ex>John</ex></ph>

@ -0,0 +1 @@
87341af13b830d6ef048d3f15db1ace2721d82f0

@ -0,0 +1 @@
87341af13b830d6ef048d3f15db1ace2721d82f0

@ -0,0 +1 @@
87341af13b830d6ef048d3f15db1ace2721d82f0

@ -0,0 +1 @@
87341af13b830d6ef048d3f15db1ace2721d82f0

@ -0,0 +1,98 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/session/guest_session_confirmation_dialog.h"
#include <memory>
#include "ash/public/cpp/window_backdrop.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/dialog_model.h"
#include "ui/base/models/dialog_model_field.h"
#include "ui/views/bubble/bubble_dialog_model_host.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
namespace ash {
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(GuestSessionConfirmationDialog,
kGuestSessionConfirmationDialogId);
GuestSessionConfirmationDialog* GuestSessionConfirmationDialog::g_dialog_ =
nullptr;
GuestSessionConfirmationDialog::~GuestSessionConfirmationDialog() = default;
// static
void GuestSessionConfirmationDialog::Show() {
// Avoid duplicate dialogs.
if (g_dialog_) {
return;
}
// dialog_ will be released when the dialog is closed.
g_dialog_ = new GuestSessionConfirmationDialog();
std::unique_ptr<ui::DialogModel> dialog_model =
ui::DialogModel::Builder(std::make_unique<ui::DialogModelDelegate>())
.SetTitle(l10n_util::GetStringUTF16(
IDS_GUEST_SESSION_CONFIRMATION_DIALOG_TITLE))
.AddOkButton(
base::BindOnce(&GuestSessionConfirmationDialog::OnConfirm,
g_dialog_->weak_ptr_factory_.GetWeakPtr()),
ui::DialogModelButton::Params().SetLabel(
l10n_util::GetStringUTF16(
IDS_GUEST_SESSION_CONFIRMATION_DIALOG_SIGN_OUT)))
.AddCancelButton(
base::DoNothing(),
ui::DialogModelButton::Params().SetLabel(
l10n_util::GetStringUTF16(
IDS_GUEST_SESSION_CONFIRMATION_DIALOG_CANCEL)))
.AddParagraph(ui::DialogModelLabel(l10n_util::GetStringUTF16(
IDS_GUEST_SESSION_CONFIRMATION_DIALOG_TEXT)))
.SetDialogDestroyingCallback(
base::BindOnce(&GuestSessionConfirmationDialog::OnDialogClosing,
g_dialog_->weak_ptr_factory_.GetWeakPtr()))
.Build();
g_dialog_->dialog_model_ = dialog_model.get();
auto bubble = views::BubbleDialogModelHost::CreateModal(
std::move(dialog_model), ui::MODAL_TYPE_SYSTEM);
bubble->SetOwnedByWidget(true);
views::Widget* widget =
views::DialogDelegate::CreateDialogWidget(std::move(bubble),
/*context=*/nullptr,
/*parent=*/nullptr);
widget->Show();
// TODO(crbug.com/1016828): Remove/update this after the dialog behavior on
// Chrome OS is defined.
WindowBackdrop::Get(widget->GetNativeWindow())
->SetBackdropType(WindowBackdrop::BackdropType::kSemiOpaque);
}
GuestSessionConfirmationDialog::GuestSessionConfirmationDialog() = default;
void GuestSessionConfirmationDialog::OnConfirm() {
should_logout_ = true;
}
void GuestSessionConfirmationDialog::OnDialogClosing() {
dialog_model_ = nullptr;
if (should_logout_) {
Shell::Get()->session_controller()->RequestSignOut();
}
delete this;
g_dialog_ = nullptr;
}
} // namespace ash

@ -0,0 +1,51 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_SESSION_GUEST_SESSION_CONFIRMATION_DIALOG_H_
#define ASH_SYSTEM_SESSION_GUEST_SESSION_CONFIRMATION_DIALOG_H_
#include "ash/ash_export.h"
#include "base/memory/weak_ptr.h"
#include "ui/base/interaction/element_identifier.h"
namespace ui {
class DialogModel;
}
namespace ash {
// This dialog explains to the user how to launch the guest mode from the login
// screen (e.g. by clicking "Browse As Guest") and asks for confirmation to log
// out the user. If the user confirms, they will be sent back to the login
// screen.
class ASH_EXPORT GuestSessionConfirmationDialog {
public:
static void Show();
GuestSessionConfirmationDialog(GuestSessionConfirmationDialog&) = delete;
GuestSessionConfirmationDialog& operator=(GuestSessionConfirmationDialog&) =
delete;
private:
GuestSessionConfirmationDialog();
~GuestSessionConfirmationDialog();
// Invoked when "ok" button is clicked.
void OnConfirm();
// Invoked when the dialog is closing.
void OnDialogClosing();
DECLARE_CLASS_ELEMENT_IDENTIFIER_VALUE(kGuestSessionConfirmationDialogId);
static GuestSessionConfirmationDialog* g_dialog_;
ui::DialogModel* dialog_model_ = nullptr;
bool should_logout_ = false;
base::WeakPtrFactory<GuestSessionConfirmationDialog> weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_SESSION_GUEST_SESSION_CONFIRMATION_DIALOG_H_

@ -5379,7 +5379,7 @@
<message name="IDS_OOBE_GESTURE_NAVIGATION_OVERVIEW_DESCRIPTION" desc="The description for the gesture navigation education overview OOBE screen shown on the first user login.">
To see all open app windows, swipe up from the bottom and hold.
</message>
<!-- Strings for ChromeVox hint -->
<message name="IDS_OOBE_ACTIVATE_CHROMEVOX" desc="Label for the button in the ChromeVox hint dialog that will activate ChromeVox.">
Yes, activate ChromeVox
@ -5820,6 +5820,16 @@
You can use this account with Android apps. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph> instead.
Permissions you've already given to apps may apply to this account. You can control permissions for Android apps in <ph name="APPS_LINK_BEGIN">&lt;a id="appsSettingsLink" href="$3<ex>https://google.com/</ex>"&gt;</ph>Apps Settings<ph name="APPS_LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_DEVICE_GUEST_MODE" desc="Text body for the Welcome screen in ChromiumOS 'Add account' dialog.">
If you want to use this account one-time only, you can <ph name="GUEST_LINK_BEGIN">&lt;a id="guestModeLink" href="#"&gt;</ph>use the device as guest<ph name="GUEST_LINK_END">&lt;/a&gt;</ph>. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.
Permissions you've already given to websites and apps may apply to this account. You can manage your Google Accounts in <ph name="SETTINGS_LINK_BEGIN">&lt;a id="osSettingsLink" href="$3<ex>https://google.com/</ex>"&gt;</ph>Settings<ph name="SETTINGS_LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITHOUT_GUEST" desc="Text body for the Welcome screen in ChromiumOS 'Add account' dialog.">
If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.
Permissions you've already given to websites and apps may apply to this account. You can manage your Google Accounts in <ph name="SETTINGS_LINK_BEGIN">&lt;a id="osSettingsLink" href="$3<ex>https://google.com/</ex>"&gt;</ph>Settings<ph name="SETTINGS_LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_ACCOUNT_MANAGER_DIALOG_ARC_TOGGLE_LABEL" desc="Toggle text for the Welcome screen in ChromeOS 'Add account' dialog. If user toggles it on, the account that will be added will be available in Android Apps. The default value for the toggle may be 'on' or 'off' depending on where the dialog is being opened from.">
Use this account with Android apps. You can control permissions for Android apps in <ph name="LINK_BEGIN">&lt;a id="appsSettingsLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>Apps Settings<ph name="LINK_END">&lt;/a&gt;</ph>.

@ -0,0 +1 @@
c4a47b5c8d424ef55417bc79b5827ab83a47ba38

@ -513,11 +513,6 @@ Chromium is unable to recover your settings.
</message>
<!-- Add account dialog -->
<if expr="chromeos_ash">
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2" desc="Text body for the Welcome screen in ChromiumOS 'Add account' dialog.">
If you want to use this account one-time only, you can use Guest mode in Chromium browser. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.
Permissions you've already given to websites and apps may apply to this account. You can manage your Google Accounts in <ph name="SETTINGS_LINK_BEGIN">&lt;a id="osSettingsLink" href="$3<ex>https://google.com/</ex>"&gt;</ph>Settings<ph name="SETTINGS_LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_GUEST_MODE" desc="Text body for the Welcome screen in ChromiumOS 'Add account' dialog.">
If you want to use this account one-time only, you can use <ph name="GUEST_LINK_BEGIN">&lt;a id="guestModeLink" href="#"&gt;</ph>Guest mode<ph name="GUEST_LINK_END">&lt;/a&gt;</ph> in Chromium browser. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.

@ -1 +0,0 @@
890dd4d972fde0e06ea98b4aac1e04b2a302ea2b

@ -536,11 +536,6 @@ Google Chrome is unable to recover your settings.
</message>
<!-- Add account dialog -->
<if expr="chromeos_ash">
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2" desc="Text body for the Welcome screen in ChromeOS 'Add account' dialog.">
If you want to use this account one-time only, you can use Guest mode in Chrome browser. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.
Permissions you've already given to websites and apps may apply to this account. You can manage your Google Accounts in <ph name="SETTINGS_LINK_BEGIN">&lt;a id="osSettingsLink" href="$3<ex>https://google.com/</ex>"&gt;</ph>Settings<ph name="SETTINGS_LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_GUEST_MODE" desc="Text body for the Welcome screen in ChromeOS 'Add account' dialog.">
If you want to use this account one-time only, you can use <ph name="GUEST_LINK_BEGIN">&lt;a id="guestModeLink" href="#"&gt;</ph>Guest mode<ph name="GUEST_LINK_END">&lt;/a&gt;</ph> in Chrome browser. If you want to add an account for someone else, <ph name="LINK_BEGIN">&lt;a target="_blank" id="newPersonLink" href="$1<ex>https://google.com/</ex>"&gt;</ph>add a new person<ph name="LINK_END">&lt;/a&gt;</ph> to your <ph name="DEVICE_TYPE">$2<ex>Chromebook</ex></ph>.

@ -0,0 +1,6 @@
include_rules = [
# //chrome/browser/ui/webui/signin/ash is conceptually part of "ash". See the
# "Lacros: ChromeOS source code directory migration" design doc at
# https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE
"+ash/system/session",
]

@ -8,6 +8,7 @@
#include <string>
#include "ash/constants/ash_pref_names.h"
#include "ash/system/session/guest_session_confirmation_dialog.h"
#include "base/base64.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
@ -18,6 +19,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/chrome_device_id_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser_commands.h"
@ -473,7 +475,13 @@ void InlineLoginHandlerImpl::HandleSkipWelcomePage(
void InlineLoginHandlerImpl::OpenGuestWindowAndCloseDialog(
const base::Value::List& args) {
crosapi::BrowserManager::Get()->NewGuestWindow();
// Open the browser guest mode if available, else the device guest mode.
if (profiles::IsGuestModeEnabled()) {
crosapi::BrowserManager::Get()->NewGuestWindow();
} else {
GuestSessionConfirmationDialog::Show();
}
close_dialog_closure_.Run();
}

@ -253,10 +253,15 @@ void CreateAndAddWebUIDataSource(Profile* profile) {
: profile->GetPrefs()->GetBoolean(
ash::prefs::kShouldSkipInlineLoginWelcomePage));
if (ash::AccountAppsAvailability::IsArcAccountRestrictionsEnabled()) {
int message_id =
profiles::IsGuestModeEnabled()
? IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_GUEST_MODE
: IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2;
int message_id = IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITHOUT_GUEST;
// Offer browser guest mode or device guest mode, if available.
if (profiles::IsGuestModeEnabled()) {
message_id = IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_GUEST_MODE;
} else if (user_manager::UserManager::Get()->IsGuestSessionAllowed()) {
message_id =
IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY_V2_WITH_DEVICE_GUEST_MODE;
}
source->AddString(
"accountManagerDialogWelcomeBody",
l10n_util::GetStringFUTF16(