Skip to content

Commit

Permalink
[Signin] Add disclaimer for managed profile in signin intercept bubble
Browse files Browse the repository at this point in the history
This CL adds an enterprise disclaimer for managed profile in signin
intercept bubble, when using a managed account or device.

Screenshots:
https://crbug.com/1282157#c36
https://crbug.com/1282157#c37

Bug: 1282157
Change-Id: Id6aa69f28afa23b069bcb82c025a7f55697914fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3735231
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Commit-Queue: Gabriel Oliveira <gabolvr@google.com>
Cr-Commit-Position: refs/heads/main@{#1021577}
  • Loading branch information
Gabriel Oliveira authored and Chromium LUCI CQ committed Jul 7, 2022
1 parent 3b775bd commit ae9096b
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 4 deletions.
6 changes: 6 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -9694,6 +9694,12 @@ Check your passwords anytime in <ph name="GOOGLE_PASSWORD_MANAGER">$1<ex>Google
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_CREATE_BUBBLE_TITLE_V2" desc="Title of the web signin interception bubble. 'Separate' is an action verb. The prompt is shown to let the user choose to keep the browsing activity for a new account in the same profile as an existing one or to move it to a new profile.">
Separate your browsing?
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_DISCLAIMER" desc="Enterprise disclaimer for a managed account in the signin interception bubble.">
This new profile will be managed by your organization. <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;<ex>https://help.google.com/articleLink</ex></ph>Learn more<ph name="END_LINK">&lt;/a&gt;</ph>
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_BY_DISCLAIMER" desc="Enterprise disclaimer for a managed account in the signin interception bubble, with the manager domain name.">
This new profile will be managed by <ph name="DOMAIN">$1<ex>example.com</ex></ph>. <ph name="BEGIN_LINK">&lt;a href="$2" target=&quot;_blank&quot;&gt;<ex>https://help.google.com/articleLink</ex></ph>Learn more<ph name="END_LINK">&lt;/a&gt;</ph>
</message>
</if>

<if expr="not chromeos_ash and not is_android">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edd9cb07791a8a063ef8914f5e06a83fa80796f2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43b9ce91552d9404564792190561ddafa6c00956
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,34 @@
}

#contents {
margin: 0 0 8px;
overflow-wrap: break-word; /** For very long names and emails */
}

#managedDisclaimer {
align-items: center;
background: var(--google-grey-50);
border-radius: 8px;
color: var(--google-grey-700);
display: flex;
flex-direction: row;
font-size: 12px;
font-weight: 400;
justify-content: flex-start;
line-height: 16px;
margin: 0 0 16px;
padding: 10px 12px;
}

#managedDisclaimerIcon {
margin-inline-end: 12px;
}

#managedDisclaimerIcon > iron-icon {
height: 16px;
width: 16px;
}

#actionRow {
display: flex;
justify-content: flex-end;
Expand Down Expand Up @@ -163,6 +188,11 @@
#interceptDialog [slot=footer] {
background: rgb(50, 54, 57); /* Custom color from Namrata. */
}

#managedDisclaimer {
background: var(--google-grey-800);
color: var(--google-grey-100);
}
}

.divider {
Expand Down Expand Up @@ -222,6 +252,17 @@
<div id="body">
<div id="title">[[interceptionParameters_.bodyTitle]]</div>
<div id="contents">[[interceptionParameters_.bodyText]]</div>
<template is="dom-if"
if="[[interceptionParameters_.showManagedDisclaimer]]">
<div id="managedDisclaimer">
<div id="managedDisclaimerIcon">
<iron-icon class="icon" icon="cr:domain"></iron-icon>
</div>
<div id="managedDisclaimerText"
inner-h-t-m-l="[[interceptionParameters_.managedDisclaimerText]]">
</div>
</div>
</template>
</div>

<div id="actionRow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export type InterceptionParameters = {
bodyText: string,
confirmButtonLabel: string,
cancelButtonLabel: string,
managedDisclaimerText: string,
headerTextColor: string,
interceptedProfileColor: string,
primaryProfileColor: string,
interceptedAccount: AccountInfo,
primaryAccount: AccountInfo,
showGuestOption: boolean,
useV2Design: boolean,
showManagedDisclaimer: boolean,
};

