Commit bbb682d5 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Remove pre-UnifiedConsent code from sync confirmation dialog.

This CL is the first CL to remove the per-UnifiedConsent code from
the sync confirmation dialog. The pre-UnifiedConsent sync confirmation
HTML and JS are still for the case when sync is disabled by policy.

Follow-up CLs will attempt to do the clean-up for these cases.

Bug: 971183

Change-Id: I9b24b5b23fad9a0658ebea0ab0c80f3157e530ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1645358Reviewed-by: default avatarThomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Auto-Submit: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667253}
parent c04c61a0
...@@ -17,80 +17,9 @@ ...@@ -17,80 +17,9 @@
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css"> <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<custom-style> <custom-style>
<style include="signin-dialog-shared paper-button-style"> <style include="signin-dialog-shared paper-button-style">
.picture img {
border-radius: 50%;
max-height: 100%;
max-width: 100%;
}
.details { .details {
padding: 0 24px; padding: 0 24px;
} }
#picture-container {
align-items: center;
display: flex;
justify-content: center;
padding-bottom: 32px;
padding-top: 24px;
}
.picture {
height: 96px;
margin-inline-start: 84px;
position: relative;
width: 96px;
}
#profile-picture,
.checkmark-circle {
position: absolute;
}
.message-container {
display: flex;
margin-bottom: 16px;
}
.message-container:last-child {
margin-bottom: 32px;
}
.message-container .logo {
background-size: cover;
flex-shrink: 0;
height: 20px;
margin-inline-end: 20px;
position: relative;
top: -2px;
width: 20px;
}
#chrome-logo {
background-image: url(../../../../../ui/webui/resources/images/200-logo_chrome.png);
}
#googleg-logo {
background-image: url(../../../../../ui/webui/resources/images/200-logo_googleg.png);
}
.message-container .title {
font-weight: 500;
margin-bottom: 4px;
}
.message-container .body {
color: var(--cr-secondary-text-color);
}
.message-container .text {
line-height: 20px;
}
.message-container #activityControlsCheckbox {
margin-inline-start: 40px;
}
#undoButton { #undoButton {
<if expr="is_macosx or is_linux"> <if expr="is_macosx or is_linux">
margin-inline-end: 8px; margin-inline-end: 8px;
...@@ -107,221 +36,6 @@ ...@@ -107,221 +36,6 @@
padding: 0 24px; padding: 0 24px;
} }
#illustration {
height: 96px;
margin: 0 auto;
position: relative;
width: 264px;
}
#checkmark-circle {
background: var(--google-blue-refresh-500);
border: 2px solid #fff;
border-radius: 50%;
bottom: 0;
height: 24px;
position: absolute;
right: 0;
transform: scale(0);
width: 24px;
}
[dark] #checkmark-circle {
background: var(--google-blue-refresh-300);
border-color: var(--google-grey-900);
}
.loaded #checkmark-circle {
animation: scale-circle 300ms cubic-bezier(0, 0, 0.2, 1) forwards;
}
@keyframes scale-circle {
from { transform: scale(0); }
to { transform: scale(1); }
}
#checkmark-check {
left: 5px;
position: absolute;
top: 7px;
}
.loaded #checkmark-path {
animation: draw-path 300ms cubic-bezier(0, 0, 0.2, 1) 100ms forwards;
}
@keyframes draw-path {
from { stroke-dashoffset: 16; }
to { stroke-dashoffset: 0; }
}
#icons {
height: 96px;
position: absolute;
width: 264px;
}
#icons > div {
-webkit-mask-repeat: no-repeat;
-webkit-mask-size: cover;
animation-delay: 200ms;
animation-duration: 1.4s;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(0.25, 0.45, 0.4, 0.7);
background-color: black;
opacity: 0;
position: absolute;
}
[dark] #icons > div {
background-color: white;
}
#icon-bookmarks {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_bookmarks.svg);
height: 36px;
left: 58px;
top: 0;
width: 36px;
}
#icon-extensions {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_extensions.svg);
height: 24px;
left: 30px;
top: 30px;
width: 24px;
}
#icon-passwords {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_passwords.svg);
height: 30px;
left: 38px;
top: 66px;
width: 40px;
}
#icon-history {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_history.svg);
height: 36px;
left: 190px;
top: 6px;
width: 36px;
}
#icon-tabs {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_tabs.svg);
height: 24px;
left: 222px;
top: 44px;
width: 24px;
}
#icon-themes {
-webkit-mask-image: url(../../../../../ui/webui/resources/images/icon_themes.svg);
height: 30px;
left: 184px;
top: 62px;
width: 32px;
}
#icon-circle-open {
border: 2px solid #000;
border-radius: 50%;
height: 8px;
left: 6px;
top: 56px;
width: 8px;
}
[dark] #icon-circle-open {
border-color: white;
}
.icon-circle {
border-radius: 50%;
height: 4px;
width: 4px;
}
#icon-circle-1 {
left: 64px;
top: 50px;
}
#icon-circle-2 {
left: 178px;
top: 18px;
}
#icon-circle-3 {
left: 194px;
top: 50px;
}
#icon-circle-4 {
left: 258px;
top: 36px;
}
.loaded .fade-top-left {
animation-name: fade-in, icon-top-left;
}
.loaded .fade-top-right {
animation-name: fade-in, icon-top-right;
}
.loaded .fade-middle-left {
animation-name: fade-in, icon-middle-left;
}
.loaded .fade-middle-right {
animation-name: fade-in, icon-middle-right;
}
.loaded .fade-bottom-left {
animation-name: fade-in, icon-bottom-left;
}
.loaded .fade-bottom-right {
animation-name: fade-in, icon-bottom-right;
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: .1; }
}
@keyframes icon-top-left {
from { transform: translate(0, 0); }
to { transform: translate(-4px, -4px); }
}
@keyframes icon-top-right {
from { transform: translate(0, 0); }
to { transform: translate(4px, -4px); }
}
@keyframes icon-middle-left {
from { transform: translate(0, 0); }
to { transform: translate(-4px, 0); }
}
@keyframes icon-middle-right {
from { transform: translate(0, 0); }
to { transform: translate(4px, 0); }
}
@keyframes icon-bottom-left {
from { transform: translate(0, 0); }
to { transform: translate(-4px, 4px); }
}
@keyframes icon-bottom-right {
from { transform: translate(0, 0); }
to { transform: translate(4px, 4px); }
}
</style> </style>
</custom-style> </custom-style>
</head> </head>
...@@ -336,70 +50,6 @@ ...@@ -336,70 +50,6 @@
<div class="top-title-bar" consent-description> <div class="top-title-bar" consent-description>
$i18n{syncConfirmationTitle} $i18n{syncConfirmationTitle}
</div> </div>
<div class="details" id="syncConfirmationDetails">
<div id="picture-container">
<div id="illustration">
<div id="icons">
<div id="icon-bookmarks" class="fade-top-left"></div>
<div id="icon-extensions" class="fade-top-left"></div>
<div id="icon-passwords" class="fade-bottom-left"></div>
<div id="icon-history" class="fade-top-right"></div>
<div id="icon-tabs" class="fade-middle-right"></div>
<div id="icon-themes" class="fade-bottom-right"></div>
<div id="icon-circle-open" class="fade-middle-left"></div>
<div id="icon-circle-1" class="icon-circle fade-middle-left"></div>
<div id="icon-circle-2" class="icon-circle fade-top-right"></div>
<div id="icon-circle-3" class="icon-circle fade-middle-right"></div>
<div id="icon-circle-4" class="icon-circle fade-top-right"></div>
</div>
<div class="picture">
<img id="profile-picture">
<div id="checkmark-circle">
<svg id="checkmark-check" width="13" height="10" viewBox="0 0 13 10">
<path id="checkmark-path" d="M1 5l3.5 3.5L12 1" stroke="#FFF"
stroke-width="2" stroke-dasharray="16"
stroke-dashoffset="16" fill="none"></path>
</svg>
</div>
</div>
</div>
</div>
<div class="message-container">
<!--
"Chrome sync" is the Google Cloud Based services used for sync. Thus
this section uses the Chrome logo even for Chromium builds.
-->
<div id="chrome-logo" class="logo"></div>
<div>
<div class="title" consent-description>
$i18n{syncConfirmationChromeSyncTitle}
</div>
<div class="body text" consent-description>
$i18n{syncConfirmationChromeSyncBody}
</div>
</div>
</div>
<div class="message-container">
<!--
This section uses the Google logo even for Chromium builds as the
user can personalize their Google services from this screen.
-->
<div id="googleg-logo" class="logo"></div>
<div>
<div class="title" consent-description>
$i18n{syncConfirmationPersonalizeServicesTitle}
</div>
<div class="body text" consent-description>
$i18n{syncConfirmationPersonalizeServicesBody}
</div>
</div>
</div>
<div class="message-container">
<div class="body" consent-description consent-confirmation>
$i18nRaw{syncConfirmationSyncSettingsLinkBody}
</div>
</div>
</div>
<div class="details" id="syncDisabledDetails"> <div class="details" id="syncDisabledDetails">
<div class="body text" consent-description> <div class="body text" consent-description>
$i18n{syncDisabledConfirmationDetails} $i18n{syncDisabledConfirmationDetails}
......
...@@ -42,24 +42,10 @@ cr.define('sync.confirmation', function() { ...@@ -42,24 +42,10 @@ cr.define('sync.confirmation', function() {
chrome.send('undo'); chrome.send('undo');
} }
function onGoToSettings(e) {
chrome.send(
'goToSettings',
[getConsentDescription(), getConsentConfirmation(e.path)]);
}
function initialize() { function initialize() {
document.addEventListener('keydown', onKeyDown); document.addEventListener('keydown', onKeyDown);
$('confirmButton').addEventListener('click', onConfirm); $('confirmButton').addEventListener('click', onConfirm);
$('undoButton').addEventListener('click', onUndo); $('undoButton').addEventListener('click', onUndo);
if (loadTimeData.getBoolean('isSyncAllowed')) {
$('settingsLink').addEventListener('click', onGoToSettings);
$('profile-picture').addEventListener('load', onPictureLoaded);
$('syncDisabledDetails').hidden = true;
} else {
$('syncConfirmationDetails').hidden = true;
}
// Prefer using |document.body.offsetHeight| instead of // Prefer using |document.body.offsetHeight| instead of
// |document.body.scrollHeight| as it returns the correct height of the // |document.body.scrollHeight| as it returns the correct height of the
// even when the page zoom in Chrome is different than 100%. // even when the page zoom in Chrome is different than 100%.
...@@ -70,18 +56,6 @@ cr.define('sync.confirmation', function() { ...@@ -70,18 +56,6 @@ cr.define('sync.confirmation', function() {
document.activeElement.blur(); document.activeElement.blur();
} }
function setUserImageURL(url) {
if (loadTimeData.getBoolean('isSyncAllowed')) {
$('profile-picture').src = url;
}
}
function onPictureLoaded(e) {
if (loadTimeData.getBoolean('isSyncAllowed')) {
$('picture-container').classList.add('loaded');
}
}
function onKeyDown(e) { function onKeyDown(e) {
// If the currently focused element isn't something that performs an action // If the currently focused element isn't something that performs an action
// on "enter" being pressed and the user hits "enter", perform the default // on "enter" being pressed and the user hits "enter", perform the default
...@@ -93,15 +67,11 @@ cr.define('sync.confirmation', function() { ...@@ -93,15 +67,11 @@ cr.define('sync.confirmation', function() {
} }
} }
// TODO(tangltom): clearFocus and setUserImageURL are called directly by the // TODO(tangltom): clearFocus is called directly by the C++ handler.
// C++ handler. C++ handlers should not be calling JS functions by name // C++ handlers should not be calling JS functions by name anymore. They
// anymore. They should be firing events with FireWebuiListener and have the // should be firing events with FireWebuiListener and have the page itself
// page itself decide whether to listen or not listen to the event. // decide whether to listen or not listen to the event.
return { return {clearFocus: clearFocus, initialize: initialize};
clearFocus: clearFocus,
initialize: initialize,
setUserImageURL: setUserImageURL
};
}); });
document.addEventListener('DOMContentLoaded', sync.confirmation.initialize); document.addEventListener('DOMContentLoaded', sync.confirmation.initialize);
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h" #include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
...@@ -90,6 +91,7 @@ void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) { ...@@ -90,6 +91,7 @@ void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) {
} }
void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) {
DCHECK(profile_->IsSyncAllowed());
did_user_explicitly_interact = true; did_user_explicitly_interact = true;
RecordConsent(args); RecordConsent(args);
CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST);
...@@ -102,6 +104,7 @@ void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { ...@@ -102,6 +104,7 @@ void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) {
void SyncConfirmationHandler::HandleAccountImageRequest( void SyncConfirmationHandler::HandleAccountImageRequest(
const base::ListValue* args) { const base::ListValue* args) {
DCHECK(profile_->IsSyncAllowed());
base::Optional<AccountInfo> primary_account_info = base::Optional<AccountInfo> primary_account_info =
identity_manager_->FindExtendedAccountInfoForAccount( identity_manager_->FindExtendedAccountInfoForAccount(
identity_manager_->GetPrimaryAccountInfo()); identity_manager_->GetPrimaryAccountInfo());
...@@ -165,6 +168,12 @@ void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) { ...@@ -165,6 +168,12 @@ void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) {
} }
void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
if (!profile_->IsSyncAllowed()) {
// The sync disabled confirmation handler does not present the user image.
// Avoid updating the image URL in this case.
return;
}
std::string picture_url_to_load; std::string picture_url_to_load;
GURL picture_gurl(picture_url); GURL picture_gurl(picture_url);
if (picture_gurl.is_valid()) { if (picture_gurl.is_valid()) {
...@@ -179,12 +188,7 @@ void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { ...@@ -179,12 +188,7 @@ void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
base::Value picture_url_value(picture_url_to_load); base::Value picture_url_value(picture_url_to_load);
AllowJavascript(); AllowJavascript();
if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
FireWebUIListener("account-image-changed", picture_url_value); FireWebUIListener("account-image-changed", picture_url_value);
} else {
CallJavascriptFunction("sync.confirmation.setUserImageURL",
picture_url_value);
}
} }
void SyncConfirmationHandler::OnExtendedAccountInfoUpdated( void SyncConfirmationHandler::OnExtendedAccountInfoUpdated(
......
...@@ -210,62 +210,12 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest, ...@@ -210,62 +210,12 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandlerTest); DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandlerTest);
}; };
class SyncConfirmationHandlerTest_UnifiedConsentDisabled
: public SyncConfirmationHandlerTest {
public:
SyncConfirmationHandlerTest_UnifiedConsentDisabled()
: scoped_unified_consent_(
unified_consent::UnifiedConsentFeatureState::kDisabled) {}
private:
unified_consent::ScopedUnifiedConsent scoped_unified_consent_;
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandlerTest_UnifiedConsentDisabled);
};
const char SyncConfirmationHandlerTest::kConsentText1[] = "consentText1"; const char SyncConfirmationHandlerTest::kConsentText1[] = "consentText1";
const char SyncConfirmationHandlerTest::kConsentText2[] = "consentText2"; const char SyncConfirmationHandlerTest::kConsentText2[] = "consentText2";
const char SyncConfirmationHandlerTest::kConsentText3[] = "consentText3"; const char SyncConfirmationHandlerTest::kConsentText3[] = "consentText3";
const char SyncConfirmationHandlerTest::kConsentText4[] = "consentText4"; const char SyncConfirmationHandlerTest::kConsentText4[] = "consentText4";
const char SyncConfirmationHandlerTest::kConsentText5[] = "consentText5"; const char SyncConfirmationHandlerTest::kConsentText5[] = "consentText5";
TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
TestSetImageIfPrimaryAccountReady) {
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
"http://picture.example.com/picture.jpg");
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
EXPECT_EQ(2U, web_ui()->call_data().size());
// When the primary account is ready, setUserImageURL happens before
// clearFocus since the image URL is known before showing the dialog.
EXPECT_EQ("sync.confirmation.setUserImageURL",
web_ui()->call_data()[0]->function_name());
EXPECT_TRUE(web_ui()->call_data()[0]->arg1()->is_string());
std::string passed_picture_url;
EXPECT_TRUE(
web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url));
EXPECT_EQ("sync.confirmation.clearFocus",
web_ui()->call_data()[1]->function_name());
identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile());
base::Optional<AccountInfo> primary_account_info =
identity_manager->FindExtendedAccountInfoForAccount(
identity_manager->GetPrimaryAccountInfo());
std::string original_picture_url =
primary_account_info ? primary_account_info->picture_url : std::string();
GURL picture_url_with_size = signin::GetAvatarImageURLWithOptions(
GURL(original_picture_url), kExpectedProfileImageSize,
false /* no_silhouette */);
EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
}
TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) { TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) {
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo( identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "", account_info_.account_id, account_info_.email, account_info_.gaia, "",
...@@ -281,55 +231,6 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) { ...@@ -281,55 +231,6 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) {
web_ui()->call_data()[1]->function_name()); web_ui()->call_data()[1]->function_name());
} }
TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
TestSetImageIfPrimaryAccountReadyLater) {
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
EXPECT_EQ(2U, web_ui()->call_data().size());
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
"http://picture.example.com/picture.jpg");
EXPECT_EQ(3U, web_ui()->call_data().size());
// When the primary account isn't yet ready when the dialog is shown,
// setUserImageURL is called with the default placeholder image.
EXPECT_EQ("sync.confirmation.setUserImageURL",
web_ui()->call_data()[0]->function_name());
EXPECT_TRUE(web_ui()->call_data()[0]->arg1()->is_string());
std::string passed_picture_url;
EXPECT_TRUE(
web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url));
EXPECT_EQ(profiles::GetPlaceholderAvatarIconUrl(), passed_picture_url);
// When the primary account isn't yet ready when the dialog is shown,
// clearFocus is called before the second call to setUserImageURL.
EXPECT_EQ("sync.confirmation.clearFocus",
web_ui()->call_data()[1]->function_name());
EXPECT_EQ("sync.confirmation.setUserImageURL",
web_ui()->call_data()[2]->function_name());
EXPECT_TRUE(web_ui()->call_data()[2]->arg1()->is_string());
EXPECT_TRUE(
web_ui()->call_data()[2]->arg1()->GetAsString(&passed_picture_url));
identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile());
base::Optional<AccountInfo> primary_account_info =
identity_manager->FindExtendedAccountInfoForAccount(
identity_manager->GetPrimaryAccountInfo());
std::string original_picture_url =
primary_account_info ? primary_account_info->picture_url : std::string();
GURL picture_url_with_size = signin::GetAvatarImageURLWithOptions(
GURL(original_picture_url), kExpectedProfileImageSize,
false /* no_silhouette */);
EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
}
TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
base::ListValue args; base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight)); args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
...@@ -349,36 +250,6 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { ...@@ -349,36 +250,6 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
ExpectAccountImageChanged(*web_ui()->call_data()[2]); ExpectAccountImageChanged(*web_ui()->call_data()[2]);
} }
TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
TestSetImageIgnoredIfSecondaryAccountUpdated) {
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
EXPECT_EQ(2U, web_ui()->call_data().size());
AccountInfo account_info =
identity_test_env()->MakeAccountAvailable("bar@example.com");
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info.account_id, account_info.email, account_info.gaia, "",
"bar_full_name", "bar_given_name", "bar_locale",
"http://picture.example.com/bar_picture.jpg");
// Updating the account info of a secondary account should not update the
// image of the sync confirmation dialog.
EXPECT_EQ(2U, web_ui()->call_data().size());
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
"http://picture.example.com/picture.jpg");
// Updating the account info of the primary account should update the
// image of the sync confirmation dialog.
EXPECT_EQ(3U, web_ui()->call_data().size());
EXPECT_EQ("sync.confirmation.setUserImageURL",
web_ui()->call_data()[2]->function_name());
}
TEST_F(SyncConfirmationHandlerTest, TEST_F(SyncConfirmationHandlerTest,
TestSetImageIgnoredIfSecondaryAccountUpdated) { TestSetImageIgnoredIfSecondaryAccountUpdated) {
base::ListValue args; base::ListValue args;
......
...@@ -29,10 +29,9 @@ ...@@ -29,10 +29,9 @@
SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
: SigninWebDialogUI(web_ui), : SigninWebDialogUI(web_ui),
consent_feature_(consent_auditor::Feature::CHROME_SYNC) { consent_feature_(consent_auditor::Feature::CHROME_SYNC) {
DCHECK(unified_consent::IsUnifiedConsentFeatureEnabled());
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
bool is_sync_allowed = profile->IsSyncAllowed(); bool is_sync_allowed = profile->IsSyncAllowed();
bool is_unified_consent_enabled =
unified_consent::IsUnifiedConsentFeatureEnabled();
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost); content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost);
...@@ -42,7 +41,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) ...@@ -42,7 +41,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
int title_ids = -1; int title_ids = -1;
int confirm_button_ids = -1; int confirm_button_ids = -1;
int undo_button_ids = -1; int undo_button_ids = -1;
if (is_unified_consent_enabled && is_sync_allowed) { if (is_sync_allowed) {
source->SetDefaultResource(IDR_DICE_SYNC_CONFIRMATION_HTML); source->SetDefaultResource(IDR_DICE_SYNC_CONFIRMATION_HTML);
source->AddResourcePath("sync_confirmation_browser_proxy.html", source->AddResourcePath("sync_confirmation_browser_proxy.html",
IDR_DICE_SYNC_CONFIRMATION_BROWSER_PROXY_HTML); IDR_DICE_SYNC_CONFIRMATION_BROWSER_PROXY_HTML);
...@@ -90,33 +89,13 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) ...@@ -90,33 +89,13 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
} else { } else {
source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS); source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS);
source->AddBoolean("isSyncAllowed", is_sync_allowed);
AddStringResource(source, "syncConfirmationChromeSyncTitle",
IDS_SYNC_CONFIRMATION_CHROME_SYNC_TITLE);
AddStringResource(source, "syncConfirmationChromeSyncBody",
IDS_SYNC_CONFIRMATION_CHROME_SYNC_MESSAGE);
AddStringResource(source, "syncConfirmationPersonalizeServicesTitle",
IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_TITLE);
AddStringResource(source, "syncConfirmationPersonalizeServicesBody",
IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_BODY);
AddStringResource(source, "syncConfirmationSyncSettingsLinkBody",
IDS_SYNC_CONFIRMATION_SYNC_SETTINGS_LINK_BODY);
AddStringResource(source, "syncDisabledConfirmationDetails", AddStringResource(source, "syncDisabledConfirmationDetails",
IDS_SYNC_DISABLED_CONFIRMATION_DETAILS); IDS_SYNC_DISABLED_CONFIRMATION_DETAILS);
title_ids = AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)
? IDS_SYNC_CONFIRMATION_DICE_TITLE
: IDS_SYNC_CONFIRMATION_TITLE;
confirm_button_ids = IDS_SETTINGS_TURN_ON;
undo_button_ids = IDS_CANCEL;
consent_feature_ = consent_auditor::Feature::CHROME_SYNC;
if (!is_sync_allowed) {
title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE; title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE;
confirm_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL; confirm_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL;
undo_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_UNDO_BUTTON_LABEL; undo_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_UNDO_BUTTON_LABEL;
} consent_feature_ = consent_auditor::Feature::CHROME_SYNC;
} }
DCHECK_GE(title_ids, 0); DCHECK_GE(title_ids, 0);
......
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