Commit 02b0b22a authored by Ramin Halavati's avatar Ramin Halavati Committed by Chromium LUCI CQ

Dont show Guest option in profile intercept when profile already exists.

During profile signin intercept, if the new account already has a
profile, do not offer moving to Guest mode.

Bug: 1157764
Change-Id: I2095eeae7c61d5ff8c91082b2f1d52d040d9a055
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611246
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841478}
parent 50089e62
......@@ -165,7 +165,8 @@
</div>
</div>
<!-- TODO(https://crbug.com/1157764): Change to make only link clickable. -->
<template is="dom-if" if="[[shouldShowGuest_]]" restamp>
<template is="dom-if" if="[[interceptionParameters_.showGuestOption]]"
restamp>
<div slot="footer">
<div class="divider"></div>
<div id="footer-description" on-click="onGuest_"
......
......@@ -35,14 +35,6 @@ Polymer({
value: false,
},
/** @private {boolean} */
shouldShowGuest_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('shouldShowGuest');
},
},
/** @private {string} */
guestLink_: {
type: String,
......
......@@ -88,6 +88,11 @@ bool HasNoBrowser(content::WebContents* web_contents) {
return chrome::FindBrowserWithWebContents(web_contents) == nullptr;
}
bool GuestOptionAvailable() {
return Profile::IsEphemeralGuestProfileEnabled() &&
!ProfileManager::GuestProfileExists();
}
} // namespace
ScopedDiceWebSigninInterceptionBubbleHandle::
......@@ -239,7 +244,8 @@ void DiceWebSigninInterceptor::MaybeInterceptWebSignin(
Delegate::BubbleParameters bubble_parameters{
SigninInterceptionType::kProfileSwitch, *account_info,
GetPrimaryAccountInfo(identity_manager_),
entry->GetProfileThemeColors().profile_highlight_color};
entry->GetProfileThemeColors().profile_highlight_color,
/*show_guest_option=*/false};
interception_bubble_handle_ = delegate_->ShowSigninInterceptionBubble(
web_contents, bubble_parameters,
base::BindOnce(&DiceWebSigninInterceptor::OnProfileSwitchChoice,
......@@ -401,7 +407,8 @@ void DiceWebSigninInterceptor::OnExtendedAccountInfoUpdated(
SkColor profile_color = GenerateNewProfileColor(entry).color;
Delegate::BubbleParameters bubble_parameters{
*interception_type, info, GetPrimaryAccountInfo(identity_manager_),
GetAutogeneratedThemeColors(profile_color).frame_color};
GetAutogeneratedThemeColors(profile_color).frame_color,
GuestOptionAvailable()};
interception_bubble_handle_ = delegate_->ShowSigninInterceptionBubble(
web_contents(), bubble_parameters,
base::BindOnce(&DiceWebSigninInterceptor::OnProfileCreationChoice,
......
......@@ -150,6 +150,7 @@ class DiceWebSigninInterceptor : public KeyedService,
AccountInfo intercepted_account;
AccountInfo primary_account;
SkColor profile_highlight_color;
bool show_guest_option;
};
virtual ~Delegate() = default;
......
......@@ -155,11 +155,10 @@ DiceWebSigninInterceptionBubbleView::DiceWebSigninInterceptionBubbleView(
std::unique_ptr<views::WebView> web_view =
std::make_unique<views::WebView>(profile);
web_view->LoadInitialURL(GURL(chrome::kChromeUIDiceWebSigninInterceptURL));
web_view->SetPreferredSize(
gfx::Size(kInterceptionBubbleWidth,
DiceWebSigninInterceptUI::ShouldShowGuestOption()
? kInterceptionBubbleWithGuestHeight
: kInterceptionBubbleWithoutGuestHeight));
web_view->SetPreferredSize(gfx::Size(
kInterceptionBubbleWidth, bubble_parameters.show_guest_option
? kInterceptionBubbleWithGuestHeight
: kInterceptionBubbleWithoutGuestHeight));
DiceWebSigninInterceptUI* web_ui = web_view->GetWebContents()
->GetWebUI()
->GetController()
......
......@@ -181,6 +181,8 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
l10n_util::GetStringUTF8(confirmButtonStringID));
parameters.SetStringKey("cancelButtonLabel",
l10n_util::GetStringUTF8(cancelButtonStringID));
parameters.SetBoolKey("showGuestOption",
bubble_parameters_.show_guest_option);
parameters.SetKey("interceptedAccount",
GetAccountInfoValue(intercepted_account()));
parameters.SetStringKey("headerBackgroundColor",
......
......@@ -33,7 +33,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS);
source->AddLocalizedString("guestLink",
IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_GUEST_LINK);
source->AddBoolean("shouldShowGuest", ShouldShowGuestOption());
source->UseStringsJs();
// Resources for testing.
......@@ -49,12 +48,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
DiceWebSigninInterceptUI::~DiceWebSigninInterceptUI() = default;
// static
bool DiceWebSigninInterceptUI::ShouldShowGuestOption() {
return Profile::IsEphemeralGuestProfileEnabled() &&
!ProfileManager::GuestProfileExists();
}
void DiceWebSigninInterceptUI::Initialize(
const DiceWebSigninInterceptor::Delegate::BubbleParameters&
bubble_parameters,
......
......@@ -28,8 +28,6 @@ class DiceWebSigninInterceptUI : public content::WebUIController {
bubble_parameters,
base::OnceCallback<void(SigninInterceptionUserChoice)> callback);
static bool ShouldShowGuestOption();
private:
WEB_UI_CONTROLLER_TYPE_DECL();
};
......
......@@ -8,7 +8,7 @@ import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {AccountInfo, DiceWebSigninInterceptBrowserProxyImpl, InterceptionParameters} from 'chrome://signin-dice-web-intercept/dice_web_signin_intercept_browser_proxy.js';
import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
import {isChildVisible} from '../test_util.m.js';
import {isChildVisible, waitAfterNextRender} from '../test_util.m.js';
import {TestDiceWebSigninInterceptBrowserProxy} from './test_dice_web_signin_intercept_browser_proxy.js';
......@@ -29,7 +29,7 @@ suite('DiceWebSigninInterceptTest', function() {
/** @type {string} */
const AVATAR_URL_2 = 'chrome://theme/IDR_PROFILE_AVATAR_2';
setup(function() {
setup(async function() {
browserProxy = new TestDiceWebSigninInterceptBrowserProxy();
browserProxy.setInterceptionParameters({
headerText: 'header_text',
......@@ -37,6 +37,7 @@ suite('DiceWebSigninInterceptTest', function() {
bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
showGuestOption: true,
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
......@@ -47,6 +48,7 @@ suite('DiceWebSigninInterceptTest', function() {
app = /** @type {!DiceWebSigninInterceptAppElement} */ (
document.createElement('dice-web-signin-intercept-app'));
document.body.append(app);
await waitAfterNextRender(app);
return browserProxy.whenCalled('pageLoaded');
});
......@@ -134,9 +136,11 @@ suite('DiceWebSigninInterceptTest', function() {
bodyText: 'new_body_text',
confirmButtonLabel: 'new_confirm_label',
cancelButtonLabel: 'new_cancel_label',
showGuestOption: true,
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
primaryAccount: {isManaged: false, pictureUrl: AVATAR_URL_2}
});
checkTextValues(
'new_header_text', 'new_body_title', 'new_body_text',
......@@ -154,9 +158,11 @@ suite('DiceWebSigninInterceptTest', function() {
bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
showGuestOption: true,
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_2},
primaryAccount: {isManaged: false, pictureUrl: AVATAR_URL_2}
};
// Update urls.
......
......@@ -17,6 +17,7 @@ export class TestDiceWebSigninInterceptBrowserProxy extends TestBrowserProxy {
bodyText: '',
cancelButtonLabel: '',
confirmButtonLabel: '',
showGuestOption: false,
headerTextColor: '',
headerBackgroundColor: '',
interceptedAccount: {isManaged: false, pictureUrl: ''},
......
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