Commit 7e057ae4 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[Dice] Add sync-paused UI to user menu

When Dice is enabled and the profile is in an
auth error state, the user menu displays a
"sync paused" UI.

Additionally, the avatar button contains a
sync-paused icon instead of an error icon.

Screenshot:
https://drive.google.com/file/d/1JwI9-MxoiMoSCYTJoHNBkz877lnwu75r/view?usp=sharing

Bug: 825533
Change-Id: I36760bedd2eb1f2e9875b570a3d90b3bfae8476a
Reviewed-on: https://chromium-review.googlesource.com/998112Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549142}
parent 77972364
...@@ -7400,6 +7400,9 @@ I don't think this site should be blocked! ...@@ -7400,6 +7400,9 @@ I don't think this site should be blocked!
<message name="IDS_PROFILES_DICE_SIGNIN_WITH_ANOTHER_ACCOUNT_BUTTON" desc="Button to sign in and turn on Sync with another web account."> <message name="IDS_PROFILES_DICE_SIGNIN_WITH_ANOTHER_ACCOUNT_BUTTON" desc="Button to sign in and turn on Sync with another web account.">
Sync to another account Sync to another account
</message> </message>
<message name="IDS_PROFILES_DICE_SYNC_PAUSED_TITLE" desc="Title of the profile user menu when sync is paused.">
Sync is paused
</message>
<message name="IDS_PROFILES_DICE_USE_ANOTHER_ACCOUNT_BUTTON" desc="Button to use another account to sign in and turn on Sync."> <message name="IDS_PROFILES_DICE_USE_ANOTHER_ACCOUNT_BUTTON" desc="Button to use another account to sign in and turn on Sync.">
Use another account Use another account
</message> </message>
......
...@@ -85,6 +85,8 @@ aggregate_vector_icons("chrome_vector_icons") { ...@@ -85,6 +85,8 @@ aggregate_vector_icons("chrome_vector_icons") {
"sync.icon", "sync.icon",
"sync_circle.icon", "sync_circle.icon",
"sync_error_circle.icon", "sync_error_circle.icon",
"sync_paused.icon",
"sync_paused_circle.icon",
"sync_problem.icon", "sync_problem.icon",
"sync_switch_account.icon", "sync_switch_account.icon",
"tab.icon", "tab.icon",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 16,
MOVE_TO, 2, 2,
R_H_LINE_TO, 12,
R_V_LINE_TO, 12,
H_LINE_TO, 2,
V_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 0, 0,
R_H_LINE_TO, 12,
R_V_LINE_TO, 12,
H_LINE_TO, 2,
V_LINE_TO, 2,
CLOSE,
MOVE_TO, 7, 5.18f,
V_LINE_TO, 4.13f,
R_CUBIC_TO, -0.4f, 0.11f, -0.77f, 0.27f, -1.11f, 0.48f,
R_LINE_TO, 0.73f, 0.73f,
R_CUBIC_TO, 0.13f, -0.06f, 0.25f, -0.12f, 0.39f, -0.16f,
CLOSE,
R_MOVE_TO, -3.57f, -0.47f,
R_LINE_TO, 1.18f, 1.18f,
R_ARC_TO, 3.96f, 3.96f, 0, 0, 0, 0.57f, 4.93f,
LINE_TO, 4, 12,
R_H_LINE_TO, 3,
V_LINE_TO, 9,
R_LINE_TO, -1.12f, 1.12f,
ARC_TO, 3, 3, 0, 0, 1, 5, 8,
R_CUBIC_TO, 0, -0.5f, 0.13f, -0.97f, 0.34f, -1.38f,
R_LINE_TO, 4.04f, 4.04f,
R_CUBIC_TO, -0.12f, 0.07f, -0.25f, 0.13f, -0.38f, 0.17f,
R_V_LINE_TO, 1.05f,
R_CUBIC_TO, 0.4f, -0.1f, 0.78f, -0.27f, 1.12f, -0.48f,
R_LINE_TO, 1.18f, 1.18f,
R_LINE_TO, 0.64f, -0.63f,
LINE_TO, 4.07f, 4.07f,
R_LINE_TO, -0.64f, 0.64f,
CLOSE,
MOVE_TO, 12, 4,
H_LINE_TO, 9,
R_V_LINE_TO, 3,
R_LINE_TO, 1.12f, -1.12f,
R_CUBIC_TO, 0.54f, 0.55f, 0.88f, 1.29f, 0.88f, 2.12f,
R_CUBIC_TO, 0, 0.5f, -0.12f, 0.97f, -0.34f, 1.39f,
R_LINE_TO, 0.73f, 0.73f,
R_ARC_TO, 3.96f, 3.96f, 0, 0, 0, -0.57f, -4.93f,
LINE_TO, 12, 4,
CLOSE
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 16,
CIRCLE, 8, 8, 8,
MOVE_TO, 2, 2,
R_H_LINE_TO, 12,
R_V_LINE_TO, 12,
H_LINE_TO, 2,
V_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 0, 0,
R_H_LINE_TO, 12,
R_V_LINE_TO, 12,
H_LINE_TO, 2,
V_LINE_TO, 2,
CLOSE,
MOVE_TO, 7, 5.18f,
V_LINE_TO, 4.13f,
R_CUBIC_TO, -0.4f, 0.11f, -0.77f, 0.27f, -1.11f, 0.48f,
R_LINE_TO, 0.73f, 0.73f,
R_CUBIC_TO, 0.13f, -0.06f, 0.25f, -0.12f, 0.39f, -0.16f,
CLOSE,
R_MOVE_TO, -3.57f, -0.47f,
R_LINE_TO, 1.18f, 1.18f,
R_ARC_TO, 3.96f, 3.96f, 0, 0, 0, 0.57f, 4.93f,
LINE_TO, 4, 12,
R_H_LINE_TO, 3,
V_LINE_TO, 9,
R_LINE_TO, -1.12f, 1.12f,
ARC_TO, 3, 3, 0, 0, 1, 5, 8,
R_CUBIC_TO, 0, -0.5f, 0.13f, -0.97f, 0.34f, -1.38f,
R_LINE_TO, 4.04f, 4.04f,
R_CUBIC_TO, -0.12f, 0.07f, -0.25f, 0.13f, -0.38f, 0.17f,
R_V_LINE_TO, 1.05f,
R_CUBIC_TO, 0.4f, -0.1f, 0.78f, -0.27f, 1.12f, -0.48f,
R_LINE_TO, 1.18f, 1.18f,
R_LINE_TO, 0.64f, -0.63f,
LINE_TO, 4.07f, 4.07f,
R_LINE_TO, -0.64f, 0.64f,
CLOSE,
MOVE_TO, 12, 4,
H_LINE_TO, 9,
R_V_LINE_TO, 3,
R_LINE_TO, 1.12f, -1.12f,
R_CUBIC_TO, 0.54f, 0.55f, 0.88f, 1.29f, 0.88f, 2.12f,
R_CUBIC_TO, 0, 0.5f, -0.12f, 0.97f, -0.34f, 1.39f,
R_LINE_TO, 0.73f, 0.73f,
R_ARC_TO, 3.96f, 3.96f, 0, 0, 0, -0.57f, -4.93f,
LINE_TO, 12, 4,
CLOSE
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service.h"
...@@ -503,8 +504,19 @@ void AvatarButton::Update() { ...@@ -503,8 +504,19 @@ void AvatarButton::Update() {
if (use_generic_button) { if (use_generic_button) {
SetImage(views::Button::STATE_NORMAL, generic_avatar_); SetImage(views::Button::STATE_NORMAL, generic_avatar_);
} else if (error_controller_.HasAvatarError()) { } else if (error_controller_.HasAvatarError()) {
SetImage(views::Button::STATE_NORMAL, // When DICE is enabled and the error is an auth error, the sync-paused icon
gfx::CreateVectorIcon(kSyncProblemIcon, 16, gfx::kGoogleRed700)); // is shown.
int dummy;
const bool should_show_sync_paused_ui =
AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_) &&
sync_ui_util::GetMessagesForAvatarSyncError(
profile_, *SigninManagerFactory::GetForProfile(profile_), &dummy,
&dummy) == sync_ui_util::AUTH_ERROR;
SetImage(
views::Button::STATE_NORMAL,
should_show_sync_paused_ui
? gfx::CreateVectorIcon(kSyncPausedIcon, 16, gfx::kGoogleBlue500)
: gfx::CreateVectorIcon(kSyncProblemIcon, 16, gfx::kGoogleRed700));
} else { } else {
SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia()); SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia());
} }
......
...@@ -67,6 +67,9 @@ gfx::ImageSkia ImageForBadgeType(BadgedProfilePhoto::BadgeType badge_type) { ...@@ -67,6 +67,9 @@ gfx::ImageSkia ImageForBadgeType(BadgedProfilePhoto::BadgeType badge_type) {
case BadgedProfilePhoto::BADGE_TYPE_SYNC_ERROR: case BadgedProfilePhoto::BADGE_TYPE_SYNC_ERROR:
return gfx::CreateVectorIcon(kSyncErrorCircleIcon, kBadgeIconSize, return gfx::CreateVectorIcon(kSyncErrorCircleIcon, kBadgeIconSize,
gfx::kGoogleRed700); gfx::kGoogleRed700);
case BadgedProfilePhoto::BADGE_TYPE_SYNC_PAUSED:
return gfx::CreateVectorIcon(kSyncPausedCircleIcon, kBadgeIconSize,
gfx::kGoogleBlue500);
case BadgedProfilePhoto::BADGE_TYPE_NONE: case BadgedProfilePhoto::BADGE_TYPE_NONE:
NOTREACHED(); NOTREACHED();
return gfx::ImageSkia(); return gfx::ImageSkia();
......
...@@ -21,6 +21,7 @@ class BadgedProfilePhoto : public views::View { ...@@ -21,6 +21,7 @@ class BadgedProfilePhoto : public views::View {
BADGE_TYPE_CHILD, BADGE_TYPE_CHILD,
BADGE_TYPE_SYNC_COMPLETE, BADGE_TYPE_SYNC_COMPLETE,
BADGE_TYPE_SYNC_ERROR, BADGE_TYPE_SYNC_ERROR,
BADGE_TYPE_SYNC_PAUSED,
}; };
static const char kViewClassName[]; static const char kViewClassName[];
......
...@@ -926,14 +926,22 @@ views::View* ProfileChooserView::CreateDiceSyncErrorView( ...@@ -926,14 +926,22 @@ views::View* ProfileChooserView::CreateDiceSyncErrorView(
view->SetLayoutManager(std::make_unique<views::BoxLayout>( view->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kVertical, gfx::Insets(kMenuEdgeMargin), views::BoxLayout::kVertical, gfx::Insets(kMenuEdgeMargin),
kMenuEdgeMargin)); kMenuEdgeMargin));
const bool show_sync_paused_ui = error == sync_ui_util::AUTH_ERROR;
// Add profile hover button. // Add profile hover button.
auto current_profile_photo = std::make_unique<BadgedProfilePhoto>( auto current_profile_photo = std::make_unique<BadgedProfilePhoto>(
BadgedProfilePhoto::BADGE_TYPE_SYNC_ERROR, avatar_item.icon); show_sync_paused_ui ? BadgedProfilePhoto::BADGE_TYPE_SYNC_PAUSED
HoverButton* current_profile = : BadgedProfilePhoto::BADGE_TYPE_SYNC_ERROR,
new HoverButton(this, std::move(current_profile_photo), avatar_item.icon);
l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE), HoverButton* current_profile = new HoverButton(
avatar_item.username); this, std::move(current_profile_photo),
current_profile->SetStyle(HoverButton::STYLE_ERROR); l10n_util::GetStringUTF16(show_sync_paused_ui
? IDS_PROFILES_DICE_SYNC_PAUSED_TITLE
: IDS_SYNC_ERROR_USER_MENU_TITLE),
avatar_item.username);
if (!show_sync_paused_ui)
current_profile->SetStyle(HoverButton::STYLE_ERROR);
current_profile->SetEnabled(false); current_profile->SetEnabled(false);
// Remove the default |HoverButton| border from |current_profile| so the // Remove the default |HoverButton| border from |current_profile| so the
// insets of |BoxLayout| are used for aligment instead. // insets of |BoxLayout| are used for aligment instead.
......
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