Commit a3f56460 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

Chrome OS: Update Supervised user icon in the system tray.

Bug: 806038
Change-Id: If82af4835f2870acf37cc902e3e2f125f4b10f7c
Reviewed-on: https://chromium-review.googlesource.com/894200
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533089}
parent fc2d18fe
// Copyright 2016 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, 20, CANVAS_DIMENSIONS, 20,
MOVE_TO, 11.62f, 9.98f, MOVE_TO, 10.32f, 2,
ARC_TO, 1.82f, 1.82f, 0, 0, 0, 10, 9.01f, LINE_TO, 4.63f, 8,
R_CUBIC_TO, -0.7f, 0, -1.31f, 0.39f, -1.62f, 0.97f, R_LINE_TO, 4.92f, 7.5f,
R_CUBIC_TO, -0.15f, 0.26f, -0.23f, 0.56f, -0.23f, 0.87f, R_LINE_TO, -0.4f, 0.6f,
R_CUBIC_TO, 0, 0.99f, 0.83f, 1.81f, 1.85f, 1.81f, R_CUBIC_TO, -0.04f, 0.07f, -0.09f, 0.12f, -0.14f, 0.18f,
R_CUBIC_TO, 1.01f, 0, 1.85f, -0.81f, 1.85f, -1.81f, R_CUBIC_TO, -0.24f, 0.25f, -0.56f, 0.39f, -0.9f, 0.39f,
R_CUBIC_TO, 0, -0.31f, -0.08f, -0.61f, -0.23f, -0.87f, R_CUBIC_TO, -0.34f, 0, -0.65f, -0.13f, -0.9f, -0.39f,
CLOSE, R_ARC_TO, 1.35f, 1.35f, 0, 0, 1, -0.37f, -0.94f,
MOVE_TO, 10, 1, R_ARC_TO, 2.72f, 2.72f, 0, 0, 0, -0.74f, -1.88f,
R_CUBIC_TO, 1.5f, 0, 2.73f, 1.2f, 2.73f, 2.67f, R_ARC_TO, 2.44f, 2.44f, 0, 0, 0, -1.78f, -0.78f,
R_CUBIC_TO, 0, 1.47f, -1.23f, 2.67f, -2.73f, 2.67f, H_LINE_TO, 4,
R_CUBIC_TO, -1.5f, 0, -2.73f, -1.2f, -2.73f, -2.67f, R_V_LINE_TO, 1.34f,
CUBIC_TO, 7.27f, 2.2f, 8.5f, 1, 10, 1, R_H_LINE_TO, 0.33f,
CLOSE, R_CUBIC_TO, 0.34f, 0, 0.65f, 0.14f, 0.9f, 0.39f,
R_MOVE_TO, -6, 9.49f, R_CUBIC_TO, 0.24f, 0.26f, 0.37f, 0.59f, 0.37f, 0.95f,
R_V_LINE_TO, 5.22f, R_CUBIC_TO, 0, 0.71f, 0.26f, 1.38f, 0.74f, 1.88f,
R_CUBIC_TO, 0, 1.05f, 1.01f, 1.95f, 2.4f, 2.55f, R_CUBIC_TO, 0.48f, 0.5f, 1.11f, 0.78f, 1.78f, 0.78f,
R_ARC_TO, 9.53f, 9.53f, 0, 0, 0, 3.6f, 0.72f, R_CUBIC_TO, 0.67f, 0, 1.31f, -0.28f, 1.78f, -0.78f,
R_CUBIC_TO, 0.31f, 0, 0.79f, 0.04f, 1.09f, 0, R_CUBIC_TO, 0.11f, -0.11f, 0.2f, -0.23f, 0.28f, -0.35f,
R_V_LINE_TO, -2.67f, R_LINE_TO, 1.27f, -1.94f,
R_CUBIC_TO, -0.27f, 0.32f, -0.78f, 0.32f, -1.09f, 0.32f, LINE_TO, 16, 8,
R_ARC_TO, 9.62f, 9.62f, 0, 0, 1, -3.54f, -0.7f, LINE_TO, 10.32f, 2,
R_CUBIC_TO, 0.31f, -0.96f, 2, -1.65f, 3.55f, -1.65f,
R_CUBIC_TO, 0.4f, 0, 0.8f, 0.05f, 1.2f, 0.14f,
R_CUBIC_TO, 1.28f, 0.28f, 2.4f, 0.98f, 2.4f, 1.83f,
R_V_LINE_TO, 2.02f,
R_CUBIC_TO, 1.39f, -0.59f, 2.4f, -1.5f, 2.4f, -2.55f,
R_V_LINE_TO, -5.22f,
R_CUBIC_TO, 0, -1.85f, -3.16f, -3.26f, -6, -3.26f,
R_CUBIC_TO, -2.84f, 0, -6, 1.41f, -6, 3.26f,
CLOSE, CLOSE,
END END
// Copyright 2016 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, 40, CANVAS_DIMENSIONS, 40,
MOVE_TO, 22.96f, 19.96f, MOVE_TO, 20.64f, 4,
ARC_TO, 3.33f, 3.33f, 0, 0, 0, 20, 18.14f, LINE_TO, 9.27f, 16,
R_ARC_TO, 3.33f, 3.33f, 0, 0, 0, -2.96f, 1.82f, R_LINE_TO, 9.84f, 14.99f,
R_ARC_TO, 3.41f, 3.41f, 0, 0, 0, -0.42f, 1.64f, R_LINE_TO, -0.8f, 1.2f,
R_CUBIC_TO, 0, 1.88f, 1.52f, 3.42f, 3.38f, 3.42f, R_CUBIC_TO, -0.08f, 0.14f, -0.18f, 0.24f, -0.28f, 0.36f,
R_CUBIC_TO, 1.86f, 0, 3.39f, -1.54f, 3.39f, -3.41f, R_CUBIC_TO, -0.48f, 0.5f, -1.11f, 0.78f, -1.79f, 0.78f,
R_ARC_TO, 3.41f, 3.41f, 0, 0, 0, -0.42f, -1.64f, R_CUBIC_TO, -0.68f, 0, -1.31f, -0.27f, -1.79f, -0.78f,
CLOSE, R_ARC_TO, 2.71f, 2.71f, 0, 0, 1, -0.74f, -1.89f,
MOVE_TO, 20, 3, R_ARC_TO, 5.44f, 5.44f, 0, 0, 0, -1.48f, -3.76f,
R_CUBIC_TO, 2.75f, 0, 5, 2.27f, 5, 5.05f, R_CUBIC_TO, -0.95f, -1.01f, -2.22f, -1.56f, -3.57f, -1.56f,
R_CUBIC_TO, 0, 2.78f, -2.25f, 5.05f, -5, 5.05f, H_LINE_TO, 8,
R_CUBIC_TO, -2.75f, 0, -5, -2.27f, -5, -5.04f, R_V_LINE_TO, 2.67f,
CUBIC_TO, 15, 5.29f, 17.25f, 3, 20, 3, R_H_LINE_TO, 0.65f,
CLOSE, R_CUBIC_TO, 0.68f, 0, 1.31f, 0.27f, 1.79f, 0.78f,
MOVE_TO, 9, 20.94f, R_CUBIC_TO, 0.48f, 0.51f, 0.74f, 1.17f, 0.74f, 1.89f,
R_V_LINE_TO, 9.85f, R_ARC_TO, 5.44f, 5.44f, 0, 0, 0, 1.48f, 3.77f,
R_CUBIC_TO, 0, 1.98f, 1.85f, 3.69f, 4.4f, 4.82f, R_CUBIC_TO, 0.95f, 1, 2.22f, 1.56f, 3.57f, 1.56f,
ARC_TO, 17.03f, 17.03f, 0, 0, 0, 20, 36.97f, R_CUBIC_TO, 1.35f, 0, 2.62f, -0.56f, 3.57f, -1.56f,
R_CUBIC_TO, 0.56f, 0, 1.44f, 0.07f, 2, 0, R_CUBIC_TO, 0.21f, -0.22f, 0.4f, -0.46f, 0.57f, -0.7f,
R_V_LINE_TO, -5.04f, R_LINE_TO, 2.55f, -3.89f,
R_CUBIC_TO, -0.5f, 0.61f, -1.44f, 0.61f, -2, 0.61f, LINE_TO, 32, 16,
R_CUBIC_TO, -2.23f, 0, -4.55f, -0.49f, -6.5f, -1.31f, LINE_TO, 20.64f, 4,
R_CUBIC_TO, 0.56f, -1.81f, 3.67f, -3.12f, 6.5f, -3.12f,
R_CUBIC_TO, 0.73f, 0, 1.47f, 0.09f, 2.2f, 0.26f,
R_CUBIC_TO, 2.35f, 0.53f, 4.4f, 1.84f, 4.4f, 3.45f,
R_V_LINE_TO, 3.81f,
R_CUBIC_TO, 2.56f, -1.11f, 4.4f, -2.83f, 4.4f, -4.82f,
R_V_LINE_TO, -9.85f,
R_CUBIC_TO, 0, -3.5f, -5.79f, -6.16f, -11, -6.16f,
CUBIC_TO, 14.79f, 14.8f, 9, 17.43f, 9, 20.94f,
CLOSE, CLOSE,
END END
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/user/tray_user.h" #include "ash/system/user/tray_user.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -21,7 +22,9 @@ ...@@ -21,7 +22,9 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -31,6 +34,14 @@ namespace { ...@@ -31,6 +34,14 @@ namespace {
const int kUserLabelToIconPadding = 5; const int kUserLabelToIconPadding = 5;
views::ImageView* CreateIcon() {
gfx::ImageSkia icon_image =
gfx::CreateVectorIcon(ash::kSystemMenuChildUserIcon, ash::kTrayIconColor);
auto* image = new views::ImageView;
image->SetImage(icon_image);
return image;
}
} // namespace } // namespace
namespace ash { namespace ash {
...@@ -85,11 +96,10 @@ void TrayUser::OnDefaultViewDestroyed() { ...@@ -85,11 +96,10 @@ void TrayUser::OnDefaultViewDestroyed() {
} }
void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) { void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) {
bool need_label = false;
bool need_avatar = false;
SessionController* session = Shell::Get()->session_controller(); SessionController* session = Shell::Get()->session_controller();
if (session->IsUserSupervised()) bool need_label = session->IsUserSupervised();
need_label = true; bool need_avatar = false;
bool need_icon = false;
switch (status) { switch (status) {
case LoginStatus::LOCKED: case LoginStatus::LOCKED:
case LoginStatus::USER: case LoginStatus::USER:
...@@ -99,7 +109,12 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) { ...@@ -99,7 +109,12 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) {
break; break;
case LoginStatus::SUPERVISED: case LoginStatus::SUPERVISED:
need_avatar = true; need_avatar = true;
need_label = true; if (session->IsUserChild()) {
need_label = false;
need_icon = true;
} else {
need_label = true;
}
break; break;
case LoginStatus::GUEST: case LoginStatus::GUEST:
need_label = true; need_label = true;
...@@ -111,28 +126,33 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) { ...@@ -111,28 +126,33 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) {
} }
if ((need_avatar != (avatar_ != nullptr)) || if ((need_avatar != (avatar_ != nullptr)) ||
(need_label != (label_ != nullptr))) { (need_label != (label_ != nullptr)) ||
(need_icon != (icon_ != nullptr))) {
delete label_; delete label_;
delete avatar_; delete avatar_;
delete icon_;
label_ = nullptr;
avatar_ = nullptr;
icon_ = nullptr;
if (need_icon) {
icon_ = CreateIcon();
layout_view_->AddChildView(icon_);
}
if (need_label) { if (need_label) {
label_ = new views::Label; label_ = new views::Label;
SetupLabelForTray(label_); SetupLabelForTray(label_);
layout_view_->AddChildView(label_); layout_view_->AddChildView(label_);
} else {
label_ = nullptr;
} }
if (need_avatar) { if (need_avatar) {
avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius);
avatar_->SetPaintToLayer(); avatar_->SetPaintToLayer();
avatar_->layer()->SetFillsBoundsOpaquely(false); avatar_->layer()->SetFillsBoundsOpaquely(false);
layout_view_->AddChildView(avatar_); layout_view_->AddChildView(avatar_);
} else {
avatar_ = nullptr;
} }
} }
if (session->IsUserSupervised()) { if (label_ && session->IsUserSupervised()) {
label_->SetText( label_->SetText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)); l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL));
} else if (status == LoginStatus::GUEST) { } else if (status == LoginStatus::GUEST) {
...@@ -141,7 +161,8 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) { ...@@ -141,7 +161,8 @@ void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) {
UpdateAvatarImage(status); UpdateAvatarImage(status);
// Update layout after setting label_ and avatar_ with new login status. // Update layout after setting label_, icon_ and avatar_ with new login
// status.
UpdateLayoutOfItem(); UpdateLayoutOfItem();
} }
......
...@@ -18,6 +18,7 @@ class Size; ...@@ -18,6 +18,7 @@ class Size;
namespace views { namespace views {
class Label; class Label;
class ImageView;
} }
namespace ash { namespace ash {
...@@ -85,6 +86,7 @@ class ASH_EXPORT TrayUser : public SystemTrayItem, public SessionObserver { ...@@ -85,6 +86,7 @@ class ASH_EXPORT TrayUser : public SystemTrayItem, public SessionObserver {
views::View* layout_view_ = nullptr; views::View* layout_view_ = nullptr;
tray::RoundedImageView* avatar_ = nullptr; tray::RoundedImageView* avatar_ = nullptr;
views::Label* label_ = nullptr; views::Label* label_ = nullptr;
views::ImageView* icon_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(TrayUser); DISALLOW_COPY_AND_ASSIGN(TrayUser);
}; };
......
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