summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authormerkulova <merkulova@chromium.org>2014-09-23 01:51:07 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-23 08:51:23 +0000
commit03a72b3faa290ad25a356f247e2d7907b3dfe1af (patch)
tree120b47357770970cd77d72d35899f0f2f067dfa6 /ash
parent357e910cfff921cb0721ca51beac25cc69e25c90 (diff)
downloadchromium_src-03a72b3faa290ad25a356f247e2d7907b3dfe1af.zip
chromium_src-03a72b3faa290ad25a356f247e2d7907b3dfe1af.tar.gz
chromium_src-03a72b3faa290ad25a356f247e2d7907b3dfe1af.tar.bz2
ash: Add checks for supervised users.
Propagate the user's supervised state to the ash system so that it becomes available for views https://chromereviews.googleplex.com/79527013/ BUG=394417 Committed: https://crrev.com/8616ac4cf7bd77f53dc001eb9d8d61c6c975eaaa Cr-Commit-Position: refs/heads/master@{#294821} Review URL: https://codereview.chromium.org/561713002 Cr-Commit-Position: refs/heads/master@{#296160}
Diffstat (limited to 'ash')
-rw-r--r--ash/shelf/shelf_widget.cc3
-rw-r--r--ash/system/chromeos/supervised/tray_supervised_user.cc16
-rw-r--r--ash/system/chromeos/supervised/tray_supervised_user.h5
-rw-r--r--ash/system/tray/default_system_tray_delegate.cc4
-rw-r--r--ash/system/tray/default_system_tray_delegate.h1
-rw-r--r--ash/system/tray/system_tray_delegate.h3
-rw-r--r--ash/system/user/tray_user.cc5
-rw-r--r--ash/system/user/user_card_view.cc4
-rw-r--r--ash/test/test_system_tray_delegate.cc5
-rw-r--r--ash/test/test_system_tray_delegate.h1
10 files changed, 39 insertions, 8 deletions
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index f912011..2d89253 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -714,6 +714,9 @@ bool ShelfWidget::IsShelfHiddenBehindBlackBar() const {
// static
bool ShelfWidget::ShelfAlignmentAllowed() {
+ if (Shell::GetInstance()->system_tray_delegate()->IsUserSupervised())
+ return false;
+
user::LoginStatus login_status =
Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus();
diff --git a/ash/system/chromeos/supervised/tray_supervised_user.cc b/ash/system/chromeos/supervised/tray_supervised_user.cc
index f85d0fe..31ddb39 100644
--- a/ash/system/chromeos/supervised/tray_supervised_user.cc
+++ b/ash/system/chromeos/supervised/tray_supervised_user.cc
@@ -29,7 +29,8 @@ const char TraySupervisedUser::kNotificationId[] =
TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray)
: SystemTrayItem(system_tray),
tray_view_(NULL),
- status_(ash::user::LOGGED_IN_NONE) {
+ status_(ash::user::LOGGED_IN_NONE),
+ is_user_supervised_(false) {
}
TraySupervisedUser::~TraySupervisedUser() {
@@ -48,7 +49,8 @@ void TraySupervisedUser::UpdateMessage() {
views::View* TraySupervisedUser::CreateDefaultView(
user::LoginStatus status) {
CHECK(tray_view_ == NULL);
- if (status != ash::user::LOGGED_IN_SUPERVISED)
+ SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
+ if (!delegate->IsUserSupervised())
return NULL;
tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_SUPERVISED_USER);
@@ -66,14 +68,18 @@ void TraySupervisedUser::OnViewClicked(views::View* sender) {
void TraySupervisedUser::UpdateAfterLoginStatusChange(
user::LoginStatus status) {
- if (status == status_)
+ SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
+
+ bool is_user_supervised = delegate->IsUserSupervised();
+ if (status == status_ && is_user_supervised == is_user_supervised_)
return;
- if (status == ash::user::LOGGED_IN_SUPERVISED &&
+
+ if (is_user_supervised &&
status_ != ash::user::LOGGED_IN_LOCKED) {
- SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
CreateOrUpdateNotification(delegate->GetSupervisedUserMessage());
}
status_ = status;
+ is_user_supervised_ = is_user_supervised;
}
void TraySupervisedUser::CreateOrUpdateNotification(
diff --git a/ash/system/chromeos/supervised/tray_supervised_user.h b/ash/system/chromeos/supervised/tray_supervised_user.h
index dbad222..5d07d25 100644
--- a/ash/system/chromeos/supervised/tray_supervised_user.h
+++ b/ash/system/chromeos/supervised/tray_supervised_user.h
@@ -15,7 +15,7 @@ class LabelTrayView;
class SystemTray;
class ASH_EXPORT TraySupervisedUser : public SystemTrayItem,
- public ViewClickListener {
+ public ViewClickListener {
public:
explicit TraySupervisedUser(SystemTray* system_tray);
virtual ~TraySupervisedUser();
@@ -43,6 +43,9 @@ class ASH_EXPORT TraySupervisedUser : public SystemTrayItem,
// Previous login status to avoid showing notification upon unlock.
user::LoginStatus status_;
+ // Previous user supervised state to avoid showing notification upon unlock.
+ bool is_user_supervised_;
+
DISALLOW_COPY_AND_ASSIGN(TraySupervisedUser);
};
diff --git a/ash/system/tray/default_system_tray_delegate.cc b/ash/system/tray/default_system_tray_delegate.cc
index e2aeae3..fde3f3d 100644
--- a/ash/system/tray/default_system_tray_delegate.cc
+++ b/ash/system/tray/default_system_tray_delegate.cc
@@ -86,6 +86,10 @@ const base::string16 DefaultSystemTrayDelegate::GetSupervisedUserMessage()
return base::string16();
}
+bool DefaultSystemTrayDelegate::IsUserSupervised() const {
+ return false;
+}
+
bool DefaultSystemTrayDelegate::SystemShouldUpgrade() const {
return true;
}
diff --git a/ash/system/tray/default_system_tray_delegate.h b/ash/system/tray/default_system_tray_delegate.h
index 0c7625b..5b88b01 100644
--- a/ash/system/tray/default_system_tray_delegate.h
+++ b/ash/system/tray/default_system_tray_delegate.h
@@ -29,6 +29,7 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate {
virtual const base::string16 GetSupervisedUserManagerName() const
OVERRIDE;
virtual const base::string16 GetSupervisedUserMessage() const OVERRIDE;
+ virtual bool IsUserSupervised() const OVERRIDE;
virtual bool SystemShouldUpgrade() const OVERRIDE;
virtual base::HourClockType GetHourClockType() const OVERRIDE;
virtual void ShowSettings() OVERRIDE;
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index de86112..f235fb2 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -119,6 +119,9 @@ class ASH_EXPORT SystemTrayDelegate {
// Returns the notification for supervised users.
virtual const base::string16 GetSupervisedUserMessage() const = 0;
+ // Returns true if the current user is supervised.
+ virtual bool IsUserSupervised() const = 0;
+
// Returns whether a system upgrade is available.
virtual bool SystemShouldUpgrade() const = 0;
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index 9851ba1..dcac2a9 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -137,6 +137,9 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
return;
bool need_label = false;
bool need_avatar = false;
+ SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
+ if (delegate->IsUserSupervised())
+ need_label = true;
switch (status) {
case user::LOGGED_IN_LOCKED:
case user::LOGGED_IN_USER:
@@ -175,7 +178,7 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
}
}
- if (status == user::LOGGED_IN_SUPERVISED) {
+ if (delegate->IsUserSupervised()) {
label_->SetText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL));
} else if (status == user::LOGGED_IN_GUEST) {
diff --git a/ash/system/user/user_card_view.cc b/ash/system/user/user_card_view.cc
index d0b77ab..5f46e2a 100644
--- a/ash/system/user/user_card_view.cc
+++ b/ash/system/user/user_card_view.cc
@@ -394,8 +394,10 @@ void UserCardView::AddUserContent(user::LoginStatus login_status,
views::Label* user_email = NULL;
if (login_status != user::LOGGED_IN_GUEST &&
(multiprofile_index || !IsMultiAccountSupportedAndUserActive())) {
+ SystemTrayDelegate* tray_delegate =
+ Shell::GetInstance()->system_tray_delegate();
base::string16 user_email_string =
- login_status == user::LOGGED_IN_SUPERVISED
+ tray_delegate->IsUserSupervised()
? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)
: base::UTF8ToUTF16(
delegate->GetUserInfo(multiprofile_index)->GetEmail());
diff --git a/ash/test/test_system_tray_delegate.cc b/ash/test/test_system_tray_delegate.cc
index c4a45b9..60fb4b3 100644
--- a/ash/test/test_system_tray_delegate.cc
+++ b/ash/test/test_system_tray_delegate.cc
@@ -8,6 +8,7 @@
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
+#include "ash/system/user/login_status.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
@@ -69,6 +70,10 @@ user::LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const {
return login_status_;
}
+bool TestSystemTrayDelegate::IsUserSupervised() const {
+ return login_status_ == ash::user::LOGGED_IN_SUPERVISED;
+}
+
bool TestSystemTrayDelegate::ShouldShowDisplayNotification() {
return should_show_display_notification_;
}
diff --git a/ash/test/test_system_tray_delegate.h b/ash/test/test_system_tray_delegate.h
index 9b85d97..1a64ac1 100644
--- a/ash/test/test_system_tray_delegate.h
+++ b/ash/test/test_system_tray_delegate.h
@@ -43,6 +43,7 @@ class TestSystemTrayDelegate : public DefaultSystemTrayDelegate {
// Overridden from SystemTrayDelegate:
virtual user::LoginStatus GetUserLoginStatus() const OVERRIDE;
+ virtual bool IsUserSupervised() const OVERRIDE;
virtual bool ShouldShowDisplayNotification() OVERRIDE;
virtual bool GetSessionStartTime(
base::TimeTicks* session_start_time) OVERRIDE;