Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1334)

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen.h

Issue 2526973002: Added retry policy (Closed)
Patch Set: Wrote Unit Test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/cancelable_callback.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/timer/timer.h"
16 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" 18 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
17 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper. h" 19 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper. h"
18 #include "chrome/browser/chromeos/login/screens/base_screen.h" 20 #include "chrome/browser/chromeos/login/screens/base_screen.h"
19 #include "chrome/browser/chromeos/policy/enrollment_config.h" 21 #include "chrome/browser/chromeos/policy/enrollment_config.h"
20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
21 #include "components/policy/core/common/cloud/enterprise_metrics.h" 23 #include "components/policy/core/common/cloud/enterprise_metrics.h"
24 #include "net/base/backoff_entry.h"
22 25
23 namespace base { 26 namespace base {
24 class ElapsedTimer; 27 class ElapsedTimer;
25 } 28 }
26 29
27 namespace pairing_chromeos { 30 namespace pairing_chromeos {
28 class ControllerPairingController; 31 class ControllerPairingController;
29 } 32 }
30 33
31 namespace chromeos { 34 namespace chromeos {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void OnDeviceEnrolled(const std::string& additional_token) override; 77 void OnDeviceEnrolled(const std::string& additional_token) override;
75 void OnDeviceAttributeUploadCompleted(bool success) override; 78 void OnDeviceAttributeUploadCompleted(bool success) override;
76 void OnDeviceAttributeUpdatePermission(bool granted) override; 79 void OnDeviceAttributeUpdatePermission(bool granted) override;
77 80
78 // Used for testing. 81 // Used for testing.
79 EnrollmentScreenActor* GetActor() { 82 EnrollmentScreenActor* GetActor() {
80 return actor_; 83 return actor_;
81 } 84 }
82 85
83 private: 86 private:
87 friend class EnterpriseEnrollmentHelperMock;
84 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess); 88 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess);
85 FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel); 89 FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel);
86 FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest, 90 FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest,
87 TestCancel); 91 TestCancel);
88 FRIEND_TEST_ALL_PREFIXES(MultiAuthEnrollmentScreenTest, TestCancel); 92 FRIEND_TEST_ALL_PREFIXES(MultiAuthEnrollmentScreenTest, TestCancel);
89 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, 93 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest,
90 TestProperPageGetsLoadedOnEnrollmentSuccess); 94 TestProperPageGetsLoadedOnEnrollmentSuccess);
91 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, 95 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest,
92 TestAttributePromptPageGetsLoaded); 96 TestAttributePromptPageGetsLoaded);
93 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, 97 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest,
94 TestAuthCodeGetsProperlyReceivedFromGaia); 98 TestAuthCodeGetsProperlyReceivedFromGaia);
95 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput); 99 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput);
100 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, Retries);
101 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, DoesNotRetryOnTopOfUser);
102 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, DoesNotRetryAfterSuccess);
96 103
97 // The authentication mechanisms that this class can use. 104 // The authentication mechanisms that this class can use.
98 enum Auth { 105 enum Auth {
99 AUTH_ATTESTATION, 106 AUTH_ATTESTATION,
100 AUTH_OAUTH, 107 AUTH_OAUTH,
101 }; 108 };
102 109
103 // Sets the current config to use for enrollment. 110 // Sets the current config to use for enrollment.
104 void SetConfig(); 111 void SetConfig();
105 112
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Shows the device attribute prompt screen. 144 // Shows the device attribute prompt screen.
138 // Used as a callback to run after successful enrollment. 145 // Used as a callback to run after successful enrollment.
139 void ShowAttributePromptScreen(); 146 void ShowAttributePromptScreen();
140 147
141 // Record metrics when we encounter an enrollment error. 148 // Record metrics when we encounter an enrollment error.
142 void RecordEnrollmentErrorMetrics(); 149 void RecordEnrollmentErrorMetrics();
143 150
144 // Advance to the next authentication mechanism if possible. 151 // Advance to the next authentication mechanism if possible.
145 bool AdvanceToNextAuth(); 152 bool AdvanceToNextAuth();
146 153
154 // Similar to OnRetry(), but responds to a timer instead of the user
155 // pressing the Retry button.
156 void AutomaticRetry();
157
158 // Processes a request to retry enrollment.
159 // Called by OnRetry() and AutomaticRetry().
160 void ProcessRetry();
161
162 // True if we are using Hands-Off Zero-Touch Attestation-Based Enterprise
163 // Enrollment.
164 bool UsingHandsOffEnrollment();
165
147 pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr; 166 pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr;
148 167
149 EnrollmentScreenActor* actor_; 168 EnrollmentScreenActor* actor_;
150 policy::EnrollmentConfig config_; 169 policy::EnrollmentConfig config_;
151 policy::EnrollmentConfig enrollment_config_; 170 policy::EnrollmentConfig enrollment_config_;
152 Auth current_auth_ = AUTH_OAUTH; 171 Auth current_auth_ = AUTH_OAUTH;
153 Auth last_auth_ = AUTH_OAUTH; 172 Auth last_auth_ = AUTH_OAUTH;
154 bool enrollment_failed_once_ = false; 173 bool enrollment_failed_once_ = false;
155 std::string enrolling_user_domain_; 174 std::string enrolling_user_domain_;
156 std::string auth_code_; 175 std::string auth_code_;
157 std::unique_ptr<base::ElapsedTimer> elapsed_timer_; 176 std::unique_ptr<base::ElapsedTimer> elapsed_timer_;
177 net::BackoffEntry::Policy retry_policy_;
178 std::unique_ptr<net::BackoffEntry> retry_backoff_;
179 base::CancelableClosure retry_task_;
180 int num_retries_ = 0;
158 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_; 181 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_;
159 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_; 182 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_;
160 183
161 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen); 184 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen);
162 }; 185 };
163 186
164 } // namespace chromeos 187 } // namespace chromeos
165 188
166 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ 189 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698