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