Skip to content

Commit

Permalink
[M115] Update icons for the tailored security dialogs (Android)
Browse files Browse the repository at this point in the history
The icons for the "sync turns on ESB" dialog box and both the
"non-sync in-flow" and "out-of-flow" are being updated to the blue
shield with the "G" in the middle. The icon for the "sync turns off ESB"
dialog box is being updated to the light gray shield. These changes are
guarded by the kTailoredSecurityUpdatedMessages feature flag.

Screenshot before (sync turns on ESB):
https://screenshot.googleplex.com/5rLH7yJhcC7tXyq.png
Screenshot after (sync turns on ESB):
https://screenshot.googleplex.com/8kHCTGViUhoMffr.png
Screenshot before (sync turns off ESB):
https://screenshot.googleplex.com/AFvo9LNrtkfasme.png
Screenshot after (sync turns off ESB):
https://screenshot.googleplex.com/Bd3NYqsAfwKtiS9.png
Screenshot before (Non-sync in-flow):
https://screenshot.googleplex.com/4Ha4WmkXovTdd72.png
Screenshot after (Non-sync in-flow):
https://screenshot.googleplex.com/AseSz2iXgdWZacD.png
Screenshot before (Non-sync out-of-flow):
https://screenshot.googleplex.com/9kZhBJxNr7h6Er3.png
Screenshot after (Non-sync out-of-flow):
https://screenshot.googleplex.com/7mXDuYZAiszGhW8.png


(cherry picked from commit fec83cf)

