Commit 73b32fca authored by merkulova's avatar merkulova Committed by Commit bot

Tray message changed for child accounts. Warning bubble removed for child accounts.

BUG=435130, 439941

CL based on https://chromereviews.googleplex.com/

TBR=jennyz@chromium.org

Review URL: https://codereview.chromium.org/783963002

Cr-Commit-Position: refs/heads/master@{#309427}
parent bd9874ec
......@@ -82,6 +82,7 @@ void TraySupervisedUser::UpdateAfterLoginStatusChange(
return;
if (is_user_supervised &&
!delegate->IsUserChild() &&
status_ != ash::user::LOGGED_IN_LOCKED &&
!delegate->GetSupervisedUserManager().empty())
CreateOrUpdateSupervisedWarningNotification();
......@@ -113,9 +114,11 @@ void TraySupervisedUser::OnCustodianInfoChanged() {
SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
std::string manager_name = delegate->GetSupervisedUserManager();
if (!manager_name.empty()) {
if (!message_center::MessageCenter::Get()->FindVisibleNotificationById(
kNotificationId))
if (!delegate->IsUserChild() &&
!message_center::MessageCenter::Get()->FindVisibleNotificationById(
kNotificationId)) {
CreateOrUpdateSupervisedWarningNotification();
}
UpdateMessage();
}
}
......
......@@ -86,6 +86,10 @@ bool DefaultSystemTrayDelegate::IsUserSupervised() const {
return GetUserLoginStatus() == ash::user::LOGGED_IN_SUPERVISED;
}
bool DefaultSystemTrayDelegate::IsUserChild() const {
return false;
}
void DefaultSystemTrayDelegate::GetSystemUpdateInfo(UpdateInfo* info) const {
DCHECK(info);
info->severity = UpdateInfo::UPDATE_NORMAL;
......
......@@ -29,6 +29,7 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate {
const base::string16 GetSupervisedUserManagerName() const override;
const base::string16 GetSupervisedUserMessage() const override;
bool IsUserSupervised() const override;
bool IsUserChild() const override;
void GetSystemUpdateInfo(UpdateInfo* info) const override;
base::HourClockType GetHourClockType() const override;
void ShowSettings() override;
......
......@@ -137,9 +137,15 @@ 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.
// Returns true if the current user is supervised: has legacy supervised
// account or kid account.
virtual bool IsUserSupervised() const = 0;
// Returns true if the current user is child.
// TODO(merkulova): remove on FakeUserManager componentization.
// crbug.com/443119
virtual bool IsUserChild() const = 0;
// Fills |info| structure with current update info.
virtual void GetSystemUpdateInfo(UpdateInfo* info) const = 0;
......
......@@ -1688,6 +1688,12 @@ Press any key to continue exploring.
<message name="IDS_USER_IS_SUPERVISED_BY_NOTICE" desc="Text for notifications showing that this user is supervised">
Usage and history of this user can be reviewed by the manager (<ph name="MANAGER_EMAIL">$1<ex>user@example.com</ex></ph>) on chrome.com.
</message>
<message name="IDS_CHILD_USER_IS_MANAGED_BY_ONE_PARENT_NOTICE" desc="Text for notifications showing that this child user is managed by parent's account.">
This is an account for kids managed by <ph name="MANAGER_EMAIL">$1<ex>user@example.com</ex></ph>
</message>
<message name="IDS_CHILD_USER_IS_MANAGED_BY_TWO_PARENTS_NOTICE" desc="Text for notifications showing that this child user is managed by two parents' accounts.">
This is an account for kids managed by <ph name="FIRST_PARENT_EMAIL">$1<ex>first@example.com</ex></ph> and <ph name="SECOND_PARENT_EMAIL">$2<ex>second@example.com</ex></ph>
</message>
<message name="IDS_SUPERVISED_USER_EXPIRED_TOKEN_WARNING" desc="Warning text that is shown on login screen trying to sign in as a supervised user that has expired token">
This supervised user may have been deleted or disabled by the manager. Please contact the manager if you would like to continue signing in as this user.
</message>
......
......@@ -110,6 +110,11 @@
#include "ui/chromeos/ime/input_method_menu_item.h"
#include "ui/chromeos/ime/input_method_menu_manager.h"
#if defined(ENABLE_SUPERVISED_USERS)
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
namespace chromeos {
namespace {
......@@ -395,12 +400,9 @@ const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
const {
if (!IsUserSupervised())
return base::string16();
std::string user_manager_name = GetSupervisedUserManager();
LOG_IF(WARNING, user_manager_name.empty()) <<
"Returning incomplete supervised user message as manager not known yet.";
return l10n_util::GetStringFUTF16(
IDS_USER_IS_SUPERVISED_BY_NOTICE,
base::UTF8ToUTF16(user_manager_name));
if (IsUserChild())
return GetChildUserMessage();
return GetLegacySupervisedUserMessage();
}
bool SystemTrayDelegateChromeOS::IsUserSupervised() const {
......@@ -408,6 +410,10 @@ bool SystemTrayDelegateChromeOS::IsUserSupervised() const {
return user && user->IsSupervised();
}
bool SystemTrayDelegateChromeOS::IsUserChild() const {
return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
}
void SystemTrayDelegateChromeOS::GetSystemUpdateInfo(
ash::UpdateInfo* info) const {
GetUpdateInfo(UpgradeDetector::GetInstance(), info);
......@@ -1318,6 +1324,41 @@ void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
OnAccessibilityModeChanged(details.notify);
}
const base::string16
SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const {
std::string user_manager_name = GetSupervisedUserManager();
return l10n_util::GetStringFUTF16(
IDS_USER_IS_SUPERVISED_BY_NOTICE,
base::UTF8ToUTF16(user_manager_name));
}
const base::string16
SystemTrayDelegateChromeOS::GetChildUserMessage() const {
#if defined(ENABLE_SUPERVISED_USERS)
SupervisedUserService* service =
SupervisedUserServiceFactory::GetForProfile(user_profile_);
base::string16 first_custodian =
base::UTF8ToUTF16(service->GetCustodianEmailAddress());
base::string16 second_custodian =
base::UTF8ToUTF16(service->GetSecondCustodianEmailAddress());
LOG_IF(WARNING, first_custodian.empty()) <<
"Returning incomplete child user message as manager not known yet.";
if (second_custodian.empty()) {
return l10n_util::GetStringFUTF16(
IDS_CHILD_USER_IS_MANAGED_BY_ONE_PARENT_NOTICE, first_custodian);
} else {
return l10n_util::GetStringFUTF16(
IDS_CHILD_USER_IS_MANAGED_BY_TWO_PARENTS_NOTICE,
first_custodian,
second_custodian);
}
#endif
LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
<< "ENABLE_SUPERVISED_USERS undefined.";
return base::string16();
}
ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
return new SystemTrayDelegateChromeOS();
}
......
......@@ -78,6 +78,7 @@ class SystemTrayDelegateChromeOS
const base::string16 GetSupervisedUserManagerName() const override;
const base::string16 GetSupervisedUserMessage() const override;
bool IsUserSupervised() const override;
bool IsUserChild() const override;
void GetSystemUpdateInfo(ash::UpdateInfo* info) const override;
base::HourClockType GetHourClockType() const override;
void ShowSettings() override;
......@@ -252,6 +253,10 @@ class SystemTrayDelegateChromeOS
void OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details);
// helper methods used by GetSupervisedUserMessage.
const base::string16 GetLegacySupervisedUserMessage() const;
const base::string16 GetChildUserMessage() const;
scoped_ptr<content::NotificationRegistrar> registrar_;
scoped_ptr<PrefChangeRegistrar> local_state_registrar_;
scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
......
......@@ -81,6 +81,10 @@ bool SystemTrayDelegateCommon::IsUserSupervised() const {
return false;
}
bool SystemTrayDelegateCommon::IsUserChild() const {
return false;
}
void SystemTrayDelegateCommon::GetSystemUpdateInfo(
ash::UpdateInfo* info) const {
GetUpdateInfo(UpgradeDetector::GetInstance(), info);
......
......@@ -39,6 +39,7 @@ class SystemTrayDelegateCommon : public ash::SystemTrayDelegate,
const base::string16 GetSupervisedUserManagerName() const override;
const base::string16 GetSupervisedUserMessage() const override;
bool IsUserSupervised() const override;
bool IsUserChild() const override;
void GetSystemUpdateInfo(ash::UpdateInfo* info) const override;
base::HourClockType GetHourClockType() const override;
void ShowSettings() override;
......
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