Commit 850597a5 authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

child user: Add 'Parent access' button to the login shelf

New button is only visible for child user account. It allows parent to
authorize unlocking child's device.
Parent access button is displayed on lock screen shelf when the device
is locked because of time limits. It might be extended to login screen
shelf in the future to authorize additional actions on child's device.

Parent access button is a part of Parent Access Code feature developed
behind kParentAccess flag.

Bug: 911326
Test: LoginShelfViewTest
Change-Id: I9b513fb6f00ba7882686094761e5528ab3d475fd
Reviewed-on: https://chromium-review.googlesource.com/c/1389166Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarGreg Kerr <kerrnel@chromium.org>
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619509}
parent badd8a0f
......@@ -505,6 +505,13 @@ void LoginScreenController::SetShowGuestButtonInOobe(bool show) {
->SetShowGuestButtonInOobe(show);
}
void LoginScreenController::SetShowParentAccess(bool show) {
Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
->shelf_widget()
->login_shelf_view()
->SetShowParentAccess(show);
}
void LoginScreenController::FocusLoginShelf(bool reverse) {
Shelf* shelf = Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow());
// Tell the focus direction to the status area or the shelf so they can focus
......
......@@ -157,6 +157,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen,
void SetShutdownButtonEnabled(bool enable) override;
void SetAllowLoginAsGuest(bool allow_guest) override;
void SetShowGuestButtonInOobe(bool show) override;
void SetShowParentAccess(bool show) override;
void FocusLoginShelf(bool reverse) override;
// Flushes the mojo pipes - to be used in tests.
......
......@@ -218,6 +218,9 @@ interface LoginScreen {
// Sets if the guest button on the login shelf can be shown during OOBE.
SetShowGuestButtonInOobe(bool show);
// Sets whether parent access button can be shown on the login shelf.
SetShowParentAccess(bool show);
// Transitions focus to the shelf area. If |reverse|, focuses the status area.
FocusLoginShelf(bool reverse);
};
......
......@@ -99,6 +99,7 @@ aggregate_vector_icons("ash_vector_icons") {
"shelf_overflow.icon",
"shelf_overflow_horizontal_dots.icon",
"shelf_overview.icon",
"shelf_parent_access_button.icon",
"shelf_position.icon",
"shelf_shutdown_button.icon",
"shelf_sign_out_button.icon",
......
CANVAS_DIMENSIONS, 40,
MOVE_TO, 30, 13.33f,
R_H_LINE_TO, -1.67f,
V_LINE_TO, 10,
R_CUBIC_TO, 0, -4.6f, -3.73f, -8.33f, -8.33f, -8.33f,
ARC_TO, 8.34f, 8.34f, 0, 0, 0, 11.67f, 10,
R_V_LINE_TO, 3.33f,
H_LINE_TO, 10,
R_ARC_TO, 3.34f, 3.34f, 0, 0, 0, -3.33f, 3.33f,
R_V_LINE_TO, 16.67f,
R_CUBIC_TO, 0, 1.83f, 1.5f, 3.33f, 3.33f, 3.33f,
R_H_LINE_TO, 20,
R_CUBIC_TO, 1.83f, 0, 3.33f, -1.5f, 3.33f, -3.33f,
V_LINE_TO, 16.67f,
R_CUBIC_TO, 0, -1.83f, -1.5f, -3.33f, -3.33f, -3.33f,
CLOSE,
MOVE_TO, 15, 10,
R_CUBIC_TO, 0, -2.77f, 2.23f, -5, 5, -5,
R_CUBIC_TO, 2.77f, 0, 5, 2.23f, 5, 5,
R_V_LINE_TO, 3.33f,
H_LINE_TO, 15,
V_LINE_TO, 10,
CLOSE,
R_MOVE_TO, 15, 23.33f,
H_LINE_TO, 10,
V_LINE_TO, 16.67f,
R_H_LINE_TO, 20,
R_V_LINE_TO, 16.67f,
CLOSE,
R_MOVE_TO, -10, -5,
R_CUBIC_TO, 1.83f, 0, 3.33f, -1.5f, 3.33f, -3.33f,
R_CUBIC_TO, 0, -1.83f, -1.5f, -3.33f, -3.33f, -3.33f,
ARC_TO, 3.34f, 3.34f, 0, 0, 0, 16.67f, 25,
R_CUBIC_TO, 0, 1.83f, 1.5f, 3.33f, 3.33f, 3.33f,
CLOSE
CANVAS_DIMENSIONS, 20,
MOVE_TO, 15, 6.67f,
R_H_LINE_TO, -0.83f,
V_LINE_TO, 5,
CUBIC_TO, 14.17f, 2.7f, 12.3f, 0.83f, 10, 0.83f,
ARC_TO, 4.17f, 4.17f, 0, 0, 0, 5.83f, 5,
R_V_LINE_TO, 1.67f,
H_LINE_TO, 5,
R_CUBIC_TO, -0.92f, 0, -1.67f, 0.75f, -1.67f, 1.67f,
R_V_LINE_TO, 8.33f,
R_CUBIC_TO, 0, 0.92f, 0.75f, 1.67f, 1.67f, 1.67f,
R_H_LINE_TO, 10,
R_CUBIC_TO, 0.92f, 0, 1.67f, -0.75f, 1.67f, -1.67f,
V_LINE_TO, 8.33f,
R_CUBIC_TO, 0, -0.92f, -0.75f, -1.67f, -1.67f, -1.67f,
CLOSE,
MOVE_TO, 7.5f, 5,
R_CUBIC_TO, 0, -1.38f, 1.12f, -2.5f, 2.5f, -2.5f,
R_CUBIC_TO, 1.38f, 0, 2.5f, 1.12f, 2.5f, 2.5f,
R_V_LINE_TO, 1.67f,
R_H_LINE_TO, -5,
V_LINE_TO, 5,
CLOSE,
MOVE_TO, 15, 16.67f,
H_LINE_TO, 5,
V_LINE_TO, 8.33f,
R_H_LINE_TO, 10,
R_V_LINE_TO, 8.33f,
CLOSE,
R_MOVE_TO, -5, -2.5f,
R_CUBIC_TO, 0.92f, 0, 1.67f, -0.75f, 1.67f, -1.67f,
R_CUBIC_TO, 0, -0.92f, -0.75f, -1.67f, -1.67f, -1.67f,
R_CUBIC_TO, -0.92f, 0, -1.67f, 0.75f, -1.67f, 1.67f,
R_CUBIC_TO, 0, 0.92f, 0.75f, 1.67f, 1.67f, 1.67f,
CLOSE
......@@ -386,6 +386,8 @@ LoginShelfView::LoginShelfView(
add_button(kBrowseAsGuest, IDS_ASH_BROWSE_AS_GUEST_BUTTON,
kShelfBrowseAsGuestButtonIcon);
add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon);
add_button(kParentAccess, IDS_ASH_PARENT_ACCESS_BUTTON,
kShelfParentAccessButtonIcon);
// Adds observers for states that affect the visiblity of different buttons.
tray_action_observer_.Add(Shell::Get()->tray_action());
......@@ -506,6 +508,11 @@ void LoginShelfView::SetAllowLoginAsGuest(bool allow_guest) {
UpdateUi();
}
void LoginShelfView::SetShowParentAccess(bool show) {
show_parent_access_ = show;
UpdateUi();
}
void LoginShelfView::SetShowGuestButtonInOobe(bool show) {
allow_guest_in_oobe_ = show;
UpdateUi();
......@@ -563,6 +570,7 @@ void LoginShelfView::UpdateUi() {
bool show_reboot = Shell::Get()->shutdown_controller()->reboot_on_shutdown();
mojom::TrayActionState tray_action_state =
Shell::Get()->tray_action()->GetLockScreenNoteState();
bool is_locked = (session_state == SessionState::LOCKED);
bool is_lock_screen_note_in_foreground =
(tray_action_state == mojom::TrayActionState::kActive ||
tray_action_state == mojom::TrayActionState::kLaunching) &&
......@@ -573,13 +581,13 @@ void LoginShelfView::UpdateUi() {
!is_lock_screen_note_in_foreground);
GetViewByID(kRestart)->SetVisible(show_reboot &&
!is_lock_screen_note_in_foreground);
GetViewByID(kSignOut)->SetVisible(session_state == SessionState::LOCKED &&
GetViewByID(kSignOut)->SetVisible(is_locked &&
!is_lock_screen_note_in_foreground);
GetViewByID(kCloseNote)
->SetVisible(session_state == SessionState::LOCKED &&
is_lock_screen_note_in_foreground);
->SetVisible(is_locked && is_lock_screen_note_in_foreground);
GetViewByID(kCancel)->SetVisible(session_state ==
SessionState::LOGIN_SECONDARY);
GetViewByID(kParentAccess)->SetVisible(is_locked && show_parent_access_);
bool is_login_primary = (session_state == SessionState::LOGIN_PRIMARY);
bool dialog_visible = dialog_state_ != mojom::OobeDialogState::HIDDEN;
......
......@@ -58,6 +58,7 @@ class ASH_EXPORT LoginShelfView : public views::View,
kBrowseAsGuest, // Use in guest mode.
kAddUser, // Add a new user.
kApps, // Show list of available kiosk apps.
kParentAccess // Unlock child device with Parent Access Code.
};
explicit LoginShelfView(
......@@ -78,6 +79,9 @@ class ASH_EXPORT LoginShelfView : public views::View,
// true the button may still not be visible.
void SetAllowLoginAsGuest(bool allow_guest);
// Sets whether parent access button can be shown on the login shelf.
void SetShowParentAccess(bool show);
// Sets if the guest button on the login shelf can be shown during gaia
// signin screen.
void SetShowGuestButtonInOobe(bool show);
......@@ -125,7 +129,7 @@ class ASH_EXPORT LoginShelfView : public views::View,
mojom::OobeDialogState dialog_state_ = mojom::OobeDialogState::HIDDEN;
bool allow_guest_ = true;
bool allow_guest_in_oobe_ = false;
bool show_parent_access_ = false;
// When the Gaia screen is active during Login, the guest-login button should
// appear if there are no user views.
bool login_screen_has_users_ = false;
......
......@@ -10,6 +10,7 @@
#include "ash/focus_cycler.h"
#include "ash/lock_screen_action/lock_screen_action_background_controller.h"
#include "ash/lock_screen_action/test_lock_screen_action_background_controller.h"
#include "ash/login/login_screen_controller.h"
#include "ash/login/mock_login_screen_client.h"
#include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/views_utils.h"
......@@ -519,5 +520,48 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiAfterShutdownButtonStatusChange) {
EXPECT_TRUE(IsButtonEnabled(LoginShelfView::kShutdown));
}
TEST_F(LoginShelfViewTest, ParentAccessButtonVisibility) {
// Parent access button should only be visible on lock screen.
Shell::Get()->login_screen_controller()->SetShowParentAccess(true);
NotifySessionStateChanged(SessionState::LOGIN_PRIMARY);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown,
LoginShelfView::kBrowseAsGuest,
LoginShelfView::kAddUser}));
NotifySessionStateChanged(SessionState::LOGGED_IN_NOT_ACTIVE);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
NotifySessionStateChanged(SessionState::ACTIVE);
EXPECT_TRUE(ShowsShelfButtons({}));
NotifySessionStateChanged(SessionState::LOGIN_SECONDARY);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kCancel}));
NotifySessionStateChanged(SessionState::ACTIVE);
EXPECT_TRUE(ShowsShelfButtons({}));
NotifySessionStateChanged(SessionState::LOCKED);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut,
LoginShelfView::kParentAccess}));
}
TEST_F(LoginShelfViewTest, ParentAccessButtonVisibilityChangeOnLockScreen) {
NotifySessionStateChanged(SessionState::LOCKED);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
Shell::Get()->login_screen_controller()->SetShowParentAccess(true);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut,
LoginShelfView::kParentAccess}));
Shell::Get()->login_screen_controller()->SetShowParentAccess(false);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
}
} // namespace
} // namespace ash
......@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/child_accounts/screen_time_controller.h"
#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/feature_list.h"
#include "base/optional.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
......@@ -13,6 +15,8 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
......@@ -177,6 +181,8 @@ void ScreenTimeController::UpdateTimeLimitsMessage(
ScreenLocker::default_screen_locker()->SetAuthEnabledForUser(
account_id, !visible,
visible ? next_unlock_time : base::Optional<base::Time>());
if (base::FeatureList::IsEnabled(features::kParentAccessCode))
LoginScreenClient::Get()->login_screen()->SetShowParentAccess(visible);
}
void ScreenTimeController::OnPolicyChanged() {
......
......@@ -432,6 +432,13 @@ const base::Feature kOobeRecommendAppsScreen{"OobeRecommendAppsScreen",
const base::Feature kUseNewAcceptLanguageHeader{
"UseNewAcceptLanguageHeader", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_CHROMEOS)
// Enables usage of Parent Access Code to authorize certain actions on child
// user device.
const base::Feature kParentAccessCode{"ParentAccessCode",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif
// Delegate permissions to cross-origin iframes when the feature has been
// allowed by feature policy.
const base::Feature kPermissionDelegation{"PermissionDelegation",
......
......@@ -289,6 +289,11 @@ extern const base::Feature kOobeRecommendAppsScreen;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kUseNewAcceptLanguageHeader;
#if defined(OS_CHROMEOS)
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kParentAccessCode;
#endif
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kPermissionDelegation;
......
......@@ -166,6 +166,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_ASH_ADD_USER_BUTTON" desc="Text shown on an add user button on login/locker screen">
Add Person
</message>
<message name="IDS_ASH_PARENT_ACCESS_BUTTON" desc="Text shown on an parent access button on login/lock screen">
Parent access
</message>
<message name="IDS_ASH_SHELF_APPS_BUTTON" desc="Text shown on apps button on login screen.">
Apps
</message>
......
0c66f67616eaa0fdc226f46282ff1e235ffa3f83
\ No newline at end of file
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