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