forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparent_access_controller_impl.h
84 lines (70 loc) · 2.98 KB
/
parent_access_controller_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_IMPL_H_
#define ASH_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_IMPL_H_
#include "ash/login/ui/pin_request_view.h"
#include "ash/login/ui/pin_request_widget.h"
#include "ash/public/cpp/child_accounts/parent_access_controller.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "components/account_id/account_id.h"
namespace ash {
// Implementation of ParentAccessController. It serves as a single point of
// access for PIN requests regarding parent access. It takes care of showing and
// hiding the PIN UI, as well as logging usage metrics.
class ASH_EXPORT ParentAccessControllerImpl : public ParentAccessController,
public PinRequestView::Delegate {
public:
// Actions that originated in parent access dialog. These values are persisted
// to metrics. Entries should not be renumbered and numeric values should
// never be reused.
enum class UMAAction {
kValidationSuccess = 0,
kValidationError = 1,
kCanceledByUser = 2,
kGetHelp = 3,
kMaxValue = kGetHelp,
};
// Context in which parent access code was used. These values are persisted to
// metrics. Entries should not be reordered and numeric values should never be
// reused.
enum class UMAUsage {
kTimeLimits = 0,
kTimeChangeLoginScreen = 1,
kTimeChangeInSession = 2,
kTimezoneChange = 3,
kAddUserLoginScreen = 4,
kReauhLoginScreen = 5,
kMaxValue = kReauhLoginScreen,
};
// Histogram to log actions that originated in parent access dialog.
static constexpr char kUMAParentAccessCodeAction[] =
"Supervision.ParentAccessCode.Action";
// Histogram to log context in which parent access code was used.
static constexpr char kUMAParentAccessCodeUsage[] =
"Supervision.ParentAccessCode.Usage";
ParentAccessControllerImpl();
ParentAccessControllerImpl(const ParentAccessControllerImpl&) = delete;
ParentAccessControllerImpl& operator=(const ParentAccessControllerImpl&) =
delete;
~ParentAccessControllerImpl() override;
// PinRequestView::Delegate:
PinRequestView::SubmissionResult OnPinSubmitted(
const std::string& pin) override;
void OnBack() override;
void OnHelp(gfx::NativeWindow parent_window) override;
// ParentAccessController:
bool ShowWidget(const AccountId& child_account_id,
PinRequest::OnPinRequestDone on_exit_callback,
SupervisedAction action,
bool extra_dimmer,
base::Time validation_time) override;
private:
AccountId account_id_;
SupervisedAction action_ = SupervisedAction::kUnlockTimeLimits;
base::Time validation_time_;
base::WeakPtrFactory<ParentAccessControllerImpl> weak_factory_{this};
};
} // namespace ash
#endif // ASH_CHILD_ACCOUNTS_PARENT_ACCESS_CONTROLLER_IMPL_H_