export interface DiceWebSigninInterceptBrowserProxy {
Expand Down
16 changes: 13 additions & 3 deletions chrome/browser/signin/dice_web_signin_interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/enterprise/util/managed_browser_utils.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/new_tab_page/chrome_colors/generated_colors_info.h"
Expand Down Expand Up @@ -122,13 +123,15 @@ DiceWebSigninInterceptor::Delegate::BubbleParameters::BubbleParameters(
AccountInfo primary_account,
SkColor profile_highlight_color,
bool show_guest_option,
bool show_link_data_option)
bool show_link_data_option,
bool show_managed_disclaimer)
: interception_type(interception_type),
intercepted_account(intercepted_account),
primary_account(primary_account),
profile_highlight_color(profile_highlight_color),
show_guest_option(show_guest_option),
show_link_data_option(show_link_data_option) {}
show_link_data_option(show_link_data_option),
show_managed_disclaimer(show_managed_disclaimer) {}

DiceWebSigninInterceptor::Delegate::BubbleParameters::BubbleParameters(
const BubbleParameters& copy) = default;
Expand Down Expand Up @@ -583,10 +586,17 @@ void DiceWebSigninInterceptor::OnInterceptionReadyToBeProcessed(
return;
}

bool show_managed_disclaimer =
*interception_type != SigninInterceptionType::kProfileSwitch &&
base::FeatureList::IsEnabled(kSigninInterceptBubbleV2) &&
(info.IsManaged() ||
policy::ManagementServiceFactory::GetForPlatform()->IsManaged());

Delegate::BubbleParameters bubble_parameters(
*interception_type, info, GetPrimaryAccountInfo(identity_manager_),
GetAutogeneratedThemeColors(profile_color).frame_color,
/*show_guest_option=*/false, show_link_data_option);
/*show_guest_option=*/false, show_link_data_option,
show_managed_disclaimer);

base::OnceCallback<void(SigninInterceptionResult)> callback;
switch (*interception_type) {
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/signin/dice_web_signin_interceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class DiceWebSigninInterceptor : public KeyedService,
AccountInfo primary_account,
SkColor profile_highlight_color = SkColor(),
bool show_guest_option = false,
bool show_link_data_option = false);
bool show_link_data_option = false,
bool show_managed_disclaimer = false);

BubbleParameters(const BubbleParameters& copy);
BubbleParameters& operator=(const BubbleParameters&);
Expand All @@ -183,6 +184,7 @@ class DiceWebSigninInterceptor : public KeyedService,
SkColor profile_highlight_color;
bool show_guest_option;
bool show_link_data_option;
bool show_managed_disclaimer;
};

virtual ~Delegate() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
namespace {
constexpr int kInterceptionBubbleWithoutGuestHeight = 326;
constexpr int kInterceptionBubbleGuestFooterHeight = 36;
constexpr int kInterceptionBubbleManagedDisclaimerHeight = 52;
constexpr int kInterceptionBubbleExtraTextHeight = 30;
constexpr int kInterceptionBubbleWidth = 290;

Expand Down Expand Up @@ -174,6 +175,11 @@ DiceWebSigninInterceptionBubbleView::DiceWebSigninInterceptionBubbleView(
// TODO: Dynamically compute the right size based on the text length.
height += kInterceptionBubbleExtraTextHeight;
}
if (bubble_parameters.show_managed_disclaimer) {
// Increase the height to display an entreprise disclaimer for managed
// profile.
height += kInterceptionBubbleManagedDisclaimerHeight;
}
web_view->SetPreferredSize(gfx::Size(kInterceptionBubbleWidth, height));
DiceWebSigninInterceptUI* web_ui = web_view->GetWebContents()
->GetWebUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"

#include <string>

#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
Expand All @@ -17,10 +19,14 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/ui/managed_ui.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/management/management_service.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "content/public/browser/web_ui.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
Expand Down Expand Up @@ -179,6 +185,7 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
parameters.SetStringKey("bodyText", GetBodyText());
parameters.SetStringKey("confirmButtonLabel", GetConfirmButtonLabel());
parameters.SetStringKey("cancelButtonLabel", GetCancelButtonLabel());
parameters.SetStringKey("managedDisclaimerText", GetManagedDisclaimerText());
parameters.SetBoolKey("showGuestOption",
bubble_parameters_.show_guest_option);
parameters.SetKey("interceptedAccount",
Expand All @@ -192,6 +199,8 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
color_utils::SkColorToRgbaString(
GetProfileHighlightColor(Profile::FromWebUI(web_ui()))));
parameters.SetBoolKey("useV2Design", GetShouldUseV2Design());
parameters.SetBoolKey("showManagedDisclaimer",
bubble_parameters_.show_managed_disclaimer);

parameters.SetStringKey(
"headerTextColor",
Expand Down Expand Up @@ -313,6 +322,29 @@ std::string DiceWebSigninInterceptHandler::GetCancelButtonLabel() {
: IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL);
}

std::string DiceWebSigninInterceptHandler::GetManagedDisclaimerText() {
std::string learn_more_url =
google_util::AppendGoogleLocaleParam(
GURL(chrome::kSigninInterceptManagedDisclaimerLearnMoreURL),
g_browser_process->GetApplicationLocale())
.spec();
std::string manager_domain = intercepted_account().IsManaged()
? intercepted_account().hosted_domain
: std::string();
if (manager_domain.empty())
manager_domain = chrome::GetDeviceManagerIdentity().value_or(std::string());

if (manager_domain.empty()) {
return l10n_util::GetStringFUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_DISCLAIMER,
base::ASCIIToUTF16(learn_more_url));
}

return l10n_util::GetStringFUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_BY_DISCLAIMER,
base::ASCIIToUTF16(manager_domain), base::ASCIIToUTF16(learn_more_url));
}

