OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void OnDeviceAttributeUploadCompleted(bool success) override; | 76 void OnDeviceAttributeUploadCompleted(bool success) override; |
77 void OnDeviceAttributeUpdatePermission(bool granted) override; | 77 void OnDeviceAttributeUpdatePermission(bool granted) override; |
78 | 78 |
79 // Used for testing. | 79 // Used for testing. |
80 EnrollmentScreenActor* GetActor() { | 80 EnrollmentScreenActor* GetActor() { |
81 return actor_; | 81 return actor_; |
82 } | 82 } |
83 | 83 |
84 private: | 84 private: |
85 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess); | 85 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess); |
| 86 FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel); |
| 87 FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest, |
| 88 TestCancel); |
| 89 FRIEND_TEST_ALL_PREFIXES(MultiAuthEnrollmentScreenTest, TestCancel); |
86 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, | 90 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, |
87 TestProperPageGetsLoadedOnEnrollmentSuccess); | 91 TestProperPageGetsLoadedOnEnrollmentSuccess); |
88 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, | 92 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, |
89 TestAttributePromptPageGetsLoaded); | 93 TestAttributePromptPageGetsLoaded); |
90 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, | 94 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, |
91 TestAuthCodeGetsProperlyReceivedFromGaia); | 95 TestAuthCodeGetsProperlyReceivedFromGaia); |
92 | 96 |
93 // Creates an enrollment helper. | 97 // The authentication mechanisms that this class can use. |
| 98 enum Auth { |
| 99 AUTH_ATTESTATION, |
| 100 AUTH_OAUTH, |
| 101 }; |
| 102 |
| 103 // Sets the current config to use for enrollment. |
| 104 void SetConfig(); |
| 105 |
| 106 // Creates an enrollment helper if needed. |
94 void CreateEnrollmentHelper(); | 107 void CreateEnrollmentHelper(); |
95 | 108 |
96 // Clears auth in |enrollment_helper_|. Deletes |enrollment_helper_| and runs | 109 // Clears auth in |enrollment_helper_|. Deletes |enrollment_helper_| and runs |
97 // |callback| on completion. See the comment for | 110 // |callback| on completion. See the comment for |
98 // EnterpriseEnrollmentHelper::ClearAuth for details. | 111 // EnterpriseEnrollmentHelper::ClearAuth for details. |
99 void ClearAuth(const base::Closure& callback); | 112 void ClearAuth(const base::Closure& callback); |
100 | 113 |
101 // Used as a callback for EnterpriseEnrollmentHelper::ClearAuth. | 114 // Used as a callback for EnterpriseEnrollmentHelper::ClearAuth. |
102 virtual void OnAuthCleared(const base::Closure& callback); | 115 virtual void OnAuthCleared(const base::Closure& callback); |
103 | 116 |
104 // Sends an enrollment access token to a remote device. | 117 // Sends an enrollment access token to a remote device. |
105 void SendEnrollmentAuthToken(const std::string& token); | 118 void SendEnrollmentAuthToken(const std::string& token); |
106 | 119 |
107 // Shows successful enrollment status after all enrollment related file | 120 // Shows successful enrollment status after all enrollment related file |
108 // operations are completed. | 121 // operations are completed. |
109 void ShowEnrollmentStatusOnSuccess(); | 122 void ShowEnrollmentStatusOnSuccess(); |
110 | 123 |
111 // Logs an UMA event in one of the "Enrollment.*" histograms, depending on | 124 // Logs an UMA event in one of the "Enrollment.*" histograms, depending on |
112 // |enrollment_mode_|. | 125 // |enrollment_mode_|. |
113 void UMA(policy::MetricEnrollment sample); | 126 void UMA(policy::MetricEnrollment sample); |
114 | 127 |
| 128 // Do attestation based enrollment. |
| 129 void AuthenticateUsingAttestation(); |
| 130 |
| 131 // Shows the interactive screen. Resets auth then shows the signin screen. |
| 132 void ShowInteractiveScreen(); |
| 133 |
115 // Shows the signin screen. Used as a callback to run after auth reset. | 134 // Shows the signin screen. Used as a callback to run after auth reset. |
116 void ShowSigninScreen(); | 135 void ShowSigninScreen(); |
117 | 136 |
118 // Shows the device attribute prompt screen. | 137 // Shows the device attribute prompt screen. |
119 // Used as a callback to run after successful enrollment. | 138 // Used as a callback to run after successful enrollment. |
120 void ShowAttributePromptScreen(); | 139 void ShowAttributePromptScreen(); |
121 | 140 |
| 141 // Handle enrollment errors. |
122 void OnAnyEnrollmentError(); | 142 void OnAnyEnrollmentError(); |
123 | 143 |
124 pairing_chromeos::ControllerPairingController* shark_controller_; | 144 // Advance to the next authentication mechanism if possible. |
| 145 bool AdvanceToNextAuth(); |
| 146 |
| 147 pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr; |
125 | 148 |
126 EnrollmentScreenActor* actor_; | 149 EnrollmentScreenActor* actor_; |
| 150 policy::EnrollmentConfig config_; |
127 policy::EnrollmentConfig enrollment_config_; | 151 policy::EnrollmentConfig enrollment_config_; |
128 bool enrollment_failed_once_; | 152 Auth current_auth_ = AUTH_OAUTH; |
| 153 Auth last_auth_ = AUTH_OAUTH; |
| 154 bool enrollment_failed_once_ = false; |
129 std::string enrolling_user_domain_; | 155 std::string enrolling_user_domain_; |
130 std::unique_ptr<base::ElapsedTimer> elapsed_timer_; | 156 std::unique_ptr<base::ElapsedTimer> elapsed_timer_; |
131 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_; | 157 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_; |
132 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_; | 158 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_; |
133 | 159 |
134 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen); | 160 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen); |
135 }; | 161 }; |
136 | 162 |
137 } // namespace chromeos | 163 } // namespace chromeos |
138 | 164 |
139 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 165 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
OLD | NEW |