Bug: 1414211, 1414213, 1414215
Change-Id: Ib287f0534ce8b5b8c7e4a9b8e7ff9f2c5ffc6118
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4544428
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Commit-Queue: Awad Osman <awado@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1148126}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4575247
Cr-Commit-Position: refs/branch-heads/5790@{#189}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Awad Osman authored and Chromium LUCI CQ committed May 31, 2023
1 parent bd1eb06 commit 82a220d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 40 deletions.
2 changes: 2 additions & 0 deletions chrome/android/chrome_java_resources.gni
Expand Up @@ -351,6 +351,7 @@ chrome_java_resources = [
"java/res/drawable/bg_circle_new_tab_button_folio.xml",
"java/res/drawable/bg_tabstrip_tab_divider.xml",
"java/res/drawable/bg_white_dialog.xml",
"java/res/drawable/blue_google_shield.xml",
"java/res/drawable/bookmark_empty_state_illustration.xml",
"java/res/drawable/bookmark_save_flow_ripple.xml",
"java/res/drawable/bookmark_title_bar_shadow.xml",
Expand All @@ -372,6 +373,7 @@ chrome_java_resources = [
"java/res/drawable/distilled_page_pref_background.xml",
"java/res/drawable/distilled_page_prefs_button_bg.xml",
"java/res/drawable/google_pay_with_divider.xml",
"java/res/drawable/gray_shield.xml",
"java/res/drawable/history_empty_state_illustration.xml",
"java/res/drawable/ic_add_box_rounded_corner.xml",
"java/res/drawable/ic_add_to_home_screen.xml",
Expand Down
20 changes: 20 additions & 0 deletions chrome/android/java/res/drawable/blue_google_shield.xml
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<vector android:alpha="0.9" android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#1967D2" android:pathData="M21.6,4.73c0,-0.83 -0.52,-1.56 -1.3,-1.85l-7.64,-2.76c-0.43,-0.16 -0.91,-0.16 -1.34,0L3.7,2.88C2.92,3.16 2.4,3.9 2.4,4.73v5.25c0.02,0.9 0.09,1.77 0.21,2.66c0.57,3.82 2.73,8.15 8.64,11.18c0.47,0.24 1.03,0.24 1.5,0c5.91,-3.03 8.07,-7.36 8.64,-11.18c0.12,-0.89 0.19,-1.76 0.21,-2.66V4.73z"/>
<group>
<clip-path android:pathData="M21.6,4.73c0,-0.83 -0.52,-1.56 -1.3,-1.85l-7.64,-2.76c-0.43,-0.16 -0.91,-0.16 -1.34,0L3.7,2.88C2.92,3.16 2.4,3.9 2.4,4.73v5.25c0.02,0.9 0.09,1.77 0.21,2.66c0.57,3.82 2.73,8.15 8.64,11.18c0.47,0.24 1.03,0.24 1.5,0c5.91,-3.03 8.07,-7.36 8.64,-11.18c0.12,-0.89 0.19,-1.76 0.21,-2.66V4.73z"/>
<path android:fillColor="#185ABC" android:pathData="M0,-0.27h12v24.55h-12z"/>
</group>
<path android:fillColor="#E8F0FE" android:pathData="M12.11,16.4c-3.09,0 -5.6,-2.51 -5.6,-5.6s2.51,-5.6 5.6,-5.6c1.51,0 2.78,0.56 3.75,1.46l-1.48,1.42c-0.43,-0.4 -1.16,-0.87 -2.27,-0.87c-1.95,0 -3.53,1.61 -3.53,3.6s1.59,3.6 3.53,3.6c2.25,0 3.18,-1.62 3.27,-2.7H12V9.78h5.35c0.08,0.35 0.13,0.68 0.13,1.14C17.49,14.13 15.35,16.4 12.11,16.4z"/>
<group>
<clip-path android:pathData="M12.11,16.4c-3.09,0 -5.6,-2.51 -5.6,-5.6s2.51,-5.6 5.6,-5.6c1.51,0 2.78,0.56 3.75,1.46l-1.48,1.42c-0.43,-0.4 -1.16,-0.87 -2.27,-0.87c-1.95,0 -3.53,1.61 -3.53,3.6s1.59,3.6 3.53,3.6c2.25,0 3.18,-1.62 3.27,-2.7H12V9.78h5.35c0.08,0.35 0.13,0.68 0.13,1.14C17.49,14.13 15.35,16.4 12.11,16.4z"/>
<path android:fillColor="#D2E3FC" android:pathData="M6.4,5.2h5.6v11.2h-5.6z"/>
</group>
</vector>
12 changes: 12 additions & 0 deletions chrome/android/java/res/drawable/gray_shield.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->

<vector android:alpha="0.9" android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/darker_gray" android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12V5l-9,-4z"/>
</vector>
3 changes: 3 additions & 0 deletions chrome/browser/android/resource_id.h
Expand Up @@ -54,6 +54,9 @@ DECLARE_RESOURCE_ID(IDR_ANDORID_MESSAGE_PERMISSION_CAMERA,
DECLARE_RESOURCE_ID(IDR_ANDROID_MESSAGE_SETTINGS, R.drawable.settings_cog)
DECLARE_RESOURCE_ID(IDR_ANDROID_MESSAGE_SAFETY_CHECK, R.drawable.safety_check)
DECLARE_RESOURCE_ID(IDR_ANDROID_MESSAGE_SHIELD, R.drawable.shield)
DECLARE_RESOURCE_ID(IDR_ANDROID_MESSAGE_SHIELD_BLUE,
R.drawable.blue_google_shield)
DECLARE_RESOURCE_ID(IDR_ANDROID_MESSAGE_SHIELD_GRAY, R.drawable.gray_shield)
DECLARE_RESOURCE_ID(IDR_ANDORID_MESSAGE_PASSWORD_MANAGER_ERROR,
R.drawable.ic_key_error)
DECLARE_RESOURCE_ID(IDR_ANDROID_IC_MOBILE_FRIENDLY,
Expand Down
Expand Up @@ -60,25 +60,32 @@ TailoredSecurityConsentedModalAndroid::TailoredSecurityConsentedModalAndroid(
safe_browsing::kTailoredSecurityUpdatedMessages)) {
description = l10n_util::GetStringUTF16(
IDS_TAILORED_SECURITY_CONSENTED_ENABLE_MESSAGE_DESCRIPTION_UPDATED);
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SHIELD_BLUE);
// Need to disable tint here because it removes a shade of blue from the
// shield which distorts the image.
message_->DisableIconTint();
} else {
description = l10n_util::GetStringUTF16(
IDS_TAILORED_SECURITY_CONSENTED_ENABLE_MESSAGE_DESCRIPTION);
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SAFETY_CHECK);
}
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SAFETY_CHECK);
} else {
title = l10n_util::GetStringUTF16(
IDS_TAILORED_SECURITY_CONSENTED_DISABLE_MESSAGE_TITLE);
if (base::FeatureList::IsEnabled(
safe_browsing::kTailoredSecurityUpdatedMessages)) {
description = l10n_util::GetStringUTF16(
IDS_TAILORED_SECURITY_CONSENTED_DISABLE_MESSAGE_DESCRIPTION_UPDATED);
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SHIELD_GRAY);
} else {
description = l10n_util::GetStringUTF16(
IDS_TAILORED_SECURITY_CONSENTED_DISABLE_MESSAGE_DESCRIPTION);
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SHIELD);
}
icon_resource_id =
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SHIELD);
message_->DisableIconTint();
}
message_->SetTitle(title);
Expand Down
Expand Up @@ -114,43 +114,52 @@ TailoredSecurityUnconsentedMessageAndroid::
}
}

