1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef ASH_PUBLIC_CPP_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_H_
6 #define ASH_PUBLIC_CPP_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_H_
7 
8 #include "ash/public/cpp/ash_public_export.h"
9 #include "base/callback_forward.h"
10 #include "base/time/time.h"
11 
12 class AccountId;
13 
14 namespace ash {
15 
16 // Actions that might require parental approval.
17 enum class SupervisedAction {
18   // Unlock a Chromebook that is locked due to a Time Limit policy.
19   kUnlockTimeLimits,
20   // When Chrome is unable to automatically verify if the OS time is correct
21   // the user becomes able to manually change the clock. The entry points are
22   // the settings page (in-session) and the tray bubble (out-session).
23   kUpdateClock,
24   // Change timezone from the settings page.
25   kUpdateTimezone,
26   // Add user flow.
27   kAddUser,
28   // Re-authentication flow.
29   kReauth,
30 };
31 
32 // ParentAccessController serves as a single point of access for PIN requests
33 // regarding parent access. It takes care of showing and hiding the PIN UI, as
34 // well as logging usage metrics.
35 class ASH_PUBLIC_EXPORT ParentAccessController {
36  public:
37   ParentAccessController();
38   virtual ~ParentAccessController();
39 
40   // Get the instance of |ParentAccessController|.
41   static ParentAccessController* Get();
42 
43   // Shows a standalone parent access dialog. If |child_account_id| is valid, it
44   // validates the parent access code for that child only, when it is empty it
45   // validates the code for any child signed in the device.
46   // |on_exit_callback| is invoked when the back button is clicked or the
47   // correct code is entered.
48   // |action| contains information about why the parent
49   // access view is necessary, it is used to modify the view appearance by
50   // changing the title and description strings and background color.
51   // The parent access widget is a modal and already contains a dimmer, however
52   // when another modal is the parent of the widget, the dimmer will be placed
53   // behind the two windows.
54   // |extra_dimmer| will create an extra dimmer between the two.
55   // |validation_time| is the time that will be used to validate the
56   // code, if null the system's time will be used. Note: this is intended for
57   // children only. If a non child account id is provided, the validation will
58   // necessarily fail.
59   // Returns whether opening the dialog was successful. Will fail if another PIN
60   // dialog is already opened.
61   virtual bool ShowWidget(const AccountId& child_account_id,
62                           base::OnceCallback<void(bool success)> callback,
63                           SupervisedAction action,
64                           bool extra_dimmer,
65                           base::Time validation_time) = 0;
66 };
67 }  // namespace ash
68 
69 #endif  // ASH_PUBLIC_CPP_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_H_