[go: nahoru, domu]

Require Parent Access Code to change the clock on child session

This CL adds a method to the login data dispatcher that shows the
parent access widget and uses it to only allow parents to change the
clock when there is a child signed in or a child is a device owner.

Bug: 921145
Change-Id: Ifd83760f8b9000576570f85c895d34c76c4c8bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1621392
Reviewed-by: Aga Wronska <agawronska@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Commit-Queue: Henrique Grandinetti <hgrandinetti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665149}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 59c6044..84245518 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -9,6 +9,7 @@
 #include "ash/focus_cycler.h"
 #include "ash/login/ui/lock_screen.h"
 #include "ash/login/ui/login_data_dispatcher.h"
+#include "ash/login/ui/parent_access_widget.h"
 #include "ash/public/cpp/ash_pref_names.h"
 #include "ash/root_window_controller.h"
 #include "ash/session/session_controller_impl.h"
@@ -180,7 +181,7 @@
 }
 
 void LoginScreenController::ValidateParentAccessCode(
-    const base::Optional<AccountId>& account_id,
+    const AccountId& account_id,
     const std::string& code,
     OnParentAccessValidation callback) {
   if (!login_screen_client_) {
@@ -300,6 +301,13 @@
   return &login_data_dispatcher_;
 }
 
+void LoginScreenController::ShowParentAccessWidget(
+    const AccountId& child_account_id,
+    base::RepeatingCallback<void(bool success)> callback) {
+  parent_access_widget_ =
+      std::make_unique<ash::ParentAccessWidget>(child_account_id, callback);
+}
+
 void LoginScreenController::SetClient(mojom::LoginScreenClientPtr client) {
   login_screen_client_ = std::move(client);
 }