if (is_in_flow_) {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
if (identity_manager &&
identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSignin)) {
gfx::ImageSkia avatar_image =
identity_manager
->FindExtendedAccountInfoByAccountId(
identity_manager->GetPrimaryAccountId(
signin::ConsentLevel::kSignin))
.account_image.AsImageSkia();

gfx::ImageSkia sized_avatar_image =
gfx::ImageSkiaOperations::CreateResizedImage(
avatar_image, skia::ImageOperations::RESIZE_BEST,
gfx::Size(kAvatarSize, kAvatarSize));
gfx::ImageSkia cropped_avatar_image =
gfx::ImageSkiaOperations::CreateMaskedImage(
sized_avatar_image,
gfx::CanvasImageSource::MakeImageSkia<CircleImageSource>(
sized_avatar_image.width(), SK_ColorWHITE));
gfx::ImageSkia final_avatar_image =
gfx::ImageSkiaOperations::CreateSuperimposedImage(
gfx::CanvasImageSource::MakeImageSkia<CircleImageSource>(
kAvatarWithBorderSize, gfx::kGoogleBlue400),
cropped_avatar_image);
gfx::ImageSkia badge = gfx::CreateVectorIcon(kSafetyCheckIcon, kBadgeSize,
gfx::kGoogleBlue500);
icon_ = gfx::ImageSkiaOperations::CreateIconWithBadge(final_avatar_image,
badge);
message_->SetIcon(*icon_.bitmap());
message_->DisableIconTint();
}
} else {
if (base::FeatureList::IsEnabled(
safe_browsing::kTailoredSecurityUpdatedMessages)) {
message_->SetIconResourceId(
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SAFETY_CHECK));
ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SHIELD_BLUE));
// Need to disable tint here because it removes a shade of blue from the
// shield which distorts the image.
message_->DisableIconTint();
} else {
if (is_in_flow_) {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
if (identity_manager &&
identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSignin)) {
gfx::ImageSkia avatar_image =
identity_manager
->FindExtendedAccountInfoByAccountId(
identity_manager->GetPrimaryAccountId(
signin::ConsentLevel::kSignin))
.account_image.AsImageSkia();

gfx::ImageSkia sized_avatar_image =
gfx::ImageSkiaOperations::CreateResizedImage(
avatar_image, skia::ImageOperations::RESIZE_BEST,
gfx::Size(kAvatarSize, kAvatarSize));
gfx::ImageSkia cropped_avatar_image =
gfx::ImageSkiaOperations::CreateMaskedImage(
sized_avatar_image,
gfx::CanvasImageSource::MakeImageSkia<CircleImageSource>(
sized_avatar_image.width(), SK_ColorWHITE));
gfx::ImageSkia final_avatar_image =
gfx::ImageSkiaOperations::CreateSuperimposedImage(
gfx::CanvasImageSource::MakeImageSkia<CircleImageSource>(
kAvatarWithBorderSize, gfx::kGoogleBlue400),
cropped_avatar_image);
gfx::ImageSkia badge = gfx::CreateVectorIcon(
kSafetyCheckIcon, kBadgeSize, gfx::kGoogleBlue500);
icon_ = gfx::ImageSkiaOperations::CreateIconWithBadge(
final_avatar_image, badge);
message_->SetIcon(*icon_.bitmap());
message_->DisableIconTint();
}
} else {
message_->SetIconResourceId(ResourceMapper::MapToJavaDrawableId(
IDR_ANDROID_MESSAGE_SAFETY_CHECK));
}
}

LogMessageOutcome(TailoredSecurityOutcome::kShown, is_in_flow_);
Expand Down

0 comments on commit 82a220d

Please sign in to comment.