bool DiceWebSigninInterceptHandler::GetShouldUseV2Design() {
if (bubble_parameters_.interception_type ==
DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DiceWebSigninInterceptHandler : public content::WebUIMessageHandler,
std::string GetBodyText();
std::string GetConfirmButtonLabel();
std::string GetCancelButtonLabel();
std::string GetManagedDisclaimerText();
bool GetShouldUseV2Design();

base::ScopedObservation<signin::IdentityManager,
Expand Down
4 changes: 4 additions & 0 deletions chrome/common/url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ const char kSyncGoogleDashboardURL[] =
const char kSyncLearnMoreURL[] =
"https://support.google.com/chrome/?p=settings_sign_in";

// TODO(https://crbug.com/1282157): convert this to a p-link.
const char kSigninInterceptManagedDisclaimerLearnMoreURL[] =
"https://support.google.com/chrome/a/answer/11198768";

#if !BUILDFLAG(IS_ANDROID)
const char kSyncTrustedVaultOptInURL[] =
"https://passwords.google.com/encryption/enroll?"
Expand Down
4 changes: 4 additions & 0 deletions chrome/common/url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ extern const char kSyncGoogleDashboardURL[];
// The URL for the "Learn more" page for sync setup on the personal stuff page.
extern const char kSyncLearnMoreURL[];

// The URL for the "Learn more" link in the enterprise disclaimer for managed
// profile in the Signin Intercept bubble.
extern const char kSigninInterceptManagedDisclaimerLearnMoreURL[];

#if !BUILDFLAG(IS_ANDROID)
// The URL for the trusted vault sync passphrase opt in.
extern const char kSyncTrustedVaultOptInURL[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ const BASE_PARAMETERS: InterceptionParameters = {
bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
managedDisclaimerText: 'managed_disclaimer',
showGuestOption: true,
headerTextColor: 'rgba(255, 255, 255, 1)',
interceptedProfileColor: 'rgba(255, 0, 0, 1)',
primaryProfileColor: 'rgba(255, 255, 255, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
primaryAccount: {isManaged: false, pictureUrl: AVATAR_URL_2},
useV2Design: false,
showManagedDisclaimer: false,
};

function fireParametersChanged(parameters: InterceptionParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export class TestDiceWebSigninInterceptBrowserProxy extends TestBrowserProxy
bodyText: '',
cancelButtonLabel: '',
confirmButtonLabel: '',
managedDisclaimerText: '',
showGuestOption: false,
headerTextColor: '',
interceptedProfileColor: '',
primaryProfileColor: '',
interceptedAccount: {isManaged: false, pictureUrl: ''},
primaryAccount: {isManaged: false, pictureUrl: ''},
useV2Design: false,
showManagedDisclaimer: false,
};
}

Expand Down

0 comments on commit ae9096b

Please sign in to comment.